Mercurial > hg
changeset 18414:c448562ad85b
bundlerepo: inline inbundle()
It didn't make it faster, it didn't make the code smaller, it didn't make the
code simpler.
-1 is never in basemap.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Wed, 16 Jan 2013 20:41:41 +0100 |
parents | 0ccb16f5956a |
children | 95b8629fd2de |
files | mercurial/bundlerepo.py |
diffstat | 1 files changed, 4 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bundlerepo.py Wed Jan 16 20:41:41 2013 +0100 +++ b/mercurial/bundlerepo.py Wed Jan 16 20:41:41 2013 +0100 @@ -71,29 +71,23 @@ chain = node n += 1 - def inbundle(self, rev): - """is rev from the bundle""" - if rev < 0: - return False - return rev in self.basemap - def _chunk(self, rev): # Warning: in case of bundle, the diff is against self.basemap, # not against rev - 1 # XXX: could use some caching - if not self.inbundle(rev): + if rev not in self.basemap: return revlog.revlog._chunk(self, rev) self.bundle.seek(self.start(rev)) return self.bundle.read(self.length(rev)) def revdiff(self, rev1, rev2): """return or calculate a delta between two revisions""" - if self.inbundle(rev1) and self.inbundle(rev2): + if rev1 in self.basemap and rev2 in self.basemap: # hot path for bundle revb = self.rev(self.basemap[rev2]) if revb == rev1: return self._chunk(rev2) - elif not self.inbundle(rev1) and not self.inbundle(rev2): + elif rev1 not in self.basemap and rev2 not in self.basemap: return revlog.revlog.revdiff(self, rev1, rev2) return mdiff.textdiff(self.revision(self.node(rev1)), @@ -117,7 +111,7 @@ chain = [] iter_node = node # reconstruct the revision if it is from a changegroup - while self.inbundle(rev): + while rev in self.basemap: if self._cache and self._cache[0] == iter_node: text = self._cache[2] break