# HG changeset patch # User Pierre-Yves David # Date 1315869018 -7200 # Node ID e62ffb77bf8c6a269a95aede4852331347544ffc # Parent b1e64d8783f032680f48122d6e2c3842ad75b860 [state] add mutable property to state object. diff --git a/hgext/states.py b/hgext/states.py --- a/hgext/states.py +++ b/hgext/states.py @@ -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'))