branching: merge with stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Fri, 21 Sep 2018 18:33:55 +0200
changeset 4126 099e264bf3be
parent 4125 865c33c16508 (diff)
parent 4122 4eb3877540f1 (current diff)
child 4127 dfa69b5ece87
branching: merge with stable
hgext3rd/evolve/cmdrewrite.py
hgext3rd/topic/__init__.py
--- a/hgext3rd/evolve/cmdrewrite.py	Fri Sep 21 15:52:53 2018 +0530
+++ b/hgext3rd/evolve/cmdrewrite.py	Fri Sep 21 18:33:55 2018 +0200
@@ -182,7 +182,8 @@
         bookmarkupdater(newnode)
         tr.close()
     finally:
-        tr.release()
+        if tr is not None:
+            tr.release()
         lockmod.release(lock, wlock)
 
 def _editandapply(ui, repo, pats, old, p1, fp, diffopts):
--- a/hgext3rd/topic/__init__.py	Fri Sep 21 15:52:53 2018 +0530
+++ b/hgext3rd/topic/__init__.py	Fri Sep 21 18:33:55 2018 +0200
@@ -454,25 +454,38 @@
 
             reporef = weakref.ref(self)
             if self.ui.configbool('experimental', 'enforce-single-head'):
-                origvalidator = tr.validator
+                if util.safehasattr(tr, 'validator'): # hg <= 4.7
+                    origvalidator = tr.validator
+                else:
+                    origvalidator = tr._validator
 
                 def validator(tr2):
                     repo = reporef()
                     flow.enforcesinglehead(repo, tr2)
                     origvalidator(tr2)
-                tr.validator = validator
+
+                if util.safehasattr(tr, 'validator'): # hg <= 4.7
+                    tr.validator = validator
+                else:
+                    tr._validator = validator
 
             topicmodeserver = self.ui.config('experimental',
                                              'topic-mode.server', 'ignore')
             ispush = (desc.startswith('push') or desc.startswith('serve'))
             if (topicmodeserver != 'ignore' and ispush):
-                origvalidator = tr.validator
+                if util.safehasattr(tr, 'validator'): # hg <= 4.7
+                    origvalidator = tr.validator
+                else:
+                    origvalidator = tr._validator
 
                 def validator(tr2):
                     repo = reporef()
                     flow.rejectuntopicedchangeset(repo, tr2)
                     return origvalidator(tr2)
-                tr.validator = validator
+                if util.safehasattr(tr, 'validator'): # hg <= 4.7
+                    tr.validator = validator
+                else:
+                    tr._validator = validator
 
             elif (self.ui.configbool('experimental', 'topic.publish-bare-branch')
                     and (desc.startswith('push')
@@ -503,9 +516,10 @@
                 empty = csetcount == 0
                 if empty and not ctwasempty:
                     ui.status('active topic %r is now empty\n' % ct)
-                    if ('phase' in getattr(tr, 'names', ())
+                    trnames = getattr(tr, 'names', getattr(tr, '_names', ()))
+                    if ('phase' in trnames
                             or any(n.startswith('push-response')
-                                   for n in getattr(tr, 'names', ()))):
+                                   for n in trnames)):
                         ui.status(_("(use 'hg topic --clear' to clear it if needed)\n"))
                 hint = _("(see 'hg help topics' for more information)\n")
                 if ctwasempty and not empty:
@@ -539,11 +553,12 @@
 
 def wrapinit(orig, self, repo, *args, **kwargs):
     orig(self, repo, *args, **kwargs)
-    if getattr(repo, 'currenttopic', ''):
-        self._extra[constants.extrakey] = repo.currenttopic
-    else:
-        # Empty key will be dropped from extra by another hack at the changegroup level
-        self._extra[constants.extrakey] = ''
+    if constants.extrakey not in self._extra:
+        if getattr(repo, 'currenttopic', ''):
+            self._extra[constants.extrakey] = repo.currenttopic
+        else:
+            # Empty key will be dropped from extra by another hack at the changegroup level
+            self._extra[constants.extrakey] = ''
 
 def wrapadd(orig, cl, manifest, files, desc, transaction, p1, p2, user,
             date=None, extra=None):
--- a/hgext3rd/topic/discovery.py	Fri Sep 21 15:52:53 2018 +0530
+++ b/hgext3rd/topic/discovery.py	Fri Sep 21 18:33:55 2018 +0200
@@ -153,7 +153,10 @@
         return
     tr._prepushheads = _nbheads(op.repo)
     reporef = weakref.ref(op.repo)
-    oldvalidator = tr.validator
+    if util.safehasattr(tr, 'validator'): # hg <= 4.7
+        oldvalidator = tr.validator
+    else:
+        oldvalidator = tr._validator
 
     def validator(tr):
         repo = reporef()
@@ -171,7 +174,10 @@
                             % branch)
                     raise error.Abort(msg)
         return oldvalidator(tr)
-    tr.validator = validator
+    if util.safehasattr(tr, 'validator'): # hg <= 4.7
+        tr.validator = validator
+    else:
+        tr._validator = validator
 handlecheckheads.params = frozenset()
 
 def _pushb2phases(orig, pushop, bundler):