[PATCH 3 of 3] exchange: introduce a '_canusebundle2' function

Martin von Zweigbergk martinvonz at google.com
Tue Apr 7 18:32:46 CDT 2015


On Tue, Apr 7, 2015 at 2:12 PM Pierre-Yves David <
pierre-yves.david at ens-lyon.org> wrote:

> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at fb.com>
> # Date 1428370319 25200
> #      Mon Apr 06 18:31:59 2015 -0700
> # Node ID 471b8404e07b638a6c987456a29251649e614a8f
> # Parent  877b5ed6bd636447ef8701b36e73d5e2b356e9b2
> exchange: introduce a '_canusebundle2' function
>
> This function factorizes the logic that decide to use 'bundle2' during an
> exchange (pull/push). This will help being consistent while transitioning
> from
> the experimental protocol to the final frozen version.
>
> I do not expect this function to survive on the long run when using
> 'bundle2'
> will become a simple capability check.
>
> This is also necessary to allow HG2Y support in an extension to ease
> transition
> of companies using the experimental protocol in production (yeah...).  Such
> extension will be able to wrap this function to use the experimental
> protocol in
> some case.
>
> diff --git a/mercurial/exchange.py b/mercurial/exchange.py
> --- a/mercurial/exchange.py
> +++ b/mercurial/exchange.py
> @@ -50,10 +50,18 @@ def buildobsmarkerspart(bundler, markers
>              raise ValueError('bundler do not support common obsmarker
> format')
>          stream = obsolete.encodemarkers(markers, True, version=version)
>          return bundler.newpart('b2x:obsmarkers', data=stream)
>      return None
>
> +def _canusebundle2(op):
> +    """return true if a pull/pull can use bundle2
>

Changing to pull/push in flight.


> +
> +    Feel free to nuke this function when we drop the experimental
> option"""
> +    return (op.repo.ui.configbool('experimental', 'bundle2-exp', False)
> +            and op.remote.capable('bundle2-exp'))
> +
> +
>  class pushoperation(object):
>      """A object that represent a single push operation
>
>      It purpose is to carry push related state and very common operation.
>
> @@ -215,13 +223,11 @@ def push(repo, remote, force=False, revs
>          unbundle = pushop.remote.capable('unbundle')
>          if not unbundle:
>              lock = pushop.remote.lock()
>          try:
>              _pushdiscovery(pushop)
> -            if (pushop.repo.ui.configbool('experimental', 'bundle2-exp',
> -                                          False)
> -                and pushop.remote.capable('bundle2-exp')):
> +            if _canusebundle2(pushop):
>                  _pushbundle2(pushop)
>              _pushchangeset(pushop)
>              _pushsyncphase(pushop)
>              _pushobsolete(pushop)
>              _pushbookmark(pushop)
> @@ -874,12 +880,11 @@ def pull(repo, remote, heads=None, force
>      pullop.remotebookmarks = remote.listkeys('bookmarks')
>      lock = pullop.repo.lock()
>      try:
>          pullop.trmanager = transactionmanager(repo, 'pull', remote.url())
>          _pulldiscovery(pullop)
> -        if (pullop.repo.ui.configbool('experimental', 'bundle2-exp',
> False)
> -            and pullop.remote.capable('bundle2-exp')):
> +        if _canusebundle2(pullop):
>              _pullbundle2(pullop)
>          _pullchangeset(pullop)
>          _pullphase(pullop)
>          _pullbookmarks(pullop)
>          _pullobsolete(pullop)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20150407/bae90dc4/attachment.html>


More information about the Mercurial-devel mailing list