mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 00:45:18 +03:00
git_handler: work around dulwich using unicode for ref names
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.
This commit is contained in:
parent
7ce87e34cf
commit
28aa302374
@ -19,6 +19,7 @@ from mercurial.i18n import _
|
|||||||
from mercurial.node import hex, bin, nullid
|
from mercurial.node import hex, bin, nullid
|
||||||
from mercurial import bookmarks
|
from mercurial import bookmarks
|
||||||
from mercurial import commands
|
from mercurial import commands
|
||||||
|
from mercurial import encoding
|
||||||
from mercurial import context, util as hgutil
|
from mercurial import context, util as hgutil
|
||||||
from mercurial import url
|
from mercurial import url
|
||||||
|
|
||||||
@ -135,12 +136,18 @@ class GitHandler(object):
|
|||||||
|
|
||||||
@hgutil.propertycache
|
@hgutil.propertycache
|
||||||
def git(self):
|
def git(self):
|
||||||
|
# Dulwich is going to try and join unicode ref names against
|
||||||
|
# the repository path to try and read unpacked refs. This
|
||||||
|
# doesn't match hg's bytes-only view of filesystems, we just
|
||||||
|
# have to cope with that. To cope, just decode the gitdir path
|
||||||
|
# in the local encoding and say a prayer that it decodes.
|
||||||
|
gitpath = self.gitdir.decode(encoding.encoding, encoding.encodingmode)
|
||||||
# make the git data directory
|
# make the git data directory
|
||||||
if os.path.exists(self.gitdir):
|
if os.path.exists(self.gitdir):
|
||||||
return Repo(self.gitdir)
|
return Repo(gitpath)
|
||||||
else:
|
else:
|
||||||
os.mkdir(self.gitdir)
|
os.mkdir(self.gitdir)
|
||||||
return Repo.init_bare(self.gitdir)
|
return Repo.init_bare(gitpath)
|
||||||
|
|
||||||
def init_author_file(self):
|
def init_author_file(self):
|
||||||
self.author_map = {}
|
self.author_map = {}
|
||||||
|
Loading…
Reference in New Issue
Block a user