Mercurial > public > mercurial-scm > hg-stable
diff 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 |
line wrap: on
line diff
--- a/hgext/histedit.py Sun Jan 13 14:46:15 2019 +0900 +++ b/hgext/histedit.py Thu Jan 10 20:11:19 2019 +0530 @@ -220,6 +220,7 @@ util, ) from mercurial.utils import ( + dateutil, stringutil, ) @@ -527,9 +528,12 @@ editor = self.commiteditor() commit = commitfuncfor(repo, rulectx) - + if repo.ui.configbool('rewrite', 'update-timestamp'): + date = dateutil.makedate() + else: + date = rulectx.date() commit(text=rulectx.description(), user=rulectx.user(), - date=rulectx.date(), extra=rulectx.extra(), editor=editor) + date=date, extra=rulectx.extra(), editor=editor) def commiteditor(self): """The editor to be used to edit the commit message.""" @@ -810,6 +814,10 @@ commitopts['date'] = ctx.date() else: commitopts['date'] = max(ctx.date(), oldctx.date()) + # if date is to be updated to current + if ui.configbool('rewrite', 'update-timestamp'): + commitopts['date'] = dateutil.makedate() + extra = ctx.extra().copy() # histedit_source # note: ctx is likely a temporary commit but that the best we can do