Mercurial > hg
changeset 10987:b3af02b1f19f stable
convert/git: check status when reading output stream
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Sun, 25 Apr 2010 23:07:46 +0200 |
parents | 610f047326b9 |
children | f2340d699e79 bb377a311109 |
files | hgext/convert/git.py tests/test-convert-git tests/test-convert-git.out |
diffstat | 3 files changed, 27 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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 <<EOF +import os +for root, dirs, files in os.walk('git-repo4/.git/objects'): + if files: + path = os.path.join(root, files[0]) + os.remove(path) + break +EOF +python damage.py +hg convert git-repo4 git-repo4-broken-hg 2>&1 | \ + sed 's/fatal:.*/fatal: git error/g' + true
--- 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