git: fix partial node matching stable
authorMatt Harbison <matt_harbison@yahoo.com>
Tue, 27 Apr 2021 00:26:12 -0400
branchstable
changeset 47045 846920d89476
parent 47044 96d295dd4968
child 47046 497cedcb6504
git: fix partial node matching Looks like everything is meant to be a str here. Differential Revision: https://phab.mercurial-scm.org/D10521
hgext/git/gitlog.py
tests/test-git-interop.t
--- a/hgext/git/gitlog.py	Tue Apr 27 00:23:05 2021 -0400
+++ b/hgext/git/gitlog.py	Tue Apr 27 00:26:12 2021 -0400
@@ -168,7 +168,8 @@
         candidates = [
             bin(x[0])
             for x in self._db.execute(
-                'SELECT node FROM changelog WHERE node LIKE ?', (id + b'%',)
+                'SELECT node FROM changelog WHERE node LIKE ?',
+                (pycompat.sysstr(id + b'%'),),
             )
         ]
         if nullhex.startswith(id):
--- a/tests/test-git-interop.t	Tue Apr 27 00:23:05 2021 -0400
+++ b/tests/test-git-interop.t	Tue Apr 27 00:26:12 2021 -0400
@@ -271,6 +271,20 @@
   $ hg log -r ae1ab744f95bfd5b07cf573baef98a778058537b --template "{shortest(node,1)}\n"
   ae
 
+This covers gitlog._partialmatch()
+  $ hg log -r a
+  abort: ambiguous revision identifier: a
+  [10]
+  $ hg log -r a1
+  changeset:   2:a1983dd7fb19
+  user:        test <test>
+  date:        Fri Mar 06 14:26:27 2020 -0500
+  summary:     more alpha
+  
+  $ hg log -r dead
+  abort: unknown revision 'dead'
+  [255]
+
 This coveres changelog.findmissing()
   $ hg merge --preview 3d9be8deba43