hgext/remotefilelog/shallowutil.py
changeset 48918 0fe003495f72
parent 48913 f254fc73d956
child 48932 176f1a0d15dc
equal deleted inserted replaced
48917:1672c5af1271 48918:0fe003495f72
   157 
   157 
   158     raise ProgrammingError when metadata key is illegal, or ValueError if
   158     raise ProgrammingError when metadata key is illegal, or ValueError if
   159     length limit is exceeded
   159     length limit is exceeded
   160     """
   160     """
   161     metabuf = b''
   161     metabuf = b''
   162     for k, v in sorted(pycompat.iteritems((metadict or {}))):
   162     for k, v in sorted((metadict or {}).items()):
   163         if len(k) != 1:
   163         if len(k) != 1:
   164             raise error.ProgrammingError(b'packmeta: illegal key: %s' % k)
   164             raise error.ProgrammingError(b'packmeta: illegal key: %s' % k)
   165         if len(v) > 0xFFFE:
   165         if len(v) > 0xFFFE:
   166             raise ValueError(
   166             raise ValueError(
   167                 b'metadata value is too long: 0x%x > 0xfffe' % len(v)
   167                 b'metadata value is too long: 0x%x > 0xfffe' % len(v)
   185 
   185 
   186     This means, METAKEYSIZE and METAKEYSIZE should have integers as values,
   186     This means, METAKEYSIZE and METAKEYSIZE should have integers as values,
   187     and METAKEYFLAG will be dropped if its value is 0.
   187     and METAKEYFLAG will be dropped if its value is 0.
   188     """
   188     """
   189     newmeta = {}
   189     newmeta = {}
   190     for k, v in pycompat.iteritems(metadict or {}):
   190     for k, v in (metadict or {}).items():
   191         expectedtype = _metaitemtypes.get(k, (bytes,))
   191         expectedtype = _metaitemtypes.get(k, (bytes,))
   192         if not isinstance(v, expectedtype):
   192         if not isinstance(v, expectedtype):
   193             raise error.ProgrammingError(b'packmeta: wrong type of key %s' % k)
   193             raise error.ProgrammingError(b'packmeta: wrong type of key %s' % k)
   194         # normalize int to binary buffer
   194         # normalize int to binary buffer
   195         if int in expectedtype:
   195         if int in expectedtype: