Patchwork D8057: rebase: abort if the user tries to rebase the working copy

login
register
mail settings
Submitter phabricator
Date Jan. 31, 2020, 7 p.m.
Message ID <differential-rev-PHID-DREV-3colyq2x35i6oxlya3tp-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/44828/
State Superseded
Headers show

Comments

phabricator - Jan. 31, 2020, 7 p.m.
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  I think it's more correct to treat `hg rebase -r 'wdirrev()' -d foo`
  as `hg co -m foo`, but I'm instead making it error out. That's partly
  because it's probably what the user wanted (in the case I heard from a
  user, they had done `hg rebase -s f` where `f` resolved to `wdir()`)
  and partly because I don't want to think about more complicated cases
  where the user specifies the working copy together with other commits.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel
phabricator - Jan. 31, 2020, 11:28 p.m.
pulkit added inline comments.

INLINE COMMENTS

> test-rebase-parameters.t:100
> +  $ hg rebase --source 'wdir()' --dest 6
> +  nothing to rebase - empty destination
> +  [1]

hm, the destination is not empty here.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8057/new/

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

To: martinvonz, #hg-reviewers
Cc: pulkit, mercurial-devel
phabricator - Feb. 1, 2020, 12:08 a.m.
martinvonz added inline comments.

INLINE COMMENTS

> pulkit wrote in test-rebase-parameters.t:100
> hm, the destination is not empty here.

Oops, that was sloppy of me to not notice (I just assumed it was the same message as above). Will fix.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8057/new/

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

To: martinvonz, #hg-reviewers
Cc: pulkit, mercurial-devel

Patch

diff --git a/tests/test-rebase-parameters.t b/tests/test-rebase-parameters.t
--- a/tests/test-rebase-parameters.t
+++ b/tests/test-rebase-parameters.t
@@ -93,11 +93,12 @@ 
   [1]
 
   $ hg rebase --rev 'wdir()' --dest 6
-  abort: working directory revision cannot be specified
+  abort: cannot rebase the working copy
   [255]
 
-  $ hg rebase --source 'wdir()' --dest 6 2>&1 | grep assert
-      assert rebaseset
+  $ hg rebase --source 'wdir()' --dest 6
+  nothing to rebase - empty destination
+  [1]
 
   $ hg rebase --source '1 & !1' --dest 8
   empty "source" revision set - nothing to rebase
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -37,6 +37,7 @@ 
     hg,
     merge as mergemod,
     mergeutil,
+    node as nodemod,
     obsolete,
     obsutil,
     patch,
@@ -1266,7 +1267,6 @@ 
             ui.status(_(b'empty "source" revision set - nothing to rebase\n'))
             return None
         rebaseset = repo.revs(b'(%ld)::', src)
-        assert rebaseset
     else:
         base = scmutil.revrange(repo, [basef or b'.'])
         if not base:
@@ -1341,6 +1341,8 @@ 
                 )
             return None
 
+    if nodemod.wdirrev in rebaseset:
+        raise error.Abort(_(b'cannot rebase the working copy'))
     rebasingwcp = repo[b'.'].rev() in rebaseset
     ui.log(
         b"rebase",