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