1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2025-03-16 06:14:55 +01:00

Added support for hg diffs generated in git mode

Summary: Fixes T2112. These are fairly common now, and are used as the storage format for `hg export` and mq in most installs.

Test Plan: Ran unit tests, used `arc patch --patch`, uploaded some diffs manually.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2112

Differential Revision: https://secure.phabricator.com/D4592
This commit is contained in:
Asher Baker 2013-01-22 18:13:53 -08:00 committed by epriestley
parent 7f93b7de02
commit 087ad5f84a
3 changed files with 22 additions and 3 deletions

View file

@ -210,7 +210,6 @@ final class ArcanistDiffParser {
'(?P<binary>Binary) files '.
'(?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". 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>.+)',
@ -226,7 +225,7 @@ final class ArcanistDiffParser {
// contains some meta information and comment at the beginning
// (isFirstNonEmptyLine() to check for beginning). Actual mercurial
// code detects where comment ends and unified diff starts by
// searching "diff -r" in the text.
// searching for "diff -r" or "diff --git" in the text.
$this->saveLine();
$line = $this->nextLineThatLooksLikeDiffStart();
if (!$this->tryMatchHeader($patterns, $line, $match)) {
@ -1049,7 +1048,7 @@ final class ArcanistDiffParser {
protected function nextLineThatLooksLikeDiffStart() {
while (($line = $this->nextLine()) !== null) {
if (preg_match('/^\s*diff\s+-r/', $line)) {
if (preg_match('/^\s*diff\s+-(?:r|-git)/', $line)) {
break;
}
}

View file

@ -526,6 +526,9 @@ EOTEXT
case 'hg-patch.hgdiff':
$this->assertEqual(1, count($changes));
break;
case 'hg-patch-git.hgdiff':
$this->assertEqual(1, count($changes));
break;
case 'custom-prefixes.gitdiff':
$this->assertEqual(1, count($changes));
$change = head($changes);

View file

@ -0,0 +1,17 @@
# HG changeset patch
# Date 1358829820 0
# Node ID 0c4c74e145f5e842a855330f600dba87b2f80fc9
# Parent 80034eb49c320ccd43a1635471baf5c359f43cb5
Added .arcconfig
diff --git a/.arcconfig b/.arcconfig
new file mode 100644
--- /dev/null
+++ b/.arcconfig
@@ -0,0 +1,5 @@
+{
+ "project_id" : "TestProject",
+ "conduit_uri" : "http://phabricator.example.com/",
+ "history.immutable" : true
+}