Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13314971
D7481.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D7481.diff
View Options
Index: src/repository/api/ArcanistMercurialAPI.php
===================================================================
--- src/repository/api/ArcanistMercurialAPI.php
+++ src/repository/api/ArcanistMercurialAPI.php
@@ -984,22 +984,15 @@
}
public function getBranches() {
- $branches = array();
-
- list($raw_output) = $this->execxLocal('branches');
- $raw_output = trim($raw_output);
-
- foreach (explode("\n", $raw_output) as $line) {
- // example line: default 0:a5ead76cdf85 (inactive)
- list($name, $rev_line) = $this->splitBranchOrBookmarkLine($line);
-
- // strip off the '(inactive)' bit if it exists
- $rev_parts = explode(' ', $rev_line);
- $revision = $rev_parts[0];
+ list($stdout) = $this->execxLocal('--debug branches');
+ $lines = ArcanistMercurialParser::parseMercurialBranches($stdout);
+ $branches = array();
+ foreach ($lines as $name => $spec) {
$branches[] = array(
'name' => $name,
- 'revision' => $revision);
+ 'revision' => $spec['rev'],
+ );
}
return $branches;
Index: src/repository/parser/ArcanistMercurialParser.php
===================================================================
--- src/repository/parser/ArcanistMercurialParser.php
+++ src/repository/parser/ArcanistMercurialParser.php
@@ -188,7 +188,13 @@
* @task parse
*/
public static function parseMercurialBranches($stdout) {
- $lines = explode("\n", trim($stdout));
+ $stdout = rtrim($stdout, "\n");
+ if (!strlen($stdout)) {
+ // No branches; commonly, this occurs in a newly initialized repository.
+ return array();
+ }
+
+ $lines = explode("\n", $stdout);
$branches = array();
foreach ($lines as $line) {
Index: src/repository/parser/__tests__/ArcanistMercurialParserTestCase.php
===================================================================
--- src/repository/parser/__tests__/ArcanistMercurialParserTestCase.php
+++ src/repository/parser/__tests__/ArcanistMercurialParserTestCase.php
@@ -36,6 +36,10 @@
array('0b9d8290c4e0', '78963faacfc7', '5db03c5500c6', 'ffffffffffff'),
array_values(ipull($output, 'rev')));
break;
+ case 'branches-empty.txt':
+ $output = ArcanistMercurialParser::parseMercurialBranches($data);
+ $this->assertEqual(array(), $output);
+ break;
case 'log-basic.txt':
$output = ArcanistMercurialParser::parseMercurialLog($data);
$this->assertEqual(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jun 13, 6:48 AM (1 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6291431
Default Alt Text
D7481.diff (2 KB)
Attached To
Mode
D7481: Handle empty output from `hg --debug branches` in the parser
Attached
Detach File
Event Timeline
Log In to Comment