2 namespace Robo\Task\Vcs;
4 use Robo\Task\CommandStack;
7 * Runs hg commands in stack. You can use `stopOnFail()` to point that stack should be terminated on first fail.
12 * ->cloneRepo('https://bitbucket.org/durin42/hgsubversion')
23 class HgStack extends CommandStack
27 * @param string $pathToHg
29 public function __construct($pathToHg = 'hg')
31 $this->executable = $pathToHg;
42 public function cloneRepo($repo, $to = '')
44 return $this->exec(['clone', $repo, $to]);
48 * Executes `hg add` command with files to add by pattern
50 * @param string $include
51 * @param string $exclude
55 public function add($include = '', $exclude = '')
57 if (strlen($include) > 0) {
58 $include = "-I {$include}";
61 if (strlen($exclude) > 0) {
62 $exclude = "-X {$exclude}";
65 return $this->exec([__FUNCTION__, $include, $exclude]);
69 * Executes `hg commit` command with a message
71 * @param string $message
72 * @param string $options
76 public function commit($message, $options = '')
78 return $this->exec([__FUNCTION__, "-m '{$message}'", $options]);
82 * Executes `hg pull` command.
84 * @param string $branch
88 public function pull($branch = '')
90 if (strlen($branch) > 0) {
91 $branch = "-b '{$branch}''";
94 return $this->exec([__FUNCTION__, $branch]);
98 * Executes `hg push` command
100 * @param string $branch
104 public function push($branch = '')
106 if (strlen($branch) > 0) {
107 $branch = "-b '{$branch}'";
110 return $this->exec([__FUNCTION__, $branch]);
116 * @param string $revision
120 public function merge($revision = '')
122 if (strlen($revision) > 0) {
123 $revision = "-r {$revision}";
126 return $this->exec([__FUNCTION__, $revision]);
130 * Executes `hg tag` command
132 * @param string $tag_name
133 * @param string $message
137 public function tag($tag_name, $message = '')
139 if ($message !== '') {
140 $message = "-m '{$message}'";
142 return $this->exec([__FUNCTION__, $message, $tag_name]);
148 public function run()
150 $this->printTaskInfo('Running hg commands...');
151 return parent::run();