mercurial/commit.py
changeset 45249 b3040b6739ce
parent 45248 4cde23ba076e
child 45250 efe8a67793b6
equal deleted inserted replaced
45248:4cde23ba076e 45249:b3040b6739ce
    66     with repo.lock(), repo.transaction(b"commit") as tr:
    66     with repo.lock(), repo.transaction(b"commit") as tr:
    67         r = _prepare_files(tr, ctx, error=error, origctx=origctx)
    67         r = _prepare_files(tr, ctx, error=error, origctx=origctx)
    68         mn, files, p1copies, p2copies, filesadded, filesremoved = r
    68         mn, files, p1copies, p2copies, filesadded, filesremoved = r
    69 
    69 
    70         extra = ctx.extra().copy()
    70         extra = ctx.extra().copy()
       
    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             )
    71 
    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)
    75         n = repo.changelog.add(
    89         n = repo.changelog.add(
   405             b'reusing manifest from p1 (listed files ' b'actually unchanged)\n'
   419             b'reusing manifest from p1 (listed files ' b'actually unchanged)\n'
   406         )
   420         )
   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