// One commit.
$against = 'HEAD';
} else {
- // 2..N commits.
- $against = $this->getRelativeCommit().'..HEAD';
+
+ // 2..N commits. We include commits reachable from HEAD which are
+ // not reachable from the relative commit; this is consistent with
+ // user expectations even though it is not actually the diff range.
+ // Particularly:
+ //
+ // |
+ // D <----- master branch
+ // |
+ // C Y <- feature branch
+ // | /|
+ // B X
+ // | /
+ // A
+ // |
+ //
+ // If "A, B, C, D" are master, and the user is at Y, when they run
+ // "arc diff B" they want (and get) a diff of B vs Y, but they think about
+ // this as being the commits X and Y. If we log "B..Y", we only show
+ // Y. With "Y --not B", we show X and Y.
+
+ $against = csprintf('%s --not %s', 'HEAD', $this->getRelativeCommit());
}
// NOTE: Windows escaping of "%" symbols apparently is inherently broken;
list($info) = $this->execxLocal(
phutil_is_windows()
- ? 'log %s --format=%C --'
- : 'log %s --format=%s --',
+ ? 'log %C --format=%C --'
+ : 'log %C --format=%s --',
$against,
// NOTE: "%B" is somewhat new, use "%s%n%n%b" instead.
'%H%x01%T%x01%P%x01%at%x01%an%x01%s%x01%s%n%n%b%x02');
$info = explode("\2", $info);
foreach ($info as $line) {
list($commit, $tree, $parents, $time, $author, $title, $message)
- = explode("\1", $line, 7);
+ = explode("\1", trim($line), 7);
$message = rtrim($message);
$commits[$commit] = array(
public function getLocalCommitInformation() {
if ($this->localCommitInfo === null) {
list($info) = $this->execxLocal(
- "log --template '%C' --rev %s..%s --",
+ "log --template '%C' --prune %s --rev %s --branch %s --",
"{node}\1{rev}\1{author}\1{date|rfc822date}\1".
"{branch}\1{tag}\1{parents}\1{desc}\2",
$this->getRelativeCommit(),
- $this->getWorkingCopyRevision());
+ $this->getWorkingCopyRevision().':0',
+ $this->getBranchName());
$logs = array_filter(explode("\2", $info));
$last_node = null;
- $is_first = true;
$futures = array();
}
}
- if (!$commit_parents && !$is_first) {
+ if (!$commit_parents) {
// We didn't get a cheap hit on previous commit, so do the full-cost
// "hg parents" call. We can run these in parallel, at least.
$futures[$node] = $this->execFutureLocal(
);
$last_node = $node;
- $is_first = false;
}
- // Get rid of the first log, it's not actually part of the diff. "hg log"
- // is inclusive, while "hg diff" is exclusive. We do this after processing
- // so we can take advantage of the cheaper lookup for the parents of the
- // first commit we keep, in the common case.
- array_shift($commits);
-
foreach (Futures($futures)->limit(4) as $node => $future) {
list($parents) = $future->resolvex();
$parents = array_filter(explode("\n", $parents));