Add me() revset selector
authorGregory Szorc <>
Thu, 07 Nov 2013 17:26:18 -0800
changeset 59 3aa34de26b6f5e1d9b9e2560c8c80b5106a2a81b
parent 58 e38832cd9dee8b1c070574080934b9c5cacb1072
child 60 46147591a90abc69edffb2d67a1d192df48bcb93
push id40
push dateFri, 08 Nov 2013 01:26:36 +0000
Add me() revset selector
--- a/
+++ b/
@@ -113,16 +113,23 @@ bugs via `hg buginfo`.
 Revisions Sets
 This extension adds the following revision set selectors functions.
    Retreive changesets that reference a specific bug. e.g. ``bug(784841)``.
+   Retrieve changesets that you are involved with.
+   Currently, this only retrieves changesets you authored (via ui.username).
+   In the future, this extension will index review syntax in commit messages
+   and return changesets that you reviewed.
    Retrieve changesets that are currently in the specified tree.
    Trees are specified with a known alias. e.g. ``tree(central)``.
    It's possible to see which changesets are in some tree but not others.
    e.g. to find changesets in *inbound* that haven't merged to *central*
    yet, do ``tree(inbound) - tree(central)``.
@@ -626,16 +633,38 @@ def revset_bug(repo, subset, x):
         raise ParseError(err)
     nodes = repo.changetracker.changesets_with_bug(n)
     revs = set(repo[node].rev() for node in nodes)
     return [r for r in subset if r in revs]
+def revset_me(repo, subset, x):
+    """``me()``
+    Changesets that you are involved in.
+    """
+    if x:
+        raise ParseError(_('me() does not take any arguments'))
+    me = repo.ui.config('ui', 'username')
+    if not me:
+        raise util.Abort(_('"[ui] username" must be set to use me()'))
+    n = encoding.lower(me)
+    kind, pattern, matcher = revset._substringmatcher(n)
+    for r in subset:
+        if matcher(encoding.lower(repo[r].user())):
+            yield r
+            continue
+        # TODO check reviewer blocks.
 def revset_tree(repo, subset, x):
     Changesets currently in the specified Mozilla tree.
     A tree is the name of a repository. e.g. ``central``.
     err = _('tree() requires a string argument.')
     tree = revset.getstring(x, err)
@@ -658,16 +687,17 @@ def extsetup(ui):
         bz_available = True
     except KeyError:
     extensions.wrapcommand(commands.table, 'pull', pullexpand)
     revset.symbols['bug'] = revset_bug
+    revset.symbols['me'] = revset_me
     revset.symbols['tree'] = revset_tree
 def reposetup(ui, repo):
     """Custom repository implementation.
     Our custom repository class tracks remote tree references so users can
     reference specific revisions on remotes.