Mercurial > evolve
changeset 67:e62ffb77bf8c
[state] add mutable property to state object.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Tue, 13 Sep 2011 01:10:18 +0200 |
parents | b1e64d8783f0 |
children | 6f7824dbce24 |
files | hgext/states.py |
diffstat | 1 files changed, 17 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/states.py Tue Sep 13 01:01:05 2011 +0200 +++ b/hgext/states.py Tue Sep 13 01:10:18 2011 +0200 @@ -375,18 +375,12 @@ XXX maybe we could stick description of the state semantic here. """ + # plumbery utily def __init__(self, name, properties=0, next=None): self.name = name self.properties = properties assert next is None or self < next self.next = next - - def __repr__(self): - return 'state(%s)' % self.name - - def __str__(self): - return self.name - @util.propertycache def trackheads(self): """Do we need to track heads of changeset in this state ? @@ -394,6 +388,7 @@ We don't need to track heads for the last state as this is repo heads""" return self.next is not None + # public utility def __cmp__(self, other): """Use property to compare states. @@ -404,6 +399,19 @@ return cmp(self.properties, other.properties) @util.propertycache + def mutable(self): + return bool(self.properties & _MUTABLE) + + # display code + def __repr__(self): + return 'state(%s)' % self.name + + def __str__(self): + return self.name + + + # revset utility + @util.propertycache def _revsetheads(self): """function to be used by revset to finds heads of this states""" assert self.trackheads @@ -655,7 +663,7 @@ rebased = [rev for rev, rbst in result[2].items() if rbst != rebase.nullmerge] base = repo.changelog.node(min(rebased)) state = repo.nodestate(base) - if not state.properties & _MUTABLE: + if not state.mutable: raise util.Abort(_('can not rebase published changeset %s') % node.short(base), hint=_('see `hg help --extension states` for details')) @@ -667,7 +675,7 @@ base = min(scmutil.revrange(repo, kwargs['rev'])) basenode = repo.changelog.node(base) state = repo.nodestate(basenode) - if not state.properties & _MUTABLE: + if not state.mutable: raise util.Abort(_('can not qimport published changeset %s') % node.short(basenode), hint=_('see `hg help --extension states` for details'))