changeset 6334:ef8c1637321a

topic: mercurial.configitems and mercurial.registrar.configitem is in hg 4.3
author Anton Shestakov <av6@dwimlabs.net>
date Sat, 12 Nov 2022 16:08:09 +0400
parents f4ffe1e67a9b
children 394c795d7ba4
files hgext3rd/topic/__init__.py
diffstat 1 files changed, 46 insertions(+), 50 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py	Sat Nov 12 15:47:57 2022 +0400
+++ b/hgext3rd/topic/__init__.py	Sat Nov 12 16:08:09 2022 +0400
@@ -168,6 +168,7 @@
     changelog,
     cmdutil,
     commands,
+    configitems,
     context,
     encoding,
     error,
@@ -238,58 +239,53 @@
 minimumhgversion = b'4.8'
 buglink = b'https://bz.mercurial-scm.org/'
 
-if util.safehasattr(registrar, 'configitem'):
-
-    from mercurial import configitems
-
-    configtable = {}
-    configitem = registrar.configitem(configtable)
+configtable = {}
+configitem = registrar.configitem(configtable)
 
-    configitem(b'experimental', b'enforce-topic',
-               default=False,
-    )
-    configitem(b'experimental', b'enforce-single-head',
-               default=False,
-    )
-    configitem(b'experimental', b'topic-mode',
-               default=None,
-    )
-    configitem(b'experimental', b'topic.publish-bare-branch',
-               default=False,
-    )
-    configitem(b'experimental', b'topic.allow-publish',
-               default=configitems.dynamicdefault,
-    )
-    configitem(b'_internal', b'keep-topic',
-               default=False,
-    )
-    configitem(b'experimental', b'topic-mode.server',
-               default=configitems.dynamicdefault,
-    )
-    configitem(b'experimental', b'topic.server-gate-topic-changesets',
-               default=False,
-    )
-    configitem(b'experimental', b'topic.linear-merge',
-               default="reject",
-    )
+configitem(b'experimental', b'enforce-topic',
+           default=False,
+)
+configitem(b'experimental', b'enforce-single-head',
+           default=False,
+)
+configitem(b'experimental', b'topic-mode',
+           default=None,
+)
+configitem(b'experimental', b'topic.publish-bare-branch',
+           default=False,
+)
+configitem(b'experimental', b'topic.allow-publish',
+           default=configitems.dynamicdefault,
+)
+configitem(b'_internal', b'keep-topic',
+           default=False,
+)
+configitem(b'experimental', b'topic-mode.server',
+           default=configitems.dynamicdefault,
+)
+configitem(b'experimental', b'topic.server-gate-topic-changesets',
+           default=False,
+)
+configitem(b'experimental', b'topic.linear-merge',
+           default="reject",
+)
 
-    def extsetup(ui):
-        # register config that strictly belong to other code (thg, core, etc)
-        #
-        # To ensure all config items we used are registered, we register them if
-        # nobody else did so far.
-        from mercurial import configitems
-        extraitem = functools.partial(configitems._register, ui._knownconfig)
-        if (b'experimental' not in ui._knownconfig
-                or not ui._knownconfig[b'experimental'].get(b'thg.displaynames')):
-            extraitem(b'experimental', b'thg.displaynames',
-                      default=None,
-            )
-        if (b'devel' not in ui._knownconfig
-                or not ui._knownconfig[b'devel'].get(b'random')):
-            extraitem(b'devel', b'randomseed',
-                      default=None,
-            )
+def extsetup(ui):
+    # register config that strictly belong to other code (thg, core, etc)
+    #
+    # To ensure all config items we used are registered, we register them if
+    # nobody else did so far.
+    extraitem = functools.partial(configitems._register, ui._knownconfig)
+    if (b'experimental' not in ui._knownconfig
+            or not ui._knownconfig[b'experimental'].get(b'thg.displaynames')):
+        extraitem(b'experimental', b'thg.displaynames',
+                  default=None,
+        )
+    if (b'devel' not in ui._knownconfig
+            or not ui._knownconfig[b'devel'].get(b'random')):
+        extraitem(b'devel', b'randomseed',
+                  default=None,
+        )
 
 def _contexttns(self, force=False):
     if not force and not self.mutable():