Changeset View
Changeset View
Standalone View
Standalone View
src/repository/parser/ArcanistMercurialParser.php
| Show All 28 Lines | if (!strlen($stdout)) { | ||||
| return $result; | return $result; | ||||
| } | } | ||||
| $last_path = null; | $last_path = null; | ||||
| $lines = explode("\n", $stdout); | $lines = explode("\n", $stdout); | ||||
| foreach ($lines as $line) { | foreach ($lines as $line) { | ||||
| $flags = 0; | $flags = 0; | ||||
| if ($line[1] !== ' ') { | if ($line[1] !== ' ') { | ||||
| throw new Exception("Unparsable Mercurial status line '{$line}'."); | throw new Exception( | ||||
| pht( | |||||
| "Unparsable Mercurial status line '%s'.", | |||||
| $line)); | |||||
| } | } | ||||
| $code = $line[0]; | $code = $line[0]; | ||||
| $path = substr($line, 2); | $path = substr($line, 2); | ||||
| switch ($code) { | switch ($code) { | ||||
| case 'A': | case 'A': | ||||
| $flags |= ArcanistRepositoryAPI::FLAG_ADDED; | $flags |= ArcanistRepositoryAPI::FLAG_ADDED; | ||||
| break; | break; | ||||
| case 'R': | case 'R': | ||||
| Show All 15 Lines | foreach ($lines as $line) { | ||||
| case 'I': | case 'I': | ||||
| // This is "ignored" and included only for completeness. | // This is "ignored" and included only for completeness. | ||||
| break; | break; | ||||
| case ' ': | case ' ': | ||||
| // This shows the source of a file move, so update the last file we | // This shows the source of a file move, so update the last file we | ||||
| // parsed to set its source. | // parsed to set its source. | ||||
| if ($last_path === null) { | if ($last_path === null) { | ||||
| throw new Exception( | throw new Exception( | ||||
| "Unexpected copy source in hg status, '{$line}'."); | pht( | ||||
| "Unexpected copy source in %s, '%s'.", | |||||
| 'hg status', | |||||
| $line)); | |||||
| } | } | ||||
| $result[$last_path]['from'] = $path; | $result[$last_path]['from'] = $path; | ||||
| continue 2; | continue 2; | ||||
| default: | default: | ||||
| throw new Exception("Unknown Mercurial status '{$code}'."); | throw new Exception(pht("Unknown Mercurial status '%s'.", $code)); | ||||
| } | } | ||||
| $result[$path] = array( | $result[$path] = array( | ||||
| 'flags' => $flags, | 'flags' => $flags, | ||||
| 'from' => null, | 'from' => null, | ||||
| ); | ); | ||||
| $last_path = $path; | $last_path = $path; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | foreach ($chunks as $chunk) { | ||||
| break; | break; | ||||
| case 'tag': | case 'tag': | ||||
| $commit['tag'] = $value; | $commit['tag'] = $value; | ||||
| break; | break; | ||||
| case 'bookmark': | case 'bookmark': | ||||
| $commit['bookmark'] = $value; | $commit['bookmark'] = $value; | ||||
| break; | break; | ||||
| default: | default: | ||||
| throw new Exception("Unknown Mercurial log field '{$name}'!"); | throw new Exception( | ||||
| pht("Unknown Mercurial log field '%s'!", $name)); | |||||
| } | } | ||||
| } | } | ||||
| $result[] = $commit; | $result[] = $commit; | ||||
| } | } | ||||
| return $result; | return $result; | ||||
| } | } | ||||
| Show All 25 Lines | foreach ($lines as $line) { | ||||
| // ...but may also have human-readable cues like: | // ...but may also have human-readable cues like: | ||||
| // | // | ||||
| // stable 15095:ec222a29bdf0 (inactive) | // stable 15095:ec222a29bdf0 (inactive) | ||||
| // | // | ||||
| // See the unit tests for more examples. | // See the unit tests for more examples. | ||||
| $regexp = '/^(\S+(?:\s+\S+)*)\s+(\d+):([a-f0-9]+)(\s+\\(inactive\\))?$/'; | $regexp = '/^(\S+(?:\s+\S+)*)\s+(\d+):([a-f0-9]+)(\s+\\(inactive\\))?$/'; | ||||
| if (!preg_match($regexp, $line, $matches)) { | if (!preg_match($regexp, $line, $matches)) { | ||||
| throw new Exception("Failed to parse 'hg branches' output: {$line}"); | throw new Exception( | ||||
| pht( | |||||
| "Failed to parse '%s' output: %s", | |||||
| 'hg branches', | |||||
| $line)); | |||||
| } | } | ||||
| $branches[$matches[1]] = array( | $branches[$matches[1]] = array( | ||||
| 'local' => $matches[2], | 'local' => $matches[2], | ||||
| 'rev' => $matches[3], | 'rev' => $matches[3], | ||||
| ); | ); | ||||
| } | } | ||||
| return $branches; | return $branches; | ||||
| } | } | ||||
| } | } | ||||