# HG changeset patch # User Marti Raudsepp # Date 1238852492 -7200 # Node ID 62154415821f5dc9edb89a85cbd62e278212e9ee # Parent 52e442fe43f4abf101e365f75746039b9818a2c2 convert: fix authormap handling of lines without '=' Unpacking the result from str.split raises ValueError, not IndexError, if the line does not contain a '='. diff -r 52e442fe43f4 -r 62154415821f hgext/convert/convcmd.py --- a/hgext/convert/convcmd.py Sat Mar 14 14:31:08 2009 +0200 +++ b/hgext/convert/convcmd.py Sat Apr 04 15:41:32 2009 +0200 @@ -197,24 +197,28 @@ def readauthormap(self, authorfile): afile = open(authorfile, 'r') for line in afile: + if line.strip() == '': continue + try: srcauthor, dstauthor = line.split('=', 1) - srcauthor = srcauthor.strip() - dstauthor = dstauthor.strip() - if srcauthor in self.authors and dstauthor != self.authors[srcauthor]: - self.ui.status( - _('Overriding mapping for author %s, was %s, will be %s\n') - % (srcauthor, self.authors[srcauthor], dstauthor)) - else: - self.ui.debug(_('mapping author %s to %s\n') - % (srcauthor, dstauthor)) - self.authors[srcauthor] = dstauthor - except IndexError: - self.ui.warn( - _('Ignoring bad line in author map file %s: %s\n') - % (authorfile, line.rstrip())) + except ValueError: + msg = _('Ignoring bad line in author map file %s: %s\n') + self.ui.warn(msg % (authorfile, line.rstrip())) + continue + + srcauthor = srcauthor.strip() + dstauthor = dstauthor.strip() + if self.authors.get(srcauthor) in (None, dstauthor): + msg = _('mapping author %s to %s\n') + self.ui.debug(msg % (srcauthor, dstauthor)) + self.authors[srcauthor] = dstauthor + continue + + m = _('overriding mapping for author %s, was %s, will be %s\n') + self.ui.status(m % (srcauthor, self.authors[srcauthor], dstauthor)) + afile.close() def cachecommit(self, rev): diff -r 52e442fe43f4 -r 62154415821f tests/test-convert-authormap --- a/tests/test-convert-authormap Sat Mar 14 14:31:08 2009 +0200 +++ b/tests/test-convert-authormap Sat Apr 04 15:41:32 2009 +0200 @@ -15,6 +15,8 @@ # Explicit --authors cat > authormap.txt <