]> khamidou — GitHub mirrors - arcanist.git/commitdiff
[Arcanist] collect svn and bookmark info for Mercurial
authordschleimer <dschleimer@fb.com>
Sat, 30 Jun 2012 23:00:48 +0000 (16:00 -0700)
committerdschleimer <dschleimer@fb.com>
Sat, 30 Jun 2012 23:00:48 +0000 (16:00 -0700)
Summary:
This increases the amount of information arc diff collects in
Mercurial repositories.  IN particular, it collects the active
bookmark, if there is one, and svn information in hgsubversion
repositories.

The Phabricator half of this is https://secure.phabricator.com/D2897

Test Plan:
[14:06:59 Sat Jun 30 2012] dschleimer@dev4022.snc6 ~/www-hg
www-hg  2941 $ ~/devtools/arcanist/bin/arc diff --only --conduit-uri http://phabricator.dschleimer.dev4022.facebook.com
HipHop Notice:  Undefined index: 1 in /data/users/dschleimer/devtools/arcanist/src/repository/api/ArcanistMercurialAPI.php on line 708
Created a new Differential diff:
        Diff URI: http://phabricator.dschleimer.dev4022.facebook.com/differential/diff/126/

Included changes:
  A       foo
HipHop Notice:  Undefined index: 1 in /data/users/dschleimer/www-hg/lib/arcanist/arcanist/FacebookArcanistConfiguration.php on line 81
mcproxy on this server is out of date
version: , expected version:
please restart (http://fburl.com/1787362)

[14:07:46 Sat Jun 30 2012] dschleimer@dev4022.snc6 ~/www-hg
www-hg  2941 $ echo '{"diff_id": 126}' | ~/devtools/arcanist/bin/arc call-conduit differential.getdiff --conduit-uri http://phabricator.dschleimer.dev4022.facebook.com | json_pretty | egrep -i 'bookmark|sourcecontrol'
        "bookmark": "bar",
        "sourceControlBaseRevision": "svn+ssh://tubbs/svnroot/tfb/trunk/www@583442",
        "sourceControlPath": "svn+ssh://tubbs/svnroot/tfb/trunk/www",
        "sourceControlSystem": "hg",

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Maniphest Tasks: T1331

Differential Revision: https://secure.phabricator.com/D2896

src/repository/api/ArcanistMercurialAPI.php
src/workflow/ArcanistDiffWorkflow.php

index 058707f52c8cd46aff766e9dbc52e47a1d1c68c5..3d8196cadecd40ef115c9d8c3750b1d9d3e722aa 100644 (file)
@@ -698,4 +698,48 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
 
   }
 
+  public function getSubversionInfo() {
+    $info = array();
+    $base_path = null;
+    $revision = null;
+    list($err, $raw_info) = $this->execManualLocal('svn info');
+    if (!$err) {
+      foreach (explode("\n", trim($raw_info)) as $line) {
+        list($key, $value) = explode(': ', $line, 2);
+        switch ($key) {
+          case 'URL':
+            $info['base_path'] = $value;
+            $base_path = $value;
+            break;
+          case 'Repository UUID':
+            $info['uuid'] = $value;
+            break;
+          case 'Revision':
+            $revision = $value;
+            break;
+          default:
+            break;
+        }
+      }
+      if ($base_path && $revision) {
+        $info['base_revision'] = $base_path.'@'.$revision;
+      }
+    }
+    return $info;
+  }
+
+  public function getActiveBookmark() {
+    list($raw_output) = $this->execxLocal('bookmarks');
+    $raw_output = trim($raw_output);
+    if ($raw_output !== 'no bookmarks set') {
+      foreach (explode("\n", $raw_output) as $line) {
+        $line = trim($line);
+        if ('*' === $line[0]) {
+          return idx(explode(' ', $line, 3), 1);
+        }
+      }
+    }
+    return null;
+  }
+
 }
index 2dea677e1dcddd3deac604b01ab1e81388a0704a..485d3089d400cef3dcbe1db3373cc3a9318d4a06 100644 (file)
@@ -1974,6 +1974,7 @@ EOTEXT
     $parent         = null;
     $source_path    = null;
     $branch         = null;
+    $bookmark       = null;
 
     if (!$this->isRawDiffSource()) {
       $repository_api = $this->getRepositoryAPI();
@@ -2001,7 +2002,15 @@ EOTEXT
       } else if ($repository_api instanceof ArcanistSubversionAPI) {
         $repo_uuid = $repository_api->getRepositorySVNUUID();
       } else if ($repository_api instanceof ArcanistMercurialAPI) {
-        // TODO: Provide this information.
+
+        $bookmark = $repository_api->getActiveBookmark();
+        $svn_info = $repository_api->getSubversionInfo();
+        $repo_uuid = idx($svn_info, 'uuid');
+        $base_path = idx($svn_info, 'base_path', $base_path);
+        $base_revision = idx($svn_info, 'base_revision', $base_revision);
+
+        // TODO: provide parent info
+
       } else {
         throw new Exception("Unsupported repository API!");
       }
@@ -2016,6 +2025,7 @@ EOTEXT
       'sourceMachine'             => php_uname('n'),
       'sourcePath'                => $source_path,
       'branch'                    => $branch,
+      'bookmark'                  => $bookmark,
       'sourceControlSystem'       => $vcs,
       'sourceControlPath'         => $base_path,
       'sourceControlBaseRevision' => $base_revision,