Patchwork [V5] rebase: fail-fast the pull if working dir is not clean (BC)

login
register
mail settings
Submitter Valters Vingolds
Date Jan. 7, 2017, 8:54 a.m.
Message ID <73c1068ae4b9ba4de6c7.1483779251@w540>
Download mbox | patch
Permalink /patch/18130/
State Accepted
Headers show

Comments

Valters Vingolds - Jan. 7, 2017, 8:54 a.m.
# HG changeset patch
# User Valters Vingolds <valters@vingolds.ch>
# Date 1483272989 -3600
#      Sun Jan 01 13:16:29 2017 +0100
# Node ID 73c1068ae4b9ba4de6c7a20ff10754b6f3b9bb85
# Parent  011122b3b1c42374fb0489d107418e1be3665ca6
rebase: fail-fast the pull if working dir is not clean (BC)

Refuse to run 'hg pull --rebase' if there are uncommitted changes:
so that instead of going ahead with fetching changes and then suddenly aborting
the rebase, we can warn user of uncommitted changes (or unclean repo state)
right up front.
In tests, we create a 'histedit' session to verify that also an unfinished
state is detected and handled.
Sean Farley - Jan. 8, 2017, 5:13 a.m.
Valters Vingolds <valters@vingolds.ch> writes:

> # HG changeset patch
> # User Valters Vingolds <valters@vingolds.ch>
> # Date 1483272989 -3600
> #      Sun Jan 01 13:16:29 2017 +0100
> # Node ID 73c1068ae4b9ba4de6c7a20ff10754b6f3b9bb85
> # Parent  011122b3b1c42374fb0489d107418e1be3665ca6
> rebase: fail-fast the pull if working dir is not clean (BC)
>
> Refuse to run 'hg pull --rebase' if there are uncommitted changes:
> so that instead of going ahead with fetching changes and then suddenly aborting
> the rebase, we can warn user of uncommitted changes (or unclean repo state)
> right up front.
> In tests, we create a 'histedit' session to verify that also an unfinished
> state is detected and handled.

If I've followed the discussion so far, this patch seems to address all
of Pierre-Yves' comments, so I think it's good to go. Marking as
pre-reviewed.
Pierre-Yves David - Jan. 8, 2017, 1:06 p.m.
On 01/08/2017 06:13 AM, Sean Farley wrote:
> Valters Vingolds <valters@vingolds.ch> writes:
>
>> # HG changeset patch
>> # User Valters Vingolds <valters@vingolds.ch>
>> # Date 1483272989 -3600
>> #      Sun Jan 01 13:16:29 2017 +0100
>> # Node ID 73c1068ae4b9ba4de6c7a20ff10754b6f3b9bb85
>> # Parent  011122b3b1c42374fb0489d107418e1be3665ca6
>> rebase: fail-fast the pull if working dir is not clean (BC)
>>
>> Refuse to run 'hg pull --rebase' if there are uncommitted changes:
>> so that instead of going ahead with fetching changes and then suddenly aborting
>> the rebase, we can warn user of uncommitted changes (or unclean repo state)
>> right up front.
>> In tests, we create a 'histedit' session to verify that also an unfinished
>> state is detected and handled.
>
> If I've followed the discussion so far, this patch seems to address all
> of Pierre-Yves' comments, so I think it's good to go. Marking as
> pre-reviewed.

Yep, that one is pushed, Thanks.

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -1316,6 +1316,10 @@ 
                 ui.debug('--update and --rebase are not compatible, ignoring '
                          'the update flag\n')
 
+            ui.debug('before rebase: ensure working dir is clean\n')
+            cmdutil.checkunfinished(repo)
+            cmdutil.bailifchanged(repo)
+
             revsprepull = len(repo)
             origpostincoming = commands.postincoming
             def _dummy(*args, **kwargs):
diff --git a/tests/test-rebase-pull.t b/tests/test-rebase-pull.t
--- a/tests/test-rebase-pull.t
+++ b/tests/test-rebase-pull.t
@@ -1,6 +1,7 @@ 
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
   > rebase=
+  > histedit=
   > 
   > [alias]
   > tglog = log -G --template "{rev}: '{desc}' {branches}\n"
@@ -72,6 +73,27 @@ 
   searching for changes
   no changes found
 
+Abort pull early if working dir is not clean:
+
+  $ echo L1-mod > L1
+  $ hg pull --rebase
+  abort: uncommitted changes
+  [255]
+  $ hg update --clean --quiet
+
+Abort pull early if another operation (histedit) is in progress:
+
+  $ hg histedit . -q --commands - << EOF
+  > edit d80cc2da061e histedit: generate unfinished state
+  > EOF
+  Editing (d80cc2da061e), you may commit or record as needed now.
+  (hg histedit --continue to resume)
+  [1]
+  $ hg pull --rebase
+  abort: histedit in progress
+  (use 'hg histedit --continue' or 'hg histedit --abort')
+  [255]
+  $ hg histedit --abort --quiet
 
 Invoke pull --rebase and nothing to rebase: