[PATCH 2 of 4] bundle2: print debug information during bundling
pierre-yves.david at ens-lyon.org
pierre-yves.david at ens-lyon.org
Fri Mar 21 22:12:54 UTC 2014
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1395194830 25200
# Tue Mar 18 19:07:10 2014 -0700
# Node ID d59b5c916f3be745fd19fab9dacc02f2352eeea0
# Parent 78db06fab6501331ff2c539d4ea37f5efe4a47c5
bundle2: print debug information during bundling
The bundler class is now feed with an ui object and use it to transmit data
about the bundling process.
diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -95,11 +95,12 @@ class bundle20(object):
`getchunks` to retrieve all the binary chunks of datathat compose the
bundle2 container.
This object does not support payload part yet."""
- def __init__(self):
+ def __init__(self, ui):
+ self.ui = ui
self._params = []
self._parts = []
def addparam(self, name, value=None):
"""add a stream level parameter"""
@@ -108,19 +109,22 @@ class bundle20(object):
if name[0] not in string.letters:
raise ValueError('non letter first character: %r' % name)
self._params.append((name, value))
def getchunks(self):
+ self.ui.debug('start emission of %s stream\n' % _magicstring)
yield _magicstring
param = self._paramchunk()
+ self.ui.debug('bundle parameter: %s\n' % param)
yield _pack(_fstreamparamsize, len(param))
if param:
yield param
# no support for parts
# to be obviously fixed soon.
assert not self._parts
+ self.ui.debug('end of bundle\n')
yield '\0\0'
def _paramchunk(self):
"""return a encoded version of all stream parameters"""
blocks = []
diff --git a/tests/test-bundle2.t b/tests/test-bundle2.t
--- a/tests/test-bundle2.t
+++ b/tests/test-bundle2.t
@@ -18,11 +18,11 @@ Create an extension to test bundle2 API
> @command('bundle2',
> [('', 'param', [], 'stream level parameter'),],
> '[OUTPUTFILE]')
> def cmdbundle2(ui, repo, path=None, **opts):
> """write a bundle2 container on standard ouput"""
- > bundler = bundle2.bundle20()
+ > bundler = bundle2.bundle20(ui)
> for p in opts['param']:
> p = p.split('=', 1)
> try:
> bundler.addparam(*p)
> except ValueError, exc:
@@ -159,13 +159,15 @@ Test unbundling
- simple
parts count: 0
Test debug output
---------------------------------------------------
-(no debug output yet)
$ hg bundle2 --debug --param 'e|! 7/=babar%#==tutu' --param simple ../out.hg2
+ start emission of HG20 stream
+ bundle parameter: e%7C%21%207/=babar%25%23%3D%3Dtutu simple
+ end of bundle
file content is ok
$ cat ../out.hg2
HG20\x00)e%7C%21%207/=babar%25%23%3D%3Dtutu simple\x00\x00 (no-eol) (esc)
More information about the Mercurial-devel
mailing list