Mercurial > hg
comparison hgext/histedit.py @ 41213:704a3aa3dc0a
histedit: add rewrite.update-timestamp support to fold and mess
This adds the config option to update time to current in histedit fold and
mess options. Setting rewrite.update-timestamp option to `True` will update
the timestamp to current time. This also adds `tests/mockmakedate.py` for
supplying testable values in case current time is invoked in the tests.
Differential Revision: https://phab.mercurial-scm.org/D5554
author | Taapas Agrawal <taapas2897@gmail.com> |
---|---|
date | Thu, 10 Jan 2019 20:11:19 +0530 |
parents | 240f8e49a7bd |
children | 32ef47b3c91c |
comparison
equal
deleted
inserted
replaced
41212:240f8e49a7bd | 41213:704a3aa3dc0a |
---|---|
218 scmutil, | 218 scmutil, |
219 state as statemod, | 219 state as statemod, |
220 util, | 220 util, |
221 ) | 221 ) |
222 from mercurial.utils import ( | 222 from mercurial.utils import ( |
223 dateutil, | |
223 stringutil, | 224 stringutil, |
224 ) | 225 ) |
225 | 226 |
226 pickle = util.pickle | 227 pickle = util.pickle |
227 cmdtable = {} | 228 cmdtable = {} |
525 repo = self.repo | 526 repo = self.repo |
526 rulectx = repo[self.node] | 527 rulectx = repo[self.node] |
527 | 528 |
528 editor = self.commiteditor() | 529 editor = self.commiteditor() |
529 commit = commitfuncfor(repo, rulectx) | 530 commit = commitfuncfor(repo, rulectx) |
530 | 531 if repo.ui.configbool('rewrite', 'update-timestamp'): |
532 date = dateutil.makedate() | |
533 else: | |
534 date = rulectx.date() | |
531 commit(text=rulectx.description(), user=rulectx.user(), | 535 commit(text=rulectx.description(), user=rulectx.user(), |
532 date=rulectx.date(), extra=rulectx.extra(), editor=editor) | 536 date=date, extra=rulectx.extra(), editor=editor) |
533 | 537 |
534 def commiteditor(self): | 538 def commiteditor(self): |
535 """The editor to be used to edit the commit message.""" | 539 """The editor to be used to edit the commit message.""" |
536 return False | 540 return False |
537 | 541 |
808 # date | 812 # date |
809 if self.firstdate(): | 813 if self.firstdate(): |
810 commitopts['date'] = ctx.date() | 814 commitopts['date'] = ctx.date() |
811 else: | 815 else: |
812 commitopts['date'] = max(ctx.date(), oldctx.date()) | 816 commitopts['date'] = max(ctx.date(), oldctx.date()) |
817 # if date is to be updated to current | |
818 if ui.configbool('rewrite', 'update-timestamp'): | |
819 commitopts['date'] = dateutil.makedate() | |
820 | |
813 extra = ctx.extra().copy() | 821 extra = ctx.extra().copy() |
814 # histedit_source | 822 # histedit_source |
815 # note: ctx is likely a temporary commit but that the best we can do | 823 # note: ctx is likely a temporary commit but that the best we can do |
816 # here. This is sufficient to solve issue3681 anyway. | 824 # here. This is sufficient to solve issue3681 anyway. |
817 extra['histedit_source'] = '%s,%s' % (ctx.hex(), oldctx.hex()) | 825 extra['histedit_source'] = '%s,%s' % (ctx.hex(), oldctx.hex()) |