Details
Details
- Reviewers
martinvonz - Group Reviewers
hg-reviewers - Commits
- rHG0fe62d8bdd50: bundlerepo: update to use new deltaiter api
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
martinvonz |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/bundlerepo.py (14 lines) |
# | # | ||||
# To differentiate a rev in the bundle from a rev in the revlog, we | # To differentiate a rev in the bundle from a rev in the revlog, we | ||||
# check revision against repotiprev. | # check revision against repotiprev. | ||||
opener = vfsmod.readonlyvfs(opener) | opener = vfsmod.readonlyvfs(opener) | ||||
revlog.revlog.__init__(self, opener, indexfile) | revlog.revlog.__init__(self, opener, indexfile) | ||||
self.bundle = bundle | self.bundle = bundle | ||||
n = len(self) | n = len(self) | ||||
self.repotiprev = n - 1 | self.repotiprev = n - 1 | ||||
chain = None | |||||
self.bundlerevs = set() # used by 'bundle()' revset expression | self.bundlerevs = set() # used by 'bundle()' revset expression | ||||
getchunk = lambda: bundle.deltachunk(chain) | for deltadata in bundle.deltaiter(): | ||||
for chunkdata in iter(getchunk, {}): | node, p1, p2, cs, deltabase, delta, flags = deltadata | ||||
node = chunkdata['node'] | |||||
p1 = chunkdata['p1'] | |||||
p2 = chunkdata['p2'] | |||||
cs = chunkdata['cs'] | |||||
deltabase = chunkdata['deltabase'] | |||||
delta = chunkdata['delta'] | |||||
flags = chunkdata['flags'] | |||||
size = len(delta) | size = len(delta) | ||||
start = bundle.tell() - size | start = bundle.tell() - size | ||||
link = linkmapper(cs) | link = linkmapper(cs) | ||||
if node in self.nodemap: | if node in self.nodemap: | ||||
# this can happen if two branches make the same change | # this can happen if two branches make the same change | ||||
chain = node | |||||
self.bundlerevs.add(self.nodemap[node]) | self.bundlerevs.add(self.nodemap[node]) | ||||
continue | continue | ||||
for p in (p1, p2): | for p in (p1, p2): | ||||
if p not in self.nodemap: | if p not in self.nodemap: | ||||
raise error.LookupError(p, self.indexfile, | raise error.LookupError(p, self.indexfile, | ||||
_("unknown parent")) | _("unknown parent")) | ||||
if deltabase not in self.nodemap: | if deltabase not in self.nodemap: | ||||
raise LookupError(deltabase, self.indexfile, | raise LookupError(deltabase, self.indexfile, | ||||
_('unknown delta base')) | _('unknown delta base')) | ||||
baserev = self.rev(deltabase) | baserev = self.rev(deltabase) | ||||
# start, size, full unc. size, base (unused), link, p1, p2, node | # start, size, full unc. size, base (unused), link, p1, p2, node | ||||
e = (revlog.offset_type(start, flags), size, -1, baserev, link, | e = (revlog.offset_type(start, flags), size, -1, baserev, link, | ||||
self.rev(p1), self.rev(p2), node) | self.rev(p1), self.rev(p2), node) | ||||
self.index.insert(-1, e) | self.index.insert(-1, e) | ||||
self.nodemap[node] = n | self.nodemap[node] = n | ||||
self.bundlerevs.add(n) | self.bundlerevs.add(n) | ||||
chain = node | |||||
n += 1 | n += 1 | ||||
def _chunk(self, rev): | def _chunk(self, rev): | ||||
# Warning: in case of bundle, the diff is against what we stored as | # Warning: in case of bundle, the diff is against what we stored as | ||||
# delta base, not against rev - 1 | # delta base, not against rev - 1 | ||||
# XXX: could use some caching | # XXX: could use some caching | ||||
if rev <= self.repotiprev: | if rev <= self.repotiprev: | ||||
return revlog.revlog._chunk(self, rev) | return revlog.revlog._chunk(self, rev) |