1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* VersionControl_HG |
4
|
|
|
* Simple OO implementation for Mercurial. |
5
|
|
|
* |
6
|
|
|
* PHP Version 5.4 |
7
|
|
|
* |
8
|
|
|
* @copyright 2014 Siad Ardroumli |
9
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT |
10
|
|
|
* @link http://siad007.github.io/versioncontrol_hg |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace Siad007\VersionControl\HG\Command; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Simple OO implementation for Mercurial. |
17
|
|
|
* |
18
|
|
|
* @author Siad Ardroumli <[email protected]> |
19
|
|
|
* |
20
|
|
|
* @method boolean getAfter() |
21
|
|
|
* @method void setAfter(boolean $flag) |
22
|
|
|
* @method boolean getForce() |
23
|
|
|
* @method void setForce(boolean $flag) |
24
|
|
|
* @method array getInclude() |
25
|
|
|
* @method void addInclude(string $pattern) |
26
|
|
|
* @method array getExclude() |
27
|
|
|
* @method void addExclude(string $pattern) |
28
|
|
|
* @method boolean getDryRun() |
29
|
|
|
* @method void setDryRun(boolean $flag) |
30
|
|
|
*/ |
31
|
|
|
class RenameCommand extends AbstractCommand |
32
|
|
|
{ |
33
|
|
|
/** |
34
|
|
|
* Available arguments for this command. |
35
|
|
|
* |
36
|
|
|
* @var array $arguments |
37
|
|
|
*/ |
38
|
|
|
protected $arguments = [ |
39
|
|
|
'source' => [], |
40
|
|
|
'dest' => '' |
41
|
|
|
]; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* {@inheritdoc} |
45
|
|
|
* |
46
|
|
|
* @var mixed $options |
47
|
|
|
*/ |
48
|
|
|
protected $options = [ |
49
|
|
|
'--after' => false, |
50
|
|
|
'--force' => false, |
51
|
|
|
'--include' => [], |
52
|
|
|
'--exclude' => [], |
53
|
|
|
'--dry-run' => false |
54
|
|
|
]; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @return array |
58
|
|
|
*/ |
59
|
2 |
|
public function getSource() |
60
|
|
|
{ |
61
|
2 |
|
return $this->arguments['source']; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @param string $source |
66
|
|
|
* |
67
|
|
|
* @return void |
68
|
|
|
*/ |
69
|
2 |
|
public function addSource($source) |
70
|
|
|
{ |
71
|
2 |
|
$this->arguments['source'][] = escapeshellarg($source); |
72
|
2 |
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @return string |
76
|
|
|
*/ |
77
|
2 |
|
public function getDestination() |
78
|
|
|
{ |
79
|
2 |
|
return $this->arguments['dest']; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @param string $destination |
84
|
|
|
* |
85
|
|
|
* @return void |
86
|
|
|
*/ |
87
|
2 |
|
public function setDestination($destination) |
88
|
|
|
{ |
89
|
2 |
|
$this->arguments['dest'] = escapeshellarg($destination); |
90
|
2 |
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* {@inheritdoc} |
94
|
|
|
*/ |
95
|
2 |
|
public function __toString() |
96
|
|
|
{ |
97
|
2 |
|
return sprintf( |
98
|
2 |
|
"%s%s %s %s", |
99
|
2 |
|
$this->name, |
100
|
2 |
|
$this->assembleOptionString(), |
101
|
2 |
|
implode(' ', $this->arguments['source']), |
102
|
2 |
|
$this->arguments['dest'] |
103
|
|
|
); |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
|