1512 |
1512 |
1513 def setnarrowpats(self, newincludes, newexcludes): |
1513 def setnarrowpats(self, newincludes, newexcludes): |
1514 narrowspec.save(self, newincludes, newexcludes) |
1514 narrowspec.save(self, newincludes, newexcludes) |
1515 self.invalidate(clearfilecache=True) |
1515 self.invalidate(clearfilecache=True) |
1516 |
1516 |
|
1517 @util.propertycache |
|
1518 def _quick_access_changeid(self): |
|
1519 """an helper dictionnary for __getitem__ calls |
|
1520 |
|
1521 This contains a list of symbol we can recognise right away without |
|
1522 further processing. |
|
1523 """ |
|
1524 return { |
|
1525 b'null': (nullrev, nullid), |
|
1526 nullrev: (nullrev, nullid), |
|
1527 nullid: (nullrev, nullid), |
|
1528 } |
|
1529 |
1517 def __getitem__(self, changeid): |
1530 def __getitem__(self, changeid): |
1518 # dealing with special cases |
1531 # dealing with special cases |
1519 if changeid is None: |
1532 if changeid is None: |
1520 return context.workingctx(self) |
1533 return context.workingctx(self) |
1521 if isinstance(changeid, context.basectx): |
1534 if isinstance(changeid, context.basectx): |
1529 for i in pycompat.xrange(*changeid.indices(len(self))) |
1542 for i in pycompat.xrange(*changeid.indices(len(self))) |
1530 if i not in self.changelog.filteredrevs |
1543 if i not in self.changelog.filteredrevs |
1531 ] |
1544 ] |
1532 |
1545 |
1533 # dealing with some special values |
1546 # dealing with some special values |
1534 if changeid == b'null' or changeid == nullrev or changeid == nullid: |
1547 quick_access = self._quick_access_changeid.get(changeid) |
1535 return context.changectx(self, nullrev, nullid, maybe_filtered=False) |
1548 if quick_access is not None: |
|
1549 rev, node = quick_access |
|
1550 return context.changectx(self, rev, node, maybe_filtered=False) |
1536 if changeid == b'tip': |
1551 if changeid == b'tip': |
1537 node = self.changelog.tip() |
1552 node = self.changelog.tip() |
1538 rev = self.changelog.rev(node) |
1553 rev = self.changelog.rev(node) |
1539 return context.changectx(self, rev, node) |
1554 return context.changectx(self, rev, node) |
1540 |
1555 |