D3314: wireproto: use command executor for unbundle

2018-04-13 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG72e26319f3b8: wireproto: use command executor for unbundle 
(authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3314?vs=8134=8182

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

AFFECTED FILES
  mercurial/exchange.py
  mercurial/localrepo.py
  mercurial/wireprotov1peer.py

CHANGE DETAILS

diff --git a/mercurial/wireprotov1peer.py b/mercurial/wireprotov1peer.py
--- a/mercurial/wireprotov1peer.py
+++ b/mercurial/wireprotov1peer.py
@@ -436,7 +436,7 @@
 else:
 return changegroupmod.cg1unpacker(f, 'UN')
 
-def unbundle(self, cg, heads, url):
+def unbundle(self, bundle, heads, url):
 '''Send cg (a readable file-like object representing the
 changegroup to push, typically a chunkbuffer object) to the
 remote server as a bundle.
@@ -456,9 +456,9 @@
 else:
 heads = wireprototypes.encodelist(heads)
 
-if util.safehasattr(cg, 'deltaheader'):
+if util.safehasattr(bundle, 'deltaheader'):
 # this a bundle10, do the old style call sequence
-ret, output = self._callpush("unbundle", cg, heads=heads)
+ret, output = self._callpush("unbundle", bundle, heads=heads)
 if ret == "":
 raise error.ResponseError(
 _('push failed:'), output)
@@ -472,7 +472,7 @@
 self.ui.status(_('remote: '), l)
 else:
 # bundle2 push. Send a stream, fetch a stream.
-stream = self._calltwowaystream('unbundle', cg, heads=heads)
+stream = self._calltwowaystream('unbundle', bundle, heads=heads)
 ret = bundle2.getunbundler(self.ui, stream)
 return ret
 
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -275,14 +275,14 @@
 raise error.Abort(_('cannot perform stream clone against local '
 'peer'))
 
-def unbundle(self, cg, heads, url):
+def unbundle(self, bundle, heads, url):
 """apply a bundle on a repo
 
 This function handles the repo locking itself."""
 try:
 try:
-cg = exchange.readbundle(self.ui, cg, None)
-ret = exchange.unbundle(self._repo, cg, heads, 'push', url)
+bundle = exchange.readbundle(self.ui, bundle, None)
+ret = exchange.unbundle(self._repo, bundle, heads, 'push', url)
 if util.safehasattr(ret, 'getchunks'):
 # This is a bundle20 object, turn it into an unbundler.
 # This little dance should be dropped eventually when the
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1096,8 +1096,12 @@
 stream = util.chunkbuffer(bundler.getchunks())
 try:
 try:
-reply = pushop.remote.unbundle(
-stream, ['force'], pushop.remote.url())
+with pushop.remote.commandexecutor() as e:
+reply = e.callcommand('unbundle', {
+'bundle': stream,
+'heads': ['force'],
+'url': pushop.remote.url(),
+}).result()
 except error.BundleValueError as exc:
 raise error.Abort(_('missing support for %s') % exc)
 try:



To: indygreg, #hg-reviewers, durin42
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D3314: wireproto: use command executor for unbundle

2018-04-13 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This also required unifying the name of the argument because the
  new API always passes arguments by keyword. I decided to change
  implementations to "bundle" instead of the interface to "cg"
  because "bundle" is more appropriate in a modern world.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/exchange.py
  mercurial/localrepo.py
  mercurial/wireprotov1peer.py

CHANGE DETAILS

diff --git a/mercurial/wireprotov1peer.py b/mercurial/wireprotov1peer.py
--- a/mercurial/wireprotov1peer.py
+++ b/mercurial/wireprotov1peer.py
@@ -436,7 +436,7 @@
 else:
 return changegroupmod.cg1unpacker(f, 'UN')
 
-def unbundle(self, cg, heads, url):
+def unbundle(self, bundle, heads, url):
 '''Send cg (a readable file-like object representing the
 changegroup to push, typically a chunkbuffer object) to the
 remote server as a bundle.
@@ -456,9 +456,9 @@
 else:
 heads = wireprototypes.encodelist(heads)
 
-if util.safehasattr(cg, 'deltaheader'):
+if util.safehasattr(bundle, 'deltaheader'):
 # this a bundle10, do the old style call sequence
-ret, output = self._callpush("unbundle", cg, heads=heads)
+ret, output = self._callpush("unbundle", bundle, heads=heads)
 if ret == "":
 raise error.ResponseError(
 _('push failed:'), output)
@@ -472,7 +472,7 @@
 self.ui.status(_('remote: '), l)
 else:
 # bundle2 push. Send a stream, fetch a stream.
-stream = self._calltwowaystream('unbundle', cg, heads=heads)
+stream = self._calltwowaystream('unbundle', bundle, heads=heads)
 ret = bundle2.getunbundler(self.ui, stream)
 return ret
 
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -275,14 +275,14 @@
 raise error.Abort(_('cannot perform stream clone against local '
 'peer'))
 
-def unbundle(self, cg, heads, url):
+def unbundle(self, bundle, heads, url):
 """apply a bundle on a repo
 
 This function handles the repo locking itself."""
 try:
 try:
-cg = exchange.readbundle(self.ui, cg, None)
-ret = exchange.unbundle(self._repo, cg, heads, 'push', url)
+bundle = exchange.readbundle(self.ui, bundle, None)
+ret = exchange.unbundle(self._repo, bundle, heads, 'push', url)
 if util.safehasattr(ret, 'getchunks'):
 # This is a bundle20 object, turn it into an unbundler.
 # This little dance should be dropped eventually when the
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1096,8 +1096,12 @@
 stream = util.chunkbuffer(bundler.getchunks())
 try:
 try:
-reply = pushop.remote.unbundle(
-stream, ['force'], pushop.remote.url())
+with pushop.remote.commandexecutor() as e:
+reply = e.callcommand('unbundle', {
+'bundle': stream,
+'heads': ['force'],
+'url': pushop.remote.url(),
+}).result()
 except error.BundleValueError as exc:
 raise error.Abort(_('missing support for %s') % exc)
 try:



To: indygreg, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel