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): |