comparison mercurial/revset.py @ 32681:a3064fe3e495

revset: add support for integer and hex wdir identifiers As I said before, partial 'ff...' hash isn't supported yet.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 03 Jun 2017 20:39:33 +0900
parents 4dd292cec3ad
children 9f840d99054c
comparison
equal deleted inserted replaced
32680:a722c8e17363 32681:a3064fe3e495
22 pathutil, 22 pathutil,
23 phases, 23 phases,
24 registrar, 24 registrar,
25 repoview, 25 repoview,
26 revsetlang, 26 revsetlang,
27 scmutil,
27 smartset, 28 smartset,
28 util, 29 util,
29 ) 30 )
30 31
31 # helpers for processing parsed tree 32 # helpers for processing parsed tree
188 return None 189 return None
189 190
190 # operator methods 191 # operator methods
191 192
192 def stringset(repo, subset, x): 193 def stringset(repo, subset, x):
193 x = repo[x].rev() 194 x = scmutil.intrev(repo[x])
194 if (x in subset 195 if (x in subset
195 or x == node.nullrev and isinstance(subset, fullreposet)): 196 or x == node.nullrev and isinstance(subset, fullreposet)):
196 return baseset([x]) 197 return baseset([x])
197 return baseset() 198 return baseset()
198 199
1295 # i18n: "id" is a keyword 1296 # i18n: "id" is a keyword
1296 n = getstring(l[0], _("id requires a string")) 1297 n = getstring(l[0], _("id requires a string"))
1297 if len(n) == 40: 1298 if len(n) == 40:
1298 try: 1299 try:
1299 rn = repo.changelog.rev(node.bin(n)) 1300 rn = repo.changelog.rev(node.bin(n))
1301 except error.WdirUnsupported:
1302 rn = node.wdirrev
1300 except (LookupError, TypeError): 1303 except (LookupError, TypeError):
1301 rn = None 1304 rn = None
1302 else: 1305 else:
1303 rn = None 1306 rn = None
1304 pm = repo.changelog._partialmatch(n) 1307 pm = repo.changelog._partialmatch(n)
1305 if pm is not None: 1308 if pm is not None:
1306 rn = repo.changelog.rev(pm) 1309 try:
1310 rn = repo.changelog.rev(pm)
1311 except error.WdirUnsupported:
1312 rn = node.wdirrev
1307 1313
1308 if rn is None: 1314 if rn is None:
1309 return baseset() 1315 return baseset()
1310 result = baseset([rn]) 1316 result = baseset([rn])
1311 return result & subset 1317 return result & subset
1618 # i18n: "rev" is a keyword 1624 # i18n: "rev" is a keyword
1619 l = int(getstring(l[0], _("rev requires a number"))) 1625 l = int(getstring(l[0], _("rev requires a number")))
1620 except (TypeError, ValueError): 1626 except (TypeError, ValueError):
1621 # i18n: "rev" is a keyword 1627 # i18n: "rev" is a keyword
1622 raise error.ParseError(_("rev expects a number")) 1628 raise error.ParseError(_("rev expects a number"))
1623 if l not in repo.changelog and l != node.nullrev: 1629 if l not in repo.changelog and l not in (node.nullrev, node.wdirrev):
1624 return baseset() 1630 return baseset()
1625 return subset & baseset([l]) 1631 return subset & baseset([l])
1626 1632
1627 @predicate('matching(revision [, field])', safe=True) 1633 @predicate('matching(revision [, field])', safe=True)
1628 def matching(repo, subset, x): 1634 def matching(repo, subset, x):