Patchwork bundle2: generate check:heads in a independent function

login
register
mail settings
Submitter Ryan McElroy
Date Oct. 1, 2015, 6:11 p.m.
Message ID <acec53a4edf0898029b7.1443723092@devbig314.prn1.facebook.com>
Download mbox | patch
Permalink /patch/10718/
State Superseded
Commit b75c4651b186360298089c0650c2f4eed0046265
Headers show

Comments

Ryan McElroy - Oct. 1, 2015, 6:11 p.m.
# HG changeset patch
# User Ryan McElroy <rmcelroy@fb.com>
# Date 1443721694 25200
#      Thu Oct 01 10:48:14 2015 -0700
# Node ID acec53a4edf0898029b7b629065047d726133a53
# Parent  b80b2ee71a08d00ec4008f3131bdf3c72e4ec2ba
bundle2: generate check:heads in a independent function
Pierre-Yves David - Oct. 1, 2015, 6:41 p.m.
On 10/01/2015 11:11 AM, Ryan McElroy wrote:
> # HG changeset patch
> # User Ryan McElroy <rmcelroy@fb.com>
> # Date 1443721694 25200
> #      Thu Oct 01 10:48:14 2015 -0700
> # Node ID acec53a4edf0898029b7b629065047d726133a53
> # Parent  b80b2ee71a08d00ec4008f3131bdf3c72e4ec2ba
> bundle2: generate check:heads in a independent function

bundle2 have extensibility in mind.

Pushed to the clowncopter.

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -475,6 +475,14 @@  def b2partsgenerator(stepname, idx=None)
         return func
     return dec
 
+def _pushb2ctxcheckheads(pushop, bundler):
+    """Generate race condition checking parts
+
+    Exists as an indepedent function to aid extensions
+    """
+    if not pushop.force:
+        bundler.newpart('check:heads', data=iter(pushop.remoteheads))
+
 @b2partsgenerator('changeset')
 def _pushb2ctx(pushop, bundler):
     """handle changegroup push through bundle2
@@ -490,8 +498,9 @@  def _pushb2ctx(pushop, bundler):
     pushop.repo.prepushoutgoinghooks(pushop.repo,
                                      pushop.remote,
                                      pushop.outgoing)
-    if not pushop.force:
-        bundler.newpart('check:heads', data=iter(pushop.remoteheads))
+
+    _pushb2ctxcheckheads(pushop, bundler)
+
     b2caps = bundle2.bundle2caps(pushop.remote)
     version = None
     cgversions = b2caps.get('changegroup')