##// END OF EJS Templates
changegroup: combine infocollect and lookup callbacks
Matt Mackall -
r13782:9131724c default
parent child Browse files
Show More
@@ -110,7 +110,10 b' def writerevs(ui, r1, r2, order, tr):'
110 order = [r1.node(r) for r in order]
110 order = [r1.node(r) for r in order]
111
111
112 # this is a bit ugly, but it works
112 # this is a bit ugly, but it works
113 lookup = lambda x: "%020d" % r1.linkrev(r1.rev(x))
113 def lookup(x):
114 progress(x)
115 return "%020d" % r1.linkrev(r1.rev(x))
116
114 unlookup = lambda x: int(x, 10)
117 unlookup = lambda x: int(x, 10)
115
118
116 try:
119 try:
@@ -1529,11 +1529,15 b' class localrepository(repo.repository):'
1529 def gengroup():
1529 def gengroup():
1530 # The set of changed files starts empty.
1530 # The set of changed files starts empty.
1531 changedfiles = set()
1531 changedfiles = set()
1532
1532 collect = changegroup.collector(cl, mfs, changedfiles)
1533 collect = changegroup.collector(cl, mfs, changedfiles)
1534 def clookup(x):
1535 collect(x)
1536 return x
1533
1537
1534 # Create a changenode group generator that will call our functions
1538 # Create a changenode group generator that will call our functions
1535 # back to lookup the owning changenode and collect information.
1539 # back to lookup the owning changenode and collect information.
1536 group = cl.group(csets, lambda x: x, collect)
1540 group = cl.group(csets, clookup)
1537 for count, chunk in enumerate(group):
1541 for count, chunk in enumerate(group):
1538 yield chunk
1542 yield chunk
1539 # revlog.group yields three entries per node, so
1543 # revlog.group yields three entries per node, so
@@ -1548,9 +1552,12 b' class localrepository(repo.repository):'
1548 prune(mf, mfs)
1552 prune(mf, mfs)
1549 # Create a generator for the manifestnodes that calls our lookup
1553 # Create a generator for the manifestnodes that calls our lookup
1550 # and data collection functions back.
1554 # and data collection functions back.
1551 group = mf.group(sorted(mfs, key=mf.rev),
1555 fcollect = filenode_collector(changedfiles)
1552 lambda mnode: mfs[mnode],
1556 def mlookup(x):
1553 filenode_collector(changedfiles))
1557 fcollect(x)
1558 return mfs[x]
1559
1560 group = mf.group(sorted(mfs, key=mf.rev), mlookup)
1554 for count, chunk in enumerate(group):
1561 for count, chunk in enumerate(group):
1555 yield chunk
1562 yield chunk
1556 # see above comment for why we divide by 3
1563 # see above comment for why we divide by 3
@@ -1577,9 +1584,12 b' class localrepository(repo.repository):'
1577 # Create a group generator and only pass in a changenode
1584 # Create a group generator and only pass in a changenode
1578 # lookup function as we need to collect no information
1585 # lookup function as we need to collect no information
1579 # from filenodes.
1586 # from filenodes.
1587 def flookup(x):
1588 return missingfnodes[x]
1589
1580 group = filerevlog.group(
1590 group = filerevlog.group(
1581 sorted(missingfnodes, key=filerevlog.rev),
1591 sorted(missingfnodes, key=filerevlog.rev),
1582 lambda fnode: missingfnodes[fnode])
1592 flookup)
1583 for chunk in group:
1593 for chunk in group:
1584 # even though we print the same progress on
1594 # even though we print the same progress on
1585 # most loop iterations, put the progress call
1595 # most loop iterations, put the progress call
@@ -1632,9 +1642,13 b' class localrepository(repo.repository):'
1632 # construct a list of all changed files
1642 # construct a list of all changed files
1633 changedfiles = set()
1643 changedfiles = set()
1634 mmfs = {}
1644 mmfs = {}
1635 collect = changegroup.collector(cl, mmfs, changedfiles)
1636
1645
1637 for count, chunk in enumerate(cl.group(nodes, lambda x: x, collect)):
1646 collect = changegroup.collector(cl, mmfs, changedfiles)
1647 def clookup(x):
1648 collect(x)
1649 return x
1650
1651 for count, chunk in enumerate(cl.group(nodes, clookup)):
1638 # revlog.group yields three entries per node, so
1652 # revlog.group yields three entries per node, so
1639 # dividing by 3 gives an approximation of how many
1653 # dividing by 3 gives an approximation of how many
1640 # nodes have been processed.
1654 # nodes have been processed.
@@ -1646,8 +1660,11 b' class localrepository(repo.repository):'
1646
1660
1647 mnfst = self.manifest
1661 mnfst = self.manifest
1648 nodeiter = gennodelst(mnfst)
1662 nodeiter = gennodelst(mnfst)
1649 for count, chunk in enumerate(mnfst.group(nodeiter,
1663 mfunc = lookuplinkrev_func(mnfst)
1650 lookuplinkrev_func(mnfst))):
1664 def mlookup(x):
1665 return mfunc(x)
1666
1667 for count, chunk in enumerate(mnfst.group(nodeiter, mlookup)):
1651 # see above comment for why we divide by 3
1668 # see above comment for why we divide by 3
1652 self.ui.progress(_('bundling'), count / 3,
1669 self.ui.progress(_('bundling'), count / 3,
1653 unit=_('manifests'), total=changecount)
1670 unit=_('manifests'), total=changecount)
@@ -1663,8 +1680,11 b' class localrepository(repo.repository):'
1663 if nodeiter:
1680 if nodeiter:
1664 yield changegroup.chunkheader(len(fname))
1681 yield changegroup.chunkheader(len(fname))
1665 yield fname
1682 yield fname
1666 lookup = lookuplinkrev_func(filerevlog)
1683 ffunc = lookuplinkrev_func(filerevlog)
1667 for chunk in filerevlog.group(nodeiter, lookup):
1684 def flookup(x):
1685 return ffunc(x)
1686
1687 for chunk in filerevlog.group(nodeiter, flookup):
1668 self.ui.progress(
1688 self.ui.progress(
1669 _('bundling'), idx, item=fname,
1689 _('bundling'), idx, item=fname,
1670 total=efiles, unit=_('files'))
1690 total=efiles, unit=_('files'))
@@ -1058,7 +1058,7 b' class revlog(object):'
1058 self._cache = (node, curr, text)
1058 self._cache = (node, curr, text)
1059 return node
1059 return node
1060
1060
1061 def group(self, nodelist, lookup, infocollect=None):
1061 def group(self, nodelist, lookup):
1062 """Calculate a delta group, yielding a sequence of changegroup chunks
1062 """Calculate a delta group, yielding a sequence of changegroup chunks
1063 (strings).
1063 (strings).
1064
1064
@@ -1086,9 +1086,6 b' class revlog(object):'
1086 a, b = revs[r], revs[r + 1]
1086 a, b = revs[r], revs[r + 1]
1087 nb = self.node(b)
1087 nb = self.node(b)
1088
1088
1089 if infocollect is not None:
1090 infocollect(nb)
1091
1092 p = self.parents(nb)
1089 p = self.parents(nb)
1093 meta = nb + p[0] + p[1] + lookup(nb)
1090 meta = nb + p[0] + p[1] + lookup(nb)
1094 if a == nullrev:
1091 if a == nullrev:
General Comments 0
You need to be logged in to leave comments. Login now