Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2891911
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
4 KB
Referenced Files
None
Subscribers
None
View Options
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
@@ -1,89 +1,99 @@
<?php
final class DiffusionMercurialHistoryQuery extends DiffusionHistoryQuery {
protected function executeQuery() {
$drequest = $this->getRequest();
$repository = $drequest->getRepository();
$path = $drequest->getPath();
$commit_hash = $drequest->getStableCommitName();
$path = DiffusionPathIDQuery::normalizePath($path);
$path = ltrim($path, '/');
// NOTE: Older versions of Mercurial give different results for these
// commands (see T1268):
//
// $ hg log -- ''
// $ hg log
//
// All versions of Mercurial give different results for these commands
// (merge commits are excluded with the "." version):
//
// $ hg log -- .
// $ hg log
//
// 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);
$lines = explode("\n", trim($stdout));
$lines = array_slice($lines, $this->getOffset());
$hash_list = array();
$parent_map = array();
$last = null;
foreach (array_reverse($lines) as $line) {
list($hash, $parents) = explode(';', $line);
$parents = trim($parents);
if (!$parents) {
if ($last === null) {
$parent_map[$hash] = array('...');
} else {
$parent_map[$hash] = array($last);
}
} else {
$parents = preg_split('/\s+/', $parents);
foreach ($parents as $parent) {
list($plocal, $phash) = explode(':', $parent);
if (!preg_match('/^0+$/', $phash)) {
$parent_map[$hash][] = $phash;
}
}
// This may happen for the zeroth commit in repository, both hashes
// are "000000000...".
if (empty($parent_map[$hash])) {
$parent_map[$hash] = array('...');
}
}
// The rendering code expects the first commit to be "mainline", like
// Git. Flip the order so it does the right thing.
$parent_map[$hash] = array_reverse($parent_map[$hash]);
$hash_list[] = $hash;
$last = $hash;
}
$hash_list = array_reverse($hash_list);
$this->parents = $parent_map;
return $this->loadHistoryForCommitIdentifiers($hash_list);
}
}
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
@@ -1,32 +1,32 @@
<?php
final class DiffusionMercurialLastModifiedQuery
extends DiffusionLastModifiedQuery {
protected function executeQuery() {
$drequest = $this->getRequest();
$repository = $drequest->getRepository();
$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, '/'), '.'));
$commit = id(new PhabricatorRepositoryCommit())->loadOneWhere(
'repositoryID = %d AND commitIdentifier = %s',
$repository->getID(),
$hash);
if ($commit) {
$commit_data = $commit->loadCommitData();
} else {
$commit_data = null;
}
return array($commit, $commit_data);
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Jan 19, 15:56 (2 w, 6 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1126231
Default Alt Text
(4 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment