Patchwork committablectx: extra is already normalized

login
register
mail settings
Submitter Sean Farley
Date May 31, 2017, 10:54 p.m.
Message ID <60b3e8946da728c377a3.1496271264@1.0.0.127.in-addr.arpa>
Download mbox | patch
Permalink /patch/21106/
State Accepted
Headers show

Comments

Sean Farley - May 31, 2017, 10:54 p.m.
# HG changeset patch
# User Sean Farley <sean@farley.io>
# Date 1494535870 25200
#      Thu May 11 13:51:10 2017 -0700
# Branch wctxds
# Node ID 60b3e8946da728c377a3a6aadb785ae308084614
# Parent  5313d98089f569efffaca25de60e73be04156713
committablectx: extra is already normalized

Avoid doing the same work again. Based on work done by Mads Kiilerix.
Jun Wu - June 1, 2017, 12:11 a.m.
Looks good to me. I'd mention extra is normalized by "changelog.add" in
commit message.

Excerpts from Sean Farley's message of 2017-05-31 15:54:24 -0700:
> # HG changeset patch
> # User Sean Farley <sean@farley.io>
> # Date 1494535870 25200
> #      Thu May 11 13:51:10 2017 -0700
> # Branch wctxds
> # Node ID 60b3e8946da728c377a3a6aadb785ae308084614
> # Parent  5313d98089f569efffaca25de60e73be04156713
> committablectx: extra is already normalized
> 
> Avoid doing the same work again. Based on work done by Mads Kiilerix.
> 
> diff --git a/mercurial/context.py b/mercurial/context.py
> index f1014ab..e2994e7 100644
> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -2077,18 +2077,10 @@ class memctx(committablectx):
>              self._filectxfn = getfilectx
>          else:
>              # memoizing increases performance for e.g. vcs convert scenarios.
>              self._filectxfn = makecachingfilectxfn(filectxfn)
>  
> -        if extra:
> -            self._extra = extra.copy()
> -        else:
> -            self._extra = {}
> -
> -        if self._extra.get('branch', '') == '':
> -            self._extra['branch'] = 'default'
> -
>          if editor:
>              self._text = editor(self._repo, self, [])
>              self._repo.savecommitmessage(self._text)
>  
>      def filectx(self, path, filelog=None):
> @@ -2297,18 +2289,10 @@ class metadataonlyctx(committablectx):
>                                 'its p2 doesn\'t match the new ctx p2')
>  
>          self._files = originalctx.files()
>          self.substate = {}
>  
> -        if extra:
> -            self._extra = extra.copy()
> -        else:
> -            self._extra = {}
> -
> -        if self._extra.get('branch', '') == '':
> -            self._extra['branch'] = 'default'
> -
>          if editor:
>              self._text = editor(self._repo, self, [])
>              self._repo.savecommitmessage(self._text)
>  
>      def manifestnode(self):
Sean Farley - June 1, 2017, 12:14 a.m.
Jun Wu <quark@fb.com> writes:

> Looks good to me. I'd mention extra is normalized by "changelog.add" in
> commit message.

Sounds like a good idea; could a reviewer add that? Or should I send a V2?
Augie Fackler - June 1, 2017, 2:24 p.m.
On Wed, May 31, 2017 at 03:54:24PM -0700, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean@farley.io>
> # Date 1494535870 25200
> #      Thu May 11 13:51:10 2017 -0700
> # Branch wctxds
> # Node ID 60b3e8946da728c377a3a6aadb785ae308084614
> # Parent  5313d98089f569efffaca25de60e73be04156713
> committablectx: extra is already normalized

queued with a wording tweak per junw, thanks

>
> Avoid doing the same work again. Based on work done by Mads Kiilerix.
>
> diff --git a/mercurial/context.py b/mercurial/context.py
> index f1014ab..e2994e7 100644
> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -2077,18 +2077,10 @@ class memctx(committablectx):
>              self._filectxfn = getfilectx
>          else:
>              # memoizing increases performance for e.g. vcs convert scenarios.
>              self._filectxfn = makecachingfilectxfn(filectxfn)
>
> -        if extra:
> -            self._extra = extra.copy()
> -        else:
> -            self._extra = {}
> -
> -        if self._extra.get('branch', '') == '':
> -            self._extra['branch'] = 'default'
> -
>          if editor:
>              self._text = editor(self._repo, self, [])
>              self._repo.savecommitmessage(self._text)
>
>      def filectx(self, path, filelog=None):
> @@ -2297,18 +2289,10 @@ class metadataonlyctx(committablectx):
>                                 'its p2 doesn\'t match the new ctx p2')
>
>          self._files = originalctx.files()
>          self.substate = {}
>
> -        if extra:
> -            self._extra = extra.copy()
> -        else:
> -            self._extra = {}
> -
> -        if self._extra.get('branch', '') == '':
> -            self._extra['branch'] = 'default'
> -
>          if editor:
>              self._text = editor(self._repo, self, [])
>              self._repo.savecommitmessage(self._text)
>
>      def manifestnode(self):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Yuya Nishihara - June 3, 2017, 2:35 a.m.
On Wed, 31 May 2017 17:11:57 -0700, Jun Wu wrote:
> Looks good to me. I'd mention extra is normalized by "changelog.add" in
> commit message.

