# HG changeset patch # User Patrick Mezard # Date 1224763511 -7200 # Node ID c1dc903dc7b65eafb56eaf3808942dde29cf12ff # Parent b340cb536893b7c0be152f8feffe25c1c9b987f7 convert: read git output in binary mode under Windows (issue 1359) diff -r b340cb536893 -r c1dc903dc7b6 hgext/convert/git.py --- a/hgext/convert/git.py Thu Oct 23 15:35:54 2008 +0200 +++ b/hgext/convert/git.py Thu Oct 23 14:05:11 2008 +0200 @@ -14,7 +14,7 @@ prevgitdir = os.environ.get('GIT_DIR') os.environ['GIT_DIR'] = self.path try: - return util.popen(s) + return util.popen(s, 'rb') finally: if prevgitdir is None: del os.environ['GIT_DIR'] @@ -22,7 +22,7 @@ os.environ['GIT_DIR'] = prevgitdir else: def gitcmd(self, s): - return util.popen('GIT_DIR=%s %s' % (self.path, s)) + return util.popen('GIT_DIR=%s %s' % (self.path, s), 'rb') def __init__(self, ui, path, rev=None): super(convert_git, self).__init__(ui, path, rev=rev) diff -r b340cb536893 -r c1dc903dc7b6 tests/test-convert-git --- a/tests/test-convert-git Thu Oct 23 15:35:54 2008 +0200 +++ b/tests/test-convert-git Thu Oct 23 14:05:11 2008 +0200 @@ -130,3 +130,20 @@ splitrepo 'only some parents of an octopus merge; "discard" a head' 'foo baz quux' +echo +echo '% test binary conversion (issue 1359)' +mkdir git-repo3 +cd git-repo3 +git init-db >/dev/null 2>/dev/null +python -c 'file("b", "wb").write("".join([chr(i) for i in range(256)])*16)' +git add b +commit -a -m addbinary +cd .. + +echo '% convert binary file' +hg convert git-repo3 git-repo3-hg + +cd git-repo3-hg +hg up -C +python -c 'print len(file("b", "rb").read())' + diff -r b340cb536893 -r c1dc903dc7b6 tests/test-convert-git.out --- a/tests/test-convert-git.out Thu Oct 23 15:35:54 2008 +0200 +++ b/tests/test-convert-git.out Thu Oct 23 14:05:11 2008 +0200 @@ -88,3 +88,13 @@ 354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz 9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo 88dfeab657e8cf2cef3dec67b914f49791ae76b1 644 quux + +% test binary conversion (issue 1359) +% convert binary file +initializing destination git-repo3-hg repository +scanning source... +sorting... +converting... +0 addbinary +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +4096