Patchwork [evolve-ext] exthelper: drop Mercurial 4.3 support

login
register
mail settings
Submitter Matt Harbison
Date Nov. 11, 2018, 4:57 a.m.
Message ID <58afc797eaeba9c1d20e.1541912259@Envy>
Download mbox | patch
Permalink /patch/36508/
State New
Headers show

Comments

Matt Harbison - Nov. 11, 2018, 4:57 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1541912086 18000
#      Sat Nov 10 23:54:46 2018 -0500
# Node ID 58afc797eaeba9c1d20e41fc832d70aef0f0e6b2
# Parent  2d9902f0ff175ff5e1baa4a4d8f7f37c7c9c7bf5
exthelper: drop Mercurial 4.3 support

The last release email noted plans to drop 4.3 and 4.4 support in the next
feature release.  I'd like to move this code into core, and dropping this should
allow the class to be copied in unmodified.
Matt Harbison - Nov. 17, 2018, 7:15 p.m.
On Sat, 10 Nov 2018 23:57:39 -0500, Matt Harbison <mharbison72@gmail.com>  
wrote:

> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1541912086 18000
> #      Sat Nov 10 23:54:46 2018 -0500
> # Node ID 58afc797eaeba9c1d20e41fc832d70aef0f0e6b2
> # Parent  2d9902f0ff175ff5e1baa4a4d8f7f37c7c9c7bf5
> exthelper: drop Mercurial 4.3 support

Gentle ping on this.
Boris Feld - Nov. 28, 2018, 3:28 p.m.
This got pushed in a while back. Thanks a lot.

We are quite excited to see someone up-streaming of this.
What's your overall plan? Feel encouraged to send further preparatory
patches evolve side if necessary.

On 11/11/2018 05:57, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1541912086 18000
> #      Sat Nov 10 23:54:46 2018 -0500
> # Node ID 58afc797eaeba9c1d20e41fc832d70aef0f0e6b2
> # Parent  2d9902f0ff175ff5e1baa4a4d8f7f37c7c9c7bf5
> exthelper: drop Mercurial 4.3 support
>
> The last release email noted plans to drop 4.3 and 4.4 support in the next
> feature release.  I'd like to move this code into core, and dropping this should
> allow the class to be copied in unmodified.
>
> diff --git a/hgext3rd/evolve/exthelper.py b/hgext3rd/evolve/exthelper.py
> --- a/hgext3rd/evolve/exthelper.py
> +++ b/hgext3rd/evolve/exthelper.py
> @@ -4,6 +4,7 @@
>  
>  from mercurial import (
>      commands,
> +    configitems,
>      extensions,
>      registrar,
>      revset,
> @@ -11,13 +12,6 @@
>      util,
>  )
>  
> -configitem = None
> -dynamicdefault = None
> -if util.safehasattr(registrar, 'configitem'):
> -    configitem = registrar.configitem
> -    from mercurial import configitems
> -    dynamicdefault = configitems.dynamicdefault
> -
>  class exthelper(object):
>      """Helper for modular extension setup
>  
> @@ -49,20 +43,12 @@
>              self.command._doregister = _newdoregister
>  
>          self.configtable = {}
> -        self._configitem = None
> -        if configitem is not None:
> -            self._configitem = configitem(self.configtable)
> -
> -    def configitem(self, section, config):
> -        """For Mercurial 4.4 and above, register a config item
> +        self._configitem = registrar.configitem(self.configtable)
>  
> -        For now constraint to 'dynamicdefault' until we only support version with the feature.
> -        Older version would otherwise not use the declare default.
> -
> -        For older version no-op fallback for old Mercurial versions
> +    def configitem(self, section, config, default=configitems.dynamicdefault):
> +        """Register a config item.
>          """
> -        if self._configitem is not None:
> -            self._configitem(section, config, default=dynamicdefault)
> +        self._configitem(section, config, default=default)
>  
>      def merge(self, other):
>          self._uicallables.extend(other._uicallables)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Matt Harbison - Nov. 28, 2018, 5:22 p.m.
> On Nov 28, 2018, at 10:28 AM, Boris FELD <boris.feld@octobus.net> wrote:
> 
> This got pushed in a while back. Thanks a lot.
> 
> We are quite excited to see someone up-streaming of this.
> What's your overall plan? Feel encouraged to send further preparatory
> patches evolve side if necessary.

I noticed over the weekend, thanks.

I just copied the module to mercurial and switched lfs over. There’s more stuff that can be added like fileset and uipopulate support.  The only hiccup is revset.loadpredicate() and templatekw.loadkeyword() take the name of the extension that calls it. Right now it’s hard coded as “evolve”, which clearly isn’t right for the general case.  But neither of those methods do anything with it. I’m not sure if there’s python magic to figure out the module that instantiates the exthelper class, or how to handle this.

Also, it doesn’t have a copyright in the header, so I’m not sure who to assign that to.

Patch

diff --git a/hgext3rd/evolve/exthelper.py b/hgext3rd/evolve/exthelper.py
--- a/hgext3rd/evolve/exthelper.py
+++ b/hgext3rd/evolve/exthelper.py
@@ -4,6 +4,7 @@ 
 
 from mercurial import (
     commands,
+    configitems,
     extensions,
     registrar,
     revset,
@@ -11,13 +12,6 @@ 
     util,
 )
 
-configitem = None
-dynamicdefault = None
-if util.safehasattr(registrar, 'configitem'):
-    configitem = registrar.configitem
-    from mercurial import configitems
-    dynamicdefault = configitems.dynamicdefault
-
 class exthelper(object):
     """Helper for modular extension setup
 
@@ -49,20 +43,12 @@ 
             self.command._doregister = _newdoregister
 
         self.configtable = {}
-        self._configitem = None
-        if configitem is not None:
-            self._configitem = configitem(self.configtable)
-
-    def configitem(self, section, config):
-        """For Mercurial 4.4 and above, register a config item
+        self._configitem = registrar.configitem(self.configtable)
 
-        For now constraint to 'dynamicdefault' until we only support version with the feature.
-        Older version would otherwise not use the declare default.
-
-        For older version no-op fallback for old Mercurial versions
+    def configitem(self, section, config, default=configitems.dynamicdefault):
+        """Register a config item.
         """
-        if self._configitem is not None:
-            self._configitem(section, config, default=dynamicdefault)
+        self._configitem(section, config, default=default)
 
     def merge(self, other):
         self._uicallables.extend(other._uicallables)