changeset 472:641e0cd43d6d

obsolete: prevent rebasing of public changeset Because we force keep we have to check this on our own.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Tue, 21 Aug 2012 02:50:11 +0200
parents 8be3973adf34
children 1f8f8dd75d18
files hgext/obsolete.py tests/test-obsolete-rebase.t
diffstat 2 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/obsolete.py	Tue Aug 21 02:25:19 2012 +0200
+++ b/hgext/obsolete.py	Tue Aug 21 02:50:11 2012 +0200
@@ -955,10 +955,15 @@
 
 def buildstate(orig, repo, dest, rebaseset, *ags, **kws):
     """wrapper for rebase 's buildstate that exclude obsolete changeset"""
+
     rebaseset = repo.revs('%ld - extinct()', rebaseset)
     if not rebaseset:
         repo.ui.warn(_('whole rebase set is extinct and ignored.\n'))
         return {}
+    root = min(rebaseset)
+    if not repo._rebasekeep and not repo[root].mutable():
+        raise util.Abort(_("can't rebase immutable changeset %s") % repo[root],
+                         hint=_('see hg help phases for details'))
     return orig(repo, dest, rebaseset, *ags, **kws)
 
 def defineparents(orig, repo, rev, target, state, *args, **kwargs):
@@ -985,6 +990,7 @@
     reallykeep = kwargs.get('keep', False)
     kwargs = dict(kwargs)
     kwargs['keep'] = True
+    repo._rebasekeep = reallykeep
 
     # We want to mark rebased revision as obsolete and set their
     # replacements if any. Doing it in concludenode() prevents
--- a/tests/test-obsolete-rebase.t	Tue Aug 21 02:25:19 2012 +0200
+++ b/tests/test-obsolete-rebase.t	Tue Aug 21 02:50:11 2012 +0200
@@ -30,6 +30,15 @@
   created new head
   $ echo e > e
   $ hg ci -Am adde e
+
+(phase compliance)
+
+  $ hg phase --public 3
+  $ hg rebase -d 1 -r 3
+  abort: can't rebase immutable changeset 98e4a024635e
+  (see hg help phases for details)
+  [255]
+  $ hg phase --draft --force 0
   $ hg rebase -d 1 -r 3 --detach --keep  
   $ glog
   @  4:9c5494949763@default(draft) adde