@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix some mercurial edge cases

Summary:
- Old versions of Mercurial give different output for `hg log -- ''` and `hg log`. Just use `hg log`.
- Branch names with spaces can't be specified in `--rev`. I talked with hstuart in #mercurial and apparently am not crazy.

Test Plan:
- Viewed history of a repository.
- Viewed history of a file.
- Viewed branch `m m m m m 2:ffffffffffff (inactive)`
- Learned that you checkout this branch with `hg checkout ':m m m m m 2:ffffffffffff (inactive)'`

Reviewers: dschleimer, btrahan

Reviewed By: dschleimer

CC: aran

Maniphest Tasks: T1268

Differential Revision: https://secure.phabricator.com/D2950

+37 -7
+22 -6
src/applications/diffusion/query/history/DiffusionMercurialHistoryQuery.php
··· 26 26 $commit_hash = $drequest->getStableCommitName(); 27 27 28 28 $path = DiffusionPathIDQuery::normalizePath($path); 29 + $path = ltrim($path, '/'); 29 30 30 - // NOTE: Using '' as a default path produces the correct behavior if HEAD 31 - // is a merge commit; using '.' does not (the merge commit is not included 32 - // in the log). 33 - $default_path = ''; 31 + // NOTE: Older versions of Mercurial give different results for these 32 + // commands (see T1268): 33 + // 34 + // $ hg log -- '' 35 + // $ hg log 36 + // 37 + // All versions of Mercurial give different results for these commands 38 + // (merge commits are excluded with the "." version): 39 + // 40 + // $ hg log -- . 41 + // $ hg log 42 + // 43 + // If we don't have a path component in the query, omit it from the command 44 + // entirely to avoid these inconsistencies. 45 + 46 + $path_arg = ''; 47 + if (strlen($path)) { 48 + $path_arg = csprintf('-- %s', $path); 49 + } 34 50 35 51 // NOTE: --branch used to be called --only-branch; use -b for compatibility. 36 52 list($stdout) = $repository->execxLocalCommand( 37 - 'log --debug --template %s --limit %d -b %s --rev %s:0 -- %s', 53 + 'log --debug --template %s --limit %d -b %s --rev %s:0 %C', 38 54 '{node};{parents}\\n', 39 55 ($this->getOffset() + $this->getLimit()), // No '--skip' in Mercurial. 40 56 $drequest->getBranch(), 41 57 $commit_hash, 42 - nonempty(ltrim($path, '/'), $default_path)); 58 + $path_arg); 43 59 44 60 $lines = explode("\n", trim($stdout)); 45 61 $lines = array_slice($lines, $this->getOffset());
+15 -1
src/applications/diffusion/request/DiffusionMercurialRequest.php
··· 59 59 if ($this->commit) { 60 60 $this->stableCommitName = $this->commit; 61 61 } else { 62 + 63 + // NOTE: For branches with spaces in their name like "a b", this 64 + // does not work properly: 65 + // 66 + // $ hg log --rev 'a b' 67 + // 68 + // We can use revsets instead: 69 + // 70 + // $ hg log --rev branch('a b') 71 + // 72 + // ...but they require a somewhat newer version of Mercurial. Instead, 73 + // use "-b" flag with limit 1 for greatest compatibility across 74 + // versions. 75 + 62 76 list($this->stableCommitName) = $this->repository->execxLocalCommand( 63 - 'log --template=%s --rev %s', 77 + 'log --template=%s -b %s --limit 1', 64 78 '{node}', 65 79 $this->getBranch()); 66 80 }