##// END OF EJS Templates
changegroup: introduce bundler objects...
Matt Mackall -
r13831:d69c9510 default
parent child Browse files
Show More
@@ -194,3 +194,18 def readbundle(fh, fname):
194 194 if version != '10':
195 195 raise util.Abort(_('%s: unknown bundle version %s') % (fname, version))
196 196 return unbundle10(fh, alg)
197
198 class bundle10(object):
199 def __init__(self, lookup):
200 self._lookup = lookup
201 def close(self):
202 return closechunk()
203 def fileheader(self, fname):
204 return chunkheader(len(fname)) + fname
205 def revchunk(self, revlog, node='', p1='', p2='', prefix='', data=''):
206 linknode = self._lookup(revlog, node)
207 meta = node + p1 + p2 + linknode + prefix
208 l = len(meta) + len(data)
209 yield chunkheader(l)
210 yield meta
211 yield data
@@ -1521,19 +1521,19 class localrepository(repo.repository):
1521 1521 unit=_('files'), total=len(changedfiles))
1522 1522 return fstate[1][x]
1523 1523
1524 # Now that we have all theses utility functions to help out and
1525 # logically divide up the task, generate the group.
1524 bundler = changegroup.bundle10(lookup)
1525
1526 1526 def gengroup():
1527 1527 # Create a changenode group generator that will call our functions
1528 1528 # back to lookup the owning changenode and collect information.
1529 for chunk in cl.group(csets, lookup):
1529 for chunk in cl.group(csets, bundler):
1530 1530 yield chunk
1531 1531 self.ui.progress(_('bundling'), None)
1532 1532
1533 1533 # Create a generator for the manifestnodes that calls our lookup
1534 1534 # and data collection functions back.
1535 1535 count[0] = 0
1536 for chunk in mf.group(prune(mf, mfs), lookup):
1536 for chunk in mf.group(prune(mf, mfs), bundler):
1537 1537 yield chunk
1538 1538 self.ui.progress(_('bundling'), None)
1539 1539
@@ -1550,17 +1550,16 class localrepository(repo.repository):
1550 1550 first = True
1551 1551
1552 1552 for chunk in filerevlog.group(prune(filerevlog, fstate[1]),
1553 lookup):
1553 bundler):
1554 1554 if first:
1555 if chunk == changegroup.closechunk():
1555 if chunk == bundler.close():
1556 1556 break
1557 1557 count[0] += 1
1558 yield changegroup.chunkheader(len(fname))
1559 yield fname
1558 yield bundler.fileheader(fname)
1560 1559 first = False
1561 1560 yield chunk
1562 1561 # Signal that no more groups are left.
1563 yield changegroup.closechunk()
1562 yield bundler.close()
1564 1563 self.ui.progress(_('bundling'), None)
1565 1564
1566 1565 if csets:
@@ -1618,16 +1617,18 class localrepository(repo.repository):
1618 1617 total=len(changedfiles), unit=_('files'))
1619 1618 return cl.node(revlog.linkrev(revlog.rev(x)))
1620 1619
1620 bundler = changegroup.bundle10(lookup)
1621
1621 1622 def gengroup():
1622 1623 '''yield a sequence of changegroup chunks (strings)'''
1623 1624 # construct a list of all changed files
1624 1625
1625 for chunk in cl.group(nodes, lookup):
1626 for chunk in cl.group(nodes, bundler):
1626 1627 yield chunk
1627 1628 self.ui.progress(_('bundling'), None)
1628 1629
1629 1630 count[0] = 0
1630 for chunk in mf.group(gennodelst(mf), lookup):
1631 for chunk in mf.group(gennodelst(mf), bundler):
1631 1632 yield chunk
1632 1633 self.ui.progress(_('bundling'), None)
1633 1634
@@ -1638,16 +1639,15 class localrepository(repo.repository):
1638 1639 raise util.Abort(_("empty or missing revlog for %s") % fname)
1639 1640 fstate[0] = fname
1640 1641 first = True
1641 for chunk in filerevlog.group(gennodelst(filerevlog), lookup):
1642 for chunk in filerevlog.group(gennodelst(filerevlog), bundler):
1642 1643 if first:
1643 if chunk == changegroup.closechunk():
1644 if chunk == bundler.close():
1644 1645 break
1645 1646 count[0] += 1
1646 yield changegroup.chunkheader(len(fname))
1647 yield fname
1647 yield bundler.fileheader(fname)
1648 1648 first = False
1649 1649 yield chunk
1650 yield changegroup.closechunk()
1650 yield bundler.close()
1651 1651 self.ui.progress(_('bundling'), None)
1652 1652
1653 1653 if nodes:
@@ -1058,7 +1058,7 class revlog(object):
1058 1058 self._cache = (node, curr, text)
1059 1059 return node
1060 1060
1061 def group(self, nodelist, lookup):
1061 def group(self, nodelist, bundler):
1062 1062 """Calculate a delta group, yielding a sequence of changegroup chunks
1063 1063 (strings).
1064 1064
@@ -1074,7 +1074,7 class revlog(object):
1074 1074
1075 1075 # if we don't have any revisions touched by these changesets, bail
1076 1076 if not revs:
1077 yield changegroup.closechunk()
1077 yield bundler.close()
1078 1078 return
1079 1079
1080 1080 # add the parent of the first rev
@@ -1085,19 +1085,18 class revlog(object):
1085 1085 for r in xrange(len(revs) - 1):
1086 1086 a, b = revs[r], revs[r + 1]
1087 1087 nb = self.node(b)
1088 p1, p2 = self.parents(nb)
1089 prefix = ''
1088 1090
1089 p = self.parents(nb)
1090 meta = nb + p[0] + p[1] + lookup(self, nb)
1091 1091 if a == nullrev:
1092 1092 d = self.revision(nb)
1093 meta += mdiff.trivialdiffheader(len(d))
1093 prefix = mdiff.trivialdiffheader(len(d))
1094 1094 else:
1095 1095 d = self.revdiff(a, b)
1096 yield changegroup.chunkheader(len(meta) + len(d))
1097 yield meta
1098 yield d
1096 for c in bundler.revchunk(self, nb, p1, p2, prefix, d):
1097 yield c
1099 1098
1100 yield changegroup.closechunk()
1099 yield bundler.close()
1101 1100
1102 1101 def addgroup(self, bundle, linkmapper, transaction):
1103 1102 """
General Comments 0
You need to be logged in to leave comments. Login now