D3959: rebase: add --stop option to stop rebase at any point (issue5206)

2018-08-14 Thread khanchi97 (Sushil khanchi)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGcc37009e95ca: rebase: add --stop option to stop rebase at 
any point (issue5206) (authored by khanchi97, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D3959?vs=10286=10354#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3959?vs=10286=10354

REVISION DETAIL
  https://phab.mercurial-scm.org/D3959

AFFECTED FILES
  hgext/rebase.py
  tests/test-rebase-obsolete.t

CHANGE DETAILS

diff --git a/tests/test-rebase-obsolete.t b/tests/test-rebase-obsolete.t
--- a/tests/test-rebase-obsolete.t
+++ b/tests/test-rebase-obsolete.t
@@ -15,6 +15,7 @@
   > [extensions]
   > rebase=
   > drawdag=$TESTDIR/drawdag.py
+  > strip=
   > EOF
 
 Setup rebase canonical repo
@@ -1788,3 +1789,217 @@
   |
   o  0:426bada5c675 A
   
+
+Test --stop option |
+
+  $ cd ..
+  $ hg init rbstop
+  $ cd rbstop
+  $ echo a>a
+  $ hg ci -Aqma
+  $ echo b>b
+  $ hg ci -Aqmb
+  $ echo c>c
+  $ hg ci -Aqmc
+  $ echo d>d
+  $ hg ci -Aqmd
+  $ hg up 0 -q
+  $ echo f>f
+  $ hg ci -Aqmf
+  $ echo D>d
+  $ hg ci -Aqm "conflict with d"
+  $ hg up 3 -q
+  $ hg log -G --template "{rev}:{short(node)} 
{person(author)}\n{firstline(desc)} {topic}\n\n"
+  o  5:00bfc9898aeb test
+  |  conflict with d
+  |
+  o  4:dafd40200f93 test
+  |  f
+  |
+  | @  3:055a42cdd887 test
+  | |  d
+  | |
+  | o  2:177f92b77385 test
+  | |  c
+  | |
+  | o  1:d2ae7f538514 test
+  |/   b
+  |
+  o  0:cb9a9f314b8b test
+ a
+  
+  $ hg rebase -s 1 -d 5
+  rebasing 1:d2ae7f538514 "b"
+  rebasing 2:177f92b77385 "c"
+  rebasing 3:055a42cdd887 "d"
+  merging d
+  warning: conflicts while merging d! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+  $ hg rebase --stop
+  1 new orphan changesets
+  $ hg log -G --template "{rev}:{short(node)} 
{person(author)}\n{firstline(desc)} {topic}\n\n"
+  o  7:7fffad344617 test
+  |  c
+  |
+  o  6:b15528633407 test
+  |  b
+  |
+  o  5:00bfc9898aeb test
+  |  conflict with d
+  |
+  o  4:dafd40200f93 test
+  |  f
+  |
+  | @  3:055a42cdd887 test
+  | |  d
+  | |
+  | x  2:177f92b77385 test
+  | |  c
+  | |
+  | x  1:d2ae7f538514 test
+  |/   b
+  |
+  o  0:cb9a9f314b8b test
+ a
+  
+Test it aborts if unstable csets is not allowed:
+===
+  $ cat >> $HGRCPATH << EOF
+  > [experimental]
+  > evolution.allowunstable=False
+  > EOF
+
+  $ hg strip 6 --no-backup -q
+  $ hg log -G --template "{rev}:{short(node)} 
{person(author)}\n{firstline(desc)} {topic}\n\n"
+  o  5:00bfc9898aeb test
+  |  conflict with d
+  |
+  o  4:dafd40200f93 test
+  |  f
+  |
+  | @  3:055a42cdd887 test
+  | |  d
+  | |
+  | o  2:177f92b77385 test
+  | |  c
+  | |
+  | o  1:d2ae7f538514 test
+  |/   b
+  |
+  o  0:cb9a9f314b8b test
+ a
+  
+  $ hg rebase -s 1 -d 5
+  rebasing 1:d2ae7f538514 "b"
+  rebasing 2:177f92b77385 "c"
+  rebasing 3:055a42cdd887 "d"
+  merging d
+  warning: conflicts while merging d! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+  $ hg rebase --stop
+  abort: cannot remove original changesets with unrebased descendants
+  (either enable obsmarkers to allow unstable revisions or use --keep to keep 
original changesets)
+  [255]
+  $ hg rebase --abort
+  saved backup bundle to 
$TESTTMP/rbstop/.hg/strip-backup/b15528633407-6eb72b6f-backup.hg
+  rebase aborted
+
+Test --stop when --keep is passed:
+==
+  $ hg rebase -s 1 -d 5 --keep
+  rebasing 1:d2ae7f538514 "b"
+  rebasing 2:177f92b77385 "c"
+  rebasing 3:055a42cdd887 "d"
+  merging d
+  warning: conflicts while merging d! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+  $ hg rebase --stop
+  $ hg log -G --template "{rev}:{short(node)} 
{person(author)}\n{firstline(desc)} {topic}\n\n"
+  o  7:7fffad344617 test
+  |  c
+  |
+  o  6:b15528633407 test
+  |  b
+  |
+  o  5:00bfc9898aeb test
+  |  conflict with d
+  |
+  o  4:dafd40200f93 test
+  |  f
+  |
+  | @  3:055a42cdd887 test
+  | |  d
+  | |
+  | o  2:177f92b77385 test
+  | |  c
+  | |
+  | o  1:d2ae7f538514 test
+  |/   b
+  |
+  o  0:cb9a9f314b8b test
+ a
+  
+Test --stop aborts when --collapse was passed:
+=
+  $ cat >> $HGRCPATH << EOF
+  > [experimental]
+  > evolution.allowunstable=True
+  > EOF
+
+  $ hg strip 6
+  saved backup bundle to 
$TESTTMP/rbstop/.hg/strip-backup/b15528633407-6eb72b6f-backup.hg
+  $ hg log -G --template "{rev}:{short(node)} 
{person(author)}\n{firstline(desc)} {topic}\n\n"
+  o  5:00bfc9898aeb test
+  |  conflict with d
+  |
+  o  4:dafd40200f93 test
+  |  f
+  |
+  | @  3:055a42cdd887 test
+  | |  d
+  | |
+  | o  2:177f92b77385 test
+  | |  c
+  | |
+  | o  1:d2ae7f538514 test
+  |/   b
+  |

D3959: rebase: add --stop option to stop rebase at any point (issue5206)

2018-08-14 Thread yuja (Yuya Nishihara)
yuja added a comment.


  Queued, many thanks.
  
  > +elif stop:
  >  +rbsrt = rebaseruntime(repo, ui)
  >  +rbsrt.restorestatus()
  
  Perhaps `restorestatus()` needs to be covered by the lock to prevent it from
  being updated by another process. Can you send a follow up?

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3959

To: khanchi97, #hg-reviewers
Cc: pulkit, yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: D3959: rebase: add --stop option to stop rebase at any point (issue5206)

2018-08-14 Thread Yuya Nishihara
Queued, many thanks.

> +elif stop:
> +rbsrt = rebaseruntime(repo, ui)
> +rbsrt.restorestatus()

Perhaps `restorestatus()` needs to be covered by the lock to prevent it from
being updated by another process. Can you send a follow up?
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D3959: rebase: add --stop option to stop rebase at any point (issue5206)

2018-08-10 Thread khanchi97 (Sushil khanchi)
khanchi97 updated this revision to Diff 10286.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3959?vs=9654=10286

REVISION DETAIL
  https://phab.mercurial-scm.org/D3959

AFFECTED FILES
  hgext/rebase.py
  tests/test-rebase-obsolete.t

CHANGE DETAILS

diff --git a/tests/test-rebase-obsolete.t b/tests/test-rebase-obsolete.t
--- a/tests/test-rebase-obsolete.t
+++ b/tests/test-rebase-obsolete.t
@@ -15,6 +15,7 @@
   > [extensions]
   > rebase=
   > drawdag=$TESTDIR/drawdag.py
+  > strip=
   > EOF
 
 Setup rebase canonical repo
@@ -1788,3 +1789,217 @@
   |
   o  0:426bada5c675 A
   
+
+Test --stop option |
+
+  $ cd ..
+  $ hg init rbstop
+  $ cd rbstop
+  $ echo a>a
+  $ hg ci -Aqma
+  $ echo b>b
+  $ hg ci -Aqmb
+  $ echo c>c
+  $ hg ci -Aqmc
+  $ echo d>d
+  $ hg ci -Aqmd
+  $ hg up 0 -q
+  $ echo f>f
+  $ hg ci -Aqmf
+  $ echo D>d
+  $ hg ci -Aqm "conflict with d"
+  $ hg up 3 -q
+  $ hg log -G --template "{rev}:{short(node)} 
{person(author)}\n{firstline(desc)} {topic}\n\n"
+  o  5:00bfc9898aeb test
+  |  conflict with d
+  |
+  o  4:dafd40200f93 test
+  |  f
+  |
+  | @  3:055a42cdd887 test
+  | |  d
+  | |
+  | o  2:177f92b77385 test
+  | |  c
+  | |
+  | o  1:d2ae7f538514 test
+  |/   b
+  |
+  o  0:cb9a9f314b8b test
+ a
+  
+  $ hg rebase -s 1 -d 5
+  rebasing 1:d2ae7f538514 "b"
+  rebasing 2:177f92b77385 "c"
+  rebasing 3:055a42cdd887 "d"
+  merging d
+  warning: conflicts while merging d! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+  $ hg rebase --stop
+  1 new orphan changesets
+  $ hg log -G --template "{rev}:{short(node)} 
{person(author)}\n{firstline(desc)} {topic}\n\n"
+  o  7:7fffad344617 test
+  |  c
+  |
+  o  6:b15528633407 test
+  |  b
+  |
+  o  5:00bfc9898aeb test
+  |  conflict with d
+  |
+  o  4:dafd40200f93 test
+  |  f
+  |
+  | @  3:055a42cdd887 test
+  | |  d
+  | |
+  | x  2:177f92b77385 test
+  | |  c
+  | |
+  | x  1:d2ae7f538514 test
+  |/   b
+  |
+  o  0:cb9a9f314b8b test
+ a
+  
+Test it aborts if unstable csets is not allowed:
+===
+  $ cat >> $HGRCPATH << EOF
+  > [experimental]
+  > evolution.allowunstable=False
+  > EOF
+
+  $ hg strip 6 --no-backup -q
+  $ hg log -G --template "{rev}:{short(node)} 
{person(author)}\n{firstline(desc)} {topic}\n\n"
+  o  5:00bfc9898aeb test
+  |  conflict with d
+  |
+  o  4:dafd40200f93 test
+  |  f
+  |
+  | @  3:055a42cdd887 test
+  | |  d
+  | |
+  | o  2:177f92b77385 test
+  | |  c
+  | |
+  | o  1:d2ae7f538514 test
+  |/   b
+  |
+  o  0:cb9a9f314b8b test
+ a
+  
+  $ hg rebase -s 1 -d 5
+  rebasing 1:d2ae7f538514 "b"
+  rebasing 2:177f92b77385 "c"
+  rebasing 3:055a42cdd887 "d"
+  merging d
+  warning: conflicts while merging d! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+  $ hg rebase --stop
+  abort: cannot remove original changesets with unrebased descendants
+  (either enable obsmarkers to allow unstable revisions or use --keep to keep 
original changesets)
+  [255]
+  $ hg rebase --abort
+  saved backup bundle to 
$TESTTMP/rbstop/.hg/strip-backup/b15528633407-6eb72b6f-backup.hg
+  rebase aborted
+
+Test --stop when --keep is passed:
+==
+  $ hg rebase -s 1 -d 5 --keep
+  rebasing 1:d2ae7f538514 "b"
+  rebasing 2:177f92b77385 "c"
+  rebasing 3:055a42cdd887 "d"
+  merging d
+  warning: conflicts while merging d! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+  $ hg rebase --stop
+  $ hg log -G --template "{rev}:{short(node)} 
{person(author)}\n{firstline(desc)} {topic}\n\n"
+  o  7:7fffad344617 test
+  |  c
+  |
+  o  6:b15528633407 test
+  |  b
+  |
+  o  5:00bfc9898aeb test
+  |  conflict with d
+  |
+  o  4:dafd40200f93 test
+  |  f
+  |
+  | @  3:055a42cdd887 test
+  | |  d
+  | |
+  | o  2:177f92b77385 test
+  | |  c
+  | |
+  | o  1:d2ae7f538514 test
+  |/   b
+  |
+  o  0:cb9a9f314b8b test
+ a
+  
+Test --stop aborts when --collapse was passed:
+=
+  $ cat >> $HGRCPATH << EOF
+  > [experimental]
+  > evolution.allowunstable=True
+  > EOF
+
+  $ hg strip 6
+  saved backup bundle to 
$TESTTMP/rbstop/.hg/strip-backup/b15528633407-6eb72b6f-backup.hg
+  $ hg log -G --template "{rev}:{short(node)} 
{person(author)}\n{firstline(desc)} {topic}\n\n"
+  o  5:00bfc9898aeb test
+  |  conflict with d
+  |
+  o  4:dafd40200f93 test
+  |  f
+  |
+  | @  3:055a42cdd887 test
+  | |  d
+  | |
+  | o  2:177f92b77385 test
+  | |  c
+  | |
+  | o  1:d2ae7f538514 test
+  |/   b
+  |
+  o  0:cb9a9f314b8b test
+ a
+  
+  $ hg rebase -s 1 -d 5 --collapse -m "collapsed b c d"
+  rebasing 1:d2ae7f538514 "b"
+  rebasing 2:177f92b77385 "c"
+  rebasing 3:055a42cdd887 "d"
+  merging d
+  warning: conflicts while merging d! (edit, then 

Re: D3959: rebase: add --stop option to stop rebase at any point (issue5206)

2018-08-08 Thread Yuya Nishihara
> -def _finishrebase(self):
> +def _finishrebase(self, stoprebase=False):
>  repo, ui, opts = self.repo, self.ui, self.opts
>  fm = ui.formatter('rebase', opts)
>  fm.startitem()
> +if stoprebase:
> +self.restorestatus()
> +if self.collapsef:
> +ui.status(_("cannot stop in --collapse session\n"))
> +return

raise Abort because it's an error?

> +
> +allowunstable = obsolete.isenabled(repo, 
> obsolete.allowunstableopt)
> +if not (self.keepf or allowunstable):
> +raise error.Abort(_("can't remove original changesets with"
> +  " unrebased descendants"),
> +hint=_('either enable obsmarkers to allow unstable '
> +   'revisions or use --keep to keep original '
> +   'changesets'))

It will be nice if we can move the pre-process out from `_finishrebase()`,
and get rid of the `stoprebase` flag somehow.

>  if self.collapsef:
>  p1, p2, _base = defineparents(repo, min(self.state), 
> self.destmap,
>self.state, self.skipped,
> @@ -626,7 +640,10 @@
>  newwd = self.originalwd
>  if newwd not in [c.rev() for c in repo[None].parents()]:
>  ui.note(_("update back to initial working directory parent\n"))
> -hg.updaterepo(repo, newwd, overwrite=False)
> +if stoprebase:
> +hg.updaterepo(repo, newwd, overwrite=True)
> +else:
> +hg.updaterepo(repo, newwd, overwrite=False)

This implies an interrupted merge won't be cleared if no update is required.
(try `hg up 3 && hg rebase -s 1 -d 5` in the first test you've added.)

Perhaps the `rebase --stop` flow can be processed as follows?

```
   rbsrt = rebaseruntime(repo, ui)
   rbsrt.restorestatus()
   ... check unsupported options ...
   with repo.wlock(), repo.lock():
   if needupdate(repo, state):
   .. update to the current working revision with overwrite=True
   .. to clear interrupted merge
   rbsrt._finishrebase()
```
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D3959: rebase: add --stop option to stop rebase at any point (issue5206)

2018-08-08 Thread yuja (Yuya Nishihara)
yuja added a comment.


  > - def _finishrebase(self): +def _finishrebase(self, stoprebase=False): 
repo, ui, opts = self.repo, self.ui, self.opts fm = ui.formatter('rebase', 
opts) fm.startitem() +if stoprebase: +self.restorestatus() 
+if self.collapsef: +ui.status(_("cannot stop in 
--collapse session\n")) +return
  
  raise Abort because it's an error?
  
  > +
  >  +allowunstable = obsolete.isenabled(repo, 
obsolete.allowunstableopt)
  >  +if not (self.keepf or allowunstable):
  >  +raise error.Abort(_("can't remove original changesets 
with"
  >  +  " unrebased descendants"),
  >  +hint=_('either enable obsmarkers to allow unstable '
  >  +   'revisions or use --keep to keep original '
  >  +   'changesets'))
  
  It will be nice if we can move the pre-process out from `_finishrebase()`,
  and get rid of the `stoprebase` flag somehow.
  
  >   if self.collapsef:
  >   p1, p2, _base = defineparents(repo, min(self.state), self.destmap,
  > self.state, self.skipped,
  > 
  > @@ -626,7 +640,10 @@
  > 
  >   newwd = self.originalwd
  >   if newwd not in [c.rev() for c in repo[None].parents()]:
  >   ui.note(_("update back to initial working directory parent\n"))
  > 
  > - hg.updaterepo(repo, newwd, overwrite=False) +if stoprebase: + 
   hg.updaterepo(repo, newwd, overwrite=True) +else: +  
  hg.updaterepo(repo, newwd, overwrite=False)
  
  This implies an interrupted merge won't be cleared if no update is required.
  (try `hg up 3 && hg rebase -s 1 -d 5` in the first test you've added.)
  
  Perhaps the `rebase --stop` flow can be processed as follows?
  
rbsrt = rebaseruntime(repo, ui)
rbsrt.restorestatus()
... check unsupported options ...
with repo.wlock(), repo.lock():
if needupdate(repo, state):
.. update to the current working revision with overwrite=True
.. to clear interrupted merge
rbsrt._finishrebase()

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3959

To: khanchi97, #hg-reviewers
Cc: pulkit, yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D3959: rebase: add --stop option to stop rebase at any point (issue5206)

2018-07-27 Thread khanchi97 (Sushil khanchi)
khanchi97 added a comment.


  In https://phab.mercurial-scm.org/D3959#61803, @pulkit wrote:
  
  > You also need to take care of bookmark movements. Bookmark from changesets 
which have successfully rebased should be moved to their successors when we 
call --stop.
  
  
  @pulkit 
  I think bookmarks movement is already handled by `clearrebased()` function. I 
going to send a patch to reflect this behaviour. Correct me if I am missing 
something.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3959

To: khanchi97, #hg-reviewers
Cc: pulkit, yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D3959: rebase: add --stop option to stop rebase at any point (issue5206)

2018-07-24 Thread khanchi97 (Sushil khanchi)
khanchi97 updated this revision to Diff 9654.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3959?vs=9642=9654

REVISION DETAIL
  https://phab.mercurial-scm.org/D3959

AFFECTED FILES
  hgext/rebase.py
  tests/test-rebase-obsolete.t

CHANGE DETAILS

diff --git a/tests/test-rebase-obsolete.t b/tests/test-rebase-obsolete.t
--- a/tests/test-rebase-obsolete.t
+++ b/tests/test-rebase-obsolete.t
@@ -15,6 +15,7 @@
   > [extensions]
   > rebase=
   > drawdag=$TESTDIR/drawdag.py
+  > strip=
   > EOF
 
 Setup rebase canonical repo
@@ -1788,3 +1789,216 @@
   |
   o  0:426bada5c675 A
   
+
+Test --stop option |
+
+  $ cd ..
+  $ hg init rbstop
+  $ cd rbstop
+  $ echo a>a
+  $ hg ci -Aqma
+  $ echo b>b
+  $ hg ci -Aqmb
+  $ echo c>c
+  $ hg ci -Aqmc
+  $ echo d>d
+  $ hg ci -Aqmd
+  $ hg up 0 -q
+  $ echo f>f
+  $ hg ci -Aqmf
+  $ echo D>d
+  $ hg ci -Aqm "conflict with d"
+  $ hg up 0 -q
+  $ hg log -G --template "{rev}:{short(node)} 
{person(author)}\n{firstline(desc)} {topic}\n\n"
+  o  5:00bfc9898aeb test
+  |  conflict with d
+  |
+  o  4:dafd40200f93 test
+  |  f
+  |
+  | o  3:055a42cdd887 test
+  | |  d
+  | |
+  | o  2:177f92b77385 test
+  | |  c
+  | |
+  | o  1:d2ae7f538514 test
+  |/   b
+  |
+  @  0:cb9a9f314b8b test
+ a
+  
+  $ hg rebase -s 1 -d 5
+  rebasing 1:d2ae7f538514 "b"
+  rebasing 2:177f92b77385 "c"
+  rebasing 3:055a42cdd887 "d"
+  merging d
+  warning: conflicts while merging d! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+  $ hg rebase --stop
+  1 new orphan changesets
+  $ hg log -G --template "{rev}:{short(node)} 
{person(author)}\n{firstline(desc)} {topic}\n\n"
+  o  7:7fffad344617 test
+  |  c
+  |
+  o  6:b15528633407 test
+  |  b
+  |
+  o  5:00bfc9898aeb test
+  |  conflict with d
+  |
+  o  4:dafd40200f93 test
+  |  f
+  |
+  | *  3:055a42cdd887 test
+  | |  d
+  | |
+  | x  2:177f92b77385 test
+  | |  c
+  | |
+  | x  1:d2ae7f538514 test
+  |/   b
+  |
+  @  0:cb9a9f314b8b test
+ a
+  
+Test it aborts if unstable csets is not allowed:
+===
+  $ cat >> $HGRCPATH << EOF
+  > [experimental]
+  > evolution.allowunstable=False
+  > EOF
+
+  $ hg strip 6 --no-backup -q
+  $ hg log -G --template "{rev}:{short(node)} 
{person(author)}\n{firstline(desc)} {topic}\n\n"
+  o  5:00bfc9898aeb test
+  |  conflict with d
+  |
+  o  4:dafd40200f93 test
+  |  f
+  |
+  | o  3:055a42cdd887 test
+  | |  d
+  | |
+  | o  2:177f92b77385 test
+  | |  c
+  | |
+  | o  1:d2ae7f538514 test
+  |/   b
+  |
+  @  0:cb9a9f314b8b test
+ a
+  
+  $ hg rebase -s 1 -d 5
+  rebasing 1:d2ae7f538514 "b"
+  rebasing 2:177f92b77385 "c"
+  rebasing 3:055a42cdd887 "d"
+  merging d
+  warning: conflicts while merging d! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+  $ hg rebase --stop
+  abort: can't remove original changesets with unrebased descendants
+  (either enable obsmarkers to allow unstable revisions or use --keep to keep 
original changesets)
+  [255]
+  $ hg rebase --abort
+  saved backup bundle to 
$TESTTMP/rbstop/.hg/strip-backup/b15528633407-6eb72b6f-backup.hg
+  rebase aborted
+
+Test --stop when --keep is passed:
+==
+  $ hg rebase -s 1 -d 5 --keep
+  rebasing 1:d2ae7f538514 "b"
+  rebasing 2:177f92b77385 "c"
+  rebasing 3:055a42cdd887 "d"
+  merging d
+  warning: conflicts while merging d! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+  $ hg rebase --stop
+  $ hg log -G --template "{rev}:{short(node)} 
{person(author)}\n{firstline(desc)} {topic}\n\n"
+  o  7:7fffad344617 test
+  |  c
+  |
+  o  6:b15528633407 test
+  |  b
+  |
+  o  5:00bfc9898aeb test
+  |  conflict with d
+  |
+  o  4:dafd40200f93 test
+  |  f
+  |
+  | o  3:055a42cdd887 test
+  | |  d
+  | |
+  | o  2:177f92b77385 test
+  | |  c
+  | |
+  | o  1:d2ae7f538514 test
+  |/   b
+  |
+  @  0:cb9a9f314b8b test
+ a
+  
+Test --stop aborts when --collapse was passed:
+=
+  $ cat >> $HGRCPATH << EOF
+  > [experimental]
+  > evolution.allowunstable=True
+  > EOF
+
+  $ hg strip 6
+  saved backup bundle to 
$TESTTMP/rbstop/.hg/strip-backup/b15528633407-6eb72b6f-backup.hg
+  $ hg log -G --template "{rev}:{short(node)} 
{person(author)}\n{firstline(desc)} {topic}\n\n"
+  o  5:00bfc9898aeb test
+  |  conflict with d
+  |
+  o  4:dafd40200f93 test
+  |  f
+  |
+  | o  3:055a42cdd887 test
+  | |  d
+  | |
+  | o  2:177f92b77385 test
+  | |  c
+  | |
+  | o  1:d2ae7f538514 test
+  |/   b
+  |
+  @  0:cb9a9f314b8b test
+ a
+  
+  $ hg rebase -s 1 -d 5 --collapse -m "collapsed b c d"
+  rebasing 1:d2ae7f538514 "b"
+  rebasing 2:177f92b77385 "c"
+  rebasing 3:055a42cdd887 "d"
+  merging d
+  warning: conflicts while merging d! (edit, then 

D3959: rebase: add --stop option to stop rebase at any point (issue5206)

2018-07-24 Thread khanchi97 (Sushil khanchi)
khanchi97 added a comment.


  @pulkit I will send a follow up which will take care of bookmarks movement. 
Thanks for review!

INLINE COMMENTS

> pulkit wrote in rebase.py:595
> nit: 'cannot stop in --collapse session'
> 
> Also, if we cannot stop, we should not fallback to aborting.

Ah, right. We should only print that message and keep everything as it is.

> pulkit wrote in rebase.py:604
> nit: we don't mention about evolve or any out of tree extension from core. 
> How about making `--stop` only work when obsmarkers are enabled and error out 
> if they are not enabled?

okay, will remove mentioning of evolve.

> How about making --stop only work when obsmarkers are enabled and error out 
> if they are not enabled?



> allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)

Don't ^ line check that obsmarker are enabled or not?

> pulkit wrote in rebase.py:692
> Can we prevent having `s` and `S` evaluate to different options i.e. leave 
> 'S' for now?

okay, will remove 'S'.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3959

To: khanchi97, #hg-reviewers
Cc: pulkit, yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D3959: rebase: add --stop option to stop rebase at any point (issue5206)

2018-07-23 Thread pulkit (Pulkit Goyal)
pulkit added a comment.


  Excellent! I like the feature and this has been on my TODO for long. Thanks 
for coding this up. You also need to take care of bookmark movements. Bookmark 
from changesets which have successfully rebased should be moved to their 
successors when we call --stop.

INLINE COMMENTS

> rebase.py:595
> +if self.collapsef:
> +ui.status(_("can't stop in --collapse session\n"))
> +return abort(self.repo, self.originalwd, self.destmap,

nit: 'cannot stop in --collapse session'

Also, if we cannot stop, we should not fallback to aborting.

> rebase.py:604
> +  " unrebased descendants"),
> +hint=_('either enable evolve extension to allow unstable 
> '
> +   'revisions or use --keep to keep original '

nit: we don't mention about evolve or any out of tree extension from core. How 
about making `--stop` only work when obsmarkers are enabled and error out if 
they are not enabled?

> rebase.py:692
>  ('t', 'tool', '', _('specify merge tool')),
> +('S', 'stop', False, _('stop interrupted rebase')),
>  ('c', 'continue', False, _('continue an interrupted rebase')),

Can we prevent having `s` and `S` evaluate to different options i.e. leave 'S' 
for now?

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3959

To: khanchi97, #hg-reviewers
Cc: pulkit, yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D3959: rebase: add --stop option to stop rebase at any point (issue5206)

2018-07-22 Thread khanchi97 (Sushil khanchi)
khanchi97 updated this revision to Diff 9642.
khanchi97 edited the summary of this revision.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3959?vs=9617=9642

REVISION DETAIL
  https://phab.mercurial-scm.org/D3959

AFFECTED FILES
  hgext/rebase.py
  tests/test-rebase-obsolete.t

CHANGE DETAILS

diff --git a/tests/test-rebase-obsolete.t b/tests/test-rebase-obsolete.t
--- a/tests/test-rebase-obsolete.t
+++ b/tests/test-rebase-obsolete.t
@@ -15,6 +15,7 @@
   > [extensions]
   > rebase=
   > drawdag=$TESTDIR/drawdag.py
+  > strip=
   > EOF
 
 Setup rebase canonical repo
@@ -1788,3 +1789,215 @@
   |
   o  0:426bada5c675 A
   
+
+Test --stop option |
+
+  $ cd ..
+  $ hg init rbstop
+  $ cd rbstop
+  $ echo a>a
+  $ hg ci -Aqma
+  $ echo b>b
+  $ hg ci -Aqmb
+  $ echo c>c
+  $ hg ci -Aqmc
+  $ echo d>d
+  $ hg ci -Aqmd
+  $ hg up 0 -q
+  $ echo f>f
+  $ hg ci -Aqmf
+  $ echo D>d
+  $ hg ci -Aqm "conflict with d"
+  $ hg up 0 -q
+  $ hg log -G --template "{rev}:{short(node)} 
{person(author)}\n{firstline(desc)} {topic}\n\n"
+  o  5:00bfc9898aeb test
+  |  conflict with d
+  |
+  o  4:dafd40200f93 test
+  |  f
+  |
+  | o  3:055a42cdd887 test
+  | |  d
+  | |
+  | o  2:177f92b77385 test
+  | |  c
+  | |
+  | o  1:d2ae7f538514 test
+  |/   b
+  |
+  @  0:cb9a9f314b8b test
+ a
+  
+  $ hg rebase -s 1 -d 5
+  rebasing 1:d2ae7f538514 "b"
+  rebasing 2:177f92b77385 "c"
+  rebasing 3:055a42cdd887 "d"
+  merging d
+  warning: conflicts while merging d! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+  $ hg rebase --stop
+  1 new orphan changesets
+  $ hg log -G --template "{rev}:{short(node)} 
{person(author)}\n{firstline(desc)} {topic}\n\n"
+  o  7:7fffad344617 test
+  |  c
+  |
+  o  6:b15528633407 test
+  |  b
+  |
+  o  5:00bfc9898aeb test
+  |  conflict with d
+  |
+  o  4:dafd40200f93 test
+  |  f
+  |
+  | *  3:055a42cdd887 test
+  | |  d
+  | |
+  | x  2:177f92b77385 test
+  | |  c
+  | |
+  | x  1:d2ae7f538514 test
+  |/   b
+  |
+  @  0:cb9a9f314b8b test
+ a
+  
+Test it aborts if unstable csets is not allowed:
+===
+  $ cat >> $HGRCPATH << EOF
+  > [experimental]
+  > evolution.allowunstable=False
+  > EOF
+
+  $ hg strip 6 --no-backup -q
+  $ hg log -G --template "{rev}:{short(node)} 
{person(author)}\n{firstline(desc)} {topic}\n\n"
+  o  5:00bfc9898aeb test
+  |  conflict with d
+  |
+  o  4:dafd40200f93 test
+  |  f
+  |
+  | o  3:055a42cdd887 test
+  | |  d
+  | |
+  | o  2:177f92b77385 test
+  | |  c
+  | |
+  | o  1:d2ae7f538514 test
+  |/   b
+  |
+  @  0:cb9a9f314b8b test
+ a
+  
+  $ hg rebase -s 1 -d 5
+  rebasing 1:d2ae7f538514 "b"
+  rebasing 2:177f92b77385 "c"
+  rebasing 3:055a42cdd887 "d"
+  merging d
+  warning: conflicts while merging d! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+  $ hg rebase --stop
+  abort: can't remove original changesets with unrebased descendants
+  (either enable evolve extension to allow unstable revisions or use --keep to 
keep original changesets)
+  [255]
+  $ hg rebase --abort
+  saved backup bundle to 
$TESTTMP/rbstop/.hg/strip-backup/b15528633407-6eb72b6f-backup.hg
+  rebase aborted
+
+Test --stop when --keep is passed:
+==
+  $ hg rebase -s 1 -d 5 --keep
+  rebasing 1:d2ae7f538514 "b"
+  rebasing 2:177f92b77385 "c"
+  rebasing 3:055a42cdd887 "d"
+  merging d
+  warning: conflicts while merging d! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+  $ hg rebase --stop
+  $ hg log -G --template "{rev}:{short(node)} 
{person(author)}\n{firstline(desc)} {topic}\n\n"
+  o  7:7fffad344617 test
+  |  c
+  |
+  o  6:b15528633407 test
+  |  b
+  |
+  o  5:00bfc9898aeb test
+  |  conflict with d
+  |
+  o  4:dafd40200f93 test
+  |  f
+  |
+  | o  3:055a42cdd887 test
+  | |  d
+  | |
+  | o  2:177f92b77385 test
+  | |  c
+  | |
+  | o  1:d2ae7f538514 test
+  |/   b
+  |
+  @  0:cb9a9f314b8b test
+ a
+  
+Test --stop aborts when --collapse was passed:
+=
+  $ cat >> $HGRCPATH << EOF
+  > [experimental]
+  > evolution.allowunstable=True
+  > EOF
+
+  $ hg strip 6
+  saved backup bundle to 
$TESTTMP/rbstop/.hg/strip-backup/b15528633407-6eb72b6f-backup.hg
+  $ hg log -G --template "{rev}:{short(node)} 
{person(author)}\n{firstline(desc)} {topic}\n\n"
+  o  5:00bfc9898aeb test
+  |  conflict with d
+  |
+  o  4:dafd40200f93 test
+  |  f
+  |
+  | o  3:055a42cdd887 test
+  | |  d
+  | |
+  | o  2:177f92b77385 test
+  | |  c
+  | |
+  | o  1:d2ae7f538514 test
+  |/   b
+  |
+  @  0:cb9a9f314b8b test
+ a
+  
+  $ hg rebase -s 1 -d 5 --collapse -m "collapsed b c d"
+  rebasing 1:d2ae7f538514 "b"
+  rebasing 2:177f92b77385 "c"
+  rebasing 3:055a42cdd887 "d"
+  merging d

D3959: rebase: add --stop option to stop rebase at any point (issue5206)

2018-07-21 Thread yuja (Yuya Nishihara)
yuja added a comment.


  >   > I doubt if this would work with --collapse. Can you try writing some 
tests?
  >   
  >   What is the expected behaviour in case of --collapse? Should it collapse 
only those revisions which are rebased, then we may have to ask user to change 
commit message accordingly.
  
  No idea. Perhaps we can revisit it later by making `hg rebase --stop` just
  abort if it was a --collapse session.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3959

To: khanchi97, #hg-reviewers
Cc: yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: D3959: rebase: add --stop option to stop rebase at any point (issue5206)

2018-07-21 Thread Yuya Nishihara
>   > I doubt if this would work with --collapse. Can you try writing some 
> tests?
>   
>   What is the expected behaviour in case of --collapse? Should it collapse 
> only those revisions which are rebased, then we may have to ask user to 
> change commit message accordingly.

No idea. Perhaps we can revisit it later by making `hg rebase --stop` just
abort if it was a --collapse session.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D3959: rebase: add --stop option to stop rebase at any point (issue5206)

2018-07-21 Thread khanchi97 (Sushil khanchi)
khanchi97 added a comment.


  In https://phab.mercurial-scm.org/D3959#61670, @yuja wrote:
  
  > > +def _stoprebase(self):
  > >  +"""stop the interrupted rebase"""
  > >  +self.restorestatus()
  > >  +if not self.stateobj.exists():
  > >  +raise error.Abort(_("no interrupted rebase found"))
  > >  +allowunstable = obsolete.isenabled(self.repo, 
obsolete.allowunstableopt)
  > >  +if not (self.keepf or allowunstable):
  > >  +raise error.Abort(_("can't remove original changesets with"
  > >  +  " unrebased descendants"),
  > >  +hint=_('either enable evolve extension to allow 
unstable '
  > >  +   'revisions or use --keep to keep original 
changesets'))
  > >  +
  > >  +# update to the last rebased node if any
  > >  +ctx = self.repo[None]
  > >  +pars = [p.node() for p in ctx.parents()]
  > >  +p1 = pars[0]
  > >  +hg.updaterepo(self.repo, p1, overwrite=True)
  >
  > Perhaps this differs from what a successful rebase would do. Unlike graft,
  >  `hg rebase` goes back to the original working directory.
  
  
  right, will change it.
  
  > 
  > 
  >> +# either mark obsolete or keep rebased revisions
  >>  +repo, ui, opts = self.repo, self.ui, self.opts
  >>  +fm = ui.formatter('rebase', opts)
  >>  +fm.startitem()
  >>  +clearrebased(ui, repo, self.destmap, self.state, self.skipped,
  >>  + collapsedas=None, keepf=self.keepf, fm=fm)
  >>  +clearstatus(self.repo)
  >>  +fm.end()
  >>  +return 0
  > 
  > I doubt if this would work with --collapse. Can you try writing some tests?
  
  What is the expected behaviour in case of --collapse? Should it collapse only 
those revisions which are rebased, then we may have to ask user to change 
commit message accordingly.
  
  > I'm not pretty sure, but it might be possible to utilize `_finishrebase()`
  >  to implement --stop, roughly by:
  > 
  > 1. restore status
  > 2. drop revisions that aren't rebased yet
  > 3. finish it
  
  yeah, trying to do it in _finishrebase()
  
  > 
  > 
  >> +elif stop:
  >>  +#todo: raise error for conflicting options
  > 
  > Yes!

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3959

To: khanchi97, #hg-reviewers
Cc: yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: D3959: rebase: add --stop option to stop rebase at any point (issue5206)

2018-07-18 Thread Yuya Nishihara
> +def _stoprebase(self):
> +"""stop the interrupted rebase"""
> +self.restorestatus()
> +if not self.stateobj.exists():
> +raise error.Abort(_("no interrupted rebase found"))
> +allowunstable = obsolete.isenabled(self.repo, 
> obsolete.allowunstableopt)
> +if not (self.keepf or allowunstable):
> +raise error.Abort(_("can't remove original changesets with"
> +  " unrebased descendants"),
> +hint=_('either enable evolve extension to allow unstable '
> +   'revisions or use --keep to keep original 
> changesets'))
> +
> +# update to the last rebased node if any
> +ctx = self.repo[None]
> +pars = [p.node() for p in ctx.parents()]
> +p1 = pars[0]
> +hg.updaterepo(self.repo, p1, overwrite=True)

Perhaps this differs from what a successful rebase would do. Unlike graft,
`hg rebase` goes back to the original working directory.

> +# either mark obsolete or keep rebased revisions
> +repo, ui, opts = self.repo, self.ui, self.opts
> +fm = ui.formatter('rebase', opts)
> +fm.startitem()
> +clearrebased(ui, repo, self.destmap, self.state, self.skipped,
> + collapsedas=None, keepf=self.keepf, fm=fm)
> +clearstatus(self.repo)
> +fm.end()
> +return 0

I doubt if this would work with --collapse. Can you try writing some tests?

I'm not pretty sure, but it might be possible to utilize `_finishrebase()`
to implement --stop, roughly by:

1. restore status
2. drop revisions that aren't rebased yet
3. finish it

> +elif stop:
> +#todo: raise error for conflicting options

Yes!
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D3959: rebase: add --stop option to stop rebase at any point (issue5206)

2018-07-18 Thread yuja (Yuya Nishihara)
yuja added a comment.


  > +def _stoprebase(self):
  >  +"""stop the interrupted rebase"""
  >  +self.restorestatus()
  >  +if not self.stateobj.exists():
  >  +raise error.Abort(_("no interrupted rebase found"))
  >  +allowunstable = obsolete.isenabled(self.repo, 
obsolete.allowunstableopt)
  >  +if not (self.keepf or allowunstable):
  >  +raise error.Abort(_("can't remove original changesets with"
  >  +  " unrebased descendants"),
  >  +hint=_('either enable evolve extension to allow unstable '
  >  +   'revisions or use --keep to keep original 
changesets'))
  >  +
  >  +# update to the last rebased node if any
  >  +ctx = self.repo[None]
  >  +pars = [p.node() for p in ctx.parents()]
  >  +p1 = pars[0]
  >  +hg.updaterepo(self.repo, p1, overwrite=True)
  
  Perhaps this differs from what a successful rebase would do. Unlike graft,
  `hg rebase` goes back to the original working directory.
  
  > +# either mark obsolete or keep rebased revisions
  >  +repo, ui, opts = self.repo, self.ui, self.opts
  >  +fm = ui.formatter('rebase', opts)
  >  +fm.startitem()
  >  +clearrebased(ui, repo, self.destmap, self.state, self.skipped,
  >  + collapsedas=None, keepf=self.keepf, fm=fm)
  >  +clearstatus(self.repo)
  >  +fm.end()
  >  +return 0
  
  I doubt if this would work with --collapse. Can you try writing some tests?
  
  I'm not pretty sure, but it might be possible to utilize `_finishrebase()`
  to implement --stop, roughly by:
  
  1. restore status
  2. drop revisions that aren't rebased yet
  3. finish it
  
  > +elif stop:
  >  +#todo: raise error for conflicting options
  
  Yes!

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3959

To: khanchi97, #hg-reviewers
Cc: yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D3959: rebase: add --stop option to stop rebase at any point (issue5206)

2018-07-17 Thread khanchi97 (Sushil khanchi)
khanchi97 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Before this patch, during a rebase if you get a point where you can't
  figure out what to do next then either you had to complete your series
  or abandon all the work you have done during this rebase.
  
  Now, with this feature you can stop at any point by keeping the rebased
  csets and mark original csets as obsolete. And if you have not enabled
  evolution extension then you can use --keep option as an alternative
  which will keep original csets too, instead of marking them obsolete.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3959

AFFECTED FILES
  hgext/rebase.py
  tests/test-rebase-obsolete.t

CHANGE DETAILS

diff --git a/tests/test-rebase-obsolete.t b/tests/test-rebase-obsolete.t
--- a/tests/test-rebase-obsolete.t
+++ b/tests/test-rebase-obsolete.t
@@ -15,6 +15,7 @@
   > [extensions]
   > rebase=
   > drawdag=$TESTDIR/drawdag.py
+  > strip=
   > EOF
 
 Setup rebase canonical repo
@@ -1788,3 +1789,155 @@
   |
   o  0:426bada5c675 A
   
+
+Test --stop option |
+
+  $ cd ..
+  $ hg init rbstop
+  $ cd rbstop
+  $ echo a>a
+  $ hg ci -Aqma
+  $ echo b>b
+  $ hg ci -Aqmb
+  $ echo c>c
+  $ hg ci -Aqmc
+  $ echo d>d
+  $ hg ci -Aqmd
+  $ hg up 0 -q
+  $ echo f>f
+  $ hg ci -Aqmf
+  $ echo D>d
+  $ hg ci -Aqm "conflict with d"
+  $ hg log -G --template "{rev}:{short(node)} 
{person(author)}\n{firstline(desc)} {topic}\n\n"
+  @  5:00bfc9898aeb test
+  |  conflict with d
+  |
+  o  4:dafd40200f93 test
+  |  f
+  |
+  | o  3:055a42cdd887 test
+  | |  d
+  | |
+  | o  2:177f92b77385 test
+  | |  c
+  | |
+  | o  1:d2ae7f538514 test
+  |/   b
+  |
+  o  0:cb9a9f314b8b test
+ a
+  
+  $ hg rebase -s 1 -d .
+  rebasing 1:d2ae7f538514 "b"
+  rebasing 2:177f92b77385 "c"
+  rebasing 3:055a42cdd887 "d"
+  merging d
+  warning: conflicts while merging d! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+  $ hg rebase --stop
+  1 new orphan changesets
+  $ hg log -G --template "{rev}:{short(node)} 
{person(author)}\n{firstline(desc)} {topic}\n\n"
+  @  7:7fffad344617 test
+  |  c
+  |
+  o  6:b15528633407 test
+  |  b
+  |
+  o  5:00bfc9898aeb test
+  |  conflict with d
+  |
+  o  4:dafd40200f93 test
+  |  f
+  |
+  | *  3:055a42cdd887 test
+  | |  d
+  | |
+  | x  2:177f92b77385 test
+  | |  c
+  | |
+  | x  1:d2ae7f538514 test
+  |/   b
+  |
+  o  0:cb9a9f314b8b test
+ a
+  
+Test it abrots if unstable csets is not allowed:
+
+  $ cat >> $HGRCPATH << EOF
+  > [experimental]
+  > evolution.allowunstable=False
+  > EOF
+
+  $ hg strip 6 --no-backup -q
+  $ hg log -G --template "{rev}:{short(node)} 
{person(author)}\n{firstline(desc)} {topic}\n\n"
+  @  5:00bfc9898aeb test
+  |  conflict with d
+  |
+  o  4:dafd40200f93 test
+  |  f
+  |
+  | o  3:055a42cdd887 test
+  | |  d
+  | |
+  | o  2:177f92b77385 test
+  | |  c
+  | |
+  | o  1:d2ae7f538514 test
+  |/   b
+  |
+  o  0:cb9a9f314b8b test
+ a
+  
+  $ hg rebase -s 1 -d .
+  rebasing 1:d2ae7f538514 "b"
+  rebasing 2:177f92b77385 "c"
+  rebasing 3:055a42cdd887 "d"
+  merging d
+  warning: conflicts while merging d! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+  $ hg rebase --stop
+  abort: can't remove original changesets with unrebased descendants
+  (either enable evolve extension to allow unstable revisions or use --keep to 
keep original changesets)
+  [255]
+  $ hg rebase --abort
+  saved backup bundle to 
$TESTTMP/rbstop/.hg/strip-backup/b15528633407-6eb72b6f-backup.hg
+  rebase aborted
+
+Test --stop when --keep is passed:
+==
+  $ hg rebase -s 1 -d . --keep
+  rebasing 1:d2ae7f538514 "b"
+  rebasing 2:177f92b77385 "c"
+  rebasing 3:055a42cdd887 "d"
+  merging d
+  warning: conflicts while merging d! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+  $ hg rebase --stop
+  $ hg log -G --template "{rev}:{short(node)} 
{person(author)}\n{firstline(desc)} {topic}\n\n"
+  @  7:7fffad344617 test
+  |  c
+  |
+  o  6:b15528633407 test
+  |  b
+  |
+  o  5:00bfc9898aeb test
+  |  conflict with d
+  |
+  o  4:dafd40200f93 test
+  |  f
+  |
+  | o  3:055a42cdd887 test
+  | |  d
+  | |
+  | o  2:177f92b77385 test
+  | |  c
+  | |
+  | o  1:d2ae7f538514 test
+  |/   b
+  |
+  o  0:cb9a9f314b8b test
+ a
+  
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -347,6 +347,33 @@
 return abort(self.repo, self.originalwd, self.destmap, self.state,
  activebookmark=self.activebookmark, backup=backup,
  suppwarns=suppwarns)
+def _stoprebase(self):
+"""stop the