Patchwork [3,of,3] rebase: introduce 'date' option

login
register
mail settings
Submitter Stanislau Hlebik
Date Nov. 3, 2015, 6:52 p.m.
Message ID <57ed68cc2a33fb68d1e0.1446576736@devvm201.lla1.facebook.com>
Download mbox | patch
Permalink /patch/11278/
State Changes Requested
Headers show

Comments

Stanislau Hlebik - Nov. 3, 2015, 6:52 p.m.
# HG changeset patch
# User Stanislau Hlebik <stash@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.
Augie Fackler - Nov. 5, 2015, 2:40 p.m.
On Tue, Nov 03, 2015 at 10:52:16AM -0800, Stanislau Hlebik wrote:
> # HG changeset patch
> # User Stanislau Hlebik <stash@fb.com>
> # Date 1446576002 28800
> #      Tue Nov 03 10:40:02 2015 -0800
> # Node ID 57ed68cc2a33fb68d1e065e31202eccc3a2168b4
> # Parent  93b187ce4d77839c3576db4d0ee626bbb8089382
> rebase: introduce 'date' option

I'm +0 on this, but wonder if it should also have a --current-date
option, as it strikes me that's the most likely use case. Thoughts?

>
> '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
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
Ryan McElroy - Nov. 5, 2015, 10:39 p.m.
On 11/5/2015 6:40 AM, Augie Fackler wrote:
> On Tue, Nov 03, 2015 at 10:52:16AM -0800, Stanislau Hlebik wrote:
>> # HG changeset patch
>> # User Stanislau Hlebik <stash@fb.com>
>> # Date 1446576002 28800
>> #      Tue Nov 03 10:40:02 2015 -0800
>> # Node ID 57ed68cc2a33fb68d1e065e31202eccc3a2168b4
>> # Parent  93b187ce4d77839c3576db4d0ee626bbb8089382
>> rebase: introduce 'date' option
> I'm +0 on this, but wonder if it should also have a --current-date
> option, as it strikes me that's the most likely use case. Thoughts?

I like the idea of a "--current-date" flag (graft has this, right?), but 
I don't trust my ability to know what useful ways people will use UI, 
and "--date now" is pretty short (shorter, in fact, than 
"--current-date", so I'd be okay with just "--date". I'm also okay with 
dropping this since the first two are what we really needed to make 
tweakdefaults do the "--current-date" behavior at all times which was 
the real goal here. :-)

I'm curious as to what other people think about adding "--date" or 
"--current-date" or not adding it at all.

>
>> '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
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel@selenic.com
>> https://selenic.com/mailman/listinfo/mercurial-devel
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
Augie Fackler - Nov. 5, 2015, 11:05 p.m.
> On Nov 5, 2015, at 5:39 PM, Ryan McElroy <rm@fb.com> wrote:
> 
> On 11/5/2015 6:40 AM, Augie Fackler wrote:
>> On Tue, Nov 03, 2015 at 10:52:16AM -0800, Stanislau Hlebik wrote:
>>> # HG changeset patch
>>> # User Stanislau Hlebik <stash@fb.com>
>>> # Date 1446576002 28800
>>> #      Tue Nov 03 10:40:02 2015 -0800
>>> # Node ID 57ed68cc2a33fb68d1e065e31202eccc3a2168b4
>>> # Parent  93b187ce4d77839c3576db4d0ee626bbb8089382
>>> rebase: introduce 'date' option
>> I'm +0 on this, but wonder if it should also have a --current-date
>> option, as it strikes me that's the most likely use case. Thoughts?
> 
> I like the idea of a "--current-date" flag (graft has this, right?), but I don't trust my ability to know what useful ways people will use UI, and "--date now”

Huh, I didn’t know --date accepted “now”. Neat. Given that, I’m actually inclined to deprecate --current-date pretty much everywhere.

> is pretty short (shorter, in fact, than "--current-date", so I'd be okay with just "--date". I'm also okay with dropping this since the first two are what we really needed to make tweakdefaults do the "--current-date" behavior at all times which was the real goal here. :-)
> 
> I'm curious as to what other people think about adding "--date" or "--current-date" or not adding it at all.

Given the --date now option, I’m fine with this patch as stated as long as nobody else objects...

> 
>> 
>>> '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
>>> _______________________________________________
>>> Mercurial-devel mailing list
>>> Mercurial-devel@selenic.com
>>> https://selenic.com/mailman/listinfo/mercurial-devel
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel@selenic.com
>> https://selenic.com/mailman/listinfo/mercurial-devel
> 
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
Sean Farley - Nov. 6, 2015, 12:28 a.m.
Augie Fackler <raf@durin42.com> writes:

>> On Nov 5, 2015, at 5:39 PM, Ryan McElroy <rm@fb.com> wrote:
>> 
>> On 11/5/2015 6:40 AM, Augie Fackler wrote:
>>> On Tue, Nov 03, 2015 at 10:52:16AM -0800, Stanislau Hlebik wrote:
>>>> # HG changeset patch
>>>> # User Stanislau Hlebik <stash@fb.com>
>>>> # Date 1446576002 28800
>>>> #      Tue Nov 03 10:40:02 2015 -0800
>>>> # Node ID 57ed68cc2a33fb68d1e065e31202eccc3a2168b4
>>>> # Parent  93b187ce4d77839c3576db4d0ee626bbb8089382
>>>> rebase: introduce 'date' option
>>> I'm +0 on this, but wonder if it should also have a --current-date
>>> option, as it strikes me that's the most likely use case. Thoughts?
>> 
>> I like the idea of a "--current-date" flag (graft has this, right?), but I don't trust my ability to know what useful ways people will use UI, and "--date now”
>
> Huh, I didn’t know --date accepted “now”. Neat. Given that, I’m actually inclined to deprecate --current-date pretty much everywhere.

