[PATCH] histedit: delete to drop

timeless timeless at gmail.com
Wed Dec 9 21:20:57 CST 2015


fwiw. I'd prefer a mode where if the user omits lines, we re-present
the editor w/ their commands and a set of "drops" at the end of the
list for all of the changesets they omitted and ask them to confirm.

While it might be a bit annoying to get a second editor, it's a lot
clearer and gives people a chance to verify that they did what they
intended. Which avoids the footgun.

On Wed, Dec 9, 2015 at 9:05 PM, Augie Fackler <raf at durin42.com> wrote:
>
>> On Dec 9, 2015, at 6:19 PM, Mateusz Kwapich <mitrandir at fb.com> wrote:
>>
>>
>>
>>
>>
>>
>> On 12/9/15, 12:32 PM, "Mercurial-devel on behalf of Mykola Nikishov" <mercurial-devel-bounces at selenic.com on behalf of mn at mn.com.ua> wrote:
>>
>>> Augie Fackler <raf at durin42.com> writes:
>>>
>>>> On Tue, Dec 08, 2015 at 03:45:42PM -0800, Mateusz Kwapich wrote:
>>>>> # HG changeset patch
>>>>> # User Mateusz Kwapich <mitrandir at fb.com>
>>>>> # Date 1449618250 28800
>>>>> #      Tue Dec 08 15:44:10 2015 -0800
>>>>> # Node ID 764d610ac682526bdfc1fefd061e8ab24b9c8966
>>>>> # Parent  0b0425aed2d4c035f3cfd1c7b1a32351b1948b40
>>>>> histedit: delete to drop
>>>>>
>>>>> Some users prefer the histedit to drop the missing lines instead
>>>>> of requiring the drop command.
>>>>>
>>>>> It allows an user to look an histedit rules from declarative perspective
>>>>> and make the rules reflect the state after histedit.  If we can move lines t
>>>>> move commits why can't we drop lines to drop commits?
>>>>
>>>> Is it worth mentioning in the log message that it's an intentional
>>>> footgun preventer that you have to be explicit about drop? Perhaps
>>>> also some warning verbiage in the documentation of the option about
>>>> how it means missing rule lines will result in deleted changes.
>>
>> I’d be happy to include more information in the log message but I heard that we are trying
>> to keep all hints to one line. What do you suggest?
>
> I meant your commit message, not the hint. :)
>
>>
>>
>>
>>>>
>>>>> Let's put this behind config knob and inform users about this feature the very
>>>>> moment they are trying to use it so they can choose desired behaviour.
>>>>>
>>>>> diff --git a/hgext/histedit.py b/hgext/histedit.py
>>>>> --- a/hgext/histedit.py
>>>>> +++ b/hgext/histedit.py
>>>>> @@ -143,6 +143,9 @@
>>>>> repository that Mercurial does not detect to be related to the source
>>>>> repo, you can add a ``--force`` option.
>>>>>
>>>>> +Config
>>>>> +======
>>>>> +
>>>>> Histedit rule lines are truncated to 80 characters by default. You
>>>>> can customize this behavior by setting a different length in your
>>>>> configuration file::
>>>>> @@ -156,6 +159,14 @@
>>>>>
>>>>>   [histedit]
>>>>>   defaultrev = only(.) & draft()
>>>>> +
>>>>> +By default each edited revision needs to be present in histedit commands.
>>>>> +To remove revision you need to use ``drop`` operation. You can configure
>>>>> +the drop to be implicit for missing commits by adding:
>>>
>>> What about:
>>>
>>>   By default each edited revision needs to be present in histedit commands
>>>   and to remove revision you need to use ``drop`` operation. You can
>>>   implicitly drop missing commits by adding:
>> Will use it.
>>>
>>>>> +
>>>>> +  [histedit]
>>>>> +  deletetodrop = True
>>>
>>> While this feature seems too dangerous to me, 'dropmissing' sounds better.
>>
>> It’s not as scary as it sounds - nowadays it’s easy to recover stripped commits.
>> I’m fine with both names for the config option. Augie: do you have any preference?
>
> It’s still not trivial for novice users to recover hidden commits - especially if obsolete is off. In any event, I think I like the ‘dropmissing' a little better than ‘deletetodrop’.
>
> Thanks for working on this!
>
>>
>>>
>>>>> +
>>>>> """
>>>>>
>>>>> try:
>>>>> @@ -1261,10 +1272,17 @@
>>>>>                         ha[:12])
>>>>>             seen.add(ha)
>>>>>     missing = sorted(expected - seen)  # sort to stabilize output
>>>>> -    if missing:
>>>>> +
>>>>> +    if state.repo.ui.configbool('histedit', 'deletetodrop'):
>>>>> +        drops = [drop(state, node.bin(n)) for n in missing]
>>>>> +        # put the in the beginning so they execute immediately and
>>>>> +        # don't show in the edit-plan in the future
>>>>> +        actions[:0] = drops
>>>>> +    elif missing:
>>>>>         raise error.Abort(_('missing rules for changeset %s') %
>>>>>                 missing[0][:12],
>>>>> -                hint=_('use "drop %s" to discard the change') % missing[0][:12])
>>>>> +                hint=_('use "drop %s" to discard, '
>>>>> +                       'see also: "hg help -e histedit.config"' % missing[0][:12]))
>>>>>
>>>>> def newnodestoabort(state):
>>>>>     """process the list of replacements to return
>>>>> diff --git a/tests/test-histedit-drop.t b/tests/test-histedit-drop.t
>>>>> --- a/tests/test-histedit-drop.t
>>>>> +++ b/tests/test-histedit-drop.t
>>>>> @@ -151,4 +151,27 @@
>>>>>      summary:     a
>>>>>
>>>>>
>>>>> -  $ cd ..
>>>>> +  $ hg histedit cb9a9f314b8b --commands - 2>&1 << EOF | fixbundle
>>>>> +  > pick cb9a9f314b8b a
>>>>> +  > pick ee283cb5f2d5 e
>>>>> +  > EOF
>>>>> +  abort: missing rules for changeset a4f7421b80f7
>>>>> +  (use "drop a4f7421b80f7" to discard, see also: "hg help -e histedit.config")
>>>>> +  $ hg --config histedit.deletetodrop=True histedit  cb9a9f314b8b --commands - 2>&1 << EOF | fixbundle
>>>>> +  > pick cb9a9f314b8b a
>>>>> +  > pick ee283cb5f2d5 e
>>>>> +  > EOF
>>>>> +  0 files updated, 0 files merged, 3 files removed, 0 files unresolved
>>>>> +  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
>>>>> +  $ hg log --graph
>>>>> +  @  changeset:   1:e99c679bf03e
>>>>> +  |  tag:         tip
>>>>> +  |  user:        test
>>>>> +  |  date:        Thu Jan 01 00:00:00 1970 +0000
>>>>> +  |  summary:     e
>>>>> +  |
>>>>> +  o  changeset:   0:cb9a9f314b8b
>>>>> +     user:        test
>>>>> +     date:        Thu Jan 01 00:00:00 1970 +0000
>>>>> +     summary:     a
>>>>> +
>>>>> _______________________________________________
>>>>> Mercurial-devel mailing list
>>>>> Mercurial-devel at selenic.com
>>>>> https://selenic.com/mailman/listinfo/mercurial-devel
>>>> _______________________________________________
>>>> Mercurial-devel mailing list
>>>> Mercurial-devel at selenic.com
>>>> https://selenic.com/mailman/listinfo/mercurial-devel
>>>
>>> _______________________________________________
>>> Mercurial-devel mailing list
>>> Mercurial-devel at selenic.com
>>> https://selenic.com/mailman/listinfo/mercurial-devel
>
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
>


More information about the Mercurial-devel mailing list