##// END OF EJS Templates
unbundle: faster computation of changed heads...
Arseniy Alekseyev -
r52288:a0d88b02 default
parent child Browse files
Show More
@@ -518,7 +518,7 b' class cg1unpacker:'
518 # will not see an inconsistent view
518 # will not see an inconsistent view
519 cl = repo.changelog
519 cl = repo.changelog
520 cl.delayupdate(tr)
520 cl.delayupdate(tr)
521 oldheads = set(cl.heads())
521 oldrevcount = len(cl)
522
522
523 trp = weakref.proxy(tr)
523 trp = weakref.proxy(tr)
524 # pull off the changeset group
524 # pull off the changeset group
@@ -673,12 +673,12 b' class cg1unpacker:'
673 tr.changes[b'changegroup-count-files'] += newfiles
673 tr.changes[b'changegroup-count-files'] += newfiles
674
674
675 deltaheads = 0
675 deltaheads = 0
676 if oldheads:
676 newrevcount = len(cl)
677 heads = cl.heads()
677 heads_removed, heads_added = cl.diffheads(oldrevcount, newrevcount)
678 deltaheads += len(heads) - len(oldheads)
678 deltaheads += len(heads_added) - len(heads_removed)
679 for h in heads:
679 for h in heads_added:
680 if h not in oldheads and repo[h].closesbranch():
680 if repo[h].closesbranch():
681 deltaheads -= 1
681 deltaheads -= 1
682
682
683 # see previous comment about checking ui.quiet
683 # see previous comment about checking ui.quiet
684 if not repo.ui.quiet:
684 if not repo.ui.quiet:
@@ -746,12 +746,11 b' class cg1unpacker:'
746 del args[b'node_last']
746 del args[b'node_last']
747 repo.hook(b"incoming", **pycompat.strkwargs(args))
747 repo.hook(b"incoming", **pycompat.strkwargs(args))
748
748
749 newheads = [h for h in repo.heads() if h not in oldheads]
750 repo.ui.log(
749 repo.ui.log(
751 b"incoming",
750 b"incoming",
752 b"%d incoming changes - new heads: %s\n",
751 b"%d incoming changes - new heads: %s\n",
753 len(added),
752 len(added),
754 b', '.join([hex(c[:6]) for c in newheads]),
753 b', '.join([hex(c[:6]) for c in heads_added]),
755 )
754 )
756
755
757 tr.addpostclose(
756 tr.addpostclose(
@@ -1735,7 +1734,6 b' class cgpacker:'
1735 x in self._fullclnodes
1734 x in self._fullclnodes
1736 or cl.rev(x) in self._precomputedellipsis
1735 or cl.rev(x) in self._precomputedellipsis
1737 ):
1736 ):
1738
1739 manifestnode = c.manifest
1737 manifestnode = c.manifest
1740 # Record the first changeset introducing this manifest
1738 # Record the first changeset introducing this manifest
1741 # version.
1739 # version.
@@ -1994,6 +1992,7 b' class cgpacker:'
1994 clrevtolocalrev.clear()
1992 clrevtolocalrev.clear()
1995
1993
1996 linkrevnodes = linknodes(filerevlog, fname)
1994 linkrevnodes = linknodes(filerevlog, fname)
1995
1997 # Lookup for filenodes, we collected the linkrev nodes above in the
1996 # Lookup for filenodes, we collected the linkrev nodes above in the
1998 # fastpath case and with lookupmf in the slowpath case.
1997 # fastpath case and with lookupmf in the slowpath case.
1999 def lookupfilelog(x):
1998 def lookupfilelog(x):
@@ -1035,6 +1035,37 b' def headrevs(revs, parentsfn):'
1035 return headrevs
1035 return headrevs
1036
1036
1037
1037
1038 def headrevsdiff(parentsfn, start, stop):
1039 """Compute how the set of heads changed between
1040 revisions `start-1` and `stop-1`.
1041 """
1042 parents = set()
1043
1044 heads_added = set()
1045 heads_removed = set()
1046
1047 for rev in range(stop - 1, start - 1, -1):
1048 if rev in parents:
1049 parents.remove(rev)
1050 else:
1051 heads_added.add(rev)
1052 for p in parentsfn(rev):
1053 parents.add(p)
1054
1055 # now `parents` is the collection of candidate removed heads
1056 rev = start - 1
1057 while parents:
1058 if rev in parents:
1059 heads_removed.add(rev)
1060 parents.remove(rev)
1061
1062 for p in parentsfn(rev):
1063 parents.discard(p)
1064 rev = rev - 1
1065
1066 return (heads_removed, heads_added)
1067
1068
1038 def headrevssubset(revsfn, parentrevsfn, startrev=None, stoprevs=None):
1069 def headrevssubset(revsfn, parentrevsfn, startrev=None, stoprevs=None):
1039 """Returns the set of all revs that have no children with control.
1070 """Returns the set of all revs that have no children with control.
1040
1071
@@ -132,6 +132,7 b" rustrevlog = policy.importrust('revlog')"
132 # max size of inline data embedded into a revlog
132 # max size of inline data embedded into a revlog
133 _maxinline = 131072
133 _maxinline = 131072
134
134
135
135 # Flag processors for REVIDX_ELLIPSIS.
136 # Flag processors for REVIDX_ELLIPSIS.
136 def ellipsisreadprocessor(rl, text):
137 def ellipsisreadprocessor(rl, text):
137 return text, False
138 return text, False
@@ -1577,7 +1578,6 b' class revlog:'
1577 ]
1578 ]
1578
1579
1579 def _loadindex(self, docket=None):
1580 def _loadindex(self, docket=None):
1580
1581 new_header, mmapindexthreshold, force_nodemap = self._init_opts()
1581 new_header, mmapindexthreshold, force_nodemap = self._init_opts()
1582
1582
1583 if self.postfix is not None:
1583 if self.postfix is not None:
@@ -2345,6 +2345,12 b' class revlog:'
2345 return rustdagop.headrevs(self.index, revs)
2345 return rustdagop.headrevs(self.index, revs)
2346 return dagop.headrevs(revs, self._uncheckedparentrevs)
2346 return dagop.headrevs(revs, self._uncheckedparentrevs)
2347
2347
2348 def headrevsdiff(self, start, stop):
2349 try:
2350 return self.index.headrevsdiff(start, stop)
2351 except AttributeError:
2352 return dagop.headrevsdiff(self._uncheckedparentrevs, start, stop)
2353
2348 def computephases(self, roots):
2354 def computephases(self, roots):
2349 return self.index.computephasesmapsets(roots)
2355 return self.index.computephasesmapsets(roots)
2350
2356
@@ -2392,6 +2398,12 b' class revlog:'
2392
2398
2393 return [self.node(rev) for rev in revs]
2399 return [self.node(rev) for rev in revs]
2394
2400
2401 def diffheads(self, start, stop):
2402 """return the nodes that make up the difference between
2403 heads of revs before `start` and heads of revs before `stop`"""
2404 removed, added = self.headrevsdiff(start, stop)
2405 return [self.node(r) for r in removed], [self.node(r) for r in added]
2406
2395 def children(self, node):
2407 def children(self, node):
2396 """find the children of a given node"""
2408 """find the children of a given node"""
2397 c = []
2409 c = []
General Comments 0
You need to be logged in to leave comments. Login now