[PATCH 6 of 7] context: introduce a `_findchangeid` method to `filectx`
Boris FELD
boris.feld at octobus.net
Fri Sep 7 14:24:08 EDT 2018
On 07/09/2018 11:17, Martin von Zweigbergk via Mercurial-devel wrote:
>
>
> On Fri, Sep 7, 2018 at 8:13 AM Boris Feld <boris.feld at octobus.net
> <mailto:boris.feld at octobus.net>> wrote:
>
> # HG changeset patch
> # User Boris Feld <boris.feld at octobus.net
> <mailto:boris.feld at octobus.net>>
> # Date 1536255775 14400
> # Thu Sep 06 13:42:55 2018 -0400
> # Node ID 441c39342d63c75ee101587b2fbf3af60800762f
> # Parent f74f706f6d061cf9369cd45caa3a71d3fc03b293
> # EXP-Topic copy-perf
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> # hg pull
> https://bitbucket.org/octobus/mercurial-devel/ -r 441c39342d63
> context: introduce a `_findchangeid` method to `filectx`
>
> In the same spirit as `_introrev` we want to introduce a way to
> limit graph
> walking when resolving `filectx.rev()`.
>
>
> Can you elaborate? I know what introrev() does.
We tried giving more details in the previous commit:
We want to add a mechanism to stop iteration early associated to
intro rev early in some case. However, it does not make sense to
expose it in the public `filectx` API. So we split the code into an
internal method instead.
Instead of modifying the `_changeid` property, we move most of the code
in a new low-level method.
In the next commit, we modify this new low-level method to introduce the
walk limitation.
>
> We introduce a new internal function for
> this purpose.
>
> diff --git a/mercurial/context.py b/mercurial/context.py
> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -631,16 +631,21 @@ class basefilectx(object):
>
> @propertycache
> def _changeid(self):
> + return self._findchangeid()
> +
> + def _findchangeid(self):
>
>
> If it's always going to return a revnum (never a nodeid), can we call
> it _findchangrev() instead?
Yes, should we send a V2 or could it be fixed inflight?
>
> if r'_changeid' in self.__dict__:
> - return self._changeid
> + changeid = self._changeid
> elif r'_changectx' in self.__dict__:
> - return self._changectx.rev()
> + changeid = self._changectx.rev()
> elif r'_descendantrev' in self.__dict__:
> # this file context was created from a revision with
> a known
> # descendant, we can (lazily) correct for linkrev aliases
> - return self._adjustlinkrev(self._descendantrev)
> + changeid = self._adjustlinkrev(self._descendantrev)
> else:
> - return self._filelog.linkrev(self._filerev)
> + changeid = self._filelog.linkrev(self._filerev)
> + self._changeid = changeid
> + return changeid
>
> @propertycache
> def _filenode(self):
> @@ -872,7 +877,7 @@ class basefilectx(object):
> else:
> return self._adjustlinkrev(lazyrev, inclusive=True)
> else:
> - return self.rev()
> + return self._findchangeid()
>
> def introfilectx(self):
> """Return filectx having identical contents, but pointing
> to the
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> <mailto:Mercurial-devel at mercurial-scm.org>
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
>
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20180907/f1fe4667/attachment.html>
More information about the Mercurial-devel
mailing list