mercurial/obsolete.py
changeset 38708 ff1182d166a2
parent 38707 6b5ca1d0aa1e
child 38783 e7aa113b14f7
equal deleted inserted replaced
38707:6b5ca1d0aa1e 38708:ff1182d166a2
    78     error,
    78     error,
    79     node,
    79     node,
    80     obsutil,
    80     obsutil,
    81     phases,
    81     phases,
    82     policy,
    82     policy,
       
    83     pycompat,
    83     util,
    84     util,
    84 )
    85 )
    85 from .utils import dateutil
    86 from .utils import dateutil
    86 
    87 
    87 parsers = policy.importmod(r'parsers')
    88 parsers = policy.importmod(r'parsers')
   598                 raise ValueError(succ)
   599                 raise ValueError(succ)
   599         if prec in succs:
   600         if prec in succs:
   600             raise ValueError(_('in-marker cycle with %s') % node.hex(prec))
   601             raise ValueError(_('in-marker cycle with %s') % node.hex(prec))
   601 
   602 
   602         metadata = tuple(sorted(metadata.iteritems()))
   603         metadata = tuple(sorted(metadata.iteritems()))
       
   604         for k, v in metadata:
       
   605             try:
       
   606                 # might be better to reject non-ASCII keys
       
   607                 k.decode('utf-8')
       
   608                 v.decode('utf-8')
       
   609             except UnicodeDecodeError:
       
   610                 raise error.ProgrammingError(
       
   611                     'obsstore metadata must be valid UTF-8 sequence '
       
   612                     '(key = %r, value = %r)'
       
   613                     % (pycompat.bytestr(k), pycompat.bytestr(v)))
   603 
   614 
   604         marker = (bytes(prec), tuple(succs), int(flag), metadata, date, parents)
   615         marker = (bytes(prec), tuple(succs), int(flag), metadata, date, parents)
   605         return bool(self.add(transaction, [marker]))
   616         return bool(self.add(transaction, [marker]))
   606 
   617 
   607     def add(self, transaction, markers):
   618     def add(self, transaction, markers):