1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-10 08:52:39 +01:00

Fix parsing of "hg diff -r x:y" diffs

Summary: When you run `hg diff -r x:y`, we get two "-r" arguments in the diff header. Currently, we parse this incorrectly.

Test Plan: Added unit test which previously failed; test now passes.

Reviewers: dschleimer, btrahan

Reviewed By: dschleimer

CC: aran, cakoose

Maniphest Tasks: T1550

Differential Revision: https://secure.phabricator.com/D3061
This commit is contained in:
epriestley 2012-07-25 15:55:32 -07:00
parent 316122c4e0
commit 11d0331d21
3 changed files with 24 additions and 2 deletions

View file

@ -229,8 +229,9 @@ final class ArcanistDiffParser {
'(?P<old>.+)\s+\d{4}-\d{2}-\d{2} and '.
'(?P<new>.+)\s+\d{4}-\d{2}-\d{2} differ.*',
// This is a normal Mercurial text change, probably from "hg diff".
'(?P<type>diff -r) (?P<hgrev>[a-f0-9]+) (?P<cur>.+)',
// This is a normal Mercurial text change, probably from "hg diff". It
// may have two "-r" blocks if it came from "hg diff -r x:y".
'(?P<type>diff -r) (?P<hgrev>[a-f0-9]+) (?:-r [a-f0-9]+ )?(?P<cur>.+)',
);
$ok = false;

View file

@ -527,6 +527,16 @@ EOTEXT
$this->assertEqual('*', idx($new_properties, 'svn:executable'));
$this->assertEqual('text/html', idx($new_properties, 'svn:mime-type'));
break;
case 'hg-diff-range.hgdiff':
$this->assertEqual(1, count($changes));
$change = array_shift($changes);
$this->assertEqual(
'Test.java',
$change->getOldPath());
$this->assertEqual(
'Test.java',
$change->getCurrentPath());
break;
default:
throw new Exception("No test block for diff file {$diff_file}.");
break;

View file

@ -0,0 +1,11 @@
diff -r 2ccefc36d42f -r 6a07a384974e Test.java
--- a/Test.java Tue Jul 24 14:57:51 2012 -0700
+++ b/Test.java Tue Jul 24 14:59:23 2012 -0700
@@ -2,6 +2,6 @@
{
public static void main(String[] args)
{
- System.out.println("Hello!");
+ System.out.println("Hello, world!");
}
}