Changeset View
Changeset View
Standalone View
Standalone View
src/repository/api/ArcanistSubversionAPI.php
| Show All 31 Lines | if ($svn_dir === null) { | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return $svn_dir; | return $svn_dir; | ||||
| } | } | ||||
| protected function buildLocalFuture(array $argv) { | protected function buildLocalFuture(array $argv) { | ||||
| $argv[0] = 'svn '.$argv[0]; | $argv[0] = 'svn '.$argv[0]; | ||||
| $future = newv('ExecFuture', $argv); | $future = newv('ExecFuture', $argv); | ||||
| $future->setCWD($this->getPath()); | $future->setCWD($this->getPath()); | ||||
| return $future; | return $future; | ||||
| } | } | ||||
| protected function buildCommitRangeStatus() { | protected function buildCommitRangeStatus() { | ||||
| ▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | if ($this->svnStatus === null) { | ||||
| switch ($props) { | switch ($props) { | ||||
| case 'none': | case 'none': | ||||
| case 'normal': | case 'normal': | ||||
| break; | break; | ||||
| case 'modified': | case 'modified': | ||||
| $mask |= self::FLAG_MODIFIED; | $mask |= self::FLAG_MODIFIED; | ||||
| break; | break; | ||||
| default: | default: | ||||
| throw new Exception("Unrecognized property status '{$props}'."); | throw new Exception(pht( | ||||
| "Unrecognized property status '%s'.", | |||||
| $props)); | |||||
| } | } | ||||
| $mask |= $this->parseSVNStatus($item); | $mask |= $this->parseSVNStatus($item); | ||||
| if ($item == 'external') { | if ($item == 'external') { | ||||
| $externals[] = $path; | $externals[] = $path; | ||||
| } | } | ||||
| // This is new in or around Subversion 1.6. | // This is new in or around Subversion 1.6. | ||||
| ▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | switch ($item) { | ||||
| return self::FLAG_MODIFIED; | return self::FLAG_MODIFIED; | ||||
| case 'deleted': | case 'deleted': | ||||
| return self::FLAG_DELETED; | return self::FLAG_DELETED; | ||||
| case 'conflicted': | case 'conflicted': | ||||
| return self::FLAG_CONFLICT; | return self::FLAG_CONFLICT; | ||||
| case 'incomplete': | case 'incomplete': | ||||
| return self::FLAG_INCOMPLETE; | return self::FLAG_INCOMPLETE; | ||||
| default: | default: | ||||
| throw new Exception("Unrecognized item status '{$item}'."); | throw new Exception(pht("Unrecognized item status '%s'.", $item)); | ||||
| } | } | ||||
| } | } | ||||
| public function addToCommit(array $paths) { | public function addToCommit(array $paths) { | ||||
| $add = array_filter($paths, 'Filesystem::pathExists'); | $add = array_filter($paths, 'Filesystem::pathExists'); | ||||
| if ($add) { | if ($add) { | ||||
| $this->execxLocal( | $this->execxLocal( | ||||
| 'add -- %Ls', | 'add -- %Ls', | ||||
| ▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | if (empty($this->svnInfo[$path])) { | ||||
| if (empty($this->svnInfoRaw[$path])) { | if (empty($this->svnInfoRaw[$path])) { | ||||
| $this->svnInfoRaw[$path] = $this->buildInfoFuture($path)->resolve(); | $this->svnInfoRaw[$path] = $this->buildInfoFuture($path)->resolve(); | ||||
| } | } | ||||
| list($err, $stdout) = $this->svnInfoRaw[$path]; | list($err, $stdout) = $this->svnInfoRaw[$path]; | ||||
| if ($err) { | if ($err) { | ||||
| throw new Exception( | throw new Exception( | ||||
| "Error #{$err} executing svn info against '{$path}'."); | pht("Error #%d executing svn info against '%s'.", $err, $path)); | ||||
| } | } | ||||
| // TODO: Hack for Windows. | // TODO: Hack for Windows. | ||||
| $stdout = str_replace("\r\n", "\n", $stdout); | $stdout = str_replace("\r\n", "\n", $stdout); | ||||
| $patterns = array( | $patterns = array( | ||||
| '/^(URL): (\S+)$/m', | '/^(URL): (\S+)$/m', | ||||
| '/^(Revision): (\d+)$/m', | '/^(Revision): (\d+)$/m', | ||||
| Show All 15 Lines | if (empty($this->svnInfo[$path])) { | ||||
| } | } | ||||
| } | } | ||||
| if (isset($result['Last Changed Date'])) { | if (isset($result['Last Changed Date'])) { | ||||
| $result['Last Changed Date'] = strtotime($result['Last Changed Date']); | $result['Last Changed Date'] = strtotime($result['Last Changed Date']); | ||||
| } | } | ||||
| if (empty($result)) { | if (empty($result)) { | ||||
| throw new Exception('Unable to parse SVN info.'); | throw new Exception(pht('Unable to parse SVN info.')); | ||||
| } | } | ||||
| $this->svnInfo[$path] = $result; | $this->svnInfo[$path] = $result; | ||||
| } | } | ||||
| return $this->svnInfo[$path]; | return $this->svnInfo[$path]; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | EODIFF; | ||||
| list($err, $stdout, $stderr) = $this->svnDiffRaw[$path]; | list($err, $stdout, $stderr) = $this->svnDiffRaw[$path]; | ||||
| // Note: GNU Diff returns 2 when SVN hands it binary files to diff and they | // Note: GNU Diff returns 2 when SVN hands it binary files to diff and they | ||||
| // differ. This is not an error; it is documented behavior. But SVN isn't | // differ. This is not an error; it is documented behavior. But SVN isn't | ||||
| // happy about it. SVN will exit with code 1 and return the string below. | // happy about it. SVN will exit with code 1 and return the string below. | ||||
| if ($err != 0 && $stderr !== "svn: 'diff' returned 2\n") { | if ($err != 0 && $stderr !== "svn: 'diff' returned 2\n") { | ||||
| throw new Exception( | throw new Exception( | ||||
| "svn diff returned unexpected error code: $err\n". | pht( | ||||
| "stdout: $stdout\n". | "%s returned unexpected error code: %d\nstdout: %s\nstderr: %s", | ||||
| "stderr: $stderr"); | 'svn diff', | ||||
| $err, | |||||
| $stdout, | |||||
| $stderr)); | |||||
| } | } | ||||
| if ($err == 0 && empty($stdout)) { | if ($err == 0 && empty($stdout)) { | ||||
| // If there are no changes, 'diff' exits with no output, but that means | // If there are no changes, 'diff' exits with no output, but that means | ||||
| // we can not distinguish between empty and unmodified files. Build a | // we can not distinguish between empty and unmodified files. Build a | ||||
| // synthetic "diff" without any changes in it. | // synthetic "diff" without any changes in it. | ||||
| return $this->buildSyntheticUnchangedDiff($path); | return $this->buildSyntheticUnchangedDiff($path); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | public function getBlame($path) { | ||||
| if (!strlen($stdout)) { | if (!strlen($stdout)) { | ||||
| // Empty file. | // Empty file. | ||||
| return $blame; | return $blame; | ||||
| } | } | ||||
| foreach (explode("\n", $stdout) as $line) { | foreach (explode("\n", $stdout) as $line) { | ||||
| $m = array(); | $m = array(); | ||||
| if (!preg_match('/^\s*(\d+)\s+(\S+)/', $line, $m)) { | if (!preg_match('/^\s*(\d+)\s+(\S+)/', $line, $m)) { | ||||
| throw new Exception("Bad blame? `{$line}'"); | throw new Exception(pht("Bad blame? `%s'", $line)); | ||||
| } | } | ||||
| $revision = $m[1]; | $revision = $m[1]; | ||||
| $author = $m[2]; | $author = $m[2]; | ||||
| $blame[] = array($author, $revision); | $blame[] = array($author, $revision); | ||||
| } | } | ||||
| return $blame; | return $blame; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | public function loadWorkingCopyDifferentialRevisions( | ||||
| foreach ($results as $key => $result) { | foreach ($results as $key => $result) { | ||||
| if ($result['sourcePath'] != $this->getPath()) { | if ($result['sourcePath'] != $this->getPath()) { | ||||
| unset($results[$key]); | unset($results[$key]); | ||||
| } | } | ||||
| } | } | ||||
| foreach ($results as $key => $result) { | foreach ($results as $key => $result) { | ||||
| $results[$key]['why'] = | $results[$key]['why'] = pht( | ||||
| 'Matching arcanist project name and working copy directory path.'; | 'Matching arcanist project name and working copy directory path.'); | ||||
| } | } | ||||
| return $results; | return $results; | ||||
| } | } | ||||
| public function updateWorkingCopy() { | public function updateWorkingCopy() { | ||||
| $this->execxLocal('up'); | $this->execxLocal('up'); | ||||
| } | } | ||||
| Show All 24 Lines | |||||