templatekw: choose {latesttag} by len(changes), not date (
issue5659)
As Augie reported in the bug, the current heuristic of choosing the
best tag of a merge commit by taking the one with newest tag (in terms
of tagging date) currently fails in the Mercurial repo itself. Copying
the example from Yuya:
$ hg glog -T '{node|short} {latesttag}+{latesttagdistance}\n' \
-r '4.2.3: & (merge() + parents(merge()) + tag())'
o
02a745c20121 4.2.3+5
|\
| o
86aca74a063b 4.2.3+4
| |\
| | o
e6d8ee3c9ec3 4.3-rc+109
| | |
| | ~
o |
a3ce07e2dde5 4.3.1+2
: |
o |
3fee7f7d2da0 4.3.1+0
|/
o
98e990bb7330 4.2.3+3
|\
| ~
o
506d7e48fbe6 4.2.3+2
:
o
943c91326b23 4.2.3+0
|
~
It seems to me like the best choice is the tag with the smallest
number of changes since it (across all paths, not the longest single
path). So that's what this patch does, even though it's
costly. Best-of-5 timings for Yuya's command above shows a slowdown
from 1.293s to 1.610s. We can optimize it later.
Differential Revision: https://phab.mercurial-scm.org/D447
#require no-symlink
# The following script was used to create the bundle:
#
# hg init symlinks
# cd symlinks
# echo a > a
# mkdir d
# echo b > d/b
# ln -s a a.lnk
# ln -s d/b d/b.lnk
# hg ci -Am t
# hg bundle --base null ../test-no-symlinks.hg
Extract a symlink on a platform not supporting them
$ hg init t
$ cd t
$ hg pull -q "$TESTDIR/bundles/test-no-symlinks.hg"
$ hg update
4 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cat a.lnk && echo
a
$ cat d/b.lnk && echo
d/b
Copy a symlink and move another
$ hg copy a.lnk d/a2.lnk
$ hg mv d/b.lnk b2.lnk
$ hg ci -Am copy
$ cat d/a2.lnk && echo
a
$ cat b2.lnk && echo
d/b
Bundle and extract again
$ hg bundle --base null ../symlinks.hg
2 changesets found
$ cd ..
$ hg init t2
$ cd t2
$ hg pull ../symlinks.hg
pulling from ../symlinks.hg
requesting all changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 6 changes to 6 files
(run 'hg update' to get a working copy)
$ hg update
5 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cat a.lnk && echo
a
$ cat d/a2.lnk && echo
a
$ cat b2.lnk && echo
d/b