Patchwork [5,of,5] localrepo: reinstate localrepo.parents with a deprecation warning

login
register
mail settings
Submitter Pierre-Yves David
Date Dec. 6, 2015, 8:45 p.m.
Message ID <c8dd0ae2182c9e46b142.1449434715@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/11865/
State Superseded
Commit 07ae7e8c8ac916de7e92af454f0c3f4602ac76e7
Delegated to: Yuya Nishihara
Headers show

Comments

Pierre-Yves David - Dec. 6, 2015, 8:45 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1449386089 28800
#      Sat Dec 05 23:14:49 2015 -0800
# Node ID c8dd0ae2182c9e46b1423fd06a4a3b4bd350c03a
# Parent  b7102e200b8b952350d0202cdb43429dc60123bd
# EXP-Topic deprecationwarning
# Available At http://hg.netv6.net/marmoute-wip/mercurial/
#              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r c8dd0ae2182c
localrepo: reinstate localrepo.parents with a deprecation warning

The function was dropped in 3fe8cb40c9c5. This API drop brokes three of my
extensions including some critical to my workflow like tortoisehg. Lets mark
this API for death and give people time to fix their code.
Yuya Nishihara - Dec. 7, 2015, 2:16 p.m.
On Sun, 06 Dec 2015 12:45:15 -0800, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1449386089 28800
> #      Sat Dec 05 23:14:49 2015 -0800
> # Node ID c8dd0ae2182c9e46b1423fd06a4a3b4bd350c03a
> # Parent  b7102e200b8b952350d0202cdb43429dc60123bd
> # EXP-Topic deprecationwarning
> # Available At http://hg.netv6.net/marmoute-wip/mercurial/
> #              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r c8dd0ae2182c
> localrepo: reinstate localrepo.parents with a deprecation warning
> 
> The function was dropped in 3fe8cb40c9c5. This API drop brokes three of my
> extensions including some critical to my workflow like tortoisehg. Lets mark
> this API for death and give people time to fix their code.
> 
> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> @@ -849,10 +849,16 @@ class localrepository(object):
>      def file(self, f):
>          if f[0] == '/':
>              f = f[1:]
>          return filelog.filelog(self.svfs, f)
>  
> +    def parents(self, changeid=None):
> +        '''get list of changectxs for parents of changeid'''
> +        msg = 'repo.parents() is deprecated, use repo[None].parents()'

Strictly speaking, it should suggest using 'repo[%r]' % changeid.
Pierre-Yves David - Dec. 7, 2015, 6:39 p.m.
On 12/07/2015 06:16 AM, Yuya Nishihara wrote:
> On Sun, 06 Dec 2015 12:45:15 -0800, Pierre-Yves David wrote:
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david@fb.com>
>> # Date 1449386089 28800
>> #      Sat Dec 05 23:14:49 2015 -0800
>> # Node ID c8dd0ae2182c9e46b1423fd06a4a3b4bd350c03a
>> # Parent  b7102e200b8b952350d0202cdb43429dc60123bd
>> # EXP-Topic deprecationwarning
>> # Available At http://hg.netv6.net/marmoute-wip/mercurial/
>> #              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r c8dd0ae2182c
>> localrepo: reinstate localrepo.parents with a deprecation warning
>>
>> The function was dropped in 3fe8cb40c9c5. This API drop brokes three of my
>> extensions including some critical to my workflow like tortoisehg. Lets mark
>> this API for death and give people time to fix their code.
>>
>> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
>> --- a/mercurial/localrepo.py
>> +++ b/mercurial/localrepo.py
>> @@ -849,10 +849,16 @@ class localrepository(object):
>>       def file(self, f):
>>           if f[0] == '/':
>>               f = f[1:]
>>           return filelog.filelog(self.svfs, f)
>>
>> +    def parents(self, changeid=None):
>> +        '''get list of changectxs for parents of changeid'''
>> +        msg = 'repo.parents() is deprecated, use repo[None].parents()'
>
> Strictly speaking, it should suggest using 'repo[%r]' % changeid.

Not super enthusiastic about that there might be people passing crazy 
changeid (like other changectx). I would rather stay simple and let 
developer add the extra two inchs of thinking here.

I'll update it if you still see it as better.
Augie Fackler - Dec. 7, 2015, 7:27 p.m.
On Mon, Dec 07, 2015 at 10:39:10AM -0800, Pierre-Yves David wrote:
>
>
> On 12/07/2015 06:16 AM, Yuya Nishihara wrote:
> >On Sun, 06 Dec 2015 12:45:15 -0800, Pierre-Yves David wrote:
> >># HG changeset patch
> >># User Pierre-Yves David <pierre-yves.david@fb.com>
> >># Date 1449386089 28800
> >>#      Sat Dec 05 23:14:49 2015 -0800
> >># Node ID c8dd0ae2182c9e46b1423fd06a4a3b4bd350c03a
> >># Parent  b7102e200b8b952350d0202cdb43429dc60123bd
> >># EXP-Topic deprecationwarning
> >># Available At http://hg.netv6.net/marmoute-wip/mercurial/
> >>#              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r c8dd0ae2182c
> >>localrepo: reinstate localrepo.parents with a deprecation warning
> >>
> >>The function was dropped in 3fe8cb40c9c5. This API drop brokes three of my
> >>extensions including some critical to my workflow like tortoisehg. Lets mark
> >>this API for death and give people time to fix their code.
> >>
> >>diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> >>--- a/mercurial/localrepo.py
> >>+++ b/mercurial/localrepo.py
> >>@@ -849,10 +849,16 @@ class localrepository(object):
> >>      def file(self, f):
> >>          if f[0] == '/':
> >>              f = f[1:]
> >>          return filelog.filelog(self.svfs, f)
> >>
> >>+    def parents(self, changeid=None):
> >>+        '''get list of changectxs for parents of changeid'''
> >>+        msg = 'repo.parents() is deprecated, use repo[None].parents()'
> >
> >Strictly speaking, it should suggest using 'repo[%r]' % changeid.
>
> Not super enthusiastic about that there might be people passing crazy
> changeid (like other changectx). I would rather stay simple and let
> developer add the extra two inchs of thinking here.
>
> I'll update it if you still see it as better.

I agree with yuya's comments on the series as a whole. Once you
resolve those things, I'm a fan.

>
> --
> Pierre-Yves David
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -849,10 +849,16 @@  class localrepository(object):
     def file(self, f):
         if f[0] == '/':
             f = f[1:]
         return filelog.filelog(self.svfs, f)
 
+    def parents(self, changeid=None):
+        '''get list of changectxs for parents of changeid'''
+        msg = 'repo.parents() is deprecated, use repo[None].parents()'
+        self.ui.deprecwarn(msg, '3.7')
+        return self[changeid].parents()
+
     def changectx(self, changeid):
         return self[changeid]
 
     def setparents(self, p1, p2=nullid):
         self.dirstate.beginparentchange()