# HG changeset patch # User Pierre-Yves David # Date 1678215392 -3600 # Node ID 88c701539ed4a91c2ede75968b4a6124af2e9a4e # Parent b27523cb3ffbfcbc925cb99fdfdcf6349cadccc9 compat: add a `setbranch` compat layer for 6.4 We now need to pass a transaction argument (might be None, but must be there). diff -r b27523cb3ffb -r 88c701539ed4 hgext3rd/evolve/cmdrewrite.py --- 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() diff -r b27523cb3ffb -r 88c701539ed4 hgext3rd/evolve/compat.py --- 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 [ diff -r b27523cb3ffb -r 88c701539ed4 hgext3rd/evolve/evolvecmd.py --- 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