]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Improve arc commit with SVN branches
authorEric Stern <eric@ericstern.com>
Sun, 4 Aug 2013 16:01:22 +0000 (09:01 -0700)
committerepriestley <git@epriestley.com>
Sun, 4 Aug 2013 16:01:22 +0000 (09:01 -0700)
Summary:
If you are trying to commit someone else's diff, arc commit gives warnings about path mismatch. This changes the path comparison to be based on the repo url rather than the local working directory. E.g. if both the author and committer are working in branches/release/2013_08_07 despite being checked out in ~/dev/2013_08_07 (system user being different, of course) it no longer warns that the WC path is different

Original behavior:

eric@Eric-MBP ~/dev/2013_07_31: arc commit --revision 21
You are not the author of 'D21: WeMerge Automatic Request'. Commit this
revision anyway? [y/N] y

Revision 'D21: WeMerge Automatic Request' was generated from '', but
current working copy root is '/Users/eric/dev/2013_07_31/'. Commit this
revision anyway? [y/N] y

Committing 'D21: WeMerge Automatic Request'...
Adding         test
Transmitting file data .
Committed revision 52676.
Closing revision D21 'WeMerge Automatic Request'...
Exception
ERR-CONDUIT-CORE: You can not mark a revision you don't own as closed.
(Run with --trace for a full exception trace.)

New behavior:

eric@Eric-MBP ~/dev/2013_07_31: arc commit --revision 24

You are not the author of 'D24: WeMerge Automatic Request'. Commit this
revision anyway? [y/N] y

Committing 'D24: WeMerge Automatic Request'...
Adding         test
Transmitting file data .
Committed revision 52679.
Closing revision D24 'WeMerge Automatic Request'...
Exception
ERR-CONDUIT-CORE: You can not mark a revision you don't own as closed.
(Run with --trace for a full exception trace.)

Test Plan: 'arc diff' changes with one user. 'arc patch Dxx' on a different working copy by a different user to review and test changes. accept review. 'arc commit --revision xx' as reviewer to land the patch. complaint goes away.

Reviewers: epriestley, ghostwriter78

Reviewed By: epriestley

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

src/repository/api/ArcanistSubversionAPI.php
src/repository/api/__tests__/ArcanistRepositoryAPIStateTestCase.php
src/workflow/ArcanistCommitWorkflow.php

index 7206e31129306857b3e2e6b0a5133eb93b4f1d52..8a32378b418d7f0db91af16ceebdab1d28e2527e 100644 (file)
@@ -233,6 +233,13 @@ final class ArcanistSubversionAPI extends ArcanistRepositoryAPI {
   }
 
   public function getBranchName() {
+    $info = $this->getSVNInfo('/');
+    $repo_root = idx($info, 'Repository Root');
+    $repo_root_length = strlen($repo_root);
+    $url = idx($info, 'URL');
+    if (substr($url, 0, $repo_root_length) == $repo_root) {
+      return substr($url, $repo_root_length);
+    }
     return 'svn';
   }
 
@@ -329,6 +336,7 @@ final class ArcanistSubversionAPI extends ArcanistRepositoryAPI {
         '/^(Last Changed Date): (.+) \(.+\)$/m',
         '/^(Copied From URL): (\S+)$/m',
         '/^(Copied From Rev): (\d+)$/m',
+        '/^(Repository Root): (\S+)$/m',
         '/^(Repository UUID): (\S+)$/m',
         '/^(Node Kind): (\S+)$/m',
       );
index d3c89f1fc24f6aff4375a85c9206854d79af09fd..13c822031f9ba19784e4c706ec3f8b25efdafae5 100644 (file)
@@ -2,22 +2,42 @@
 
 final class ArcanistRepositoryAPIStateTestCase extends ArcanistTestCase {
 
-  public function testStateParsing() {
-    $dir = dirname(__FILE__).'/state/';
+  public function testGitStateParsing() {
+    if (Filesystem::binaryExists('git')) {
+      $this->parseState('git_basic.git.tgz');
+    } else {
+      $this->assertSkipped('Git is not installed');
+    }
+  }
 
-    $tests = Filesystem::listDirectory($dir, $include_hidden = false);
-    foreach ($tests as $test) {
-      $fixture = PhutilDirectoryFixture::newFromArchive($dir.'/'.$test);
+  public function testHgStateParsing() {
+    if (Filesystem::binaryExists('hg')) {
+      $this->parseState('hg_basic.hg.tgz');
+    } else {
+      $this->assertSkipped('Mercurial is not installed');
+    }
+  }
 
-      $fixture_path = $fixture->getPath();
-      $working_copy = ArcanistWorkingCopyIdentity::newFromPath($fixture_path);
+  public function testSvnStateParsing() {
+    if (Filesystem::binaryExists('svn')) {
+      $this->parseState('svn_basic.svn.tgz');
+    } else {
+      $this->assertSkipped('Subversion is not installed');
+    }
+  }
 
-      $api = ArcanistRepositoryAPI::newAPIFromWorkingCopyIdentity(
-        $working_copy);
-      $api->setBaseCommitArgumentRules('arc:this');
+  private function parseState($test) {
+    $dir = dirname(__FILE__) . '/state/';
+    $fixture = PhutilDirectoryFixture::newFromArchive($dir.'/'.$test);
 
-      $this->assertCorrectState($test, $api);
-    }
+    $fixture_path = $fixture->getPath();
+    $working_copy = ArcanistWorkingCopyIdentity::newFromPath($fixture_path);
+
+    $api = ArcanistRepositoryAPI::newAPIFromWorkingCopyIdentity(
+      $working_copy);
+    $api->setBaseCommitArgumentRules('arc:this');
+
+    $this->assertCorrectState($test, $api);
   }
 
   private function assertCorrectState($test, ArcanistRepositoryAPI $api) {
index 45243ac9d2096ad237e108f0ef3773bc44843fa0..e54ad9ce254bd383c372aa0acfa812fcef9e0cc5 100644 (file)
@@ -320,8 +320,8 @@ EOTEXT
         "Commit this revision anyway?";
     }
 
-    $revision_source = idx($revision, 'sourcePath');
-    $current_source = $repository_api->getPath();
+    $revision_source = idx($revision, 'branch');
+    $current_source = $repository_api->getSourceControlPath();
     if ($revision_source != $current_source) {
       $confirm[] =
         "Revision 'D{$revision_id}: {$revision_title}' was generated from ".