Rev 360 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 360 | Rev 386 | ||
---|---|---|---|
Line 67... | Line 67... | ||
67 | 67 | ||
68 | /** |
68 | /** |
69 | * Respository Version. |
69 | * Respository Version. |
70 | * |
70 | * |
71 | * @access private |
71 | * @access private |
72 | * @var interger |
72 | * @var int |
73 | */ |
73 | */ |
74 | private $_repVersion; |
74 | private $_repVersion; |
75 | 75 | ||
76 | /** |
76 | /** |
77 | * Last error number |
77 | * Last error number |
Line 104... | Line 104... | ||
104 | $this->actVersion = $this->getVersion(); |
104 | $this->actVersion = $this->getVersion(); |
105 | } |
105 | } |
106 | 106 | ||
107 | /** |
107 | /** |
108 | * Function for creating directories. |
108 | * Function for creating directories. |
109 | * @param type $path The path to the directory that will be created. |
109 | * @param $path (string) The path to the directory that will be created. |
110 | */ |
110 | */ |
111 | private function createDirs($path) |
111 | private function createDirs($path) |
112 | { |
112 | { |
113 | $dirs = explode("/", $path); |
113 | $dirs = explode("/", $path); |
114 | 114 | ||
Line 120... | Line 120... | ||
120 | } |
120 | } |
121 | } |
121 | } |
122 | 122 | ||
123 | /** |
123 | /** |
124 | * Function for the recursive removal of directories. |
124 | * Function for the recursive removal of directories. |
125 | * @param type $path The path to the directory to be deleted. |
125 | * @param $path (string) The path to the directory to be deleted. |
126 | * @return type Returns the status of a function or function rmdir unlink. |
126 | * @return (string) Returns the status of a function or function rmdir unlink. |
127 | */ |
127 | */ |
128 | private function removeDirs($path) |
128 | private function removeDirs($path) |
129 | { |
129 | { |
130 | if (is_dir($path)) { |
130 | if (is_dir($path)) { |
131 | $entries = scandir($path); |
131 | $entries = scandir($path); |
Line 147... | Line 147... | ||
147 | * Public Functions |
147 | * Public Functions |
148 | */ |
148 | */ |
149 | 149 | ||
150 | /** |
150 | /** |
151 | * Updates a working copy |
151 | * Updates a working copy |
152 | * @param $from_revision Either a revision number or a text file with the |
152 | * @param $from_revision (string) Either a revision number or a text file with the |
153 | * contents "Revision ..." (if it is a file, |
153 | * contents "Revision ..." (if it is a file, |
154 | * the file revision will be updated if everything |
154 | * the file revision will be updated if everything |
155 | * was successful) |
155 | * was successful) |
156 | * @param $folder SVN remote folder |
156 | * @param $folder (string) SVN remote folder |
157 | * @param $outpath Local path of the working copy |
157 | * @param $outpath (string) Local path of the working copy |
158 | * @param $preview Only simulate, do not write to files |
158 | * @param $preview (bool) Only simulate, do not write to files |
159 | **/ |
159 | **/ |
160 | public function updateWorkingCopy($from_revision='version.txt', $folder = '/trunk/', $outPath = '.', $preview = false) |
160 | public function updateWorkingCopy($from_revision='version.txt', $folder = '/trunk/', $outPath = '.', $preview = false) |
161 | { |
161 | { |
162 | if (!is_dir($outPath)) { |
162 | if (!is_dir($outPath)) { |
163 | echo "ERROR: Local path $outPath not existing\n"; |
163 | echo "ERROR: Local path $outPath not existing\n"; |
Line 176... | Line 176... | ||
176 | flush(); |
176 | flush(); |
177 | return false; |
177 | return false; |
178 | } else { |
178 | } else { |
179 | //Obtain the number of current version number of the local copy. |
179 | //Obtain the number of current version number of the local copy. |
180 | $cont = file_get_contents($version_file); |
180 | $cont = file_get_contents($version_file); |
- | 181 | $m = array(); |
|
181 | if (!preg_match('@Revision (\d+)@', $cont, $m)) { |
182 | if (!preg_match('@Revision (\d+)@', $cont, $m)) { |
182 | echo "ERROR: $version_file unknown format\n"; |
183 | echo "ERROR: $version_file unknown format\n"; |
183 | flush(); |
184 | flush(); |
184 | return false; |
185 | return false; |
185 | } |
186 | } |
Line 342... | Line 343... | ||
342 | { |
343 | { |
343 | if ($version == -1 || $version > $this->actVersion) { |
344 | if ($version == -1 || $version > $this->actVersion) { |
344 | $version = $this->actVersion; |
345 | $version = $this->actVersion; |
345 | } |
346 | } |
346 | $url = $this->cleanURL($this->_url . "/!svn/bc/" . $version . "/" . $folder . "/"); |
347 | $url = $this->cleanURL($this->_url . "/!svn/bc/" . $version . "/" . $folder . "/"); |
- | 348 | $args = array(); |
|
347 | $this->initQuery($args, "PROPFIND", $url); |
349 | $this->initQuery($args, "PROPFIND", $url); |
348 | $args['Body'] = self::PHPSVN_NORMAL_REQUEST; |
350 | $args['Body'] = self::PHPSVN_NORMAL_REQUEST; |
349 | $args['Headers']['Content-Length'] = strlen(self::PHPSVN_NORMAL_REQUEST); |
351 | $args['Headers']['Content-Length'] = strlen(self::PHPSVN_NORMAL_REQUEST); |
350 | 352 | ||
- | 353 | $headers = array(); |
|
- | 354 | $body = ''; |
|
351 | if (!$this->Request($args, $headers, $body)) |
355 | if (!$this->Request($args, $headers, $body)) |
352 | throw new OIDplusException("Cannot get rawDirectoryDump (Request failed)"); |
356 | throw new OIDplusException("Cannot get rawDirectoryDump (Request failed)"); |
353 | 357 | ||
354 | return self::xmlParse($body); |
358 | return self::xmlParse($body); |
355 | } |
359 | } |
Line 546... | Line 550... | ||
546 | // SVN server. Maybe add this as an option/parameter? ES 23/06/08 |
550 | // SVN server. Maybe add this as an option/parameter? ES 23/06/08 |
547 | $fileInfo = $this->getDirectoryTree($file, $version, false); |
551 | $fileInfo = $this->getDirectoryTree($file, $version, false); |
548 | if ($fileInfo["type"] == "directory") |
552 | if ($fileInfo["type"] == "directory") |
549 | return false; |
553 | return false; |
550 | 554 | ||
- | 555 | $args = array(); |
|
551 | $url = $this->cleanURL($this->_url . "/!svn/bc/" . $version . "/" . $file . "/"); |
556 | $url = $this->cleanURL($this->_url . "/!svn/bc/" . $version . "/" . $file . "/"); |
552 | $this->initQuery($args, "GET", $url); |
557 | $this->initQuery($args, "GET", $url); |
- | 558 | $headers = array(); |
|
- | 559 | $body = ''; |
|
553 | if (!$this->Request($args, $headers, $body)) |
560 | if (!$this->Request($args, $headers, $body)) |
554 | throw new OIDplusException("Cannot call getFile (Request failed)"); |
561 | throw new OIDplusException("Cannot call getFile (Request failed)"); |
555 | 562 | ||
556 | return $body; |
563 | return $body; |
557 | } |
564 | } |
Line 573... | Line 580... | ||
573 | flush(); |
580 | flush(); |
574 | return null; |
581 | return null; |
575 | } |
582 | } |
576 | 583 | ||
577 | $url = $this->cleanURL($this->_url . "/!svn/bc/" . $this->actVersion . "/" . $file . "/"); |
584 | $url = $this->cleanURL($this->_url . "/!svn/bc/" . $this->actVersion . "/" . $file . "/"); |
- | 585 | $args = array(); |
|
578 | $this->initQuery($args, "REPORT", $url); |
586 | $this->initQuery($args, "REPORT", $url); |
579 | $args['Body'] = sprintf(self::PHPSVN_LOGS_REQUEST, $vini, $vend); |
587 | $args['Body'] = sprintf(self::PHPSVN_LOGS_REQUEST, $vini, $vend); |
580 | $args['Headers']['Content-Length'] = strlen($args['Body']); |
588 | $args['Headers']['Content-Length'] = strlen($args['Body']); |
581 | $args['Headers']['Depth'] = 1; |
589 | $args['Headers']['Depth'] = 1; |
582 | 590 | ||
- | 591 | $headers = array(); |
|
- | 592 | $body = ''; |
|
583 | if (!$this->Request($args, $headers, $body)) |
593 | if (!$this->Request($args, $headers, $body)) |
584 | throw new OIDplusException("Cannot call getLogsForUpdate (Request failed)"); |
594 | throw new OIDplusException("Cannot call getLogsForUpdate (Request failed)"); |
585 | 595 | ||
586 | $arrOutput = self::xmlParse($body); |
596 | $arrOutput = self::xmlParse($body); |
587 | 597 | ||
Line 721... | Line 731... | ||
721 | { |
731 | { |
722 | if ($this->_repVersion > 0) |
732 | if ($this->_repVersion > 0) |
723 | return $this->_repVersion; |
733 | return $this->_repVersion; |
724 | 734 | ||
725 | $this->_repVersion = -1; |
735 | $this->_repVersion = -1; |
- | 736 | $args = array(); |
|
726 | $this->initQuery($args, "PROPFIND", $this->cleanURL($this->_url . "/!svn/vcc/default")); |
737 | $this->initQuery($args, "PROPFIND", $this->cleanURL($this->_url . "/!svn/vcc/default")); |
727 | $args['Body'] = self::PHPSVN_VERSION_REQUEST; |
738 | $args['Body'] = self::PHPSVN_VERSION_REQUEST; |
728 | $args['Headers']['Content-Length'] = strlen(self::PHPSVN_NORMAL_REQUEST); |
739 | $args['Headers']['Content-Length'] = strlen(self::PHPSVN_NORMAL_REQUEST); |
729 | $args['Headers']['Depth'] = 0; |
740 | $args['Headers']['Depth'] = 0; |
730 | 741 | ||
- | 742 | $tmp = array(); |
|
- | 743 | $body = ''; |
|
731 | if (!$this->Request($args, $tmp, $body)) |
744 | if (!$this->Request($args, $tmp, $body)) |
732 | throw new OIDplusException("Cannot get repository revision (Request failed)"); |
745 | throw new OIDplusException("Cannot get repository revision (Request failed)"); |
733 | 746 | ||
734 | $this->_repVersion = null; |
747 | $this->_repVersion = null; |
- | 748 | $m = array(); |
|
735 | if (preg_match('@/(\d+)\s*</D:href>@ismU', $body, $m)) { |
749 | if (preg_match('@/(\d+)\s*</D:href>@ismU', $body, $m)) { |
736 | $this->_repVersion = $m[1]; |
750 | $this->_repVersion = $m[1]; |
737 | } else { |
751 | } else { |
738 | throw new OIDplusException("Cannot get repository revision (RegEx failed)"); |
752 | throw new OIDplusException("Cannot get repository revision (RegEx failed)"); |
739 | } |
753 | } |