tests/test-template-functions.t
changeset 40341 d916ed3ca951
parent 40189 9458dbfa7f33
child 40934 d3e688b9ef2e
--- a/tests/test-template-functions.t	Wed Oct 03 16:45:24 2018 +0300
+++ b/tests/test-template-functions.t	Tue Oct 16 07:21:00 2018 -0700
@@ -804,6 +804,8 @@
   e777603221
   bcc7ff960b
   f7769ec2ab
+  $ hg log --template '{shortest(node, 1)}\n' -r null
+  00
   $ hg log --template '{node|shortest}\n' -l1
   e777
 
@@ -915,6 +917,55 @@
 
   $ cd ..
 
+Test prefixhexnode when the first character of the hash is 0.
+  $ hg init hashcollision2
+  $ cd hashcollision2
+  $ cat <<EOF >> .hg/hgrc
+  > [experimental]
+  > evolution.createmarkers=True
+  > EOF
+  $ echo 0 > a
+  $ hg ci -qAm 0
+  $ echo 21 > a
+  $ hg ci -qm 21
+  $ hg up -q null
+  $ hg log -r0: -T '{rev}:{node}\n'
+  0:b4e73ffab476aa0ee32ed81ca51e07169844bc6a
+  1:0cf177ba2b1dc3862a00fb81715fec90950201be
+
+ we need the 'x' prefix to ensure we aren't colliding with rev0. We identify
+ the collision with nullid if we aren't using disambiguatewithin, so we need to set
+ that as well.
+  $ hg --config experimental.revisions.disambiguatewithin='descendants(0)' \
+  >    --config experimental.revisions.prefixhexnode=yes \
+  >    log -r 1 -T '{rev}:{shortest(node, 0)}\n'
+  1:x0
+
+  $ hg debugobsolete 0cf177ba2b1dc3862a00fb81715fec90950201be
+  obsoleted 1 changesets
+  $ hg up -q 0
+  $ echo 61 > a
+  $ hg ci -m 61
+  $ hg log -r0: -T '{rev}:{node}\n'
+  0:b4e73ffab476aa0ee32ed81ca51e07169844bc6a
+  2:01384dde84b3a511ae0835f35ac40bd806c99bb8
+
+ we still have the 'x' prefix because '0' is still the shortest prefix, since
+ rev1's '0c' is hidden.
+  $ hg --config experimental.revisions.disambiguatewithin=0:-1-0 \
+  >    --config experimental.revisions.prefixhexnode=yes \
+  >    log -r 0:-1-0 -T '{rev}:{shortest(node, 0)}\n'
+  2:x0
+
+ we don't have the 'x' prefix on 2 because '01' is not a synonym for rev1.
+  $ hg --config experimental.revisions.disambiguatewithin=0:-1-0 \
+  >    --config experimental.revisions.prefixhexnode=yes \
+  >    log -r 0:-1-0 -T '{rev}:{shortest(node, 0)}\n' --hidden
+  1:0c
+  2:01
+
+  $ cd ..
+
 Test pad function
 
   $ cd r