Commits

Pierre-Yves David committed 641e0cd

obsolete: prevent rebasing of public changeset

Because we force keep we have to check this on our own.

Comments (0)

Files changed (2)

hgext/obsolete.py

 
 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):
     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

tests/test-obsolete-rebase.t

   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