Mercurial > public > mercurial-scm > python-hglib
comparison 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 |
comparison
equal
deleted
inserted
replaced
109:9324a89dd84e | 110:c635e6e7054f |
---|---|
1 from hglib.error import CommandError | |
1 import client, util, templates | 2 import client, util, templates |
2 | 3 |
3 _nullcset = ['-1', '000000000000000000000000000000000000000', '', '', '', '', ''] | 4 _nullcset = ['-1', '000000000000000000000000000000000000000', '', '', '', '', ''] |
4 | 5 |
5 class changectx(object): | 6 class changectx(object): |
16 cset = _nullcset | 17 cset = _nullcset |
17 else: | 18 else: |
18 if isinstance(changeid, (long, int)): | 19 if isinstance(changeid, (long, int)): |
19 changeid = 'rev(%d)' % changeid | 20 changeid = 'rev(%d)' % changeid |
20 | 21 |
21 cset = self._repo.log(changeid) | 22 notfound = False |
22 if not len(cset): | 23 try: |
24 cset = self._repo.log(changeid) | |
25 except CommandError: | |
26 notfound = True | |
27 | |
28 if notfound or not len(cset): | |
23 raise ValueError('changeid %r not found in repo' % changeid) | 29 raise ValueError('changeid %r not found in repo' % changeid) |
24 if len(cset) > 1: | 30 if len(cset) > 1: |
25 raise ValueError('changeid must yield a single changeset') | 31 raise ValueError('changeid must yield a single changeset') |
26 cset = cset[0] | 32 cset = cset[0] |
27 | 33 |