changeset 6446:88c701539ed4 stable

compat: add a `setbranch` compat layer for 6.4 We now need to pass a transaction argument (might be None, but must be there).
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 07 Mar 2023 19:56:32 +0100
parents b27523cb3ffb
children 050d3f21ea30
files hgext3rd/evolve/cmdrewrite.py hgext3rd/evolve/compat.py hgext3rd/evolve/evolvecmd.py
diffstat 3 files changed, 16 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/cmdrewrite.py	Tue Mar 07 12:24:33 2023 -0500
+++ b/hgext3rd/evolve/cmdrewrite.py	Tue Mar 07 19:56:32 2023 +0100
@@ -1153,7 +1153,7 @@
 
         # Set the right branch
         # XXX-TODO: Find a way to set the branch without altering the dirstate
-        repo.dirstate.setbranch(ctx.branch())
+        compat.setbranch(repo, ctx.branch())
 
         if pats:
             # refresh the wctx used for the matcher
@@ -1252,7 +1252,7 @@
         tr.close()
     finally:
         # Restore the old branch
-        repo.dirstate.setbranch(savedbranch)
+        compat.setbranch(repo, savedbranch)
 
         lockmod.release(tr, lock, wlock)
 
@@ -1421,7 +1421,7 @@
         newnode = repo.commit(text=origctx.description(),
                               user=origctx.user(),
                               date=origctx.date(), extra=origctx.extra())
-    repo.dirstate.setbranch(origctx.branch())
+    compat.setbranch(repo, origctx.branch())
 
     if pickstate:
         pickstate.delete()
--- a/hgext3rd/evolve/compat.py	Tue Mar 07 12:24:33 2023 -0500
+++ b/hgext3rd/evolve/compat.py	Tue Mar 07 19:56:32 2023 +0100
@@ -529,6 +529,15 @@
 
     context.overlayworkingctx._markdirty = fixedmarkdirty
 
+def setbranch(repo, branch):
+    # this attribute was introduced at about the same time dirstate.setbranch()
+    # was modified
+    # hg <= 6.3 (e9379b55ed80)
+    if util.safehasattr(dirstate, 'requires_changing_files_or_status'):
+        repo.dirstate.setbranch(branch, repo.currenttransaction())
+    else:
+        repo.dirstate.setbranch(branch)
+
 if util.safehasattr(dirstate.dirstate, 'get_entry'):
     def dirchanges(dirstate):
         return [
--- a/hgext3rd/evolve/evolvecmd.py	Tue Mar 07 12:24:33 2023 -0500
+++ b/hgext3rd/evolve/evolvecmd.py	Tue Mar 07 19:56:32 2023 +0100
@@ -791,7 +791,7 @@
             # preserved
             pass
         elif basebranch == divbranch and basebranch != othbranch:
-            repo.dirstate.setbranch(othbranch)
+            compat.setbranch(repo, othbranch)
         else:
             # all the three branches are different
             index = repo.ui.promptchoice(_(b"content divergent changesets on "
@@ -802,11 +802,11 @@
                                          (basebranch, divbranch, othbranch), 0)
 
             if index == 0:
-                repo.dirstate.setbranch(basebranch)
+                compat.setbranch(repo, basebranch)
             elif index == 1:
                 pass
             elif index == 2:
-                repo.dirstate.setbranch(othbranch)
+                compat.setbranch(repo, othbranch)
 
 def mergecommitmessages(ui, basedesc, divdesc, othdesc):
     """merges the commit messages and return the new merged message and whether
@@ -999,7 +999,7 @@
     if repo[b'.'].rev() != dest.rev():
         compat._update(repo, dest, branchmerge=False, force=True)
     if keepbranch:
-        repo.dirstate.setbranch(orig.branch())
+        compat.setbranch(repo, orig.branch())
     if util.safehasattr(repo, 'currenttopic'):
         # uurrgs
         # there no other topic setter yet