Patchwork D8622: hgext.git: decode node IDs back into Python strings (issue6349)

login
register
mail settings
Submitter phabricator
Date June 9, 2020, 8:49 p.m.
Message ID <differential-rev-PHID-DREV-owxz5gzofdmopp2qn3x2-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46489/
State Superseded
Headers show

Comments

phabricator - June 9, 2020, 8:49 p.m.
hollisb created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  db.text_factory = bytes, so the database contains only strings. The object IDs
  we get from pygit2 are Python strings. b'foo' != 'foo'
  
  This change allows the "don't reindex" optimization to work by allowing the
  "cur_cache_heads == cache_heads" comparison a few lines down to succeed.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

REVISION DETAIL
  https://phab.mercurial-scm.org/D8622

AFFECTED FILES
  hgext/git/index.py

CHANGE DETAILS




To: hollisb, durin42, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/hgext/git/index.py b/hgext/git/index.py
--- a/hgext/git/index.py
+++ b/hgext/git/index.py
@@ -245,7 +245,10 @@ 
     # TODO: we should figure out how to incrementally index history
     # (preferably by detecting rewinds!) so that we don't have to do a
     # full changelog walk every time a new commit is created.
-    cache_heads = {x[0] for x in db.execute('SELECT node FROM possible_heads')}
+    cache_heads = {
+        x[0].decode("utf-8")
+        for x in db.execute('SELECT node FROM possible_heads')
+    }
     walker = None
     cur_cache_heads = {h.hex for h in possible_heads}
     if cur_cache_heads == cache_heads: