Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revlog.py @ 19200:4cfdec944edf
bundle-ng: move group into the bundler
No additional semantic changes made.
author | Sune Foldager <cryo@cyanite.org> |
---|---|
date | Fri, 10 May 2013 21:03:01 +0200 |
parents | c010cb6fdef7 |
children | 7014526d67a8 |
comparison
equal
deleted
inserted
replaced
19199:d6d0f1ed8ebb | 19200:4cfdec944edf |
---|---|
12 """ | 12 """ |
13 | 13 |
14 # import stuff from node for others to import from revlog | 14 # import stuff from node for others to import from revlog |
15 from node import bin, hex, nullid, nullrev | 15 from node import bin, hex, nullid, nullrev |
16 from i18n import _ | 16 from i18n import _ |
17 import ancestor, mdiff, parsers, error, util, dagutil | 17 import ancestor, mdiff, parsers, error, util |
18 import struct, zlib, errno | 18 import struct, zlib, errno |
19 | 19 |
20 _pack = struct.pack | 20 _pack = struct.pack |
21 _unpack = struct.unpack | 21 _unpack = struct.unpack |
22 _compress = zlib.compress | 22 _compress = zlib.compress |
1141 if type(text) == str: # only accept immutable objects | 1141 if type(text) == str: # only accept immutable objects |
1142 self._cache = (node, curr, text) | 1142 self._cache = (node, curr, text) |
1143 self._basecache = (curr, chainbase) | 1143 self._basecache = (curr, chainbase) |
1144 return node | 1144 return node |
1145 | 1145 |
1146 def group(self, nodelist, bundler, reorder=None): | |
1147 """Calculate a delta group, yielding a sequence of changegroup chunks | |
1148 (strings). | |
1149 | |
1150 Given a list of changeset revs, return a set of deltas and | |
1151 metadata corresponding to nodes. The first delta is | |
1152 first parent(nodelist[0]) -> nodelist[0], the receiver is | |
1153 guaranteed to have this parent as it has all history before | |
1154 these changesets. In the case firstparent is nullrev the | |
1155 changegroup starts with a full revision. | |
1156 """ | |
1157 | |
1158 # if we don't have any revisions touched by these changesets, bail | |
1159 if len(nodelist) == 0: | |
1160 yield bundler.close() | |
1161 return | |
1162 | |
1163 # for generaldelta revlogs, we linearize the revs; this will both be | |
1164 # much quicker and generate a much smaller bundle | |
1165 if (self._generaldelta and reorder is not False) or reorder: | |
1166 dag = dagutil.revlogdag(self) | |
1167 revs = set(self.rev(n) for n in nodelist) | |
1168 revs = dag.linearize(revs) | |
1169 else: | |
1170 revs = sorted([self.rev(n) for n in nodelist]) | |
1171 | |
1172 # add the parent of the first rev | |
1173 p = self.parentrevs(revs[0])[0] | |
1174 revs.insert(0, p) | |
1175 | |
1176 # build deltas | |
1177 for r in xrange(len(revs) - 1): | |
1178 prev, curr = revs[r], revs[r + 1] | |
1179 for c in bundler.revchunk(self, curr, prev): | |
1180 yield c | |
1181 | |
1182 yield bundler.close() | |
1183 | |
1184 def addgroup(self, bundle, linkmapper, transaction): | 1146 def addgroup(self, bundle, linkmapper, transaction): |
1185 """ | 1147 """ |
1186 add a delta group | 1148 add a delta group |
1187 | 1149 |
1188 given a set of deltas, add them to the revision log. the | 1150 given a set of deltas, add them to the revision log. the |