Dulwich treats ref names internally as unicode strings (probably because of Python 3?), which means that at some points it tries to do os.path.join between the repo path and the unicode of the ref name, which fails miserably if we construct the repo with a str and not a unicode. Kludge around this problem. Fixes issue 172.
Unified · Split
| @@ -19,6 +19,7 @@ from mercurial.i18n import _ · 18 unmodified lines | ||
| 19 | 19 | from mercurial.node import hex, bin, nullid |
| 20 | 20 | from mercurial import bookmarks |
| 21 | 21 | from mercurial import commands |
| 22 | +from mercurial import encoding | |
| 22 | 23 | from mercurial import context, util as hgutil |
| 23 | 24 | from mercurial import url |
| 24 | 25 | |
| @@ -135,12 +136,18 @@ class GitHandler(object): · 110 unmodified lines | ||
| 135 | 136 | |
| 136 | 137 | @hgutil.propertycache |
| 137 | 138 | def git(self): |
| 139 | + # Dulwich is going to try and join unicode ref names against | |
| 140 | + # the repository path to try and read unpacked refs. This | |
| 141 | + # doesn't match hg's bytes-only view of filesystems, we just | |
| 142 | + # have to cope with that. To cope, just decode the gitdir path | |
| 143 | + # in the local encoding and say a prayer that it decodes. | |
| 144 | + gitpath = self.gitdir.decode(encoding.encoding, encoding.encodingmode) | |
| 138 | 145 | # make the git data directory |
| 139 | 146 | if os.path.exists(self.gitdir): |
| 140 | − return Repo(self.gitdir) | |
| 147 | + return Repo(gitpath) | |
| 141 | 148 | else: |
| 142 | 149 | os.mkdir(self.gitdir) |
| 143 | − return Repo.init_bare(self.gitdir) | |
| 150 | + return Repo.init_bare(gitpath) | |
| 144 | 151 | |
| 145 | 152 | def init_author_file(self): |
| 146 | 153 | self.author_map = {} |