Patchwork [2,of,2] bundle2: gracefully skip 'obsmarkers' part if evolution is disabled

login
register
mail settings
Submitter Pierre-Yves David
Date Oct. 15, 2015, 11:56 a.m.
Message ID <a0a62bda6a9ac5877e3c.1444910161@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/11102/
State Accepted
Headers show

Comments

Pierre-Yves David - Oct. 15, 2015, 11:56 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1444876140 -3600
#      Thu Oct 15 03:29:00 2015 +0100
# Node ID a0a62bda6a9ac5877e3c20747b7d6e6521126771
# Parent  b882853b5f3a207c283e3bf6a9ad1e40fc7a254b
# EXP-Topic obs.advisory
# Available At http://hg.netv6.net/marmoute-wip/mercurial/
#              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r a0a62bda6a9a
bundle2: gracefully skip 'obsmarkers' part if evolution is disabled

We would skip the part if it was fully unknown. So we should also skip it if we
know we won't be able to apply it. This will allow us to produce bundle with
obsolescence markers alongside changegroup while still being able to apply them
on any client.
Augie Fackler - Oct. 15, 2015, 5:32 p.m.
On Thu, Oct 15, 2015 at 12:56:01PM +0100, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1444876140 -3600
> #      Thu Oct 15 03:29:00 2015 +0100
> # Node ID a0a62bda6a9ac5877e3c20747b7d6e6521126771
> # Parent  b882853b5f3a207c283e3bf6a9ad1e40fc7a254b
> # EXP-Topic obs.advisory
> # Available At http://hg.netv6.net/marmoute-wip/mercurial/
> #              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r a0a62bda6a9a
> bundle2: gracefully skip 'obsmarkers' part if evolution is disabled

these are queued, thanks

>
> We would skip the part if it was fully unknown. So we should also skip it if we
> know we won't be able to apply it. This will allow us to produce bundle with
> obsolescence markers alongside changegroup while still being able to apply them
> on any client.
>
> diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
> --- a/mercurial/bundle2.py
> +++ b/mercurial/bundle2.py
> @@ -1479,10 +1479,15 @@ def handleobsmarker(op, inpart):
>      tr = op.gettransaction()
>      markerdata = inpart.read()
>      if op.ui.config('experimental', 'obsmarkers-exchange-debug', False):
>          op.ui.write(('obsmarker-exchange: %i bytes received\n')
>                      % len(markerdata))
> +    # The merge marker call will crash if marker creation is not enabled.
> +    # we want to avoid this if the part is advisory.
> +    if not inpart.mandatory and op.repo.obsstore.readonly:
> +        op.repo.ui.debug('ignoring obsolescence markers, feature no enabled')
> +        return
>      new = op.repo.obsstore.mergemarkers(tr, markerdata)
>      if new:
>          op.repo.ui.status(_('%i new obsolescence markers\n') % new)
>      op.records.add('obsmarkers', {'new': new})
>      if op.reply is not None:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -1479,10 +1479,15 @@  def handleobsmarker(op, inpart):
     tr = op.gettransaction()
     markerdata = inpart.read()
     if op.ui.config('experimental', 'obsmarkers-exchange-debug', False):
         op.ui.write(('obsmarker-exchange: %i bytes received\n')
                     % len(markerdata))
+    # The merge marker call will crash if marker creation is not enabled.
+    # we want to avoid this if the part is advisory.
+    if not inpart.mandatory and op.repo.obsstore.readonly:
+        op.repo.ui.debug('ignoring obsolescence markers, feature no enabled')
+        return
     new = op.repo.obsstore.mergemarkers(tr, markerdata)
     if new:
         op.repo.ui.status(_('%i new obsolescence markers\n') % new)
     op.records.add('obsmarkers', {'new': new})
     if op.reply is not None: