Navigation | Overlay |
---|---|
t Navigate files | h Toggle hits |
y Change url to tip of branch | m Toggle misses |
b / v Jump to prev/next hit line | p Toggle partial |
z / x Jump to prev/next missed or partial line | 1..9 Toggle flags |
shift + o Open current page in GitHub | a Toggle all on |
/ or ? Show keyboard shortcuts dialog | c Toggle context lines or commits |
1 |
<?php
|
|
2 |
/**
|
|
3 |
* Utilise Mercurial from within Phing.
|
|
4 |
*
|
|
5 |
* PHP Version 5.4
|
|
6 |
*
|
|
7 |
* @category Tasks
|
|
8 |
* @package phing.tasks.ext
|
|
9 |
* @author Ken Guest <kguest@php.net>
|
|
10 |
* @license LGPL (see http://www.gnu.org/licenses/lgpl.html)
|
|
11 |
* @link https://github.com/kenguest/Phing-HG
|
|
12 |
*/
|
|
13 |
|
|
14 |
/**
|
|
15 |
* Integration/Wrapper for hg push
|
|
16 |
*
|
|
17 |
* @category Tasks
|
|
18 |
* @package phing.tasks.ext.hg
|
|
19 |
* @author Ken Guest <kguest@php.net>
|
|
20 |
* @license LGPL (see http://www.gnu.org/licenses/lgpl.html)
|
|
21 |
* @link HgPushTask.php
|
|
22 |
*/
|
|
23 |
class HgPushTask extends HgBaseTask |
|
24 |
{
|
|
25 |
/**
|
|
26 |
* Whether the task should halt if an error occurs.
|
|
27 |
*
|
|
28 |
* @var bool
|
|
29 |
*/
|
|
30 |
protected $haltonerror = false; |
|
31 |
|
|
32 |
/**
|
|
33 |
* Set haltonerror attribute.
|
|
34 |
*
|
|
35 |
* @param string $halt 'yes', or '1' to halt.
|
|
36 |
*
|
|
37 |
* @return void
|
|
38 |
*/
|
|
39 |
public function setHaltonerror($halt) |
|
40 |
{
|
|
41 |
$this->haltonerror = StringHelper::booleanValue($halt); |
|
42 |
}
|
|
43 |
|
|
44 |
/**
|
|
45 |
* Return haltonerror value.
|
|
46 |
*
|
|
47 |
* @return bool
|
|
48 |
*/
|
|
49 |
public function getHaltonerror() |
|
50 |
{
|
|
51 |
return $this->haltonerror; |
|
52 |
}
|
|
53 |
|
|
54 |
/**
|
|
55 |
* The main entry point method.
|
|
56 |
*
|
|
57 |
* @throws BuildException
|
|
58 |
* @return void
|
|
59 |
*/
|
|
60 |
public function main() |
|
61 |
{
|
|
62 |
$clone = $this->getFactoryInstance('push'); |
|
63 |
$this->log('Pushing...', Project::MSG_INFO); |
|
64 |
$clone->setInsecure($this->getInsecure()); |
|
65 |
$clone->setQuiet($this->getQuiet()); |
|
66 |
if ($this->repository === '') { |
|
67 |
$project = $this->getProject(); |
|
68 |
$dir = $project->getProperty('application.startdir'); |
|
69 |
} else { |
|
70 |
$dir = $this->repository; |
|
71 |
}
|
|
72 |
$cwd = getcwd(); |
|
73 |
$this->checkRepositoryIsDirAndExists($dir); |
|
74 |
chdir($dir); |
|
75 |
try { |
|
76 |
$this->log("Executing: " . $clone->asString(), Project::MSG_INFO); |
|
77 |
$output = $clone->execute(); |
|
78 |
if ($output !== '') { |
|
79 |
$this->log($output); |
|
80 |
}
|
|
81 |
} catch (Exception $ex) { |
|
82 |
$msg = $ex->getMessage(); |
|
83 |
$p = strpos($msg, 'hg returned:'); |
|
84 |
if ($p !== false) { |
|
85 |
$msg = substr($msg, $p + 13); |
|
86 |
}
|
|
87 |
chdir($cwd); |
|
88 |
if ($this->haltonerror) { |
|
89 |
throw new BuildException($msg); |
|
90 |
}
|
|
91 |
$this->log($msg, Project::MSG_ERR); |
|
92 |
}
|
|
93 |
chdir($cwd); |
|
94 |
}
|
|
95 |
}
|
Read our documentation on viewing source code .