Mercurial > hg-stable
diff hgext/convert/convcmd.py @ 7962:62154415821f
convert: fix authormap handling of lines without '='
Unpacking the result from str.split raises ValueError, not IndexError, if the
line does not contain a '='.
author | Marti Raudsepp <marti@juffo.org> |
---|---|
date | Sat, 04 Apr 2009 15:41:32 +0200 |
parents | de377b1a9a84 |
children | 43b70a964e0d |
line wrap: on
line diff
--- 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):