# HG changeset patch # User Patrick Mezard # Date 2010-04-25 21:07:46 # Node ID b3af02b1f19fa8ece30b6a0ff664548b879c9ac2 # Parent 610f047326b9ad2a05fdec5d108a84104917b360 convert/git: check status when reading output stream diff --git a/hgext/convert/git.py b/hgext/convert/git.py --- a/hgext/convert/git.py +++ b/hgext/convert/git.py @@ -94,6 +94,8 @@ class convert_git(converter_source): self.modecache[(f, h)] = (p and "x") or (s and "l") or "" changes.append((f, h)) entry = None + if fh.close(): + raise util.Abort(_('cannot read changes in %s') % version) return (changes, {}) def getcommit(self, version): @@ -144,6 +146,8 @@ class convert_git(converter_source): continue tag = tag[len(prefix):-3] tags[tag] = node + if fh.close(): + raise util.Abort(_('cannot read tags from %s') % self.path) return tags @@ -156,11 +160,11 @@ class convert_git(converter_source): continue m, f = l[:-1].split("\t") changes.append(f) - fh.close() else: fh = self.gitopen('git diff-tree --name-only --root -r %s "%s^%s" --' % (version, version, i + 1)) changes = [f.rstrip('\n') for f in fh] - fh.close() + if fh.close(): + raise util.Abort(_('cannot read changes in %s') % version) return changes diff --git a/tests/test-convert-git b/tests/test-convert-git --- a/tests/test-convert-git +++ b/tests/test-convert-git @@ -170,4 +170,17 @@ hg -R git-repo4-hg log -v echo '% --sourceorder should fail' hg convert --sourcesort git-repo4 git-repo4-sourcesort-hg +echo '% damage git repository and convert again' +cat > damage.py <&1 | \ + sed 's/fatal:.*/fatal: git error/g' + true diff --git a/tests/test-convert-git.out b/tests/test-convert-git.out --- a/tests/test-convert-git.out +++ b/tests/test-convert-git.out @@ -127,3 +127,11 @@ addfoo % --sourceorder should fail initializing destination git-repo4-sourcesort-hg repository abort: --sourcesort is not supported by this data source +% damage git repository and convert again +fatal: git error +initializing destination git-repo4-broken-hg repository +scanning source... +sorting... +converting... +1 addfoo +abort: cannot read changes in 6a101ac3f6d8b2524a64295ffd9be87ed927bfeb