# HG changeset patch # User Matt Harbison # Date 2023-08-20 04:55:52 # Node ID 13ad1b2ad3b4910fd00aacca457d30eb848b6e29 # Parent aad6e62d64f83a3aac0cf4d551a704ed9872859c branch: migrate `opts` to native kwargs diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -1007,7 +1007,7 @@ def findcmd(cmd, table, strict=True): raise error.UnknownCommand(cmd, allcmds) -def changebranch(ui, repo, revs, label, opts): +def changebranch(ui, repo, revs, label, **opts): """Change the branch name of given revs to label""" with repo.wlock(), repo.lock(), repo.transaction(b'branches'): @@ -1026,7 +1026,7 @@ def changebranch(ui, repo, revs, label, root = repo[roots.first()] rpb = {parent.branch() for parent in root.parents()} if ( - not opts.get(b'force') + not opts.get('force') and label not in rpb and label in repo.branchmap() ): diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1339,12 +1339,11 @@ def branch(ui, repo, label=None, **opts) Returns 0 on success. """ - opts = pycompat.byteskwargs(opts) - revs = opts.get(b'rev') + revs = opts.get('rev') if label: label = label.strip() - if not opts.get(b'clean') and not label: + if not opts.get('clean') and not label: if revs: raise error.InputError( _(b"no branch name specified for the revisions") @@ -1353,7 +1352,7 @@ def branch(ui, repo, label=None, **opts) return with repo.wlock(): - if opts.get(b'clean'): + if opts.get('clean'): label = repo[b'.'].branch() repo.dirstate.setbranch(label, repo.currenttransaction()) ui.status(_(b'reset working directory to branch %s\n') % label) @@ -1361,9 +1360,9 @@ def branch(ui, repo, label=None, **opts) scmutil.checknewlabel(repo, label, b'branch') if revs: - return cmdutil.changebranch(ui, repo, revs, label, opts) - - if not opts.get(b'force') and label in repo.branchmap(): + return cmdutil.changebranch(ui, repo, revs, label, **opts) + + if not opts.get('force') and label in repo.branchmap(): if label not in [p.branch() for p in repo[None].parents()]: raise error.InputError( _(b'a branch of the same name already exists'),