|
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 getNoupdate() |
|
21
|
|
|
* @method void setNoupdate(boolean $flag) |
|
22
|
|
|
* @method string getUpdaterev() |
|
23
|
|
|
* @method void setUpdaterev(string $revision) |
|
24
|
|
|
* @method string getRev() |
|
25
|
|
|
* @method void addRev(string $revision) |
|
26
|
|
|
* @method string getBranch() |
|
27
|
|
|
* @method void addBranch(string $branch) |
|
28
|
|
|
* @method boolean getPull() |
|
29
|
|
|
* @method void setPull(boolean $flag) |
|
30
|
|
|
* @method boolean getUncompressed() |
|
31
|
|
|
* @method void setUncompressed(boolean $flag) |
|
32
|
|
|
* @method string getSsh() |
|
33
|
|
|
* @method void setSsh(string $command) |
|
34
|
|
|
* @method string getRemotecmd() |
|
35
|
|
|
* @method void setRemotecmd(string $command) |
|
36
|
|
|
* @method boolean getInsecure() |
|
37
|
|
|
* @method void setInsecure(boolean $flag) |
|
38
|
|
|
*/ |
|
39
|
|
|
class CloneCommand extends AbstractCommand |
|
40
|
|
|
{ |
|
41
|
|
|
/** |
|
42
|
|
|
* Available arguments for this command. |
|
43
|
|
|
* |
|
44
|
|
|
* @var array $arguments |
|
45
|
|
|
*/ |
|
46
|
|
|
protected $arguments = [ |
|
47
|
|
|
'destination' => '', |
|
48
|
|
|
'source' => '' |
|
49
|
|
|
]; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* {@inheritdoc} |
|
53
|
|
|
* |
|
54
|
|
|
* @var array $options |
|
55
|
|
|
*/ |
|
56
|
|
|
protected $options = [ |
|
57
|
|
|
'--noupdate' => false, |
|
58
|
|
|
'--updaterev' => '', |
|
59
|
|
|
'--rev' => [], |
|
60
|
|
|
'--branch' => [], |
|
61
|
|
|
'--pull' => false, |
|
62
|
|
|
'--uncompressed' => false, |
|
63
|
|
|
'--ssh' => '', |
|
64
|
|
|
'--remotecmd' => '', |
|
65
|
|
|
'--insecure' => false |
|
66
|
|
|
]; |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Get the destination. |
|
70
|
|
|
* |
|
71
|
|
|
* @return string |
|
72
|
|
|
*/ |
|
73
|
1 |
|
public function getDestination() |
|
74
|
|
|
{ |
|
75
|
1 |
|
return $this->arguments['destination']; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Set the destination. |
|
80
|
|
|
* |
|
81
|
|
|
* @param string $destination |
|
82
|
|
|
* |
|
83
|
|
|
* @return void |
|
84
|
|
|
*/ |
|
85
|
1 |
|
public function setDestination($destination) |
|
86
|
|
|
{ |
|
87
|
1 |
|
$this->arguments['destination'] = escapeshellarg($destination); |
|
88
|
1 |
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* Get the source argument for this command. |
|
92
|
|
|
* |
|
93
|
|
|
* @return string |
|
94
|
|
|
*/ |
|
95
|
1 |
|
public function getSource() |
|
96
|
|
|
{ |
|
97
|
1 |
|
return $this->arguments['source']; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* Set the source argument for this command. |
|
102
|
|
|
* |
|
103
|
|
|
* @param string $source |
|
104
|
|
|
* |
|
105
|
|
|
* @return void |
|
106
|
|
|
*/ |
|
107
|
2 |
|
public function setSource($source) |
|
108
|
|
|
{ |
|
109
|
2 |
|
$this->arguments['source'] = escapeshellarg($source); |
|
110
|
2 |
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* {@inheritdoc} |
|
114
|
|
|
*/ |
|
115
|
3 |
|
public function __toString() |
|
116
|
|
|
{ |
|
117
|
3 |
|
if ($this->arguments['source'] === '') { |
|
118
|
1 |
|
trigger_error('No source directory given.', E_USER_ERROR); |
|
119
|
|
|
|
|
120
|
1 |
|
return ''; |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
2 |
|
if ($this->arguments['destination'] === '') { |
|
124
|
1 |
|
$result = sprintf( |
|
125
|
1 |
|
"%s%s %s", |
|
126
|
1 |
|
$this->name, |
|
127
|
1 |
|
$this->assembleOptionString(), |
|
128
|
1 |
|
$this->arguments['source'] |
|
129
|
|
|
); |
|
130
|
|
|
} else { |
|
131
|
1 |
|
$result = sprintf( |
|
132
|
1 |
|
"%s%s %s %s", |
|
133
|
1 |
|
$this->name, |
|
134
|
1 |
|
$this->assembleOptionString(), |
|
135
|
1 |
|
$this->arguments['source'], |
|
136
|
1 |
|
$this->arguments['destination'] |
|
137
|
|
|
); |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
2 |
|
return $result; |
|
141
|
|
|
} |
|
142
|
|
|
} |
|
143
|
|
|
|