[PATCH 5 of 5] bundle2.bundlepart: remove detection of mandatory bit from parttype
Eric Sumner
ericsumner at fb.com
Tue Dec 16 15:57:34 CST 2014
# HG changeset patch
# User Eric Sumner <ericsumner at fb.com>
# Date 1418766795 28800
# Tue Dec 16 13:53:15 2014 -0800
# Node ID 78a3d81227cbda2bfe5dcc134b8f16a20ab3c7e9
# Parent 9729f1cb29923ab0e4f2bad7a0b8193dbbd87a70
bundle2.bundlepart: remove detection of mandatory bit from parttype
Encoding whether or not a part is mandatory in the capitalization of the
parttype is unintuitive and error-prone. This sequence of patches separates
these concerns in the API to reduce programmer error and pave the way for
a potential change in how this information is transmitted over the wire.
This diff removes the ability to use a capitalized parttype to indicate a
mandatory part, instead requiring it to be set via a
separate parameter/property. In order to provide a transition period for
extension authors, it may make sense to delay applying this patch for a few
weeks.
diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -588,7 +588,7 @@
"""
def __init__(self, parttype, mandatoryparams=(), advisoryparams=(),
- data='', mandatory = 'UNSPECIFIED'):
+ data='', mandatory = False):
self.id = None
self.type = parttype
self._data = data
@@ -605,10 +605,7 @@
# - False: currently generated,
# - True: generation done.
self._generated = None
- if mandatory is 'UNSPECIFIED':
- self._mandatory = None
- else:
- self._mandatory = bool(mandatory)
+ self._mandatory = bool(mandatory)
# methods used to defines the part content
def __setdata(self, data):
@@ -631,11 +628,7 @@
@property
def mandatory(self):
- if self._mandatory is None:
- # remove this autodetect once everything uses the new API
- return self.type != self.type.lower()
- else:
- return self._mandatory
+ return self._mandatory
@mandatory.setter
def mandatory(self, value):
More information about the Mercurial-devel
mailing list