[PATCH] git_handler: fix 'hg tags' with non-ASCII remote refs

13 views
Skip to first unread message

Dan Villiom Podlaski Christiansen

unread,
Feb 18, 2020, 12:55:02 PM2/18/20
to hg-...@googlegroups.com
# HG changeset patch
# User Dan Villiom Podlaski Christiansen <d...@magenta.dk>
# Date 1582047524 -3600
# Tue Feb 18 18:38:44 2020 +0100
# Node ID 14a0f9cd32be902caad707f8255b4fe32786a26c
# Parent 896c7916b456d55dee2557a1c058eabec7042d2f
git_handler: fix 'hg tags' with non-ASCII remote refs

The Dulwich path is a Unicode string; use 'gitdir' instead.

diff --git a/hggit/git_handler.py b/hggit/git_handler.py
--- a/hggit/git_handler.py
+++ b/hggit/git_handler.py
@@ -246,7 +246,8 @@ class GitHandler(object):

def load_remote_refs(self):
self._remote_refs = {}
- refdir = os.path.join(self.git.path, 'refs', 'remotes')
+
+ refdir = os.path.join(self.gitdir, 'refs', 'remotes')

paths = self.paths
# if paths are set, we should still check 'default'
diff --git a/tests/test-encoding.t b/tests/test-encoding.t
--- a/tests/test-encoding.t
+++ b/tests/test-encoding.t
@@ -125,3 +125,38 @@ The warning message changed in Git 1.8.0
Date: Mon Jan 1 00:00:10 2007 +0000

add älphà
+
+push and pull of utf-8 encoded bookmark/branch name
+
+ $ export HGENCODING=UTF-8
+
+ $ cd hgrepo
+ $ hg bookmark 'ṁäştéř'
+ $ hg push ../gitrepo2
+ pushing to ../gitrepo2
+ searching for changes
+ $ cd ..
+ $ hg clone gitrepo2 hgrepo2
+ importing git objects into hg
+ updating to branch default
+ 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ $ hg -R hgrepo2 book
+ * master 3:aabeccdc8b1e
+ \xe1\xb9\x81\xc3\xa4\xc5\x9ft\xc3\xa9\xc5\x99 3:aabeccdc8b1e (esc)
+
+this used to fail due to Unicode errors
+
+ $ hg -R hgrepo2 tags
+ tip 3:aabeccdc8b1e
+ default/\xe1\xb9\x81\xc3\xa4\xc5\x9ft\xc3\xa9\xc5\x99 3:aabeccdc8b1e (esc)
+ default/master 3:aabeccdc8b1e
+
+this is a bug:
+
+ $ HGENCODING=ascii hg clone gitrepo2 hgrepo3
+ importing git objects into hg
+ transaction abort!
+ rollback completed
+ abort: .* (re)
+ [255]
+

Manuel Jacob

unread,
May 8, 2020, 1:14:03 AM5/8/20
to hg-...@googlegroups.com, Dan Villiom Podlaski Christiansen
A change very similar to yours was recently merged as part of the effort
to port hg-git onto Python 3, probably fixing the issue also on Python
2. Can you verify?
Reply all
Reply to author
Forward
0 new messages