Mercurial > python-hglib
diff hglib/context.py @ 110:c635e6e7054f 0.9
context: raise same error when not found for all hg versions
hg log behavior changed, so modify context constructor to account for this
author | Alexander Plavin <me@aplavin.ru> |
---|---|
date | Fri, 26 Apr 2013 01:46:08 +0400 |
parents | 6e423f7c784f |
children | cc7569bffb26 |
line wrap: on
line diff
--- a/hglib/context.py Tue Apr 23 22:11:26 2013 +0200 +++ b/hglib/context.py Fri Apr 26 01:46:08 2013 +0400 @@ -1,3 +1,4 @@ +from hglib.error import CommandError import client, util, templates _nullcset = ['-1', '000000000000000000000000000000000000000', '', '', '', '', ''] @@ -18,8 +19,13 @@ if isinstance(changeid, (long, int)): changeid = 'rev(%d)' % changeid - cset = self._repo.log(changeid) - if not len(cset): + notfound = False + try: + cset = self._repo.log(changeid) + except CommandError: + notfound = True + + if notfound or not len(cset): raise ValueError('changeid %r not found in repo' % changeid) if len(cset) > 1: raise ValueError('changeid must yield a single changeset')