[PATCH 3 of 3] rebase: introduce 'date' option

Stanislau Hlebik stash at fb.com
Tue Nov 3 12:52:16 CST 2015


# HG changeset patch
# User Stanislau Hlebik <stash at fb.com>
# Date 1446576002 28800
#      Tue Nov 03 10:40:02 2015 -0800
# Node ID 57ed68cc2a33fb68d1e065e31202eccc3a2168b4
# Parent  93b187ce4d77839c3576db4d0ee626bbb8089382
rebase: introduce 'date' option

'date' can be used to set the date of the rebased commits. It can be useful in automation that does rebases.
Also it can be used in extensions to set the date of the rebased commits to be the rebase date not the original commit date.

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -104,7 +104,8 @@
     ('i', 'interactive', False, _('(DEPRECATED)')),
     ('t', 'tool', '', _('specify merge tool')),
     ('c', 'continue', False, _('continue an interrupted rebase')),
-    ('a', 'abort', False, _('abort an interrupted rebase'))] +
+    ('a', 'abort', False, _('abort an interrupted rebase')),
+    ('', 'date', '', _('record the specified date as commit date'))] +
      templateopts,
     _('[-s REV | -b REV] [-d REV] [OPTION]'))
 def rebase(ui, repo, **opts):
@@ -221,6 +222,8 @@
         collapsef = opts.get('collapse', False)
         collapsemsg = cmdutil.logmessage(ui, opts)
         date = opts.get('date', None)
+        if date == '':
+            date = None
         e = opts.get('extrafn') # internal, used by e.g. hgsubversion
         extrafns = [_savegraft]
         if e:
diff --git a/tests/test-rebase-parameters.t b/tests/test-rebase-parameters.t
--- a/tests/test-rebase-parameters.t
+++ b/tests/test-rebase-parameters.t
@@ -499,6 +499,36 @@
 
   $ cd ..
 
+Test --date parameter
+  $ hg init testdaterepo
+  $ cd testdaterepo
+  $ touch init
+  $ hg commit -Aqm init
+  $ touch a
+  $ hg commit -Aqm a
+  $ hg bookmark destination
+  $ hg up -q 0
+  $ touch b
+  $ hg commit -Aqm b
+  $ hg bookmark source
+  $ touch c
+  $ hg commit -Aqm c
+  $ hg rebase -q --base source -d destination --date "1 1"
+  $ hg log -T '{date}\n' -l 3
+  1.01
+  1.01
+  0.00
+  $ hg tglog
+  @  3: 'c'
+  |
+  o  2: 'b'
+  |
+  o  1: 'a'
+  |
+  o  0: 'init'
+  
+  $ cd ..
+
 No common ancestor
 
   $ hg init separaterepo


More information about the Mercurial-devel mailing list