[PATCH 18 of 18] phases: prevent rebase to rebase immutable changeset
pierre-yves.david at logilab.fr
pierre-yves.david at logilab.fr
Mon Oct 10 12:28:14 UTC 2011
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1318249203 -7200
# Node ID 5da93a73cedb114ecbb071dabca332ec7256d663
# Parent 4b70d79e03205d956264683e9542ca7f0875625a
phases: prevent rebase to rebase immutable changeset.
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -158,11 +158,12 @@ def rebase(ui, repo, **opts):
_('detach requires a revision to be specified'))
if basef:
raise util.Abort(_('cannot specify a base with detach'))
cmdutil.bailifchanged(repo)
- result = buildstate(repo, destf, srcf, basef, detachf)
+ result = buildstate(repo, destf, srcf, basef, detachf,
+ keep=keepf)
if not result:
# Empty state built, nothing to rebase
ui.status(_('nothing to rebase\n'))
return 1
else:
@@ -513,11 +514,11 @@ def abort(repo, originalwd, target, stat
repair.strip(repo.ui, repo, repo[strippoint].node())
clearstatus(repo)
repo.ui.warn(_('rebase aborted\n'))
return 0
-def buildstate(repo, dest, src, base, detach):
+def buildstate(repo, dest, src, base, detach, keep=False):
'Define which revisions are going to be rebased and where'
targetancestors = set()
detachset = set()
if not dest:
@@ -572,10 +573,14 @@ def buildstate(repo, dest, src, base, de
return None
cwdancestors.add(cwd)
rebasingbranch = cwdancestors - targetancestors
source = min(rebasingbranch)
+ if not (keep or repo[source].mutable()):
+ raise util.Abort(_("Can't rebase immutable changeset %s")
+ % repo[source],
+ hint=_('see hg help phases for details'))
repo.ui.debug('rebase onto %d starting from %d\n' % (dest, source))
state = dict.fromkeys(repo.changelog.descendants(source), nullrev)
state.update(dict.fromkeys(detachset, nullmerge))
state[source] = nullrev
diff --git a/tests/test-rebase-scenario-global.t b/tests/test-rebase-scenario-global.t
--- a/tests/test-rebase-scenario-global.t
+++ b/tests/test-rebase-scenario-global.t
@@ -16,10 +16,11 @@
adding file changes
added 8 changesets with 7 changes to 7 files (+2 heads)
(run 'hg heads' to see heads, 'hg merge' to merge)
$ hg up tip
3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ $ rm -f .hg/store/phases-heads # XXX ensure imported changeset are mutable
$ cd ..
Rebasing
D onto H - simple rebase:
@@ -268,5 +269,15 @@ C onto A - rebase onto an ancestor:
| o 1: 'B'
|/
o 0: 'A'
+Check rebasing public changeset
+
+ $ hg phase -p 0 -r 6
+ $ hg rebase -d 5 -b 6
+ abort: Can't rebase immutable changeset e1c4361dd923
+ (see hg help phases for details)
+ [255]
+
+ $ hg rebase -d 5 -b 6 --keep
+
More information about the Mercurial-devel
mailing list