comparison hgext/states.py @ 78:ddcc4bb6c4d4

[states] add some documentation for extension wrapping
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Wed, 14 Sep 2011 17:55:17 +0200
parents 45afdbf062f4
children 97a5c943db19
comparison
equal deleted inserted replaced
77:45afdbf062f4 78:ddcc4bb6c4d4
662 662
663 # Other extension support 663 # Other extension support
664 ######################### 664 #########################
665 665
666 def wraprebasebuildstate(orig, repo, *args, **kwargs): 666 def wraprebasebuildstate(orig, repo, *args, **kwargs):
667 result = orig(repo, *args, **kwargs) 667 """Wrapped rebuild state that check for immutable changeset
668 if result is not None: 668
669 buildstate are the best place i found to hook :-/"""
670 result = orig(repo, *args, **kwargs)
671 if result is not None:
669 # rebase.nullmerge is issued in the detach case 672 # rebase.nullmerge is issued in the detach case
670 rebase = extensions.find('rebase') 673 rebase = extensions.find('rebase')
671 rebased = [rev for rev, rbst in result[2].items() if rbst != rebase.nullmerge] 674 rebased = [rev for rev, rbst in result[2].items() if rbst != rebase.nullmerge]
672 base = repo.changelog.node(min(rebased)) 675 base = repo.changelog.node(min(rebased))
673 state = repo.nodestate(base) 676 state = repo.nodestate(base)
674 if not state.mutable: 677 if not state.mutable:
675 raise util.Abort(_('can not rebase published changeset %s') 678 raise util.Abort(_('can not rebase published changeset %s')
676 % node.short(base), 679 % node.short(base),
677 hint=_('see `hg help --extension states` for details')) 680 hint=_('see `hg help --extension states` for details'))
678 return result 681 return result
679 682
680 def wrapmqqimport(orig, queue, repo, *args, **kwargs): 683 def wrapmqqimport(orig, queue, repo, *args, **kwargs):
681 if 'rev' in kwargs: 684 """Wrapper for rebuild state that deny importing immutable changeset
685 """
686 if 'rev' in kwargs:
682 # we can take the min as non linear import will break 687 # we can take the min as non linear import will break
683 # anyway 688 # anyway
684 revs = scmutil.revrange(repo, kwargs['rev']) 689 revs = scmutil.revrange(repo, kwargs['rev'])
685 if revs: 690 if revs:
686 base = min(revs) 691 base = min(revs)
688 state = repo.nodestate(basenode) 693 state = repo.nodestate(basenode)
689 if not state.mutable: 694 if not state.mutable:
690 raise util.Abort(_('can not qimport published changeset %s') 695 raise util.Abort(_('can not qimport published changeset %s')
691 % node.short(basenode), 696 % node.short(basenode),
692 hint=_('see `hg help --extension states` for details')) 697 hint=_('see `hg help --extension states` for details'))
693 return orig(queue, repo, *args, **kwargs) 698 return orig(queue, repo, *args, **kwargs)
694 699
695 700
696 def uisetup(ui): 701 def uisetup(ui):
697 """ 702 """
698 * patch stuff for the _NOSHARE property 703 * patch stuff for the _NOSHARE property