hgext/states.py
changeset 64 6a7dc5ca05b8
parent 63 f47a5f990eb2
child 65 7c8f992d567e
equal deleted inserted replaced
63:f47a5f990eb2 64:6a7dc5ca05b8
   248     - add ``<state>()`` directives that match all node in a state.
   248     - add ``<state>()`` directives that match all node in a state.
   249 
   249 
   250 Other extensions
   250 Other extensions
   251 ................
   251 ................
   252 
   252 
   253 :Rebase:     can't rewrite unpublished changeset.
   253 :rebase:     can't rebase immutable changeset.
       
   254 :mq:         can't qimport immutable changeset.
   254 
   255 
   255 
   256 
   256 
   257 
   257 Implementation
   258 Implementation
   258 ==============
   259 ==============
   654             raise util.Abort(_('can not rebase published changeset %s')
   655             raise util.Abort(_('can not rebase published changeset %s')
   655                              % node.short(base),
   656                              % node.short(base),
   656                              hint=_('see `hg help --extension states` for details'))
   657                              hint=_('see `hg help --extension states` for details'))
   657    return result
   658    return result
   658 
   659 
       
   660 def wrapmqqimport(orig, queue, repo, *args, **kwargs):
       
   661    if 'rev' in kwargs:
       
   662        # we can take the min as non linear import wil break
       
   663        base = min(scmutil.revrange(repo, kwargs['rev']))
       
   664        basenode = repo.changelog.node(base)
       
   665        state = repo.nodestate(basenode)
       
   666        if not state.properties & _MUTABLE:
       
   667            raise util.Abort(_('can not qimport published changeset %s')
       
   668                             % node.short(basenode),
       
   669                             hint=_('see `hg help --extension states` for details'))
       
   670    return orig(queue, repo, *args, **kwargs)
       
   671 
   659 
   672 
   660 def uisetup(ui):
   673 def uisetup(ui):
   661     """
   674     """
   662     * patch stuff for the _NOSHARE property
   675     * patch stuff for the _NOSHARE property
   663     * add template keyword
   676     * add template keyword
   677 
   690 
   678     * add revset entry"""
   691     * add revset entry"""
   679     for state in STATES:
   692     for state in STATES:
   680         if state.trackheads:
   693         if state.trackheads:
   681             revset.symbols[state.headssymbol] = state._revsetheads
   694             revset.symbols[state.headssymbol] = state._revsetheads
       
   695     # wrap rebase
   682     try:
   696     try:
   683         rebase = extensions.find('rebase')
   697         rebase = extensions.find('rebase')
   684         if rebase:
   698         if rebase:
   685             extensions.wrapfunction(rebase, 'buildstate', wraprebasebuildstate)
   699             extensions.wrapfunction(rebase, 'buildstate', wraprebasebuildstate)
   686     except KeyError:
   700     except KeyError:
   687         pass # rebase not found
   701         pass # rebase not found
       
   702     # wrap mq
       
   703     try:
       
   704         mq = extensions.find('mq')
       
   705         if mq:
       
   706             extensions.wrapfunction(mq.queue, 'qimport', wrapmqqimport)
       
   707     except KeyError:
       
   708         pass # mq not found
   688 
   709 
   689 
   710 
   690 
   711 
   691 def reposetup(ui, repo):
   712 def reposetup(ui, repo):
   692     """Repository setup
   713     """Repository setup