[PATCH] update: add a hint when aborting for uncommitted changes

Martin von Zweigbergk martinvonz at google.com
Wed Apr 5 11:17:27 EDT 2017


On Apr 5, 2017 04:01, "Pierre-Yves David" <pierre-yves.david at ens-lyon.org>
wrote:



On 04/05/2017 07:29 AM, Martin von Zweigbergk wrote:

> On Tue, Apr 4, 2017 at 9:40 AM, Pierre-Yves David
> <pierre-yves.david at ens-lyon.org> wrote:
>
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
>> # Date 1491225382 -7200
>> #      Mon Apr 03 15:16:22 2017 +0200
>> # Node ID 32116e1ad0d93b48d344f317899b974628310850
>> # Parent  2632df096fc0ac7582382b1f94ea4b9ad0bce8f2
>> # EXP-Topic update.mergehint
>> # Available At https://www.mercurial-scm.org/
>> repo/users/marmoute/mercurial/
>> #              hg pull https://www.mercurial-scm.org/
>> repo/users/marmoute/mercurial/ -r 32116e1ad0d9
>> update: add a hint when aborting for uncommitted changes
>>
>> Plain abort is a bit frustrating for the user. We now point at the
>> '--merge' option
>> in the hint. This is similar to what evolve 'next' and 'prev' do. Not that
>> evolution use a more direct hint "(do you want --merge)", but it might be
>> a bit
>> too error prone for new user.
>>
>> diff --git a/mercurial/hg.py b/mercurial/hg.py
>> --- a/mercurial/hg.py
>> +++ b/mercurial/hg.py
>> @@ -761,7 +761,8 @@ def updatetotally(ui, repo, checkout, br
>>              ret = _clean(repo, checkout)
>>          else:
>>              if updatecheck == 'abort':
>> -                cmdutil.bailifchanged(repo, merge=False)
>> +                hint = _('to merge these changes with destination, use
>> --merge')
>>
>
> The existing messages say "commit or update --clean to discard
> changes". I sent a patch to also suggest --merge in the
> updatecheck=linear case (i.e. the legacy and default case), but we
> ended up dropping that because it's hard to recover from the merge
> state.
>

Note that we could easily build a `hg update --abort` that makes it easy to
recover.


I didn't realize we kept the uncommitted file content around somewhere so
it could be restored. But I know you can re-resolve a file, so I should
have figured that out.



I don't see a reason that we should recommend something
> different when updatecheck=abort. Using a hint of "commit or update
> --clean to discard changes" seems completely uncontroversial. Should
> we do that instead? Or should we start recommending --merge (for both
> these cases) despite the risk? I'm not sure.
>

My usecase for "abort" is "I do not want to move away with uncommitted
change without realizing it". They are a good chance I actually wanted to
commit or amend the change locally. I'm using the "uncommited change" in
prev/next the same way. However they also are many case where I actually
want the merge to happens (and I'll use --merge).
In such case the hint with --merge in it provides me with a clear visual
hint that the abort is not a bit deal and that they are an easy way forward.

The hard abort with no hint looks like something serious with no easy
solution is happening to my repository.

In my current opinion is that we should:
1) get `hg abort --abort`


Yes, please! (You obviously meant "hg update --abort" here too.)

2) add the hint point at --merge in all cases


Yep, I agree.

3) move the feature out of experimental once the two point above are solved.


Sounds good. An important reason it was in experimental was because we
didn't have a good name for the config. Now we have the [commands] section.


What do you think ?


