comparison mercurial/cmdutil.py @ 47438:7f7457f84311

cmdutil: make resolvecommitoptions() work on str-keyed opts As with `checknotesize()`, I also changed to snake_case while at it, to help extensions a little. Differential Revision: https://phab.mercurial-scm.org/D10863
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 10 Jun 2021 15:45:22 -0700
parents fca9c63f160e
children 00ae1fb6c459
comparison
equal deleted inserted replaced
47437:fca9c63f160e 47438:7f7457f84311
299 """ 299 """
300 for other in others: 300 for other in others:
301 check_at_most_one_arg(opts, first, other) 301 check_at_most_one_arg(opts, first, other)
302 302
303 303
304 def resolvecommitoptions(ui, opts): 304 def resolve_commit_options(ui, opts):
305 """modify commit options dict to handle related options 305 """modify commit options dict to handle related options
306 306
307 The return value indicates that ``rewrite.update-timestamp`` is the reason 307 The return value indicates that ``rewrite.update-timestamp`` is the reason
308 the ``date`` option is set. 308 the ``date`` option is set.
309 """ 309 """
310 check_at_most_one_arg(opts, b'date', b'currentdate') 310 check_at_most_one_arg(opts, 'date', 'currentdate')
311 check_at_most_one_arg(opts, b'user', b'currentuser') 311 check_at_most_one_arg(opts, 'user', 'currentuser')
312 312
313 datemaydiffer = False # date-only change should be ignored? 313 datemaydiffer = False # date-only change should be ignored?
314 314
315 if opts.get(b'currentdate'): 315 if opts.get('currentdate'):
316 opts[b'date'] = b'%d %d' % dateutil.makedate() 316 opts['date'] = b'%d %d' % dateutil.makedate()
317 elif ( 317 elif (
318 not opts.get(b'date') 318 not opts.get('date')
319 and ui.configbool(b'rewrite', b'update-timestamp') 319 and ui.configbool(b'rewrite', b'update-timestamp')
320 and opts.get(b'currentdate') is None 320 and opts.get('currentdate') is None
321 ): 321 ):
322 opts[b'date'] = b'%d %d' % dateutil.makedate() 322 opts['date'] = b'%d %d' % dateutil.makedate()
323 datemaydiffer = True 323 datemaydiffer = True
324 324
325 if opts.get(b'currentuser'): 325 if opts.get('currentuser'):
326 opts[b'user'] = ui.username() 326 opts['user'] = ui.username()
327 327
328 return datemaydiffer 328 return datemaydiffer
329 329
330 330
331 def check_note_size(opts): 331 def check_note_size(opts):
2781 else: 2781 else:
2782 return f not in ctx2.manifest() 2782 return f not in ctx2.manifest()
2783 2783
2784 2784
2785 def amend(ui, repo, old, extra, pats, opts): 2785 def amend(ui, repo, old, extra, pats, opts):
2786 opts = pycompat.byteskwargs(opts)
2787 # avoid cycle context -> subrepo -> cmdutil 2786 # avoid cycle context -> subrepo -> cmdutil
2788 from . import context 2787 from . import context
2789 2788
2790 # amend will reuse the existing user if not specified, but the obsolete 2789 # amend will reuse the existing user if not specified, but the obsolete
2791 # marker creation requires that the current user's name is specified. 2790 # marker creation requires that the current user's name is specified.
2814 2813
2815 # Also update it from the from the wctx 2814 # Also update it from the from the wctx
2816 extra.update(wctx.extra()) 2815 extra.update(wctx.extra())
2817 2816
2818 # date-only change should be ignored? 2817 # date-only change should be ignored?
2819 datemaydiffer = resolvecommitoptions(ui, opts) 2818 datemaydiffer = resolve_commit_options(ui, opts)
2819 opts = pycompat.byteskwargs(opts)
2820 2820
2821 date = old.date() 2821 date = old.date()
2822 if opts.get(b'date'): 2822 if opts.get(b'date'):
2823 date = dateutil.parsedate(opts.get(b'date')) 2823 date = dateutil.parsedate(opts.get(b'date'))
2824 user = opts.get(b'user') or old.user() 2824 user = opts.get(b'user') or old.user()