Patchwork rfc for a change in an error message (cross branch dirty update)

login
register
mail settings
Submitter via Mercurial-devel
Date Oct. 4, 2017, 10:33 p.m.
Message ID <d24256fc-15c9-be14-6ca7-b5352b5e2a94@inwind.it>
Download mbox | patch
Permalink /patch/24526/
State Rejected
Headers show

Comments

via Mercurial-devel - Oct. 4, 2017, 10:33 p.m.
Hi,
I would like some comments about a small proposal I was thinking to do

The change consists in modifying the error messages mercurial spits when
performing an update across branches with a dirty working copy.
This is a change in the command line output for an error message (not a
behavioural one), but the command line is supposed to be stable, hence
my doubt.

The rationale of the change is explained in the commit message (in the
hope to make more discoverable the ux).

The second doubt is about internationalization: if I change an error
message, what should I do something in /i18n?

An extract of the hypotetical patch series follows, please let me know
if it makes sense.

Thanks





[...]
the same for the other tests (where applies: not for the "conflicting 
changes" case)
[...]
Denis Laxalde - Oct. 5, 2017, 7:39 a.m.
muxator via Mercurial-devel a écrit :
> 
> # HG changeset patch
> # User muxator <a.mux@inwind.it>
> # Date 1507151594 -7200
> #      Wed Oct 04 23:13:14 2017 +0200
> # Node ID fb134b55bce708f567cb4f32c0d96bb032c2651c
> # Parent  c67db5dc131d0facdfdadc8c3344a8f3e689867d
> ux: propose "hg update --merge" in the error message of a nonlinear 
> dirty update

For the record, this has been proposed previously when the option got 
introduced. See 
https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-February/093128.html 
(follow replies for the rationale).

> When trying an "hg update" of a dirty working copy across branches, 
> mercurial
> protects the user aborting with:
>     abort: uncommitted changes
>     (commit or update --clean to discard changes)
> 
> Since mercurial 4.2, however, it is possible to perform such updates 
> invoking
> "hg up --merge", but this is not signaled in the error message.
> 
> Only for these type of updates, this commit modifies the hint after the 
> error
> message to:
>     abort: uncommitted changes
>     (commit or update --merge to merge the changes. To discard the 
> changes, update --clean)
> 
> The case in which the update is aborted due to conflicting changes keeps
> printing the old error message:
>    abort: conflicting changes
>    (commit or update --clean to discard changes)
> 
> diff --git a/mercurial/merge.py b/mercurial/merge.py
> --- a/mercurial/merge.py
> +++ b/mercurial/merge.py
> @@ -1615,7 +1615,7 @@
>                           pass # allow updating to successors
>                       else:
>                           msg = _("uncommitted changes")
> -                        hint = _("commit or update --clean to discard 
> changes")
> +                        hint = _("commit or update --merge to merge the 
> changes. To discard the changes, update --clean")
>                           raise error.UpdateAbort(msg, hint=hint)
>                   else:
>                       # Allow jumping branches if clean and specific rev 
> given
> diff --git a/tests/test-merge5.t b/tests/test-merge5.t
> --- a/tests/test-merge5.t
> +++ b/tests/test-merge5.t
> @@ -26,7 +26,7 @@
> 
>     $ hg update 1
>     abort: uncommitted changes
> -  (commit or update --clean to discard changes)
> +  (commit or update --merge to merge the changes. To discard the 
> changes, update --clean)
>     [255]
>     $ mv c a
> 
> [...]
> the same for the other tests (where applies: not for the "conflicting 
> changes" case)
> [...]
>
via Mercurial-devel - Oct. 5, 2017, 8:27 p.m.
Thanks Denis,

I see I was late to the party.

Maybe, once "experimental.updatecheck=noconflict" stabilizes, we could 
suggest "--merge" only if it is not going to cause a conflict.



On 10/05/2017 09:39 AM, Denis Laxalde wrote:
> muxator via Mercurial-devel a écrit :
>>
>> # HG changeset patch
>> # User muxator <a.mux@inwind.it>
>> # Date 1507151594 -7200
>> #      Wed Oct 04 23:13:14 2017 +0200
>> # Node ID fb134b55bce708f567cb4f32c0d96bb032c2651c
>> # Parent  c67db5dc131d0facdfdadc8c3344a8f3e689867d
>> ux: propose "hg update --merge" in the error message of a nonlinear 
>> dirty update
>
> For the record, this has been proposed previously when the option got 
> introduced. See 
> https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-February/093128.html 
> (follow replies for the rationale).
>
>> When trying an "hg update" of a dirty working copy across branches, 
>> mercurial
>> protects the user aborting with:
>>     abort: uncommitted changes
>>     (commit or update --clean to discard changes)
>>
>> Since mercurial 4.2, however, it is possible to perform such updates 
>> invoking
>> "hg up --merge", but this is not signaled in the error message.
>>
>> Only for these type of updates, this commit modifies the hint after 
>> the error
>> message to:
>>     abort: uncommitted changes
>>     (commit or update --merge to merge the changes. To discard the 
>> changes, update --clean)
>>
>> The case in which the update is aborted due to conflicting changes keeps
>> printing the old error message:
>>    abort: conflicting changes
>>    (commit or update --clean to discard changes)
>>
>> diff --git a/mercurial/merge.py b/mercurial/merge.py
>> --- a/mercurial/merge.py
>> +++ b/mercurial/merge.py
>> @@ -1615,7 +1615,7 @@
>>                           pass # allow updating to successors
>>                       else:
>>                           msg = _("uncommitted changes")
>> -                        hint = _("commit or update --clean to 
>> discard changes")
>> +                        hint = _("commit or update --merge to merge 
>> the changes. To discard the changes, update --clean")
>>                           raise error.UpdateAbort(msg, hint=hint)
>>                   else:
>>                       # Allow jumping branches if clean and specific 
>> rev given
>> diff --git a/tests/test-merge5.t b/tests/test-merge5.t
>> --- a/tests/test-merge5.t
>> +++ b/tests/test-merge5.t
>> @@ -26,7 +26,7 @@
>>
>>     $ hg update 1
>>     abort: uncommitted changes
>> -  (commit or update --clean to discard changes)
>> +  (commit or update --merge to merge the changes. To discard the 
>> changes, update --clean)
>>     [255]
>>     $ mv c a
>>
>> [...]
>> the same for the other tests (where applies: not for the "conflicting 
>> changes" case)
>> [...]
>>
>

Patch

==================================

ant@cuben:/opt/mercurial/hg/i18n$ hg diff --stat --change 34463
  mercurial/merge.py           |   2 +-
  tests/test-merge5.t          |   2 +-
  tests/test-subrepo-svn.t     |   2 +-
  tests/test-update-branches.t |  12 ++++++------
  4 files changed, 9 insertions(+), 9 deletions(-)

==================================

# HG changeset patch
# User muxator <a.mux@inwind.it>
# Date 1507151594 -7200
#      Wed Oct 04 23:13:14 2017 +0200
# Node ID fb134b55bce708f567cb4f32c0d96bb032c2651c
# Parent  c67db5dc131d0facdfdadc8c3344a8f3e689867d
ux: propose "hg update --merge" in the error message of a nonlinear 
dirty update

When trying an "hg update" of a dirty working copy across branches, 
mercurial
protects the user aborting with:
    abort: uncommitted changes
    (commit or update --clean to discard changes)

Since mercurial 4.2, however, it is possible to perform such updates 
invoking
"hg up --merge", but this is not signaled in the error message.

Only for these type of updates, this commit modifies the hint after the 
error
message to:
    abort: uncommitted changes
    (commit or update --merge to merge the changes. To discard the 
changes, update --clean)

The case in which the update is aborted due to conflicting changes keeps
printing the old error message:
   abort: conflicting changes
   (commit or update --clean to discard changes)

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1615,7 +1615,7 @@ 
                          pass # allow updating to successors
                      else:
                          msg = _("uncommitted changes")
-                        hint = _("commit or update --clean to discard 
changes")
+                        hint = _("commit or update --merge to merge the 
changes. To discard the changes, update --clean")
                          raise error.UpdateAbort(msg, hint=hint)
                  else:
                      # Allow jumping branches if clean and specific rev 
given
diff --git a/tests/test-merge5.t b/tests/test-merge5.t
--- a/tests/test-merge5.t
+++ b/tests/test-merge5.t
@@ -26,7 +26,7 @@ 

    $ hg update 1
    abort: uncommitted changes
-  (commit or update --clean to discard changes)
+  (commit or update --merge to merge the changes. To discard the 
changes, update --clean)
    [255]
    $ mv c a