Show More
@@ -328,7 +328,7 b' def _fm0decodemeta(data):' | |||
|
328 | 328 | # |
|
329 | 329 | # - remaining bytes: the metadata, each (key, value) pair after the other. |
|
330 | 330 | _fm1version = 1 |
|
331 |
_fm1fixed = b'>IdhHBBB |
|
|
331 | _fm1fixed = b'>IdhHBBB' | |
|
332 | 332 | _fm1nodesha1 = b'20s' |
|
333 | 333 | _fm1nodesha256 = b'32s' |
|
334 | 334 | _fm1nodesha1size = _calcsize(_fm1nodesha1) |
@@ -360,48 +360,36 b' def _fm1purereadmarkers(data, off, stop)' | |||
|
360 | 360 | while off < stop: |
|
361 | 361 | # read fixed part |
|
362 | 362 | o1 = off + fsize |
|
363 |
t, secs, tz, flags, numsuc, numpar, nummeta |
|
|
363 | t, secs, tz, flags, numsuc, numpar, nummeta = ufixed(data[off:o1]) | |
|
364 | 364 | |
|
365 | 365 | if flags & sha2flag: |
|
366 | # FIXME: prec was read as a SHA1, needs to be amended | |
|
366 | nodefmt = sha2fmt | |
|
367 | nodesize = sha2size | |
|
368 | else: | |
|
369 | nodefmt = sha1fmt | |
|
370 | nodesize = sha1size | |
|
367 | 371 | |
|
368 | # read 0 or more successors | |
|
369 | if numsuc == 1: | |
|
370 | o2 = o1 + sha2size | |
|
371 | sucs = (data[o1:o2],) | |
|
372 | else: | |
|
373 | o2 = o1 + sha2size * numsuc | |
|
374 | sucs = unpack(sha2fmt * numsuc, data[o1:o2]) | |
|
372 | (prec,) = unpack(nodefmt, data[o1 : o1 + nodesize]) | |
|
373 | o1 += nodesize | |
|
375 | 374 | |
|
376 | # read parents | |
|
377 |
|
|
|
378 |
|
|
|
379 | parents = None | |
|
380 | elif numpar == 1: | |
|
381 | o3 = o2 + sha2size | |
|
382 | parents = (data[o2:o3],) | |
|
383 | else: | |
|
384 | o3 = o2 + sha2size * numpar | |
|
385 | parents = unpack(sha2fmt * numpar, data[o2:o3]) | |
|
375 | # read 0 or more successors | |
|
376 | if numsuc == 1: | |
|
377 | o2 = o1 + nodesize | |
|
378 | sucs = (data[o1:o2],) | |
|
386 | 379 | else: |
|
387 | # read 0 or more successors | |
|
388 | if numsuc == 1: | |
|
389 | o2 = o1 + sha1size | |
|
390 | sucs = (data[o1:o2],) | |
|
391 | else: | |
|
392 | o2 = o1 + sha1size * numsuc | |
|
393 | sucs = unpack(sha1fmt * numsuc, data[o1:o2]) | |
|
380 | o2 = o1 + nodesize * numsuc | |
|
381 | sucs = unpack(nodefmt * numsuc, data[o1:o2]) | |
|
394 | 382 | |
|
395 |
|
|
|
396 |
|
|
|
397 |
|
|
|
398 |
|
|
|
399 |
|
|
|
400 |
|
|
|
401 |
|
|
|
402 |
|
|
|
403 |
|
|
|
404 |
|
|
|
383 | # read parents | |
|
384 | if numpar == noneflag: | |
|
385 | o3 = o2 | |
|
386 | parents = None | |
|
387 | elif numpar == 1: | |
|
388 | o3 = o2 + nodesize | |
|
389 | parents = (data[o2:o3],) | |
|
390 | else: | |
|
391 | o3 = o2 + nodesize * numpar | |
|
392 | parents = unpack(nodefmt * numpar, data[o2:o3]) | |
|
405 | 393 | |
|
406 | 394 | # read metadata |
|
407 | 395 | off = o3 + metasize * nummeta |
@@ -423,7 +411,7 b' def _fm1encodeonemarker(marker):' | |||
|
423 | 411 | if flags & usingsha256: |
|
424 | 412 | _fm1node = _fm1nodesha256 |
|
425 | 413 | numsuc = len(sucs) |
|
426 | numextranodes = numsuc | |
|
414 | numextranodes = 1 + numsuc | |
|
427 | 415 | if parents is None: |
|
428 | 416 | numpar = _fm1parentnone |
|
429 | 417 | else: |
@@ -624,6 +612,7 b' class obsstore(object):' | |||
|
624 | 612 | return True if a new marker have been added, False if the markers |
|
625 | 613 | already existed (no op). |
|
626 | 614 | """ |
|
615 | flag = int(flag) | |
|
627 | 616 | if metadata is None: |
|
628 | 617 | metadata = {} |
|
629 | 618 | if date is None: |
@@ -636,11 +625,18 b' class obsstore(object):' | |||
|
636 | 625 | date = dateutil.makedate() |
|
637 | 626 | else: |
|
638 | 627 | date = dateutil.makedate() |
|
639 | if len(prec) != 20: | |
|
640 |
|
|
|
641 | for succ in succs: | |
|
642 |
|
|
|
643 |
|
|
|
628 | if flag & usingsha256: | |
|
629 | if len(prec) != 32: | |
|
630 | raise ValueError(prec) | |
|
631 | for succ in succs: | |
|
632 | if len(succ) != 32: | |
|
633 | raise ValueError(succ) | |
|
634 | else: | |
|
635 | if len(prec) != 20: | |
|
636 | raise ValueError(prec) | |
|
637 | for succ in succs: | |
|
638 | if len(succ) != 20: | |
|
639 | raise ValueError(succ) | |
|
644 | 640 | if prec in succs: |
|
645 | 641 | raise ValueError( |
|
646 | 642 | 'in-marker cycle with %s' % pycompat.sysstr(node.hex(prec)) |
@@ -659,7 +655,7 b' class obsstore(object):' | |||
|
659 | 655 | % (pycompat.bytestr(k), pycompat.bytestr(v)) |
|
660 | 656 | ) |
|
661 | 657 | |
|
662 |
marker = (bytes(prec), tuple(succs), |
|
|
658 | marker = (bytes(prec), tuple(succs), flag, metadata, date, parents) | |
|
663 | 659 | return bool(self.add(transaction, [marker])) |
|
664 | 660 | |
|
665 | 661 | def add(self, transaction, markers): |
General Comments 0
You need to be logged in to leave comments.
Login now