comparison mercurial/cmdutil.py @ 41120:79f8f032c706

amend: add config option to update time to current in hg amend (issue5828) The given config option i.e. `rewrite.update-timestamp` updates date to current when //True//. However when only date is to be updated to current with the working directory clean and no other attributes changing then it does not amend as stated in issue 5828. Further when `--date` flag is specified along with the new config option then `--date` is given priority over the config option. Differential Revision: https://phab.mercurial-scm.org/D5491
author Taapas Agrawal <taapas2897@gmail.com>
date Fri, 04 Jan 2019 20:27:17 +0530
parents 69268a13ffa5
children b153a4aa06f8
comparison
equal deleted inserted replaced
41119:685cf59a134f 41120:79f8f032c706
2441 extra.update(wctx.extra()) 2441 extra.update(wctx.extra())
2442 2442
2443 user = opts.get('user') or old.user() 2443 user = opts.get('user') or old.user()
2444 date = opts.get('date') or old.date() 2444 date = opts.get('date') or old.date()
2445 2445
2446 if ui.configbool('rewrite', 'update-timestamp'):
2447 if opts.get('date'):
2448 pass
2449 else:
2450 date = dateutil.makedate()
2451
2446 # Parse the date to allow comparison between date and old.date() 2452 # Parse the date to allow comparison between date and old.date()
2447 date = dateutil.parsedate(date) 2453 date = dateutil.parsedate(date)
2448 2454
2449 if len(old.parents()) > 1: 2455 if len(old.parents()) > 1:
2450 # ctx.files() isn't reliable for merges, so fall back to the 2456 # ctx.files() isn't reliable for merges, so fall back to the
2556 2562
2557 newdesc = changelog.stripdesc(new.description()) 2563 newdesc = changelog.stripdesc(new.description())
2558 if ((not changes) 2564 if ((not changes)
2559 and newdesc == old.description() 2565 and newdesc == old.description()
2560 and user == old.user() 2566 and user == old.user()
2561 and date == old.date()
2562 and pureextra == old.extra()): 2567 and pureextra == old.extra()):
2563 # nothing changed. continuing here would create a new node 2568 # nothing changed. continuing here would create a new node
2564 # anyway because of the amend_source noise. 2569 # anyway because of the amend_source noise.
2565 # 2570 #
2566 # This not what we expect from amend. 2571 # This not what we expect from amend.
2567 return old.node() 2572 if (date == old.date() or
2573 (ui.configbool('rewrite', 'update-timestamp') and
2574 not opts.get('date'))):
2575 return old.node()
2568 2576
2569 commitphase = None 2577 commitphase = None
2570 if opts.get('secret'): 2578 if opts.get('secret'):
2571 commitphase = phases.secret 2579 commitphase = phases.secret
2572 newid = repo.commitctx(new) 2580 newid = repo.commitctx(new)