comparison mercurial/localrepo.py @ 32660:a722c8e17363

localrepo: map integer and hex wdir identifiers to workingctx changectx.__init__() is slightly modified to take str(wdirrev) as a valid integer revision (and raise WdirUnsupported exception.) Test will be added by the next patch.
author Yuya Nishihara <yuya@tcha.org>
date Fri, 19 Aug 2016 18:40:35 +0900
parents a87dabb053d0
children 19b9fc40cc51
comparison
equal deleted inserted replaced
32659:7b17f9de6d3e 32660:a722c8e17363
18 from .i18n import _ 18 from .i18n import _
19 from .node import ( 19 from .node import (
20 hex, 20 hex,
21 nullid, 21 nullid,
22 short, 22 short,
23 wdirrev,
24 ) 23 )
25 from . import ( 24 from . import (
26 bookmarks, 25 bookmarks,
27 branchmap, 26 branchmap,
28 bundle2, 27 bundle2,
562 self.ui.warn(_("warning: ignoring unknown" 561 self.ui.warn(_("warning: ignoring unknown"
563 " working parent %s!\n") % short(node)) 562 " working parent %s!\n") % short(node))
564 return nullid 563 return nullid
565 564
566 def __getitem__(self, changeid): 565 def __getitem__(self, changeid):
567 if changeid is None or changeid == wdirrev: 566 if changeid is None:
568 return context.workingctx(self) 567 return context.workingctx(self)
569 if isinstance(changeid, slice): 568 if isinstance(changeid, slice):
569 # wdirrev isn't contiguous so the slice shouldn't include it
570 return [context.changectx(self, i) 570 return [context.changectx(self, i)
571 for i in xrange(*changeid.indices(len(self))) 571 for i in xrange(*changeid.indices(len(self)))
572 if i not in self.changelog.filteredrevs] 572 if i not in self.changelog.filteredrevs]
573 return context.changectx(self, changeid) 573 try:
574 return context.changectx(self, changeid)
575 except error.WdirUnsupported:
576 return context.workingctx(self)
574 577
575 def __contains__(self, changeid): 578 def __contains__(self, changeid):
576 """True if the given changeid exists 579 """True if the given changeid exists
577 580
578 error.LookupError is raised if an ambiguous node specified. 581 error.LookupError is raised if an ambiguous node specified.