+                cmdutil.bailifchanged(repo, merge=False, hint=hint)
>>                  updatecheck = 'none'
>>              ret = _update(repo, checkout, updatecheck=updatecheck)
>>
>> diff --git a/tests/test-merge5.t b/tests/test-merge5.t
>> --- a/tests/test-merge5.t
>> +++ b/tests/test-merge5.t
>> @@ -16,6 +16,7 @@
>>    $ rm b
>>    $ hg update -c 2
>>    abort: uncommitted changes
>> +  (to merge these changes with destination, use --merge)
>>    [255]
>>    $ hg revert b
>>    $ hg update -c 2
>> diff --git a/tests/test-pull-update.t b/tests/test-pull-update.t
>> --- a/tests/test-pull-update.t
>> +++ b/tests/test-pull-update.t
>> @@ -27,6 +27,7 @@ Should respect config to disable dirty u
>>    adding file changes
>>    added 1 changesets with 1 changes to 1 files (+1 heads)
>>    abort: uncommitted changes
>> +  (to merge these changes with destination, use --merge)
>>    [255]
>>    $ hg --config extensions.strip= strip --no-backup tip
>>    $ hg co -qC tip
>> diff --git a/tests/test-update-branches.t b/tests/test-update-branches.t
>> --- a/tests/test-update-branches.t
>> +++ b/tests/test-update-branches.t
>> @@ -157,6 +157,7 @@ Cases are run as shown in that table, ro
>>
>>    $ revtest '-c dirty linear'   dirty 1 2 -c
>>    abort: uncommitted changes
>> +  (to merge these changes with destination, use --merge)
>>    parent=1
>>    M foo
>>
>> @@ -172,6 +173,7 @@ Cases are run as shown in that table, ro
>>
>>    $ revtest '-c dirtysub linear'   dirtysub 1 2 -c
>>    abort: uncommitted changes in subrepository 'sub'
>> +  (to merge these changes with destination, use --merge)
>>    parent=1
>>    M sub/suba
>>
>> @@ -200,11 +202,13 @@ Cases are run as shown in that table, ro
>>
>>    $ revtest 'none dirty linear' dirty 1 2
>>    abort: uncommitted changes
>> +  (to merge these changes with destination, use --merge)
>>    parent=1
>>    M foo
>>
>>    $ revtest 'none dirty linear' dirty 1 2 -c
>>    abort: uncommitted changes
>> +  (to merge these changes with destination, use --merge)
>>    parent=1
>>    M foo
>>
>> @@ -226,6 +230,7 @@ Cases are run as shown in that table, ro
>>
>>    $ revtest 'none dirty linear' dirty 1 2 -c
>>    abort: uncommitted changes
>> +  (to merge these changes with destination, use --merge)
>>    parent=1
>>    M foo
>>
>> @@ -269,6 +274,7 @@ Cases are run as shown in that table, ro
>>
>>    $ revtest 'none dirty linear' dirty 1 2 -c
>>    abort: uncommitted changes
>> +  (to merge these changes with destination, use --merge)
>>    parent=1
>>    M foo
>>
>> @@ -323,6 +329,7 @@ Uses default value of "linear" when valu
>>  Setup for later tests
>>    $ revtest 'none dirty linear' dirty 1 2 -c
>>    abort: uncommitted changes
>> +  (to merge these changes with destination, use --merge)
>>    parent=1
>>    M foo
>>
>> @@ -560,6 +567,7 @@ Test that boolean flags allow --no-flag
>>    > EOF
>>    $ hg co 2
>>    abort: uncommitted changes
>> +  (to merge these changes with destination, use --merge)
>>    [255]
>>    $ hg co --no-check 2
>>    0 files updated, 0 files merged, 0 files removed, 0 files unresolved
>> diff --git a/tests/test-update-issue1456.t b/tests/test-update-issue1456.
>> t
>> --- a/tests/test-update-issue1456.t
>> +++ b/tests/test-update-issue1456.t
>> @@ -19,6 +19,7 @@ Test that local removed/deleted, remote
>>    $ echo dirty > foo
>>    $ hg up -c
>>    abort: uncommitted changes
>> +  (to merge these changes with destination, use --merge)
>>    [255]
>>    $ hg up -q
>>    $ cat foo
>>
>
-- 
Pierre-Yves David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20170405/15eb4fb2/attachment.html>


More information about the Mercurial-devel mailing list