comparison mercurial/changelog.py @ 45275:b3040b6739ce

commitctx: extract copy information encoding into extra into commit.py The encoding of copy information into extra has multiple subcases and become quite complicated (eg: empty list can be explicitly or implicitly stored for example). In addition, it is niche experimental feature since as it affect the hash, it is only suitable for user who don't mercurial for storage server side (ie: Google). Having this complexity part of the changelog will get in the way of further cleanup. We could have to either move more of that logic into the changelog or to move or extract more of the logic at the higher level. We take the second approach and start gather logic in dedicated function in commit.py.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 25 Jul 2020 15:13:25 +0200
parents 4c1d39215034
children 6c56277317c2
comparison
equal deleted inserted replaced
45274:4cde23ba076e 45275:b3040b6739ce
559 raise error.StorageError( 559 raise error.StorageError(
560 _(b'the name \'%s\' is reserved') % branch 560 _(b'the name \'%s\' is reserved') % branch
561 ) 561 )
562 sortedfiles = sorted(files) 562 sortedfiles = sorted(files)
563 sidedata = None 563 sidedata = None
564 if extra is not None: 564 if self._copiesstorage == b'changeset-sidedata':
565 for name in (
566 b'p1copies',
567 b'p2copies',
568 b'filesadded',
569 b'filesremoved',
570 ):
571 extra.pop(name, None)
572 if p1copies is not None:
573 p1copies = metadata.encodecopies(sortedfiles, p1copies)
574 if p2copies is not None:
575 p2copies = metadata.encodecopies(sortedfiles, p2copies)
576 if filesadded is not None:
577 filesadded = metadata.encodefileindices(sortedfiles, filesadded)
578 if filesremoved is not None:
579 filesremoved = metadata.encodefileindices(sortedfiles, filesremoved)
580 if self._copiesstorage == b'extra':
581 extrasentries = p1copies, p2copies, filesadded, filesremoved
582 if extra is None and any(x is not None for x in extrasentries):
583 extra = {}
584 if p1copies is not None:
585 extra[b'p1copies'] = p1copies
586 if p2copies is not None:
587 extra[b'p2copies'] = p2copies
588 if filesadded is not None:
589 extra[b'filesadded'] = filesadded
590 if filesremoved is not None:
591 extra[b'filesremoved'] = filesremoved
592 elif self._copiesstorage == b'changeset-sidedata':
593 sidedata = {} 565 sidedata = {}
594 if p1copies: 566 if p1copies:
567 p1copies = metadata.encodecopies(sortedfiles, p1copies)
595 sidedata[sidedatamod.SD_P1COPIES] = p1copies 568 sidedata[sidedatamod.SD_P1COPIES] = p1copies
596 if p2copies: 569 if p2copies:
570 p2copies = metadata.encodecopies(sortedfiles, p2copies)
597 sidedata[sidedatamod.SD_P2COPIES] = p2copies 571 sidedata[sidedatamod.SD_P2COPIES] = p2copies
598 if filesadded: 572 if filesadded:
573 filesadded = metadata.encodefileindices(sortedfiles, filesadded)
599 sidedata[sidedatamod.SD_FILESADDED] = filesadded 574 sidedata[sidedatamod.SD_FILESADDED] = filesadded
600 if filesremoved: 575 if filesremoved:
576 filesremoved = metadata.encodefileindices(
577 sortedfiles, filesremoved
578 )
601 sidedata[sidedatamod.SD_FILESREMOVED] = filesremoved 579 sidedata[sidedatamod.SD_FILESREMOVED] = filesremoved
602 if not sidedata: 580 if not sidedata:
603 sidedata = None 581 sidedata = None
604 582
605 if extra: 583 if extra: