From e2c9ebdbc1d0d8bccc68b20804718939ceec48e2 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 27 Feb 2013 19:17:26 -0800 Subject: [PATCH] Fix DiffusionMercurialHistoryQuery for file history Summary: When querying history of a path, we should continue past branchpoints. See D5146 for more discussion. Test Plan: Viewing history of a file on a branch which never modified the file no longer fatals. (Arguably we could render something like "this file was never modified on this branch" and maybe link to the branch where the branchpoint stems from, but that seems of limited use.) Reviewers: DurhamGoode, vrana, chad Reviewed By: DurhamGoode CC: aran Differential Revision: https://secure.phabricator.com/D5148 --- .../history/DiffusionMercurialHistoryQuery.php | 18 ++++++++++++++---- .../DiffusionMercurialLastModifiedQuery.php | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/applications/diffusion/query/history/DiffusionMercurialHistoryQuery.php b/src/applications/diffusion/query/history/DiffusionMercurialHistoryQuery.php index 5377e820f9..244c54f0a1 100644 --- a/src/applications/diffusion/query/history/DiffusionMercurialHistoryQuery.php +++ b/src/applications/diffusion/query/history/DiffusionMercurialHistoryQuery.php @@ -27,17 +27,27 @@ final class DiffusionMercurialHistoryQuery extends DiffusionHistoryQuery { // If we don't have a path component in the query, omit it from the command // entirely to avoid these inconsistencies. - $path_arg = ''; + // NOTE: When viewing the history of a file, we don't use "-b", because + // Mercurial stops history at the branchpoint but we're interested in all + // ancestors. When viewing history of a branch, we do use "-b", and thus + // stop history (this is more consistent with the Mercurial worldview of + // branches). + if (strlen($path)) { $path_arg = csprintf('-- %s', $path); + $branch_arg = ''; + } else { + $path_arg = ''; + // NOTE: --branch used to be called --only-branch; use -b for + // compatibility. + $branch_arg = csprintf('-b %s', $drequest->getBranch()); } - // NOTE: --branch used to be called --only-branch; use -b for compatibility. list($stdout) = $repository->execxLocalCommand( - 'log --debug --template %s --limit %d -b %s --rev %s:0 %C', + 'log --debug --template %s --limit %d %C --rev %s::0 %C', '{node};{parents}\\n', ($this->getOffset() + $this->getLimit()), // No '--skip' in Mercurial. - $drequest->getBranch(), + $branch_arg, $commit_hash, $path_arg); diff --git a/src/applications/diffusion/query/lastmodified/DiffusionMercurialLastModifiedQuery.php b/src/applications/diffusion/query/lastmodified/DiffusionMercurialLastModifiedQuery.php index 5a5f686351..9a8e648e66 100644 --- a/src/applications/diffusion/query/lastmodified/DiffusionMercurialLastModifiedQuery.php +++ b/src/applications/diffusion/query/lastmodified/DiffusionMercurialLastModifiedQuery.php @@ -10,7 +10,7 @@ final class DiffusionMercurialLastModifiedQuery $path = $drequest->getPath(); list($hash) = $repository->execxLocalCommand( - 'log --template %s --limit 1 --rev %s:0 -- %s', + 'log --template %s --limit 1 --rev %s::0 -- %s', '{node}', $drequest->getCommit(), nonempty(ltrim($path, '/'), '.'));