D3291: hg: use command executor for wire protocol commands

2018-04-13 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGce8828217369: hg: use command executor for wire protocol 
commands (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3291?vs=8130&id=8176

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

AFFECTED FILES
  mercurial/hg.py

CHANGE DETAILS

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -81,7 +81,9 @@
 raise error.Abort(_("remote branch lookup not supported"))
 revs.append(hashbranch)
 return revs, revs[0]
-branchmap = peer.branchmap()
+
+with peer.commandexecutor() as e:
+branchmap = e.callcommand('branchmap', {}).result()
 
 def primary(branch):
 if branch == '.':
@@ -421,7 +423,15 @@
 raise error.Abort(_("src repository does not support "
"revision lookup and so doesn't "
"support clone by revision"))
-revs = [srcpeer.lookup(r) for r in rev]
+
+# TODO this is batchable.
+remoterevs = []
+for r in rev:
+with srcpeer.commandexecutor() as e:
+remoterevs.append(e.callcommand('lookup', {
+'key': r,
+}).result())
+revs = remoterevs
 
 # Obtain a lock before checking for or cloning the pooled repo otherwise
 # 2 clients may race creating or populating it.
@@ -567,7 +577,11 @@
 # raises RepoLookupError if revision 0 is filtered or otherwise
 # not available. If we fail to resolve, sharing is not enabled.
 try:
-rootnode = srcpeer.lookup('0')
+with srcpeer.commandexecutor() as e:
+rootnode = e.callcommand('lookup', {
+'key': '0',
+}).result()
+
 if rootnode != node.nullid:
 sharepath = os.path.join(sharepool, node.hex(rootnode))
 else:
@@ -663,7 +677,16 @@
 raise error.Abort(_("src repository does not support "
"revision lookup and so doesn't "
"support clone by revision"))
-revs = [srcpeer.lookup(r) for r in revs]
+
+# TODO this is batchable.
+remoterevs = []
+for rev in revs:
+with srcpeer.commandexecutor() as e:
+remoterevs.append(e.callcommand('lookup', {
+'key': rev,
+}).result())
+revs = remoterevs
+
 checkout = revs[0]
 else:
 revs = None
@@ -705,7 +728,11 @@
 
 if update:
 if update is not True:
-checkout = srcpeer.lookup(update)
+with srcpeer.commandexecutor() as e:
+checkout = e.callcommand('lookup', {
+'key': update,
+}).result()
+
 uprev = None
 status = None
 if checkout is not None:



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


D3291: hg: use command executor for wire protocol commands

2018-04-13 Thread indygreg (Gregory Szorc)
indygreg updated this revision to Diff 8130.
indygreg edited the summary of this revision.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3291?vs=8084&id=8130

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

AFFECTED FILES
  mercurial/hg.py

CHANGE DETAILS

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -81,7 +81,9 @@
 raise error.Abort(_("remote branch lookup not supported"))
 revs.append(hashbranch)
 return revs, revs[0]
-branchmap = peer.branchmap()
+
+with peer.commandexecutor() as e:
+branchmap = e.callcommand('branchmap', {}).result()
 
 def primary(branch):
 if branch == '.':
@@ -421,7 +423,15 @@
 raise error.Abort(_("src repository does not support "
"revision lookup and so doesn't "
"support clone by revision"))
-revs = [srcpeer.lookup(r) for r in rev]
+
+# TODO this is batchable.
+remoterevs = []
+for r in rev:
+with srcpeer.commandexecutor() as e:
+remoterevs.append(e.callcommand('lookup', {
+'key': r,
+}).result())
+revs = remoterevs
 
 # Obtain a lock before checking for or cloning the pooled repo otherwise
 # 2 clients may race creating or populating it.
@@ -567,7 +577,11 @@
 # raises RepoLookupError if revision 0 is filtered or otherwise
 # not available. If we fail to resolve, sharing is not enabled.
 try:
-rootnode = srcpeer.lookup('0')
+with srcpeer.commandexecutor() as e:
+rootnode = e.callcommand('lookup', {
+'key': '0',
+}).result()
+
 if rootnode != node.nullid:
 sharepath = os.path.join(sharepool, node.hex(rootnode))
 else:
@@ -663,7 +677,16 @@
 raise error.Abort(_("src repository does not support "
"revision lookup and so doesn't "
"support clone by revision"))
-revs = [srcpeer.lookup(r) for r in revs]
+
+# TODO this is batchable.
+remoterevs = []
+for rev in revs:
+with srcpeer.commandexecutor() as e:
+remoterevs.append(e.callcommand('lookup', {
+'key': rev,
+}).result())
+revs = remoterevs
+
 checkout = revs[0]
 else:
 revs = None
@@ -705,7 +728,11 @@
 
 if update:
 if update is not True:
-checkout = srcpeer.lookup(update)
+with srcpeer.commandexecutor() as e:
+checkout = e.callcommand('lookup', {
+'key': update,
+}).result()
+
 uprev = None
 status = None
 if checkout is not None:



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


D3291: hg: use command executor for wire protocol commands

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

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/hg.py

CHANGE DETAILS

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -81,7 +81,11 @@
 raise error.Abort(_("remote branch lookup not supported"))
 revs.append(hashbranch)
 return revs, revs[0]
-branchmap = peer.branchmap()
+
+with peer.commandexecutor() as e:
+fbranchmap = e.callcommand('branchmap', {})
+
+branchmap = fbranchmap.result()
 
 def primary(branch):
 if branch == '.':
@@ -421,7 +425,17 @@
 raise error.Abort(_("src repository does not support "
"revision lookup and so doesn't "
"support clone by revision"))
-revs = [srcpeer.lookup(r) for r in rev]
+
+remoterevs = []
+for r in rev:
+with srcpeer.commandexecutor() as e:
+frev = e.callcommand('lookup', {
+'key': r,
+})
+
+remoterevs.append(frev.result())
+
+revs = remoterevs
 
 # Obtain a lock before checking for or cloning the pooled repo otherwise
 # 2 clients may race creating or populating it.
@@ -567,7 +581,13 @@
 # raises RepoLookupError if revision 0 is filtered or otherwise
 # not available. If we fail to resolve, sharing is not enabled.
 try:
-rootnode = srcpeer.lookup('0')
+with srcpeer.commandexecutor() as e:
+frootnode = e.callcommand('lookup', {
+'key': '0',
+})
+
+rootnode = frootnode.result()
+
 if rootnode != node.nullid:
 sharepath = os.path.join(sharepool, node.hex(rootnode))
 else:
@@ -663,7 +683,17 @@
 raise error.Abort(_("src repository does not support "
"revision lookup and so doesn't "
"support clone by revision"))
-revs = [srcpeer.lookup(r) for r in revs]
+
+remoterevs = []
+for rev in revs:
+with srcpeer.commandexecutor() as e:
+frev = e.callcommand('lookup', {
+'key': rev,
+})
+
+remoterevs.append(frev.result())
+
+revs = remoterevs
 checkout = revs[0]
 else:
 revs = None
@@ -705,7 +735,13 @@
 
 if update:
 if update is not True:
-checkout = srcpeer.lookup(update)
+with srcpeer.commandexecutor() as e:
+fcheckout = e.callcommand('lookup', {
+'key': update,
+})
+
+checkout = fcheckout.result()
+
 uprev = None
 status = None
 if checkout is not None:



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