@@ -23,101 +23,101 @@ discard block |
||
23 | 23 | */ |
24 | 24 | class SVNHelper |
25 | 25 | { |
26 | - /** |
|
27 | - * @var integer |
|
28 | - */ |
|
26 | + /** |
|
27 | + * @var integer |
|
28 | + */ |
|
29 | 29 | const ERROR_LOCAL_PATH_DOES_NOT_EXIST = 22401; |
30 | 30 | |
31 | - /** |
|
32 | - * @var integer |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @var integer |
|
33 | + */ |
|
34 | 34 | const ERROR_INVALID_REP_URL = 22402; |
35 | 35 | |
36 | - /** |
|
37 | - * @var integer |
|
38 | - */ |
|
36 | + /** |
|
37 | + * @var integer |
|
38 | + */ |
|
39 | 39 | const ERROR_PATH_IS_OUTSIDE_REPOSITORY = 22403; |
40 | 40 | |
41 | - /** |
|
42 | - * @var integer |
|
43 | - */ |
|
41 | + /** |
|
42 | + * @var integer |
|
43 | + */ |
|
44 | 44 | const ERROR_TARGET_FOLDER_IS_A_FILE = 22404; |
45 | 45 | |
46 | - /** |
|
47 | - * @var integer |
|
48 | - */ |
|
46 | + /** |
|
47 | + * @var integer |
|
48 | + */ |
|
49 | 49 | const ERROR_CANNOT_ADD_INEXISTENT_FILE = 22405; |
50 | 50 | |
51 | - /** |
|
52 | - * @var integer |
|
53 | - */ |
|
51 | + /** |
|
52 | + * @var integer |
|
53 | + */ |
|
54 | 54 | const ERROR_TARGET_PATH_NOT_FOUND = 22406; |
55 | 55 | |
56 | - /** |
|
57 | - * @var integer |
|
58 | - */ |
|
56 | + /** |
|
57 | + * @var integer |
|
58 | + */ |
|
59 | 59 | const ERROR_INVALID_TARGET_TYPE = 22407; |
60 | 60 | |
61 | - /** |
|
62 | - * @var integer |
|
63 | - */ |
|
61 | + /** |
|
62 | + * @var integer |
|
63 | + */ |
|
64 | 64 | const ERROR_INVALID_LOG_CALLBACK = 22408; |
65 | 65 | |
66 | - /** |
|
67 | - * @var SVNHelper_Target_Folder |
|
68 | - */ |
|
66 | + /** |
|
67 | + * @var SVNHelper_Target_Folder |
|
68 | + */ |
|
69 | 69 | protected $target; |
70 | 70 | |
71 | - /** |
|
72 | - * @var string |
|
73 | - */ |
|
71 | + /** |
|
72 | + * @var string |
|
73 | + */ |
|
74 | 74 | protected $path; |
75 | 75 | |
76 | - /** |
|
77 | - * @var string |
|
78 | - */ |
|
76 | + /** |
|
77 | + * @var string |
|
78 | + */ |
|
79 | 79 | protected $url; |
80 | 80 | |
81 | - /** |
|
82 | - * @var string |
|
83 | - */ |
|
81 | + /** |
|
82 | + * @var string |
|
83 | + */ |
|
84 | 84 | protected $user; |
85 | 85 | |
86 | - /** |
|
87 | - * @var string |
|
88 | - */ |
|
86 | + /** |
|
87 | + * @var string |
|
88 | + */ |
|
89 | 89 | protected $pass; |
90 | 90 | |
91 | - /** |
|
92 | - * @var array |
|
93 | - */ |
|
91 | + /** |
|
92 | + * @var array |
|
93 | + */ |
|
94 | 94 | protected $options = array( |
95 | 95 | 'binaries-path' => '' |
96 | 96 | ); |
97 | 97 | |
98 | - /** |
|
99 | - * @var boolean |
|
100 | - */ |
|
98 | + /** |
|
99 | + * @var boolean |
|
100 | + */ |
|
101 | 101 | protected $isWindows = false; |
102 | 102 | |
103 | - /** |
|
104 | - * @var array |
|
105 | - */ |
|
103 | + /** |
|
104 | + * @var array |
|
105 | + */ |
|
106 | 106 | protected $normalize = array( |
107 | 107 | 'from' => '\\', |
108 | 108 | 'to' => '/' |
109 | 109 | ); |
110 | 110 | |
111 | - /** |
|
112 | - * @var string |
|
113 | - */ |
|
111 | + /** |
|
112 | + * @var string |
|
113 | + */ |
|
114 | 114 | protected $sourcePath; |
115 | 115 | |
116 | - /** |
|
117 | - * @param string $repPath The path to the repository |
|
118 | - * @param string $repURL The SVN URL to the repository |
|
119 | - * @throws SVNHelper_Exception |
|
120 | - */ |
|
116 | + /** |
|
117 | + * @param string $repPath The path to the repository |
|
118 | + * @param string $repURL The SVN URL to the repository |
|
119 | + * @throws SVNHelper_Exception |
|
120 | + */ |
|
121 | 121 | public function __construct(string $repPath, string $repURL) |
122 | 122 | { |
123 | 123 | $this->isWindows = substr(PHP_OS, 0, 3) == 'WIN'; |
@@ -178,16 +178,16 @@ discard block |
||
178 | 178 | return $this->pass; |
179 | 179 | } |
180 | 180 | |
181 | - /** |
|
182 | - * Normalizes slashes in the path according to the |
|
183 | - * operating system, i.e. forward slashes for NIX-systems |
|
184 | - * and backward slashes for Windows. |
|
185 | - * |
|
186 | - * @param string $path An absolute path to normalize |
|
187 | - * @param bool $relativize Whether to return a path relative to the repository |
|
188 | - * @throws SVNHelper_Exception |
|
189 | - * @return string |
|
190 | - */ |
|
181 | + /** |
|
182 | + * Normalizes slashes in the path according to the |
|
183 | + * operating system, i.e. forward slashes for NIX-systems |
|
184 | + * and backward slashes for Windows. |
|
185 | + * |
|
186 | + * @param string $path An absolute path to normalize |
|
187 | + * @param bool $relativize Whether to return a path relative to the repository |
|
188 | + * @throws SVNHelper_Exception |
|
189 | + * @return string |
|
190 | + */ |
|
191 | 191 | public function normalizePath($path, $relativize=false) |
192 | 192 | { |
193 | 193 | if(empty($path)) { |
@@ -222,32 +222,32 @@ discard block |
||
222 | 222 | ); |
223 | 223 | } |
224 | 224 | |
225 | - /** |
|
226 | - * Retrieves the path slash style according to the |
|
227 | - * current operating system. |
|
228 | - * |
|
229 | - * @return string |
|
230 | - */ |
|
225 | + /** |
|
226 | + * Retrieves the path slash style according to the |
|
227 | + * current operating system. |
|
228 | + * |
|
229 | + * @return string |
|
230 | + */ |
|
231 | 231 | public function getSlash() |
232 | 232 | { |
233 | 233 | return $this->normalize['to']; |
234 | 234 | } |
235 | 235 | |
236 | - /** |
|
237 | - * Keeps instances of files. |
|
238 | - * @var SVNHelper_Target[] |
|
239 | - */ |
|
236 | + /** |
|
237 | + * Keeps instances of files. |
|
238 | + * @var SVNHelper_Target[] |
|
239 | + */ |
|
240 | 240 | protected $targets = array(); |
241 | 241 | |
242 | - /** |
|
243 | - * Retrieves a file instance from the SVN repository: |
|
244 | - * this allows all possible operations on the file as |
|
245 | - * well as accessing more information on it. |
|
246 | - * |
|
247 | - * @param string $path A path to the file, relative to the repository path or absolute. |
|
248 | - * @return SVNHelper_Target_File |
|
249 | - * @throws SVNHelper_Exception |
|
250 | - */ |
|
242 | + /** |
|
243 | + * Retrieves a file instance from the SVN repository: |
|
244 | + * this allows all possible operations on the file as |
|
245 | + * well as accessing more information on it. |
|
246 | + * |
|
247 | + * @param string $path A path to the file, relative to the repository path or absolute. |
|
248 | + * @return SVNHelper_Target_File |
|
249 | + * @throws SVNHelper_Exception |
|
250 | + */ |
|
251 | 251 | public function getFile($path) |
252 | 252 | { |
253 | 253 | $path = $this->filterPath($path); |
@@ -255,15 +255,15 @@ discard block |
||
255 | 255 | return $this->getTarget('File', $this->relativizePath($path)); |
256 | 256 | } |
257 | 257 | |
258 | - /** |
|
259 | - * Retrieves a folder instance from the SVN repository: |
|
260 | - * This allows all possible operations on the folder as |
|
261 | - * well as accessing more information on it. |
|
262 | - * |
|
263 | - * @param string $path |
|
264 | - * @return SVNHelper_Target_Folder |
|
265 | - * @throws SVNHelper_Exception |
|
266 | - */ |
|
258 | + /** |
|
259 | + * Retrieves a folder instance from the SVN repository: |
|
260 | + * This allows all possible operations on the folder as |
|
261 | + * well as accessing more information on it. |
|
262 | + * |
|
263 | + * @param string $path |
|
264 | + * @return SVNHelper_Target_Folder |
|
265 | + * @throws SVNHelper_Exception |
|
266 | + */ |
|
267 | 267 | public function getFolder($path) |
268 | 268 | { |
269 | 269 | $path = $this->filterPath($path); |
@@ -271,13 +271,13 @@ discard block |
||
271 | 271 | return $this->getTarget('Folder', $this->relativizePath($path)); |
272 | 272 | } |
273 | 273 | |
274 | - /** |
|
275 | - * Passes the path through realpath and ensures it exists. |
|
276 | - * |
|
277 | - * @param string $path |
|
278 | - * @throws SVNHelper_Exception |
|
279 | - * @return string |
|
280 | - */ |
|
274 | + /** |
|
275 | + * Passes the path through realpath and ensures it exists. |
|
276 | + * |
|
277 | + * @param string $path |
|
278 | + * @throws SVNHelper_Exception |
|
279 | + * @return string |
|
280 | + */ |
|
281 | 281 | protected function filterPath($path) |
282 | 282 | { |
283 | 283 | if(empty($path)) { |
@@ -302,13 +302,13 @@ discard block |
||
302 | 302 | ); |
303 | 303 | } |
304 | 304 | |
305 | - /** |
|
306 | - * Retrieves a target file or folder within the repository. |
|
307 | - * |
|
308 | - * @param string $type The target type, "File" or "Folder". |
|
309 | - * @param string $relativePath A path relative to the root folder. |
|
310 | - * @return SVNHelper_Target |
|
311 | - */ |
|
305 | + /** |
|
306 | + * Retrieves a target file or folder within the repository. |
|
307 | + * |
|
308 | + * @param string $type The target type, "File" or "Folder". |
|
309 | + * @param string $relativePath A path relative to the root folder. |
|
310 | + * @return SVNHelper_Target |
|
311 | + */ |
|
312 | 312 | protected function getTarget($type, $relativePath) |
313 | 313 | { |
314 | 314 | $key = $type.':'.$relativePath; |
@@ -356,33 +356,33 @@ discard block |
||
356 | 356 | return $this->url; |
357 | 357 | } |
358 | 358 | |
359 | - /** |
|
360 | - * Updates the whole SVN repository from the root folder. |
|
361 | - * @return SVNHelper_CommandResult |
|
362 | - */ |
|
359 | + /** |
|
360 | + * Updates the whole SVN repository from the root folder. |
|
361 | + * @return SVNHelper_CommandResult |
|
362 | + */ |
|
363 | 363 | public function runUpdate() |
364 | 364 | { |
365 | 365 | return $this->createUpdate($this->target)->execute(); |
366 | 366 | } |
367 | 367 | |
368 | - /** |
|
369 | - * Creates an update command for the target file or folder. |
|
370 | - * This can be configured further before it is executed. |
|
371 | - * |
|
372 | - * @param SVNHelper_Target $target |
|
373 | - * @return SVNHelper_Command_Update |
|
374 | - */ |
|
368 | + /** |
|
369 | + * Creates an update command for the target file or folder. |
|
370 | + * This can be configured further before it is executed. |
|
371 | + * |
|
372 | + * @param SVNHelper_Target $target |
|
373 | + * @return SVNHelper_Command_Update |
|
374 | + */ |
|
375 | 375 | public function createUpdate(SVNHelper_Target $target) |
376 | 376 | { |
377 | 377 | return $this->createCommand('Update', $target); |
378 | 378 | } |
379 | 379 | |
380 | - /** |
|
381 | - * Creates an add command for the targt file or folder. |
|
382 | - * |
|
383 | - * @param SVNHelper_Target $target |
|
384 | - * @return SVNHelper_Command_Add |
|
385 | - */ |
|
380 | + /** |
|
381 | + * Creates an add command for the targt file or folder. |
|
382 | + * |
|
383 | + * @param SVNHelper_Target $target |
|
384 | + * @return SVNHelper_Command_Add |
|
385 | + */ |
|
386 | 386 | public function createAdd(SVNHelper_Target $target) |
387 | 387 | { |
388 | 388 | return $this->createCommand('Add', $target); |
@@ -399,12 +399,12 @@ discard block |
||
399 | 399 | return $this->createCommand('Info', $target); |
400 | 400 | } |
401 | 401 | |
402 | - /** |
|
403 | - * Creates a status command for the target file or folder. |
|
404 | - * |
|
405 | - * @param SVNHelper_Target $target |
|
406 | - * @return SVNHelper_Command_Status |
|
407 | - */ |
|
402 | + /** |
|
403 | + * Creates a status command for the target file or folder. |
|
404 | + * |
|
405 | + * @param SVNHelper_Target $target |
|
406 | + * @return SVNHelper_Command_Status |
|
407 | + */ |
|
408 | 408 | public function createStatus(SVNHelper_Target $target) |
409 | 409 | { |
410 | 410 | return $this->createCommand('Status', $target); |
@@ -429,28 +429,28 @@ discard block |
||
429 | 429 | return $cmd; |
430 | 430 | } |
431 | 431 | |
432 | - /** |
|
433 | - * Creates a path relative to the repository for the target |
|
434 | - * file or folder, from an absolute path. |
|
435 | - * |
|
436 | - * @param string $path An absolute path. |
|
437 | - * @return string |
|
438 | - */ |
|
432 | + /** |
|
433 | + * Creates a path relative to the repository for the target |
|
434 | + * file or folder, from an absolute path. |
|
435 | + * |
|
436 | + * @param string $path An absolute path. |
|
437 | + * @return string |
|
438 | + */ |
|
439 | 439 | public function relativizePath($path) |
440 | 440 | { |
441 | 441 | return $this->normalizePath($path, true); |
442 | 442 | } |
443 | 443 | |
444 | - /** |
|
445 | - * Adds a folder: creates it as necessary (recursive), |
|
446 | - * and adds it to be committed if it is not versioned yet. |
|
447 | - * Use this instead of {@link getFolder()} when you are |
|
448 | - * not sure that it exists yet, and will need it. |
|
449 | - * |
|
450 | - * @param string $path Absolute or relative path to the folder |
|
451 | - * @throws SVNHelper_Exception |
|
452 | - * @return SVNHelper_Target_Folder |
|
453 | - */ |
|
444 | + /** |
|
445 | + * Adds a folder: creates it as necessary (recursive), |
|
446 | + * and adds it to be committed if it is not versioned yet. |
|
447 | + * Use this instead of {@link getFolder()} when you are |
|
448 | + * not sure that it exists yet, and will need it. |
|
449 | + * |
|
450 | + * @param string $path Absolute or relative path to the folder |
|
451 | + * @throws SVNHelper_Exception |
|
452 | + * @return SVNHelper_Target_Folder |
|
453 | + */ |
|
454 | 454 | public function addFolder($path) |
455 | 455 | { |
456 | 456 | if(is_dir($path)) { |
@@ -500,14 +500,14 @@ discard block |
||
500 | 500 | |
501 | 501 | protected static $logCallback; |
502 | 502 | |
503 | - /** |
|
504 | - * Sets the callback function/method to use for |
|
505 | - * SVH helper log messages. This gets the message |
|
506 | - * and the SVNHelper instance as parameters. |
|
507 | - * |
|
508 | - * @param callable $callback |
|
509 | - * @throws SVNHelper_Exception |
|
510 | - */ |
|
503 | + /** |
|
504 | + * Sets the callback function/method to use for |
|
505 | + * SVH helper log messages. This gets the message |
|
506 | + * and the SVNHelper instance as parameters. |
|
507 | + * |
|
508 | + * @param callable $callback |
|
509 | + * @throws SVNHelper_Exception |
|
510 | + */ |
|
511 | 511 | public static function setLogCallback($callback) |
512 | 512 | { |
513 | 513 | if(!is_callable($callback)) { |
@@ -528,22 +528,22 @@ discard block |
||
528 | 528 | } |
529 | 529 | } |
530 | 530 | |
531 | - /** |
|
532 | - * Retrieves information about the file, and adds it |
|
533 | - * to be committed later if it not versioned yet. |
|
534 | - * |
|
535 | - * @param string $path |
|
536 | - * @return SVNHelper_Target_File |
|
537 | - */ |
|
531 | + /** |
|
532 | + * Retrieves information about the file, and adds it |
|
533 | + * to be committed later if it not versioned yet. |
|
534 | + * |
|
535 | + * @param string $path |
|
536 | + * @return SVNHelper_Target_File |
|
537 | + */ |
|
538 | 538 | public function addFile($path) |
539 | 539 | { |
540 | 540 | return $this->getFile($path)->runAdd(); |
541 | 541 | } |
542 | 542 | |
543 | - /** |
|
544 | - * Commits all changes in the repository. |
|
545 | - * @param string $message The commit message to log. |
|
546 | - */ |
|
543 | + /** |
|
544 | + * Commits all changes in the repository. |
|
545 | + * @param string $message The commit message to log. |
|
546 | + */ |
|
547 | 547 | public function runCommit($message) |
548 | 548 | { |
549 | 549 | $this->createCommit($this->getFolder($this->path), $message)->execute(); |