Perhaps this should say "normalized by committablectx.__init__". changelog.py
normalizes extra in inverse direction.

> Excerpts from Sean Farley's message of 2017-05-31 15:54:24 -0700:
> > # HG changeset patch
> > # User Sean Farley <sean@farley.io>
> > # Date 1494535870 25200
> > #      Thu May 11 13:51:10 2017 -0700
> > # Branch wctxds
> > # Node ID 60b3e8946da728c377a3a6aadb785ae308084614
> > # Parent  5313d98089f569efffaca25de60e73be04156713
> > committablectx: extra is already normalized
> > 
> > Avoid doing the same work again. Based on work done by Mads Kiilerix.
> > 
> > diff --git a/mercurial/context.py b/mercurial/context.py
> > index f1014ab..e2994e7 100644
> > --- a/mercurial/context.py
> > +++ b/mercurial/context.py
> > @@ -2077,18 +2077,10 @@ class memctx(committablectx):
> >              self._filectxfn = getfilectx
> >          else:
> >              # memoizing increases performance for e.g. vcs convert scenarios.
> >              self._filectxfn = makecachingfilectxfn(filectxfn)
> >  
> > -        if extra:
> > -            self._extra = extra.copy()
> > -        else:
> > -            self._extra = {}
> > -
> > -        if self._extra.get('branch', '') == '':
> > -            self._extra['branch'] = 'default'
via Mercurial-devel - June 3, 2017, 5:01 a.m.
On Fri, Jun 2, 2017 at 7:35 PM, Yuya Nishihara <yuya@tcha.org> wrote:
> On Wed, 31 May 2017 17:11:57 -0700, Jun Wu wrote:
>> Looks good to me. I'd mention extra is normalized by "changelog.add" in
>> commit message.
>
> Perhaps this should say "normalized by committablectx.__init__". changelog.py
> normalizes extra in inverse direction.

Good catch. I'll update it in flight.

>
>> Excerpts from Sean Farley's message of 2017-05-31 15:54:24 -0700:
>> > # HG changeset patch
>> > # User Sean Farley <sean@farley.io>
>> > # Date 1494535870 25200
>> > #      Thu May 11 13:51:10 2017 -0700
>> > # Branch wctxds
>> > # Node ID 60b3e8946da728c377a3a6aadb785ae308084614
>> > # Parent  5313d98089f569efffaca25de60e73be04156713
>> > committablectx: extra is already normalized
>> >
>> > Avoid doing the same work again. Based on work done by Mads Kiilerix.
>> >
>> > diff --git a/mercurial/context.py b/mercurial/context.py
>> > index f1014ab..e2994e7 100644
>> > --- a/mercurial/context.py
>> > +++ b/mercurial/context.py
>> > @@ -2077,18 +2077,10 @@ class memctx(committablectx):
>> >              self._filectxfn = getfilectx
>> >          else:
>> >              # memoizing increases performance for e.g. vcs convert scenarios.
>> >              self._filectxfn = makecachingfilectxfn(filectxfn)
>> >
>> > -        if extra:
>> > -            self._extra = extra.copy()
>> > -        else:
>> > -            self._extra = {}
>> > -
>> > -        if self._extra.get('branch', '') == '':
>> > -            self._extra['branch'] = 'default'
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
index f1014ab..e2994e7 100644
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -2077,18 +2077,10 @@  class memctx(committablectx):
             self._filectxfn = getfilectx
         else:
             # memoizing increases performance for e.g. vcs convert scenarios.
             self._filectxfn = makecachingfilectxfn(filectxfn)
 
-        if extra:
-            self._extra = extra.copy()
-        else:
-            self._extra = {}
-
-        if self._extra.get('branch', '') == '':
-            self._extra['branch'] = 'default'
-
         if editor:
             self._text = editor(self._repo, self, [])
             self._repo.savecommitmessage(self._text)
 
     def filectx(self, path, filelog=None):
@@ -2297,18 +2289,10 @@  class metadataonlyctx(committablectx):
                                'its p2 doesn\'t match the new ctx p2')
 
         self._files = originalctx.files()
         self.substate = {}
 
-        if extra:
-            self._extra = extra.copy()
-        else:
-            self._extra = {}
-
-        if self._extra.get('branch', '') == '':
-            self._extra['branch'] = 'default'
-
         if editor:
             self._text = editor(self._repo, self, [])
             self._repo.savecommitmessage(self._text)
 
     def manifestnode(self):