Same for me.

>> is pretty short (shorter, in fact, than "--current-date", so I'd be okay with just "--date". I'm also okay with dropping this since the first two are what we really needed to make tweakdefaults do the "--current-date" behavior at all times which was the real goal here. :-)
>> 
>> I'm curious as to what other people think about adding "--date" or "--current-date" or not adding it at all.
>
> Given the --date now option, I’m fine with this patch as stated as long as nobody else objects...

Again, same for me.
Durham Goode - Nov. 6, 2015, 3:05 a.m.
On 11/5/15 3:05 PM, Augie Fackler wrote:
>> On Nov 5, 2015, at 5:39 PM, Ryan McElroy <rm@fb.com> wrote:
>>
>> On 11/5/2015 6:40 AM, Augie Fackler wrote:
>>> On Tue, Nov 03, 2015 at 10:52:16AM -0800, Stanislau Hlebik wrote:
>>>> # HG changeset patch
>>>> # User Stanislau Hlebik <stash@fb.com>
>>>> # Date 1446576002 28800
>>>> #      Tue Nov 03 10:40:02 2015 -0800
>>>> # Node ID 57ed68cc2a33fb68d1e065e31202eccc3a2168b4
>>>> # Parent  93b187ce4d77839c3576db4d0ee626bbb8089382
>>>> rebase: introduce 'date' option
>>> I'm +0 on this, but wonder if it should also have a --current-date
>>> option, as it strikes me that's the most likely use case. Thoughts?
>> I like the idea of a "--current-date" flag (graft has this, right?), but I don't trust my ability to know what useful ways people will use UI, and "--date now”
> Huh, I didn’t know --date accepted “now”. Neat. Given that, I’m actually inclined to deprecate --current-date pretty much everywhere.
"--date now" is about as discoverable as a kick in the butt (as shown by 
the fact that not even we knew about it).  I like the elegance of it, 
but if 'now' is the primary use case, --current-date is way more 
discoverable.

I don't care enough either way though.  Just throwing that out there.
Sean Farley - Nov. 6, 2015, 5:07 a.m.
Durham Goode <durham@fb.com> writes:

> On 11/5/15 3:05 PM, Augie Fackler wrote:
>>> On Nov 5, 2015, at 5:39 PM, Ryan McElroy <rm@fb.com> wrote:
>>>
>>> On 11/5/2015 6:40 AM, Augie Fackler wrote:
>>>> On Tue, Nov 03, 2015 at 10:52:16AM -0800, Stanislau Hlebik wrote:
>>>>> # HG changeset patch
>>>>> # User Stanislau Hlebik <stash@fb.com>
>>>>> # Date 1446576002 28800
>>>>> #      Tue Nov 03 10:40:02 2015 -0800
>>>>> # Node ID 57ed68cc2a33fb68d1e065e31202eccc3a2168b4
>>>>> # Parent  93b187ce4d77839c3576db4d0ee626bbb8089382
>>>>> rebase: introduce 'date' option
>>>> I'm +0 on this, but wonder if it should also have a --current-date
>>>> option, as it strikes me that's the most likely use case. Thoughts?
>>> I like the idea of a "--current-date" flag (graft has this, right?), but I don't trust my ability to know what useful ways people will use UI, and "--date now”
>> Huh, I didn’t know --date accepted “now”. Neat. Given that, I’m actually inclined to deprecate --current-date pretty much everywhere.
> "--date now" is about as discoverable as a kick in the butt (as shown by 
> the fact that not even we knew about it).  I like the elegance of it, 
> but if 'now' is the primary use case, --current-date is way more 
> discoverable.

Personally, I don't like a new option that does something we already do
in other places (i.e. --date VAL). If discoverability is difficult, then
I'd rather work on that.
Pierre-Yves David - Nov. 6, 2015, 10:54 p.m.
On 11/05/2015 09:40 AM, Augie Fackler wrote:
> On Tue, Nov 03, 2015 at 10:52:16AM -0800, Stanislau Hlebik wrote:
>> # HG changeset patch
>> # User Stanislau Hlebik <stash@fb.com>
>> # Date 1446576002 28800
>> #      Tue Nov 03 10:40:02 2015 -0800
>> # Node ID 57ed68cc2a33fb68d1e065e31202eccc3a2168b4
>> # Parent  93b187ce4d77839c3576db4d0ee626bbb8089382
>> rebase: introduce 'date' option
>
> I'm +0 on this, but wonder if it should also have a --current-date
> option, as it strikes me that's the most likely use case. Thoughts?

mq have --currentdate (no hyphen) with a -D option. This was very useful 
(and set as default for qrefresh for multiple hgrc I say)

We should probably have it too for stuff with --date (rebase, amend and co)

MQ also have a --currentuser -U options, that is probably less useful 
(MQ did not record user or date otherwise)

Patch

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