##// END OF EJS Templates
commitctx: extract copy information encoding into extra into commit.py...
marmoute -
r45809:b3040b67 default
parent child Browse files
Show More
@@ -561,43 +561,21 b' class changelog(revlog.revlog):'
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
@@ -69,6 +69,20 b' def commitctx(repo, ctx, error=False, or'
69
69
70 extra = ctx.extra().copy()
70 extra = ctx.extra().copy()
71
71
72 files = sorted(files)
73 if extra is not None:
74 for name in (
75 b'p1copies',
76 b'p2copies',
77 b'filesadded',
78 b'filesremoved',
79 ):
80 extra.pop(name, None)
81 if repo.changelog._copiesstorage == b'extra':
82 extra = _extra_with_copies(
83 repo, extra, files, p1copies, p2copies, filesadded, filesremoved
84 )
85
72 # update changelog
86 # update changelog
73 repo.ui.note(_(b"committing changelog\n"))
87 repo.ui.note(_(b"committing changelog\n"))
74 repo.changelog.delayupdate(tr)
88 repo.changelog.delayupdate(tr)
@@ -407,3 +421,25 b' def _commit_manifest(tr, linkrev, ctx, m'
407 mn = p1.manifestnode()
421 mn = p1.manifestnode()
408
422
409 return mn
423 return mn
424
425
426 def _extra_with_copies(
427 repo, extra, files, p1copies, p2copies, filesadded, filesremoved
428 ):
429 """encode copy information into a `extra` dictionnary"""
430 extrasentries = p1copies, p2copies, filesadded, filesremoved
431 if extra is None and any(x is not None for x in extrasentries):
432 extra = {}
433 if p1copies is not None:
434 p1copies = metadata.encodecopies(files, p1copies)
435 extra[b'p1copies'] = p1copies
436 if p2copies is not None:
437 p2copies = metadata.encodecopies(files, p2copies)
438 extra[b'p2copies'] = p2copies
439 if filesadded is not None:
440 filesadded = metadata.encodefileindices(files, filesadded)
441 extra[b'filesadded'] = filesadded
442 if filesremoved is not None:
443 filesremoved = metadata.encodefileindices(files, filesremoved)
444 extra[b'filesremoved'] = filesremoved
445 return extra
General Comments 0
You need to be logged in to leave comments. Login now