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
abstract public function getRawDiffText($path);
abstract public function getOriginalFileData($path);
abstract public function getCurrentFileData($path);
+ abstract public function getLocalCommitInformation();
}
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(
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)',
$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}'!");
}
return $info['Repository UUID'];
}
+ public function getLocalCommitInformation() {
+ return null;
+ }
+
}
));
}
+ $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) {