Commits

Pierre-Yves David  committed e62ffb7

[state] add mutable property to state object.

  • Participants
  • Parent commits b1e64d8
  • Branches default

Comments (0)

Files changed (1)

File hgext/states.py

     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 ?
         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.
 
         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
         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'))
        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'))