Patchwork [1,of,4] bundle2: add ability to write to a file to the test

login
register
mail settings
Submitter Pierre-Yves David
Date March 21, 2014, 10:12 p.m.
Message ID <78db06fab6501331ff2c.1395439973@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/4031/
State Accepted
Commit cff562fe77a072b9946c35cd32e8766f97718565
Headers show

Comments

Pierre-Yves David - March 21, 2014, 10:12 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1395221781 25200
#      Wed Mar 19 02:36:21 2014 -0700
# Node ID 78db06fab6501331ff2c539d4ea37f5efe4a47c5
# Parent  eec1f3d69dcd9f8656776045e36f277ec5ebd8f9
bundle2: add ability to write to a file to the test

Next changesets are about improving debug output during bundling. We won't be
able to simply bundle to stdin in this case. The bundle2 stream would be
interleaved with debug output.

Patch

diff --git a/tests/test-bundle2.t b/tests/test-bundle2.t
--- a/tests/test-bundle2.t
+++ b/tests/test-bundle2.t
@@ -15,23 +15,28 @@  Create an extension to test bundle2 API
   > cmdtable = {}
   > command = cmdutil.command(cmdtable)
   > 
   > @command('bundle2',
   >          [('', 'param', [], 'stream level parameter'),],
-  >          '')
-  > def cmdbundle2(ui, repo, **opts):
+  >          '[OUTPUTFILE]')
+  > def cmdbundle2(ui, repo, path=None, **opts):
   >     """write a bundle2 container on standard ouput"""
   >     bundler = bundle2.bundle20()
   >     for p in opts['param']:
   >         p = p.split('=', 1)
   >         try:
   >             bundler.addparam(*p)
   >         except ValueError, exc:
   >             raise util.Abort('%s' % exc)
   > 
+  >     if path is None:
+  >        file = sys.stdout
+  >     else:
+  >         file = open(path, 'w')
+  > 
   >     for chunk in bundler.getchunks():
-  >         ui.write(chunk)
+  >         file.write(chunk)
   > 
   > @command('unbundle2', [], '')
   > def cmdunbundle2(ui, repo):
   >     """read a bundle2 container from standard input"""
   >     unbundler = bundle2.unbundle20(sys.stdin)
@@ -152,10 +157,21 @@  Test unbundling
   - e|! 7/
       babar%#==tutu
   - simple
   parts count:   0
 
+Test debug output
+---------------------------------------------------
+(no debug output yet)
+
+  $ hg bundle2 --debug --param 'e|! 7/=babar%#==tutu' --param simple ../out.hg2
+
+file content is ok
+
+  $ cat ../out.hg2
+  HG20\x00)e%7C%21%207/=babar%25%23%3D%3Dtutu simple\x00\x00 (no-eol) (esc)
+
 Test buggy input
 ---------------------------------------------------
 
 empty parameter name