`hg tags` fails in a repository with non-ASCII remote refs
I pushed a git “branch” with a non-ascii character in it, and after that, hg tags
persistently failed with Unicode errors.
(Also posted to the list about a week ago.)
# HG changeset patch
# User Dan Villiom Podlaski Christiansen <dan@magenta.dk>
# Date 1582047524 -3600
# Tue Feb 18 18:38:44 2020 +0100
# Node ID 421d15c83f43afd617a0ca2bc8f8d2e2ebdf0335
# Parent 896c7916b456d55dee2557a1c058eabec7042d2f
# EXP-Topic non-ascii-refs
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]
+