Mercurial > evolve
comparison hgext/states.py @ 96:d5170cc7881c
[states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
author | Alain Leufroy <alain.leufroy@logilab.fr> |
---|---|
date | Sun, 25 Sep 2011 12:43:00 +0200 |
parents | a5f6194eb05c |
children | e672cb1263cb |
comparison
equal
deleted
inserted
replaced
95:5dcece86aeb0 | 96:d5170cc7881c |
---|---|
194 revs])) | 194 revs])) |
195 :hg --exact --force <state> revs: move boundary event if it create inconsistency | 195 :hg --exact --force <state> revs: move boundary event if it create inconsistency |
196 (with tag for example) | 196 (with tag for example) |
197 | 197 |
198 TODO: | 198 TODO: |
199 | |
200 - implement --exact | |
201 | 199 |
202 - implement consistency check | 200 - implement consistency check |
203 | 201 |
204 - implement --force | 202 - implement --force |
205 | 203 |
531 | 529 |
532 cmdtable = {'states': (cmdstates, [ ('', 'off', False, _('desactivate the state') )], '<state>')} | 530 cmdtable = {'states': (cmdstates, [ ('', 'off', False, _('desactivate the state') )], '<state>')} |
533 | 531 |
534 # automatic generation of command that set state | 532 # automatic generation of command that set state |
535 def makecmd(state): | 533 def makecmd(state): |
536 def cmdmoveheads(ui, repo, *changesets): | 534 def cmdmoveheads(ui, repo, *changesets, **opts): |
537 """set revisions in %s state | 535 """set revisions in %s state |
538 | 536 |
539 This command also alter state of ancestors if necessary. | 537 This command also alter state of ancestors if necessary. |
540 """ % state | 538 """ % state |
539 if not state in repo._enabledstates: | |
540 raise error.Abort( | |
541 _('state %s is not activated' % state), | |
542 hint=_('try ``hg states %s`` before' % state)) | |
543 if opts.get('exact'): | |
544 repo.setstate_unsafe(state, changesets) | |
545 return 0 | |
541 revs = scmutil.revrange(repo, changesets) | 546 revs = scmutil.revrange(repo, changesets) |
542 repo.setstate(state, [repo.changelog.node(rev) for rev in revs]) | 547 repo.setstate(state, [repo.changelog.node(rev) for rev in revs]) |
543 return 0 | 548 return 0 |
544 return cmdmoveheads | 549 return cmdmoveheads |
545 | 550 |
546 for state in STATES: | 551 for state in STATES: |
547 if state.trackheads: | 552 cmdmoveheads = makecmd(state) |
548 cmdmoveheads = makecmd(state) | 553 cmdtable[state.name] = (cmdmoveheads, [ |
549 cmdtable[state.name] = (cmdmoveheads, [], '<revset>') | 554 ('e', 'exact', False, _('move boundary so that revs are exactly in ' |
555 'state <state> ( all([rev.state == <state> for ' | |
556 'rev in revs]))')) | |
557 ], '<revset>') | |
550 | 558 |
551 # Pushkey mechanism for mutable | 559 # Pushkey mechanism for mutable |
552 ######################################### | 560 ######################################### |
553 | 561 |
554 def pushstatesheads(repo, key, old, new): | 562 def pushstatesheads(repo, key, old, new): |
792 | 800 |
793 @util.propertycache | 801 @util.propertycache |
794 def _statesheads(self): | 802 def _statesheads(self): |
795 """{ state-object -> set(defining head)} mapping""" | 803 """{ state-object -> set(defining head)} mapping""" |
796 return _readstatesheads(self) | 804 return _readstatesheads(self) |
805 | |
806 def setstate_unsafe(self, state, changesets): | |
807 """Change state of targets changesets and it's ancestors. | |
808 | |
809 Simplify the list of heads. | |
810 | |
811 Unlike ``setstate``, the "lower" states are also changed | |
812 """ | |
813 #modify "lower" states | |
814 req_nodes_rst = '|'.join('((%s)::)' % rst for rst in changesets) | |
815 for st in STATES: | |
816 if st >= state: # only modify lower state heads for now | |
817 continue | |
818 try: | |
819 heads = self._statesheads[st] | |
820 except KeyError: # forget non-activated states | |
821 continue | |
822 olds = heads[:] | |
823 rst = "heads((::%s()) - (%s))" % (st.headssymbol, req_nodes_rst) | |
824 heads[:] = noderange(repo, [rst]) | |
825 if olds != heads: | |
826 _writestateshead(self) | |
827 #modify the state | |
828 if state in self._statesheads: | |
829 revs = scmutil.revrange(repo, changesets) | |
830 repo.setstate(state, [repo.changelog.node(rev) for rev in revs]) | |
797 | 831 |
798 def setstate(self, state, nodes): | 832 def setstate(self, state, nodes): |
799 """change state of targets changeset and it's ancestors. | 833 """change state of targets changeset and it's ancestors. |
800 | 834 |
801 Simplify the list of head.""" | 835 Simplify the list of head.""" |