Patchwork [2,of,3,batching] wireproto: make wirepeer look-before-you-leap on batching

login
register
mail settings
Submitter Augie Fackler
Date Aug. 5, 2015, 7:29 p.m.
Message ID <88593e1112f0eb4cc4f2.1438802997@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/10109/
State Accepted
Headers show

Comments

Augie Fackler - Aug. 5, 2015, 7:29 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1438798517 14400
#      Wed Aug 05 14:15:17 2015 -0400
# Node ID 88593e1112f0eb4cc4f2b35258cf2b9ad02ac4e0
# Parent  9c49271fe180f287ca3b43e07ca9b593e2f8c2ce
wireproto: make wirepeer look-before-you-leap on batching

This means that users of request batching don't need to worry
themselves with capability checking. Instead, they can just use
batching, and if the remote server doesn't support batching for some
reason the wirepeer code will transparently un-batch the requests.

This will allow for some slight simplification in a handful of
places. Prior to this change, largefiles would have been silently
broken against a server which did not support batching.

Patch

diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireproto.py
@@ -149,7 +149,10 @@  gboptsmap = {'heads':  'nodes',
 class wirepeer(peer.peerrepository):
 
     def batch(self):
-        return remotebatch(self)
+        if self.capable('batch'):
+            return remotebatch(self)
+        else:
+            return peer.localbatch(self)
     def _submitbatch(self, req):
         cmds = []
         for op, argsdict in req: