comparison mercurial/changelog.py @ 45324:6c56277317c2

commitctx: directly pass a ChangingFiles object to changelog.add We pass the rich object to the changelog and it read the field it needs.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 25 Jul 2020 15:55:09 +0200
parents b3040b6739ce
children c6eea5804551
comparison
equal deleted inserted replaced
45323:aea6a812f7cb 45324:6c56277317c2
522 p1, 522 p1,
523 p2, 523 p2,
524 user, 524 user,
525 date=None, 525 date=None,
526 extra=None, 526 extra=None,
527 p1copies=None,
528 p2copies=None,
529 filesadded=None,
530 filesremoved=None,
531 ): 527 ):
532 # Convert to UTF-8 encoded bytestrings as the very first 528 # Convert to UTF-8 encoded bytestrings as the very first
533 # thing: calling any method on a localstr object will turn it 529 # thing: calling any method on a localstr object will turn it
534 # into a str object and the cached UTF-8 string is thus lost. 530 # into a str object and the cached UTF-8 string is thus lost.
535 user, desc = encoding.fromlocal(user), encoding.fromlocal(desc) 531 user, desc = encoding.fromlocal(user), encoding.fromlocal(desc)
557 del extra[b"branch"] 553 del extra[b"branch"]
558 elif branch in (b".", b"null", b"tip"): 554 elif branch in (b".", b"null", b"tip"):
559 raise error.StorageError( 555 raise error.StorageError(
560 _(b'the name \'%s\' is reserved') % branch 556 _(b'the name \'%s\' is reserved') % branch
561 ) 557 )
562 sortedfiles = sorted(files) 558 sortedfiles = sorted(files.touched)
563 sidedata = None 559 sidedata = None
564 if self._copiesstorage == b'changeset-sidedata': 560 if self._copiesstorage == b'changeset-sidedata':
565 sidedata = {} 561 sidedata = {}
562 p1copies = files.copied_from_p1
566 if p1copies: 563 if p1copies:
567 p1copies = metadata.encodecopies(sortedfiles, p1copies) 564 p1copies = metadata.encodecopies(sortedfiles, p1copies)
568 sidedata[sidedatamod.SD_P1COPIES] = p1copies 565 sidedata[sidedatamod.SD_P1COPIES] = p1copies
566 p2copies = files.copied_from_p2
569 if p2copies: 567 if p2copies:
570 p2copies = metadata.encodecopies(sortedfiles, p2copies) 568 p2copies = metadata.encodecopies(sortedfiles, p2copies)
571 sidedata[sidedatamod.SD_P2COPIES] = p2copies 569 sidedata[sidedatamod.SD_P2COPIES] = p2copies
570 filesadded = files.added
572 if filesadded: 571 if filesadded:
573 filesadded = metadata.encodefileindices(sortedfiles, filesadded) 572 filesadded = metadata.encodefileindices(sortedfiles, filesadded)
574 sidedata[sidedatamod.SD_FILESADDED] = filesadded 573 sidedata[sidedatamod.SD_FILESADDED] = filesadded
574 filesremoved = files.removed
575 if filesremoved: 575 if filesremoved:
576 filesremoved = metadata.encodefileindices( 576 filesremoved = metadata.encodefileindices(
577 sortedfiles, filesremoved 577 sortedfiles, filesremoved
578 ) 578 )
579 sidedata[sidedatamod.SD_FILESREMOVED] = filesremoved 579 sidedata[sidedatamod.SD_FILESREMOVED] = filesremoved