Patchwork [STABLE] bundle2: disable ouput capture unless we use http (issue4613 issue4615)

login
register
mail settings
Submitter Pierre-Yves David
Date April 29, 2015, 1:07 a.m.
Message ID <35697380c24b2b6e4ee0.1430269637@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/8814/
State Accepted
Headers show

Comments

Pierre-Yves David - April 29, 2015, 1:07 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1430267882 25200
#      Tue Apr 28 17:38:02 2015 -0700
# Branch stable
# Node ID 35697380c24b2b6e4ee0e518f81e81db056666ba
# Parent  cc497780eaf9c191564c64b40ca549f706c62724
bundle2: disable ouput capture unless we use http (issue4613 issue4615)

The current bundle2 processing was capturing all output. This is nice as it
provide better meta data about what output what, but this was changing two
things:

1) adding a prefix "remote: " to "other" output during local push (issue4613)
2) local and ssh push does not provide real time output anymore (issue4615)

As we are unsure about what form should be used in (1) and how to solve (2) we
disable output capture in this two cases. Output capture can be forced using an
experimental option.
Matt Mackall - April 29, 2015, 10:36 a.m.
On Tue, 2015-04-28 at 18:07 -0700, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1430267882 25200
> #      Tue Apr 28 17:38:02 2015 -0700
> # Branch stable
> # Node ID 35697380c24b2b6e4ee0e518f81e81db056666ba
> # Parent  cc497780eaf9c191564c64b40ca549f706c62724
> bundle2: disable ouput capture unless we use http (issue4613 issue4615)

Queued for stable, thanks.

Patch

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -266,16 +266,17 @@  class bundleoperation(object):
     * a way to retrieve a transaction to add changes to the repo,
     * a way to record the result of processing each part,
     * a way to construct a bundle response when applicable.
     """
 
-    def __init__(self, repo, transactiongetter):
+    def __init__(self, repo, transactiongetter, captureoutput=True):
         self.repo = repo
         self.ui = repo.ui
         self.records = unbundlerecords()
         self.gettransaction = transactiongetter
         self.reply = None
+        self.captureoutput = captureoutput
 
 class TransactionUnavailable(RuntimeError):
     pass
 
 def _notransaction():
@@ -357,11 +358,11 @@  def _processpart(op, part):
         # handler is called outside the above try block so that we don't
         # risk catching KeyErrors from anything other than the
         # parthandlermapping lookup (any KeyError raised by handler()
         # itself represents a defect of a different variety).
         output = None
-        if op.reply is not None:
+        if op.captureoutput and op.reply is not None:
             op.ui.pushbuffer(error=True, subproc=True)
             output = ''
         try:
             handler(op, part)
         finally:
@@ -838,10 +839,11 @@  class interruptoperation(object):
     """
 
     def __init__(self, ui):
         self.ui = ui
         self.reply = None
+        self.captureoutput = False
 
     @property
     def repo(self):
         raise RuntimeError('no repo access from stream interruption')
 
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1283,10 +1283,15 @@  def unbundle(repo, cg, heads, source, ur
     If the push was raced as PushRaced exception is raised."""
     r = 0
     # need a transaction when processing a bundle2 stream
     wlock = lock = tr = None
     recordout = None
+    # quick fix for output mismatch with bundle2 in 3.4
+    captureoutput = repo.ui.configbool('experimental', 'bundle2-output-capture',
+                                       False)
+    if url.startswith('remote:http:') or url.startswith('remote:https:'):
+        captureoutput = True
     try:
         check_heads(repo, heads, 'uploading changes')
         # push can proceed
         if util.safehasattr(cg, 'params'):
             r = None
@@ -1295,23 +1300,24 @@  def unbundle(repo, cg, heads, source, ur
                 lock = repo.lock()
                 tr = repo.transaction(source)
                 tr.hookargs['source'] = source
                 tr.hookargs['url'] = url
                 tr.hookargs['bundle2'] = '1'
-                op = bundle2.bundleoperation(repo, lambda: tr)
+                op = bundle2.bundleoperation(repo, lambda: tr,
+                                             captureoutput=captureoutput)
                 try:
                     r = bundle2.processbundle(repo, cg, op=op)
                 finally:
                     r = op.reply
-                    if r is not None:
+                    if captureoutput and r is not None:
                         repo.ui.pushbuffer(error=True, subproc=True)
                         def recordout(output):
                             r.newpart('output', data=output, mandatory=False)
                 tr.close()
             except Exception, exc:
                 exc.duringunbundle2 = True
-                if r is not None:
+                if captureoutput and r is not None:
                     parts = exc._bundle2salvagedoutput = r.salvageoutput()
                     def recordout(output):
                         part = bundle2.bundlepart('output', data=output,
                                                   mandatory=False)
                         parts.append(part)
diff --git a/tests/test-bundle2-exchange.t b/tests/test-bundle2-exchange.t
--- a/tests/test-bundle2-exchange.t
+++ b/tests/test-bundle2-exchange.t
@@ -14,10 +14,11 @@  enable obsolescence
 
   $ cat >> $HGRCPATH << EOF
   > [experimental]
   > evolution=createmarkers,exchange
   > bundle2-exp=True
+  > bundle2-output-capture=True
   > [ui]
   > ssh=python "$TESTDIR/dummyssh"
   > logtemplate={rev}:{node|short} {phase} {author} {bookmarks} {desc|firstline}
   > [web]
   > push_ssl = false
@@ -665,5 +666,54 @@  Check error from hook during the unbundl
   remote: transaction abort!
   remote: Cleaning up the mess...
   remote: rollback completed
   abort: pretxnchangegroup hook exited with status 1
   [255]
+
+Check output capture control.
+
+(should be still forced for http, disabled for local and ssh)
+
+  $ cat >> $HGRCPATH << EOF
+  > [experimental]
+  > bundle2-output-capture=False
+  > EOF
+
+  $ hg -R main push other -r e7ec4e813ba6
+  pushing to other
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  Fail early!
+  transaction abort!
+  Cleaning up the mess...
+  rollback completed
+  abort: pretxnchangegroup hook exited with status 1
+  [255]
+  $ hg -R main push ssh://user@dummy/other -r e7ec4e813ba6
+  pushing to ssh://user@dummy/other
+  searching for changes
+  abort: pretxnchangegroup hook exited with status 1
+  remote: adding changesets
+  remote: adding manifests
+  remote: adding file changes
+  remote: added 1 changesets with 1 changes to 1 files
+  remote: Fail early!
+  remote: transaction abort!
+  remote: Cleaning up the mess...
+  remote: rollback completed
+  [255]
+  $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6
+  pushing to http://localhost:$HGPORT2/
+  searching for changes
+  remote: adding changesets
+  remote: adding manifests
+  remote: adding file changes
+  remote: added 1 changesets with 1 changes to 1 files
+  remote: Fail early!
+  remote: transaction abort!
+  remote: Cleaning up the mess...
+  remote: rollback completed
+  abort: pretxnchangegroup hook exited with status 1
+  [255]