Commits

Anonymous committed 0fe7145

[states] add a <state>heads() revset for the highest state (for instance ``hg log -r 'draftheads()'``)

  • Participants
  • Parent commits cd82e9a

Comments (0)

Files changed (2)

     @util.propertycache
     def _revsetheads(self):
         """function to be used by revset to finds heads of this states"""
-        assert self.trackheads
         def revsetheads(repo, subset, x):
-            args = revset.getargs(x, 0, 0, 'publicheads takes no arguments')
+            args = revset.getargs(x, 0, 0,
+                                  '%sheads takes no arguments' % self.name)
+            _heads = repo._statesheads[self] if self.trackheads else repo.heads()
             heads = []
-            for h in repo._statesheads[self]:
+            for h in _heads:
                 try:
                     heads.append(repo.changelog.rev(h))
                 except error.LookupError:
     @util.propertycache
     def headssymbol(self):
         """name of the revset symbols"""
-        if self.trackheads:
-            return "%sheads" % self.name
-        else:
-            return 'heads'
+        return "%sheads" % self.name
 
 # Actual state definition
 
 
     * add revset entry"""
     for state in STATES:
-        if state.trackheads:
-            revset.symbols[state.headssymbol] = state._revsetheads
+        revset.symbols[state.headssymbol] = state._revsetheads
     # wrap rebase
     try:
         rebase = extensions.find('rebase')

tests/test-draft.t

   2:3c8695235a32: draft
   1:710fe444b3b0: published
   0:5caa672bac26: published
+  $ hg log --template='{rev}:{node|short}: {state}\n' -r 'draftheads()'
+  3:73585b17392a: draft
+
 
 test outgoing and push
   $ hg out  ../remote1 --template='{rev}:{node|short}\n'