Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 50825:13ad1b2ad3b4
branch: migrate `opts` to native kwargs
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sun, 20 Aug 2023 00:55:52 -0400 |
parents | aad6e62d64f8 |
children | 3bd013e8e024 |
comparison
equal
deleted
inserted
replaced
50824:aad6e62d64f8 | 50825:13ad1b2ad3b4 |
---|---|
1337 When all heads of a branch are closed, the branch will be | 1337 When all heads of a branch are closed, the branch will be |
1338 considered closed. | 1338 considered closed. |
1339 | 1339 |
1340 Returns 0 on success. | 1340 Returns 0 on success. |
1341 """ | 1341 """ |
1342 opts = pycompat.byteskwargs(opts) | 1342 revs = opts.get('rev') |
1343 revs = opts.get(b'rev') | |
1344 if label: | 1343 if label: |
1345 label = label.strip() | 1344 label = label.strip() |
1346 | 1345 |
1347 if not opts.get(b'clean') and not label: | 1346 if not opts.get('clean') and not label: |
1348 if revs: | 1347 if revs: |
1349 raise error.InputError( | 1348 raise error.InputError( |
1350 _(b"no branch name specified for the revisions") | 1349 _(b"no branch name specified for the revisions") |
1351 ) | 1350 ) |
1352 ui.write(b"%s\n" % repo.dirstate.branch()) | 1351 ui.write(b"%s\n" % repo.dirstate.branch()) |
1353 return | 1352 return |
1354 | 1353 |
1355 with repo.wlock(): | 1354 with repo.wlock(): |
1356 if opts.get(b'clean'): | 1355 if opts.get('clean'): |
1357 label = repo[b'.'].branch() | 1356 label = repo[b'.'].branch() |
1358 repo.dirstate.setbranch(label, repo.currenttransaction()) | 1357 repo.dirstate.setbranch(label, repo.currenttransaction()) |
1359 ui.status(_(b'reset working directory to branch %s\n') % label) | 1358 ui.status(_(b'reset working directory to branch %s\n') % label) |
1360 elif label: | 1359 elif label: |
1361 | 1360 |
1362 scmutil.checknewlabel(repo, label, b'branch') | 1361 scmutil.checknewlabel(repo, label, b'branch') |
1363 if revs: | 1362 if revs: |
1364 return cmdutil.changebranch(ui, repo, revs, label, opts) | 1363 return cmdutil.changebranch(ui, repo, revs, label, **opts) |
1365 | 1364 |
1366 if not opts.get(b'force') and label in repo.branchmap(): | 1365 if not opts.get('force') and label in repo.branchmap(): |
1367 if label not in [p.branch() for p in repo[None].parents()]: | 1366 if label not in [p.branch() for p in repo[None].parents()]: |
1368 raise error.InputError( | 1367 raise error.InputError( |
1369 _(b'a branch of the same name already exists'), | 1368 _(b'a branch of the same name already exists'), |
1370 # i18n: "it" refers to an existing branch | 1369 # i18n: "it" refers to an existing branch |
1371 hint=_(b"use 'hg update' to switch to it"), | 1370 hint=_(b"use 'hg update' to switch to it"), |