]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Attach local commit information to DVCS revisions
authorepriestley <git@epriestley.com>
Wed, 24 Aug 2011 01:48:55 +0000 (18:48 -0700)
committerepriestley <git@epriestley.com>
Fri, 26 Aug 2011 01:13:53 +0000 (18:13 -0700)
Summary: When a revision is created, attach relevant information about the local
commits which it came from if applicable. This supports T473, for DCVSes and
DCVS workflows with immutable history where we can't just amend commit messages.
It will also allow us to enrich the web interface.

Test Plan: Will verify this info shows up for this very diff.

Reviewers: fratrik, aran, jungejason, tuomaspelkonen

Reviewed By: fratrik

CC: aran, epriestley, fratrik
Differential Revision: 857

src/repository/api/base/ArcanistRepositoryAPI.php
src/repository/api/git/ArcanistGitAPI.php
src/repository/api/mercurial/ArcanistMercurialAPI.php
src/repository/api/subversion/ArcanistSubversionAPI.php
src/workflow/diff/ArcanistDiffWorkflow.php

index 1acdd39f31368ba6b91e7c2c4e69ef23b289ff52..1a987707f89c0c58c23a8f980c9cc867753b7887 100644 (file)
@@ -157,5 +157,6 @@ abstract class ArcanistRepositoryAPI {
   abstract public function getRawDiffText($path);
   abstract public function getOriginalFileData($path);
   abstract public function getCurrentFileData($path);
+  abstract public function getLocalCommitInformation();
 
 }
index 520aad783aed8415ff2f56a918ee87050f5370b3..17181d76a691de909086100502f2c205b318ba56 100644 (file)
@@ -46,6 +46,35 @@ class ArcanistGitAPI extends ArcanistRepositoryAPI {
     return $this;
   }
 
+  public function getLocalCommitInformation() {
+    list($info) = execx(
+      '(cd %s && git log %s..%s --format=%s --)',
+      $this->getPath(),
+      $this->getRelativeCommit(),
+      'HEAD',
+      '%H%x00%T%x00%P%x00%at%x00%an%x00%s');
+
+    $commits = array();
+
+    $info = trim($info);
+    $info = explode("\n", $info);
+    foreach ($info as $line) {
+      list($commit, $tree, $parents, $time, $author, $title)
+        = explode("\0", $line, 6);
+
+      $commits[] = array(
+        'commit'  => $commit,
+        'tree'    => $tree,
+        'parents' => array_filter(explode(' ', $parents)),
+        'time'    => $time,
+        'author'  => $author,
+        'summary' => $title,
+      );
+    }
+
+    return $commits;
+  }
+
   public function getRelativeCommit() {
     if ($this->relativeCommit === null) {
       list($err) = exec_manual(
index 0571cced63abf11b6e099656b735210fd401b795..d9de1a1bc35168ac19868cd48d915b85b0288fcf 100644 (file)
@@ -82,6 +82,16 @@ class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
     return $this->relativeCommit;
   }
 
+  public function getLocalCommitInformation() {
+    list($info) = execx(
+      '(cd %s && hg log --rev %s..%s --)',
+      $this->getPath(),
+      $this->getRelativeCommit(),
+      'tip');
+    return $this->parseMercurialLog($info);
+  }
+
+
   public function getBlame($path) {
     list($stdout) = execx(
       '(cd %s && hg blame -u -v -c --rev %s -- %s)',
@@ -284,6 +294,16 @@ class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
             $commit['local'] = $local;
             $commit['rev'] = $rev;
             break;
+          case 'parent':
+            if (empty($commit['parents'])) {
+              $commit['parents'] = array();
+            }
+            list($local, $rev) = explode(':', $value, 2);
+            $commit['parents'][] = array(
+              'local' => $local,
+              'rev'   => $rev,
+            );
+            break;
           default:
             throw new Exception("Unknown Mercurial log field '{$name}'!");
         }
index 9a6941e21e8cd95e19f4ac41406f8b6e724594fe..4616ed353d3ccd7631aef0a05b7ea684a215d208 100644 (file)
@@ -478,4 +478,8 @@ EODIFF;
     return $info['Repository UUID'];
   }
 
+  public function getLocalCommitInformation() {
+    return null;
+  }
+
 }
index 0a8c4cde6b6b76e692b98626c267f47df5aea55f..8fa933906fcb3e9e19b0c143485bcbba859de083 100644 (file)
@@ -339,6 +339,17 @@ EOTEXT
         ));
     }
 
+    $local_info = $repository_api->getLocalCommitInformation();
+    if ($local_info) {
+      $conduit->callMethodSynchronous(
+        'differential.setdiffproperty',
+        array(
+          'diff_id' => $diff_info['diffid'],
+          'name'    => 'local:commits',
+          'data'    => json_encode($local_info),
+        ));
+    }
+
     if ($this->unresolvedTests) {
       $data = array();
       foreach ($this->unresolvedTests as $test) {