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

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Oct 15 06:56:01 CDT 2015


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at 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.

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:


More information about the Mercurial-devel mailing list