##// END OF EJS Templates
localrepo: also fastpath access to working copy parents when possible...
marmoute -
r44563:85c4cd73 default
parent child Browse files
Show More
@@ -1989,6 +1989,7 b' class workingctx(committablectx):'
1989 for f in self.removed():
1989 for f in self.removed():
1990 self._repo.dirstate.drop(f)
1990 self._repo.dirstate.drop(f)
1991 self._repo.dirstate.setparents(node)
1991 self._repo.dirstate.setparents(node)
1992 self._repo._quick_access_changeid_invalidate()
1992
1993
1993 # write changes out explicitly, because nesting wlock at
1994 # write changes out explicitly, because nesting wlock at
1994 # runtime may prevent 'wlock.release()' in 'repo.commit()'
1995 # runtime may prevent 'wlock.release()' in 'repo.commit()'
@@ -1517,18 +1517,51 b' class localrepository(object):'
1517 narrowspec.save(self, newincludes, newexcludes)
1517 narrowspec.save(self, newincludes, newexcludes)
1518 self.invalidate(clearfilecache=True)
1518 self.invalidate(clearfilecache=True)
1519
1519
1520 @util.propertycache
1520 @unfilteredpropertycache
1521 def _quick_access_changeid_null(self):
1522 return {
1523 b'null': (nullrev, nullid),
1524 nullrev: (nullrev, nullid),
1525 nullid: (nullrev, nullid),
1526 }
1527
1528 @unfilteredpropertycache
1529 def _quick_access_changeid_wc(self):
1530 # also fast path access to the working copy parents
1531 # however, only do it for filter that ensure wc is visible.
1532 quick = {}
1533 cl = self.unfiltered().changelog
1534 for node in self.dirstate.parents():
1535 if node == nullid:
1536 continue
1537 rev = cl.index.get_rev(node)
1538 if rev is None:
1539 # unknown working copy parent case:
1540 #
1541 # skip the fast path and let higher code deal with it
1542 continue
1543 pair = (rev, node)
1544 quick[rev] = pair
1545 quick[node] = pair
1546 return quick
1547
1548 @unfilteredmethod
1549 def _quick_access_changeid_invalidate(self):
1550 if '_quick_access_changeid_wc' in vars(self):
1551 del self.__dict__['_quick_access_changeid_wc']
1552
1553 @property
1521 def _quick_access_changeid(self):
1554 def _quick_access_changeid(self):
1522 """an helper dictionnary for __getitem__ calls
1555 """an helper dictionnary for __getitem__ calls
1523
1556
1524 This contains a list of symbol we can recognise right away without
1557 This contains a list of symbol we can recognise right away without
1525 further processing.
1558 further processing.
1526 """
1559 """
1527 return {
1560 mapping = self._quick_access_changeid_null
1528 b'null': (nullrev, nullid),
1561 if self.filtername in repoview.filter_has_wc:
1529 nullrev: (nullrev, nullid),
1562 mapping = mapping.copy()
1530 nullid: (nullrev, nullid),
1563 mapping.update(self._quick_access_changeid_wc)
1531 }
1564 return mapping
1532
1565
1533 def __getitem__(self, changeid):
1566 def __getitem__(self, changeid):
1534 # dealing with special cases
1567 # dealing with special cases
@@ -1887,6 +1920,7 b' class localrepository(object):'
1887
1920
1888 def setparents(self, p1, p2=nullid):
1921 def setparents(self, p1, p2=nullid):
1889 self[None].setparents(p1, p2)
1922 self[None].setparents(p1, p2)
1923 self._quick_access_changeid_invalidate()
1890
1924
1891 def filectx(self, path, changeid=None, fileid=None, changectx=None):
1925 def filectx(self, path, changeid=None, fileid=None, changectx=None):
1892 """changeid must be a changeset revision, if specified.
1926 """changeid must be a changeset revision, if specified.
@@ -2484,6 +2518,7 b' class localrepository(object):'
2484 def invalidatevolatilesets(self):
2518 def invalidatevolatilesets(self):
2485 self.filteredrevcache.clear()
2519 self.filteredrevcache.clear()
2486 obsolete.clearobscaches(self)
2520 obsolete.clearobscaches(self)
2521 self._quick_access_changeid_invalidate()
2487
2522
2488 def invalidatedirstate(self):
2523 def invalidatedirstate(self):
2489 '''Invalidates the dirstate, causing the next call to dirstate
2524 '''Invalidates the dirstate, causing the next call to dirstate
@@ -1466,6 +1466,7 b' def movedirstate(repo, newctx, match=Non'
1466 if src not in newctx or dst in newctx or ds[dst] != b'a':
1466 if src not in newctx or dst in newctx or ds[dst] != b'a':
1467 src = None
1467 src = None
1468 ds.copy(src, dst)
1468 ds.copy(src, dst)
1469 repo._quick_access_changeid_invalidate()
1469
1470
1470
1471
1471 def writerequires(opener, requirements):
1472 def writerequires(opener, requirements):
@@ -62,7 +62,6 b' Getting status of null'
62 Getting status of working copy
62 Getting status of working copy
63
63
64 $ hg status
64 $ hg status
65 debug.filters: computing revision filter for "visible"
66 M c
65 M c
67 A d
66 A d
68 R a
67 R a
@@ -78,7 +77,6 b' Getting data about the working copy pare'
78 Getting working copy diff
77 Getting working copy diff
79
78
80 $ hg diff
79 $ hg diff
81 debug.filters: computing revision filter for "visible"
82 diff -r c2932ca7786be30b67154d541a8764fae5532261 a
80 diff -r c2932ca7786be30b67154d541a8764fae5532261 a
83 --- a/a Thu Jan 01 00:00:00 1970 +0000
81 --- a/a Thu Jan 01 00:00:00 1970 +0000
84 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
82 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
General Comments 0
You need to be logged in to leave comments. Login now