D4251: tests: extract printrevset extension from test-glog-beautifygraph.t

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Fri Aug 10 12:03:24 EDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHGa271466cb53a: tests: extract printrevset extension from test-glog-beautifygraph.t (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4251?vs=10303&id=10311

REVISION DETAIL
  https://phab.mercurial-scm.org/D4251

AFFECTED FILES
  tests/printrevset.py
  tests/test-glog-beautifygraph.t

CHANGE DETAILS

diff --git a/tests/test-glog-beautifygraph.t b/tests/test-glog-beautifygraph.t
--- a/tests/test-glog-beautifygraph.t
+++ b/tests/test-glog-beautifygraph.t
@@ -80,52 +80,8 @@
   >   hg commit -Aqd "$rev 0" -m "($rev) $msg"
   > }
 
-  $ cat > printrevset.py <<EOF
-  > from __future__ import absolute_import
-  > from mercurial import (
-  >   cmdutil,
-  >   commands,
-  >   extensions,
-  >   logcmdutil,
-  >   revsetlang,
-  >   smartset,
-  > )
-  > 
-  > from mercurial.utils import (
-  >   stringutil,
-  > )
-  > 
-  > def logrevset(repo, pats, opts):
-  >     revs = logcmdutil._initialrevs(repo, opts)
-  >     if not revs:
-  >         return None
-  >     match, pats, slowpath = logcmdutil._makematcher(repo, revs, pats, opts)
-  >     return logcmdutil._makerevset(repo, match, pats, slowpath, opts)
-  > 
-  > def uisetup(ui):
-  >     def printrevset(orig, repo, pats, opts):
-  >         revs, filematcher = orig(repo, pats, opts)
-  >         if opts.get(b'print_revset'):
-  >             expr = logrevset(repo, pats, opts)
-  >             if expr:
-  >                 tree = revsetlang.parse(expr)
-  >                 tree = revsetlang.analyze(tree)
-  >             else:
-  >                 tree = []
-  >             ui = repo.ui
-  >             ui.write(b'%s\n' % stringutil.pprint(opts.get(b'rev', [])))
-  >             ui.write(revsetlang.prettyformat(tree) + b'\n')
-  >             ui.write(stringutil.prettyrepr(revs) + b'\n')
-  >             revs = smartset.baseset()  # display no revisions
-  >         return revs, filematcher
-  >     extensions.wrapfunction(logcmdutil, 'getrevs', printrevset)
-  >     aliases, entry = cmdutil.findcmd(b'log', commands.table)
-  >     entry[1].append((b'', b'print-revset', False,
-  >                      b'print generated revset and exit (DEPRECATED)'))
-  > EOF
-
   $ echo "[extensions]" >> $HGRCPATH
-  $ echo "printrevset=`pwd`/printrevset.py" >> $HGRCPATH
+  $ echo "printrevset=$TESTDIR/printrevset.py" >> $HGRCPATH
   $ echo "beautifygraph=" >> $HGRCPATH
 
 Set a default of narrow-text UTF-8.
diff --git a/tests/printrevset.py b/tests/printrevset.py
new file mode 100644
--- /dev/null
+++ b/tests/printrevset.py
@@ -0,0 +1,41 @@
+from __future__ import absolute_import
+from mercurial import (
+  cmdutil,
+  commands,
+  extensions,
+  logcmdutil,
+  revsetlang,
+  smartset,
+)
+
+from mercurial.utils import (
+  stringutil,
+)
+
+def logrevset(repo, pats, opts):
+    revs = logcmdutil._initialrevs(repo, opts)
+    if not revs:
+        return None
+    match, pats, slowpath = logcmdutil._makematcher(repo, revs, pats, opts)
+    return logcmdutil._makerevset(repo, match, pats, slowpath, opts)
+
+def uisetup(ui):
+    def printrevset(orig, repo, pats, opts):
+        revs, filematcher = orig(repo, pats, opts)
+        if opts.get(b'print_revset'):
+            expr = logrevset(repo, pats, opts)
+            if expr:
+                tree = revsetlang.parse(expr)
+                tree = revsetlang.analyze(tree)
+            else:
+                tree = []
+            ui = repo.ui
+            ui.write(b'%s\n' % stringutil.pprint(opts.get(b'rev', [])))
+            ui.write(revsetlang.prettyformat(tree) + b'\n')
+            ui.write(stringutil.prettyrepr(revs) + b'\n')
+            revs = smartset.baseset()  # display no revisions
+        return revs, filematcher
+    extensions.wrapfunction(logcmdutil, 'getrevs', printrevset)
+    aliases, entry = cmdutil.findcmd(b'log', commands.table)
+    entry[1].append((b'', b'print-revset', False,
+                     b'print generated revset and exit (DEPRECATED)'))



To: durin42, #hg-reviewers, pulkit
Cc: mjpieters, mercurial-devel


More information about the Mercurial-devel mailing list