1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-22 06:42:41 +01:00

Attach local commit information to DVCS revisions

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
This commit is contained in:
epriestley 2011-08-23 18:48:55 -07:00
parent 4c05dc3cd6
commit aa138a80d2
5 changed files with 65 additions and 0 deletions

View 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();
}

View 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(

View 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}'!");
}

View file

@ -478,4 +478,8 @@ EODIFF;
return $info['Repository UUID'];
}
public function getLocalCommitInformation() {
return null;
}
}

View 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) {