Patchwork [2,of,5] bundle2._processpart: forcing lower-case compare is no longer necessary

login
register
mail settings
Submitter Eric Sumner
Date Dec. 16, 2014, 9:57 p.m.
Message ID <db0ab9e45c6d967d0e0c.1418767051@dev911.prn1.facebook.com>
Download mbox | patch
Permalink /patch/7124/
State Accepted
Delegated to: Pierre-Yves David
Headers show

Comments

Eric Sumner - Dec. 16, 2014, 9:57 p.m.
# HG changeset patch
# User Eric Sumner <ericsumner@fb.com>
# Date 1418416301 28800
#      Fri Dec 12 12:31:41 2014 -0800
# Node ID db0ab9e45c6d967d0e0c07de24db77d84266de33
# Parent  e28406020f46ee791c4c7aa71915ce869c4a579d
bundle2._processpart: forcing lower-case compare is no longer necessary

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.

Since the parttype and mandatory bit are separated in bundle2.unbundlepart
(see previous patch), there is no longer a need to remove the mandatory bit
before working with the parttype.
Pierre-Yves David - Dec. 17, 2014, 1:10 a.m.
On 12/16/2014 01:57 PM, Eric Sumner wrote:
> # HG changeset patch
> # User Eric Sumner <ericsumner@fb.com>
> # Date 1418416301 28800
> #      Fri Dec 12 12:31:41 2014 -0800
> # Node ID db0ab9e45c6d967d0e0c07de24db77d84266de33
> # Parent  e28406020f46ee791c4c7aa71915ce869c4a579d
> bundle2._processpart: forcing lower-case compare is no longer necessary

The first two are pushed to the clowncopter. I'm waiting for a new 
series with reworked version of the other ones.

Patch

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -319,19 +319,16 @@ 
     The part is guaranteed to have been fully consumed when the function exits
     (even if an exception is raised)."""
     try:
-        parttype = part.type
-        # part key are matched lower case
-        key = parttype.lower()
         try:
-            handler = parthandlermapping.get(key)
+            handler = parthandlermapping.get(part.type)
             if handler is None:
-                raise error.UnsupportedPartError(parttype=key)
-            op.ui.debug('found a handler for part %r\n' % parttype)
+                raise error.UnsupportedPartError(parttype=part.type)
+            op.ui.debug('found a handler for part %r\n' % part.type)
             unknownparams = part.mandatorykeys - handler.params
             if unknownparams:
                 unknownparams = list(unknownparams)
                 unknownparams.sort()
-                raise error.UnsupportedPartError(parttype=key,
+                raise error.UnsupportedPartError(parttype=part.type,
                                                params=unknownparams)
         except error.UnsupportedPartError, exc:
             if part.mandatory: # mandatory parts