Patchwork [2,of,3,STABLE] localrepo: reintroduce 'repo.changectx' as deprecated

login
register
mail settings
Submitter Boris Feld
Date July 26, 2018, 12:21 p.m.
Message ID <a920f2620726ef26e6ca.1532607679@FB-lair>
Download mbox | patch
Permalink /patch/32945/
State New
Headers show

Comments

Boris Feld - July 26, 2018, 12:21 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1532596370 -7200
#      Thu Jul 26 11:12:50 2018 +0200
# Branch stable
# Node ID a920f2620726ef26e6caed3d72b24297699b5b39
# Parent  fd0db472d69ac41a0540a15a3019707a368727b3
# EXP-Topic compat-hggit
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r a920f2620726
localrepo: reintroduce 'repo.changectx' as deprecated

This method is used by various extension (like hg-git, hg-subversion). It
should go through the usual deprecated cycle to reduce the impact on users.

This changeset effectively backout changeset 836867586b83.
Yuya Nishihara - July 26, 2018, 1:09 p.m.
On Thu, 26 Jul 2018 14:21:19 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1532596370 -7200
> #      Thu Jul 26 11:12:50 2018 +0200
> # Branch stable
> # Node ID a920f2620726ef26e6caed3d72b24297699b5b39
> # Parent  fd0db472d69ac41a0540a15a3019707a368727b3
> # EXP-Topic compat-hggit
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r a920f2620726
> localrepo: reintroduce 'repo.changectx' as deprecated
> 
> This method is used by various extension (like hg-git, hg-subversion). It
> should go through the usual deprecated cycle to reduce the impact on users.
> 
> This changeset effectively backout changeset 836867586b83.

Why now?

It was removed before the release of 4.6, and fixing extension code is
pretty easy since repo.changectx() was an alias of repo[] for years.

> +    def changectx(self, changeid):
> +        msg = ("repo.changectx(...) is deprecated, use repo[...] or"
> +              " scmutil.revsymbol[...]")
> +        self.ui.deprecwarn(msg, '4.7')
> +        if nodemod.isnode(changeid):
> +            return self[changeid]
> +        else:
> +            return scmutil.revsymbol(self, changeid)

If we restore repo.changectx(changeid), it should be aliased to self[changeid].
Boris Feld - July 26, 2018, 1:23 p.m.
On 26/07/2018 15:09, Yuya Nishihara wrote:
> On Thu, 26 Jul 2018 14:21:19 +0200, Boris Feld wrote:
>> # HG changeset patch
>> # User Boris Feld <boris.feld@octobus.net>
>> # Date 1532596370 -7200
>> #      Thu Jul 26 11:12:50 2018 +0200
>> # Branch stable
>> # Node ID a920f2620726ef26e6caed3d72b24297699b5b39
>> # Parent  fd0db472d69ac41a0540a15a3019707a368727b3
>> # EXP-Topic compat-hggit
>> # Available At https://bitbucket.org/octobus/mercurial-devel/
>> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r a920f2620726
>> localrepo: reintroduce 'repo.changectx' as deprecated
>>
>> This method is used by various extension (like hg-git, hg-subversion). It
>> should go through the usual deprecated cycle to reduce the impact on users.
>>
>> This changeset effectively backout changeset 836867586b83.
> Why now?
>
> It was removed before the release of 4.6, and fixing extension code is
> pretty easy since repo.changectx() was an alias of repo[] for years.
We thought it was dropped during this cycle as we saw a crash porting 
extensions for 4.7.

If this was already dropped in 4.6, we can drop this specific patch.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -45,6 +45,7 @@  from . import (
     mergeutil,
     namespaces,
     narrowspec,
+    node as nodemod,
     obsolete,
     pathutil,
     phases,
@@ -1125,6 +1126,15 @@  class localrepository(object):
             f = f[1:]
         return filelog.filelog(self.svfs, f)
 
+    def changectx(self, changeid):
+        msg = ("repo.changectx(...) is deprecated, use repo[...] or"
+              " scmutil.revsymbol[...]")
+        self.ui.deprecwarn(msg, '4.7')
+        if nodemod.isnode(changeid):
+            return self[changeid]
+        else:
+            return scmutil.revsymbol(self, changeid)
+
     def setparents(self, p1, p2=nullid):
         with self.dirstate.parentchange():
             copies = self.dirstate.setparents(p1, p2)
diff --git a/mercurial/repository.py b/mercurial/repository.py
--- a/mercurial/repository.py
+++ b/mercurial/repository.py
@@ -1173,6 +1173,9 @@  class completelocalrepository(interfaceu
         The returned type conforms to the ``ifilestorage`` interface.
         """
 
+    def changectx(changeid):
+        """deprecated method, identical to __getitem__."""
+
     def setparents(p1, p2):
         """Set the parent nodes of the working directory."""