1. Shlomi Fish
  2. hg-prompt


Steve Losh  committed d3e1536

Add the count filter to count revsets.

  • Participants
  • Parent commits 8ca1c99
  • Branches default

Comments (0)

Files changed (1)

File prompt.py

View file
 import subprocess
 from datetime import datetime, timedelta
 from os import path
-from mercurial import extensions, commands, help
+from mercurial import extensions, commands, cmdutil, help
 from mercurial.node import hex, short
 CACHE_PATH = ".hg/prompt/cache"
         return _with_groups(g, sep.join(tags)) if tags else ''
+    def _count(m):
+        g = m.groups()
+        query = [g[1][1:]] if g[1] else ['all()']
+        return _with_groups(g, str(len(cmdutil.revrange(repo, query))))
     def _task(m):
             task = extensions.find('tasks').current(repo)
     patterns = {
         'bookmark': _bookmark,
         'branch(\|quiet)?': _branch,
+        'count(\|[^%s]*?)?' % brackets[-1]: _count,
          Display the current branch only if it is not the default branch.
+     Display the number of revisions in the given revset (the revset `all()`
+     will be used if none is given.
+     See `hg help revsets` for more information.
+     |REVSET
+         The revset to count.
      Display nothing, but if the default path contains incoming changesets the 
      extra text will be expanded.