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 update
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     HgPullTask.php
22
 */
23
class HgPullTask extends HgBaseTask
24
{
25
    /**
26
     * Path to target directory
27
     *
28
     * @var string
29
     */
30
    protected $targetPath;
31

32
    /**
33
     * Set path to source repo
34
     *
35
     * @param string $targetPath Path to repository used as source
36
     *
37
     * @return void
38
     */
39 0
    public function setTargetPath($targetPath)
40
    {
41 0
        $this->targetPath = $targetPath;
42
    }
43

44
    /**
45
     * The main entry point method.
46
     *
47
     * @throws BuildException
48
     * @return void
49
     */
50 1
    public function main()
51
    {
52 1
        $clone = $this->getFactoryInstance('pull');
53 1
        $clone->setInsecure($this->getInsecure());
54 1
        $clone->setQuiet($this->getQuiet());
55

56 1
        $cwd = getcwd();
57

58 1
        if ($this->repository === '') {
59 1
            $project = $this->getProject();
60 1
            $dir = $project->getProperty('application.startdir');
61
        } else {
62 1
            $dir = $this->repository;
63
        }
64 1
        $this->checkRepositoryIsDirAndExists($dir);
65 1
        chdir($dir);
66

67
        try {
68 1
            $this->log("Executing: " . $clone->asString(), Project::MSG_INFO);
69 1
            $output = $clone->execute();
70 0
            if ($output !== '') {
71 0
                $this->log($output);
72
            }
73 1
        } catch (Exception $ex) {
74 1
            $msg = $ex->getMessage();
75 1
            $p = strpos($msg, 'hg returned:');
76 1
            if ($p !== false) {
77 1
                $msg = substr($msg, $p + 13);
78
            }
79 1
            chdir($cwd);
80 1
            throw new BuildException($msg);
81
        }
82 0
        chdir($cwd);
83
    }
84
}

Read our documentation on viewing source code .

Loading