Commits

Pierre-Yves David committed 6a7dc5c

[states] add mq support

Comments (0)

Files changed (2)

 Other extensions
 ................
 
-:Rebase:     can't rewrite unpublished changeset.
+:rebase:     can't rebase immutable changeset.
+:mq:         can't qimport immutable changeset.
 
 
 
                              hint=_('see `hg help --extension states` for details'))
    return result
 
+def wrapmqqimport(orig, queue, repo, *args, **kwargs):
+   if 'rev' in kwargs:
+       # we can take the min as non linear import wil break
+       base = min(scmutil.revrange(repo, kwargs['rev']))
+       basenode = repo.changelog.node(base)
+       state = repo.nodestate(basenode)
+       if not state.properties & _MUTABLE:
+           raise util.Abort(_('can not qimport published changeset %s')
+                            % node.short(basenode),
+                            hint=_('see `hg help --extension states` for details'))
+   return orig(queue, repo, *args, **kwargs)
+
 
 def uisetup(ui):
     """
     for state in STATES:
         if state.trackheads:
             revset.symbols[state.headssymbol] = state._revsetheads
+    # wrap rebase
     try:
         rebase = extensions.find('rebase')
         if rebase:
             extensions.wrapfunction(rebase, 'buildstate', wraprebasebuildstate)
     except KeyError:
         pass # rebase not found
+    # wrap mq
+    try:
+        mq = extensions.find('mq')
+        if mq:
+            extensions.wrapfunction(mq.queue, 'qimport', wrapmqqimport)
+    except KeyError:
+        pass # mq not found
 
 
 

tests/test-published.t

   > allow_push = *
   > [extensions]
   > hgext.rebase=
+  > hgext.mq=
   > EOF
   $ echo "states=$(echo $(dirname $TESTDIR))/hgext/states.py" >> $HGRCPATH
 
 
-test you can't rebase published changeset
+init stuff
 
   $ hg init local
   $ cd local
   $ hg add rhino
   $ hg ci -m "add rhino"
   created new head
+  $ hg published 1 2
   $ hg up 1 -q
-  $ hg rebase
+  $ hg states draft
+  $ echo "flore" > babar
+  $ hg ci -m "add daughter"
+
+test you can't qimport published changeset
+
+  $ hg qimport -r 1
+  abort: can not qimport published changeset 710fe444b3b0
+  (see `hg help --extension states` for details)
+  [255]
+
+but other are ok
+
+  $ hg qimport -r 3
+  $ hg qfinish -a
+
+test you can't rebase published changeset
+
+  $ hg rebase --dest 2 -b 1
   abort: can not rebase published changeset 710fe444b3b0
   (see `hg help --extension states` for details)
   [255]
 
 test you still can rebase other one
 
-  $ hg published 1 2
-  $ hg states draft
-  $ echo "flore" > babar
-  $ hg ci -m "add daughter"
-  $ hg rebase --dest 2
-  abort: can not rebase published changeset 710fe444b3b0
-  (see `hg help --extension states` for details)
-  [255]
   $ hg rebase --dest 2 -s 3
   saved backup bundle to $TESTTMP/local/.hg/strip-backup/b7f6698b7ad7-backup.hg
+