# HG changeset patch # User Patrick Mezard # Date 1272229666 -7200 # Node ID b3af02b1f19fa8ece30b6a0ff664548b879c9ac2 # Parent 610f047326b9ad2a05fdec5d108a84104917b360 convert/git: check status when reading output stream diff -r 610f047326b9 -r b3af02b1f19f hgext/convert/git.py --- a/hgext/convert/git.py Sun Apr 25 22:59:50 2010 +0200 +++ b/hgext/convert/git.py Sun Apr 25 23:07:46 2010 +0200 @@ -94,6 +94,8 @@ 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 @@ 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 @@ 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 -r 610f047326b9 -r b3af02b1f19f tests/test-convert-git --- a/tests/test-convert-git Sun Apr 25 22:59:50 2010 +0200 +++ b/tests/test-convert-git Sun Apr 25 23:07:46 2010 +0200 @@ -170,4 +170,17 @@ 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 -r 610f047326b9 -r b3af02b1f19f tests/test-convert-git.out --- a/tests/test-convert-git.out Sun Apr 25 22:59:50 2010 +0200 +++ b/tests/test-convert-git.out Sun Apr 25 23:07:46 2010 +0200 @@ -127,3 +127,11 @@ % --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