diff mercurial/exchange.py @ 35305:483b5dd0f1aa

push: restrict common discovery to the pushed set This changeset make use of the ability of the set discovery to only search common changeset for a subset of the repository. Restricting that search to the pushed set avoid potential waste of time finding out the status of many unrelated related revision. Repository with many heads were especially badly affected by this. Here is an example of findcommonhead discovery for pushing 11 outgoing changeset on a repository with tens of thousand of unrelated heads. (discovery run over a ssh link to localhost). Before: queries: 92 time: 44.1996s After: queries: 3 time: 0.6938s A x63 speedup even with a network link without latency.
author Boris Feld <boris.feld@octobus.net>
date Wed, 06 Dec 2017 23:33:01 +0100
parents 44b8b5ad30eb
children a29fe459fc49
line wrap: on
line diff
--- a/mercurial/exchange.py	Wed Dec 06 22:44:51 2017 +0100
+++ b/mercurial/exchange.py	Wed Dec 06 23:33:01 2017 +0100
@@ -514,7 +514,11 @@
 def _pushdiscoverychangeset(pushop):
     """discover the changeset that need to be pushed"""
     fci = discovery.findcommonincoming
-    commoninc = fci(pushop.repo, pushop.remote, force=pushop.force)
+    if pushop.revs:
+        commoninc = fci(pushop.repo, pushop.remote, force=pushop.force,
+                        ancestorsof=pushop.revs)
+    else:
+        commoninc = fci(pushop.repo, pushop.remote, force=pushop.force)
     common, inc, remoteheads = commoninc
     fco = discovery.findcommonoutgoing
     outgoing = fco(pushop.repo, pushop.remote, onlyheads=pushop.revs,