]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Change hg arc diff to detect up to the nearest parent with a diff
authordurham <durham@fb.com>
Fri, 12 Apr 2013 21:11:51 +0000 (14:11 -0700)
committerdurham <durham@fb.com>
Fri, 12 Apr 2013 21:11:51 +0000 (14:11 -0700)
Summary:
Changes arc diff to choose the base commit as the first ancestor
that has a diff.  So if your tree looks like master->A->B->C->D, if you
have a diff on B (which will include A), when you run arc diff on D it will
only include C and D.

This makes the scenario for stacked diffs nicer.  A user can commit A, commit B,
arc diff, commit C, commit D, arc diff, arc land B, arc land D.

Test Plan:
Commit A on top of master
Commit B on top of A
arc diff
Commit C on top of B
Commit D on top of C
arc diff

Verify the second diff contains the changes in C and D, but not A and B.

hg up B
arc land --preview
Verify that arc land shows A and B

hg up D
arc land --preview
Verify that arc land shows A, B, C, and D
(arc land should be unaffected by this change.
It always tries to land the entire branch)

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D5639

src/parser/ArcanistBaseCommitParser.php
src/repository/api/ArcanistMercurialAPI.php

index 24cf6c73148642cca748f809f0f71651c833f488..3081e7ed85cfd0da78e0446ee9b37c5b5d4ade9e 100644 (file)
@@ -165,6 +165,8 @@ final class ArcanistBaseCommitParser {
           } else {
             return null;
           }
+        } else if (preg_match('/^nodiff\((.*)\)$/', $name, $matches)) {
+          return $this->api->resolveBaseCommitRule($rule, $source);
         }
 
         throw new ArcanistUsageException(
index 001eeebabef9536f129fb8be954c05272178754e..7b9d78abe02422861e0f5295136ce03f1f4caab7 100644 (file)
@@ -832,7 +832,35 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
               "you specified '{$rule}' in your {$source} 'base' ".
               "configuration.");
             return $this->getCanonicalRevisionName('.^');
-        }
+          default:
+            if (preg_match('/^nodiff\((.+)\)$/', $name, $matches)) {
+              list($results) = $this->execxLocal(
+                'log --template %s --rev %s',
+                '{node}\1{desc}\2',
+                sprintf('ancestor(.,%s)::.^', $matches[1]));
+              $results = array_reverse(explode("\2", trim($results)));
+
+              foreach ($results as $result) {
+                if (empty($result)) {
+                  continue;
+                }
+
+                list($node, $desc) = explode("\1", $result, 2);
+
+                $message = ArcanistDifferentialCommitMessage::newFromRawCorpus(
+                  $desc);
+                if ($message->getRevisionID()) {
+                  $this->setBaseCommitExplanation(
+                    "it is the first ancestor of . that has a diff ".
+                    "and is the gca or a descendant of the gca with ".
+                    "'{$matches[1]}', specified by '{$rule}' in your ".
+                    "{$source} 'base' configuration.");
+                  return $node;
+                }
+              }
+            }
+            break;
+          }
         break;
       default:
         return null;