Commits

Dan Villiom Podlaski Christiansen committed 7b17d50

New patch.

Comments (0)

Files changed (2)

revset+templatekw.diff

+# HG changeset patch
+# Parent 06c6d3ac633f1e5f552b93881c6694146c81a7e3
+# User Dan Villiom Podlaski Christiansen <dan@cabo.dk>
+add a revset and a template keyword
+
+diff --git a/perfarce.py b/perfarce.py
+--- a/perfarce.py
++++ b/perfarce.py
+@@ -106,6 +106,9 @@ except ImportError:
+     util_setflags = util.set_flags
+     revpair = cmdutil.revpair
+ 
++from mercurial import revset
++from mercurial import templatekw
++
+ def uisetup(ui):
+     '''monkeypatch pull and push for p4:// support'''
+ 
+@@ -1640,6 +1643,26 @@ def identify(ui, repo, *args, **opts):
+ 
+     ui.write("%s\n" % ' '.join(output))
+ 
++def revsetp4(repo, subset, x):
++    """``p4([changelist])``
++    Matches all changesets from Perforce, or the ones from the given changelist.
++    """
++    args = revset.getargs(x, 0, 1, 'p4 takes one or no arguments')
++    if args:
++        changelist = revset.getstring(args[0],
++                                      'the argument to p4 must be a string')
++
++        return [r for r in subset if repo[r].extra().get('p4') == changelist]
++    else:
++        return [r for r in subset if repo[r].extra().get('p4')]
++
++def kwp4changelist(repo, ctx, **args):
++    """:p4changelist: String. Converted Perforce changelist, if any."""
++    return ctx.extra().get('p4') or ''
++
++def extsetup(ui):
++    revset.symbols['p4'] = revsetp4
++    templatekw.keywords['p4changelist'] = kwp4changelist
+ 
+ cmdtable = {
+     # 'command-name': (function-call, options-list, help-string)
 skiplist.diff
 filemap.diff
 exceptions.diff
+revset+templatekw.diff