##// END OF EJS Templates
tag: migrate `opts` to native kwargs
Matt Harbison -
r51744:fa675fd6 default
parent child Browse files
Show More
@@ -7478,7 +7478,7 b' def tag(ui, repo, name1, *names, **opts)'
7478 Returns 0 on success.
7478 Returns 0 on success.
7479 """
7479 """
7480 cmdutil.check_incompatible_arguments(opts, 'remove', ['rev'])
7480 cmdutil.check_incompatible_arguments(opts, 'remove', ['rev'])
7481 opts = pycompat.byteskwargs(opts)
7481
7482 with repo.wlock(), repo.lock():
7482 with repo.wlock(), repo.lock():
7483 rev_ = b"."
7483 rev_ = b"."
7484 names = [t.strip() for t in (name1,) + names]
7484 names = [t.strip() for t in (name1,) + names]
@@ -7490,11 +7490,11 b' def tag(ui, repo, name1, *names, **opts)'
7490 raise error.InputError(
7490 raise error.InputError(
7491 _(b'tag names cannot consist entirely of whitespace')
7491 _(b'tag names cannot consist entirely of whitespace')
7492 )
7492 )
7493 if opts.get(b'rev'):
7493 if opts.get('rev'):
7494 rev_ = opts[b'rev']
7494 rev_ = opts['rev']
7495 message = opts.get(b'message')
7495 message = opts.get('message')
7496 if opts.get(b'remove'):
7496 if opts.get('remove'):
7497 if opts.get(b'local'):
7497 if opts.get('local'):
7498 expectedtype = b'local'
7498 expectedtype = b'local'
7499 else:
7499 else:
7500 expectedtype = b'global'
7500 expectedtype = b'global'
@@ -7521,18 +7521,18 b' def tag(ui, repo, name1, *names, **opts)'
7521 if not message:
7521 if not message:
7522 # we don't translate commit messages
7522 # we don't translate commit messages
7523 message = b'Removed tag %s' % b', '.join(names)
7523 message = b'Removed tag %s' % b', '.join(names)
7524 elif not opts.get(b'force'):
7524 elif not opts.get('force'):
7525 for n in names:
7525 for n in names:
7526 if n in repo.tags():
7526 if n in repo.tags():
7527 raise error.InputError(
7527 raise error.InputError(
7528 _(b"tag '%s' already exists (use -f to force)") % n
7528 _(b"tag '%s' already exists (use -f to force)") % n
7529 )
7529 )
7530 if not opts.get(b'local'):
7530 if not opts.get('local'):
7531 p1, p2 = repo.dirstate.parents()
7531 p1, p2 = repo.dirstate.parents()
7532 if p2 != repo.nullid:
7532 if p2 != repo.nullid:
7533 raise error.StateError(_(b'uncommitted merge'))
7533 raise error.StateError(_(b'uncommitted merge'))
7534 bheads = repo.branchheads()
7534 bheads = repo.branchheads()
7535 if not opts.get(b'force') and bheads and p1 not in bheads:
7535 if not opts.get('force') and bheads and p1 not in bheads:
7536 raise error.InputError(
7536 raise error.InputError(
7537 _(
7537 _(
7538 b'working directory is not at a branch head '
7538 b'working directory is not at a branch head '
@@ -7544,7 +7544,7 b' def tag(ui, repo, name1, *names, **opts)'
7544 # don't allow tagging the null rev or the working directory
7544 # don't allow tagging the null rev or the working directory
7545 if node is None:
7545 if node is None:
7546 raise error.InputError(_(b"cannot tag working directory"))
7546 raise error.InputError(_(b"cannot tag working directory"))
7547 elif not opts.get(b'remove') and node == nullid:
7547 elif not opts.get('remove') and node == nullid:
7548 raise error.InputError(_(b"cannot tag null revision"))
7548 raise error.InputError(_(b"cannot tag null revision"))
7549
7549
7550 if not message:
7550 if not message:
@@ -7554,25 +7554,23 b' def tag(ui, repo, name1, *names, **opts)'
7554 short(node),
7554 short(node),
7555 )
7555 )
7556
7556
7557 date = opts.get(b'date')
7557 date = opts.get('date')
7558 if date:
7558 if date:
7559 date = dateutil.parsedate(date)
7559 date = dateutil.parsedate(date)
7560
7560
7561 if opts.get(b'remove'):
7561 if opts.get('remove'):
7562 editform = b'tag.remove'
7562 editform = b'tag.remove'
7563 else:
7563 else:
7564 editform = b'tag.add'
7564 editform = b'tag.add'
7565 editor = cmdutil.getcommiteditor(
7565 editor = cmdutil.getcommiteditor(editform=editform, **opts)
7566 editform=editform, **pycompat.strkwargs(opts)
7567 )
7568
7566
7569 tagsmod.tag(
7567 tagsmod.tag(
7570 repo,
7568 repo,
7571 names,
7569 names,
7572 node,
7570 node,
7573 message,
7571 message,
7574 opts.get(b'local'),
7572 opts.get('local'),
7575 opts.get(b'user'),
7573 opts.get('user'),
7576 date,
7574 date,
7577 editor=editor,
7575 editor=editor,
7578 )
7576 )
General Comments 0
You need to be logged in to leave comments. Login now