Mercurial > hg
diff hgext/convert/p4.py @ 31590:78ac8acfc4bd
convert: fix the handling of empty changlist descriptions in P4
Empty changelist descriptions are valid in Perforce. If we encounter one of
them we are currently running into an IndexError. In case of empty commit
messages set the commit message to **empty changelist description**, which
follows Perforce terminology.
author | David Soria Parra <davidsp@fb.com> |
---|---|
date | Wed, 22 Mar 2017 14:12:58 -0500 |
parents | 1d0e4832e616 |
children | 0fa781320203 |
line wrap: on
line diff
--- a/hgext/convert/p4.py Tue Mar 21 17:50:44 2017 -0700 +++ b/hgext/convert/p4.py Wed Mar 22 14:12:58 2017 -0500 @@ -161,7 +161,12 @@ d = self._fetch_revision(change) c = self._construct_commit(d, parents) - shortdesc = c.desc.splitlines(True)[0].rstrip('\r\n') + descarr = c.desc.splitlines(True) + if len(descarr) > 0: + shortdesc = descarr[0].rstrip('\r\n') + else: + shortdesc = '**empty changelist description**' + t = '%s %s' % (c.rev, repr(shortdesc)[1:-1]) ui.status(util.ellipsis(t, 80) + '\n')