Mercurial > hg
changeset 11451:51021f4c80b5 stable
resolve: do not crash on empty mergestate
I managed to get an empty .hg/merge/state file by interrupting a merge
by pressing Control-C. This lead to this error:
TypeError: a2b_hex() argument 1 must be string or read-only buffer,
not None
since localnode is assigned None before the iteration over lines in
the mergestate begins.
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Sun, 27 Jun 2010 23:12:05 +0200 |
parents | 6bca9801c92a |
children | eac141407b85 |
files | mercurial/merge.py tests/test-resolve tests/test-resolve.out |
diffstat | 3 files changed, 8 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/merge.py Wed Jun 23 16:54:12 2010 -1000 +++ b/mercurial/merge.py Sun Jun 27 23:12:05 2010 +0200 @@ -23,15 +23,13 @@ def _read(self): self._state = {} try: - localnode = None f = self._repo.opener("merge/state") for i, l in enumerate(f): if i == 0: - localnode = l[:-1] + self._local = bin(l[:-1]) else: bits = l[:-1].split("\0") self._state[bits[0]] = bits[1:] - self._local = bin(localnode) except IOError, err: if err.errno != errno.ENOENT: raise
--- a/tests/test-resolve Wed Jun 23 16:54:12 2010 -1000 +++ b/tests/test-resolve Sun Jun 27 23:12:05 2010 +0200 @@ -25,3 +25,9 @@ echo % resolve -l, should be empty hg resolve -l + +# test crashed merge with empty mergestate +mkdir .hg/merge +touch .hg/merge/state +echo % resolve -l, should be empty +hg resolve -l
--- a/tests/test-resolve.out Wed Jun 23 16:54:12 2010 -1000 +++ b/tests/test-resolve.out Sun Jun 27 23:12:05 2010 +0200 @@ -6,3 +6,4 @@ 0 files updated, 0 files merged, 0 files removed, 1 files unresolved use 'hg resolve' to retry unresolved file merges or 'hg update -C' to abandon % resolve -l, should be empty +% resolve -l, should be empty