Mercurial > public > mercurial-scm > hg
comparison mercurial/revlog.py @ 11999:62e2bbf523f2
revlog: generate full revisions when parent node is missing
The full revision is sent if the first parent, against which diff is calculated, is
missing at remote. This happens in the case of shallow clones.
author | Vishakh H <vsh426@gmail.com> |
---|---|
date | Fri, 13 Aug 2010 19:41:51 +0530 |
parents | e789a811c21d |
children | 3361075816f8 |
comparison
equal
deleted
inserted
replaced
11998:e789a811c21d | 11999:62e2bbf523f2 |
---|---|
1218 | 1218 |
1219 if type(text) == str: # only accept immutable objects | 1219 if type(text) == str: # only accept immutable objects |
1220 self._cache = (node, curr, text) | 1220 self._cache = (node, curr, text) |
1221 return node | 1221 return node |
1222 | 1222 |
1223 def group(self, nodelist, lookup, infocollect=None): | 1223 def group(self, nodelist, lookup, infocollect=None, fullrev=False): |
1224 """Calculate a delta group, yielding a sequence of changegroup chunks | 1224 """Calculate a delta group, yielding a sequence of changegroup chunks |
1225 (strings). | 1225 (strings). |
1226 | 1226 |
1227 Given a list of changeset revs, return a set of deltas and | 1227 Given a list of changeset revs, return a set of deltas and |
1228 metadata corresponding to nodes. the first delta is | 1228 metadata corresponding to nodes. The first delta is |
1229 parent(nodes[0]) -> nodes[0] the receiver is guaranteed to | 1229 first parent(nodelist[0]) -> nodelist[0], the receiver is |
1230 have this parent as it has all history before these | 1230 guaranteed to have this parent as it has all history before |
1231 changesets. parent is parent[0] | 1231 these changesets. In the case firstparent is nullrev the |
1232 changegroup starts with a full revision. | |
1233 fullrev forces the insertion of the full revision, necessary | |
1234 in the case of shallow clones where the first parent might | |
1235 not exist at the reciever. | |
1232 """ | 1236 """ |
1233 | 1237 |
1234 revs = [self.rev(n) for n in nodelist] | 1238 revs = [self.rev(n) for n in nodelist] |
1235 | 1239 |
1236 # if we don't have any revisions touched by these changesets, bail | 1240 # if we don't have any revisions touched by these changesets, bail |
1239 return | 1243 return |
1240 | 1244 |
1241 # add the parent of the first rev | 1245 # add the parent of the first rev |
1242 p = self.parentrevs(revs[0])[0] | 1246 p = self.parentrevs(revs[0])[0] |
1243 revs.insert(0, p) | 1247 revs.insert(0, p) |
1248 if p == nullrev: | |
1249 fullrev = True | |
1244 | 1250 |
1245 # build deltas | 1251 # build deltas |
1246 for d in xrange(len(revs) - 1): | 1252 for d in xrange(len(revs) - 1): |
1247 a, b = revs[d], revs[d + 1] | 1253 a, b = revs[d], revs[d + 1] |
1248 nb = self.node(b) | 1254 nb = self.node(b) |
1250 if infocollect is not None: | 1256 if infocollect is not None: |
1251 infocollect(nb) | 1257 infocollect(nb) |
1252 | 1258 |
1253 p = self.parents(nb) | 1259 p = self.parents(nb) |
1254 meta = nb + p[0] + p[1] + lookup(nb) | 1260 meta = nb + p[0] + p[1] + lookup(nb) |
1255 if a == -1: | 1261 if fullrev: |
1256 d = self.revision(nb) | 1262 d = self.revision(nb) |
1257 meta += mdiff.trivialdiffheader(len(d)) | 1263 meta += mdiff.trivialdiffheader(len(d)) |
1264 fullrev = False | |
1258 else: | 1265 else: |
1259 d = self.revdiff(a, b) | 1266 d = self.revdiff(a, b) |
1260 yield changegroup.chunkheader(len(meta) + len(d)) | 1267 yield changegroup.chunkheader(len(meta) + len(d)) |
1261 yield meta | 1268 yield meta |
1262 yield d | 1269 yield d |