[PATCH 2 of 4] revlog: addgroup adds punched revisions for missing parents
Vishakh H
vsh426 at gmail.com
Fri Aug 13 14:12:45 UTC 2010
# HG changeset patch
# User Vishakh H <vsh426 at gmail.com>
# Date 1281708748 -19800
# Node ID 7db1d33716faaa2eb4f570d46c280e43df5b75a5
# Parent f529cea7638f4d0dce2c9ea695c0b69521266c8a
revlog: addgroup adds punched revisions for missing parents
While reading changegroup if a node with missing parents is encountered,
we add a punched entry in the index with null parents for the missing
parent node.
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1121,7 +1121,8 @@
def _addrevision(self, text, transaction, link, p1, p2, d, ifh, dfh):
node = hash(text, p1, p2)
- if node in self.nodemap:
+ if (node in self.nodemap and
+ (not self.flags(self.rev(node)) & REVIDX_PUNCHED_FLAG)):
return node
curr = len(self)
@@ -1257,7 +1258,8 @@
for chunk in revs:
node, p1, p2, cs = struct.unpack("20s20s20s20s", chunk[:80])
link = linkmapper(cs)
- if node in self.nodemap:
+ if (node in self.nodemap and
+ (not self.flags(self.rev(node)) & REVIDX_PUNCHED_FLAG)):
# this can happen if two branches make the same change
chain = node
continue
@@ -1266,7 +1268,21 @@
for p in (p1, p2):
if not p in self.nodemap:
- raise LookupError(p, self.indexfile, _('unknown parent'))
+ if self._shallow:
+ # add null entries for missing parents
+ if base == nullrev:
+ base = len(self)
+ e = (offset_type(end, REVIDX_PUNCHED_FLAG),
+ 0, 0, base, nullrev, nullrev, nullrev, p)
+ self.index.insert(-1, e)
+ self.nodemap[p] = r
+ entry = self._io.packentry(e, self.node,
+ self.version, r)
+ ifh.write(entry)
+ t, r = r, r + 1
+ else:
+ raise LookupError(p, self.indexfile,
+ _('unknown parent'))
if not chain:
# retrieve the parent revision of the delta chain
@@ -1293,6 +1309,7 @@
text = self.revision(chain)
if len(text) == 0:
# skip over trivial delta header
+ # text == '' in the case of nullrev or punched revision
text = buffer(delta, 12)
else:
text = mdiff.patches(text, [delta])
More information about the Mercurial-devel
mailing list