Mercurial > hg
diff tests/test-command-template @ 9536:f04d17912441
cmdutil: templating keywords latesttag and latesttagdistance
This can be used for referring to revisions in a reasonable
meaningful, stable and monotonically increasing way, suitable for
releases or builds directly from a repository.
The latest tag is found by searching through untagged ancestors and
finding the latest tagged ancestor based on tag date. The distance is
found from the length of the longest path to the tagged revision.
For example:
hg log -l1 --template '{latesttag}+{latesttagdistance}\n'
can return
1.3.1+197
This is mostly work by Gilles Moris <gilles.moris@free.fr>
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Sat, 03 Oct 2009 18:31:20 +0200 |
parents | 829ac0af66a4 |
children | 0aa1a632262b 8ebb34b0f6f7 |
line wrap: on
line diff
--- a/tests/test-command-template Sat Oct 03 23:38:10 2009 +0200 +++ b/tests/test-command-template Sat Oct 03 18:31:20 2009 +0200 @@ -127,4 +127,49 @@ echo 'x = "f' >> t hg log +cd .. + +echo '# latesttag' +hg init latesttag +cd latesttag + +echo a > file +hg ci -Am a -d '0 0' + +echo b >> file +hg ci -m b -d '1 0' + +echo c >> head1 +hg ci -Am h1c -d '2 0' + +hg update -q 1 +echo d >> head2 +hg ci -Am h2d -d '3 0' + +echo e >> head2 +hg ci -m h2e -d '4 0' + +hg merge -q +hg ci -m merge -d '5 0' + +echo '# No tag set' +hg log --template '{rev}: {latesttag}+{latesttagdistance}\n' + +echo '# one common tag: longuest path wins' +hg tag -r 1 -m t1 -d '6 0' t1 +hg log --template '{rev}: {latesttag}+{latesttagdistance}\n' + +echo '# one ancestor tag: more recent wins' +hg tag -r 2 -m t2 -d '7 0' t2 +hg log --template '{rev}: {latesttag}+{latesttagdistance}\n' + +echo '# two branch tags: more recent wins' +hg tag -r 3 -m t3 -d '8 0' t3 +hg log --template '{rev}: {latesttag}+{latesttagdistance}\n' + +echo '# merged tag overrides' +hg tag -r 5 -m t5 -d '9 0' t5 +hg tag -r 3 -m at3 -d '10 0' at3 +hg log --template '{rev}: {latesttag}+{latesttagdistance}\n' + echo '# done'