Mercurial > hg-stable
changeset 28488:437c32dcec7d
context: use changelogrevision
Upcoming patches will make the changelogrevision object perform
lazy parsing. Let's switch to it.
Because we're switching from a tuple to an object, everthing that
accesses the internal cached attribute needs to be updated to access
via attributes. A nice side-effect is this makes the code easier to
read!
Surprisingly, this appears to make revsets accessing this data
slightly faster (values are before series, p1, this patch):
author(mpm)
0.896565
0.929984
0.914234
desc(bug)
0.887169
0.935642
0.921073
date(2015)
0.878797
0.908094
0.891980
extra(rebase_source)
0.865446
0.922624
0.912514
author(mpm) or author(greg)
1.801832
1.902112
1.860402
author(mpm) or desc(bug)
1.812438
1.860977
1.844850
date(2015) or branch(default)
0.968276
1.005824
0.994673
author(mpm) or desc(bug) or date(2015) or extra(rebase_source)
3.656193
3.743381
3.721032
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 06 Mar 2016 13:26:37 -0800 |
parents | 98d98a645e9d |
children | 8939a95064f1 |
files | mercurial/context.py |
diffstat | 1 files changed, 21 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/context.py Sun Mar 06 14:28:02 2016 -0800 +++ b/mercurial/context.py Sun Mar 06 13:26:37 2016 -0800 @@ -259,7 +259,7 @@ if path in self._manifestdelta: return (self._manifestdelta[path], self._manifestdelta.flags(path)) - node, flag = self._repo.manifest.find(self._changeset[0], path) + node, flag = self._repo.manifest.find(self._changeset.manifest, path) if not node: raise error.ManifestLookupError(self._node, path, _('not found in manifest')) @@ -524,15 +524,15 @@ @propertycache def _changeset(self): - return self._repo.changelog.read(self.rev()) + return self._repo.changelog.changelogrevision(self.rev()) @propertycache def _manifest(self): - return self._repo.manifest.read(self._changeset[0]) + return self._repo.manifest.read(self._changeset.manifest) @propertycache def _manifestdelta(self): - return self._repo.manifest.readdelta(self._changeset[0]) + return self._repo.manifest.readdelta(self._changeset.manifest) @propertycache def _parents(self): @@ -543,24 +543,32 @@ return [changectx(repo, p1), changectx(repo, p2)] def changeset(self): - return self._changeset + c = self._changeset + return ( + c.manifest, + c.user, + c.date, + c.files, + c.description, + c.extra, + ) def manifestnode(self): - return self._changeset[0] + return self._changeset.manifest def user(self): - return self._changeset[1] + return self._changeset.user def date(self): - return self._changeset[2] + return self._changeset.date def files(self): - return self._changeset[3] + return self._changeset.files def description(self): - return self._changeset[4] + return self._changeset.description def branch(self): - return encoding.tolocal(self._changeset[5].get("branch")) + return encoding.tolocal(self._changeset.extra.get("branch")) def closesbranch(self): - return 'close' in self._changeset[5] + return 'close' in self._changeset.extra def extra(self): - return self._changeset[5] + return self._changeset.extra def tags(self): return self._repo.nodetags(self._node) def bookmarks(self):