D5453: test: introduce a new flag to display env variable line per line

lothiraldan (Boris Feld) phabricator at mercurial-scm.org
Sat Dec 22 02:35:52 EST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG73da729ccfef: test: introduce a new flag to display env variable line per line (authored by lothiraldan, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5453?vs=12929&id=12946

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

AFFECTED FILES
  tests/printenv.py
  tests/test-http.t

CHANGE DETAILS

diff --git a/tests/test-http.t b/tests/test-http.t
--- a/tests/test-http.t
+++ b/tests/test-http.t
@@ -140,7 +140,7 @@
   $ cd copy-pull
   $ cat >> .hg/hgrc <<EOF
   > [hooks]
-  > changegroup = sh -c "printenv.py changegroup"
+  > changegroup = sh -c "printenv.py --line changegroup"
   > EOF
   $ hg pull
   pulling from http://localhost:$HGPORT1/
@@ -150,7 +150,14 @@
   adding file changes
   added 1 changesets with 1 changes to 1 files
   new changesets 5fed3813f7f5
-  changegroup hook: HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=5fed3813f7f5e1824344fdc9cf8f63bb662c292d HG_NODE_LAST=5fed3813f7f5e1824344fdc9cf8f63bb662c292d HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_URL=http://localhost:$HGPORT1/
+  changegroup hook: HG_HOOKNAME=changegroup
+  HG_HOOKTYPE=changegroup
+  HG_NODE=5fed3813f7f5e1824344fdc9cf8f63bb662c292d
+  HG_NODE_LAST=5fed3813f7f5e1824344fdc9cf8f63bb662c292d
+  HG_SOURCE=pull
+  HG_TXNID=TXN:$ID$
+  HG_URL=http://localhost:$HGPORT1/
+  
   (run 'hg update' to get a working copy)
   $ cd ..
 
diff --git a/tests/printenv.py b/tests/printenv.py
--- a/tests/printenv.py
+++ b/tests/printenv.py
@@ -37,6 +37,11 @@
 parser.add_argument(
     "out", nargs="?", default=None, help="where to write the output"
 )
+parser.add_argument(
+    "--line",
+    action="store_true",
+    help="print environment variables one per line instead of on a single line",
+)
 args = parser.parse_args()
 
 if args.out is None:
@@ -56,9 +61,18 @@
     filter = lambda x: x.replace('\\', '/')
 else:
     filter = lambda x: x
+
 vars = [b"%s=%s" % (k.encode('ascii'), filter(v).encode('ascii'))
         for k, v in env]
-out.write(b" ".join(vars))
+
+# Print variables on out
+if not args.line:
+    out.write(b" ".join(vars))
+else:
+    for var in vars:
+        out.write(var)
+        out.write(b"\n")
+
 out.write(b"\n")
 out.close()
 



To: lothiraldan, #hg-reviewers
Cc: yuja, mercurial-devel


More information about the Mercurial-devel mailing list