comparison mercurial/commit.py @ 45251:0041a42c6f28

commitctx: gather more code dealing with copy-in-extra Now that we have a function that deal with the copy-in-extra special case, we can gather more code meant to deal with this special case. Making the rest of the code simpler.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 25 Jul 2020 15:37:05 +0200
parents efe8a67793b6
children aea6a812f7cb
comparison
equal deleted inserted replaced
45250:efe8a67793b6 45251:0041a42c6f28
146 filesremoved = removed 146 filesremoved = removed
147 filesadded = added 147 filesadded = added
148 148
149 if origctx and origctx.manifestnode() == mn: 149 if origctx and origctx.manifestnode() == mn:
150 touched = origctx.files() 150 touched = origctx.files()
151
152 if not writefilecopymeta:
153 # If writing only to changeset extras, use None to indicate that
154 # no entry should be written. If writing to both, write an empty
155 # entry to prevent the reader from falling back to reading
156 # filelogs.
157 p1copies = p1copies or None
158 p2copies = p2copies or None
159 filesadded = filesadded or None
160 filesremoved = filesremoved or None
161 151
162 return mn, touched, p1copies, p2copies, filesadded, filesremoved 152 return mn, touched, p1copies, p2copies, filesadded, filesremoved
163 153
164 154
165 def _process_files(tr, ctx, error=False): 155 def _process_files(tr, ctx, error=False):
425 415
426 def _extra_with_copies( 416 def _extra_with_copies(
427 repo, extra, files, p1copies, p2copies, filesadded, filesremoved 417 repo, extra, files, p1copies, p2copies, filesadded, filesremoved
428 ): 418 ):
429 """encode copy information into a `extra` dictionnary""" 419 """encode copy information into a `extra` dictionnary"""
420 if not _write_copy_meta(repo)[1]:
421 # If writing only to changeset extras, use None to indicate that
422 # no entry should be written. If writing to both, write an empty
423 # entry to prevent the reader from falling back to reading
424 # filelogs.
425 p1copies = p1copies or None
426 p2copies = p2copies or None
427 filesadded = filesadded or None
428 filesremoved = filesremoved or None
429
430 extrasentries = p1copies, p2copies, filesadded, filesremoved 430 extrasentries = p1copies, p2copies, filesadded, filesremoved
431 if extra is None and any(x is not None for x in extrasentries): 431 if extra is None and any(x is not None for x in extrasentries):
432 extra = {} 432 extra = {}
433 if p1copies is not None: 433 if p1copies is not None:
434 p1copies = metadata.encodecopies(files, p1copies) 434 p1copies = metadata.encodecopies(files, p1copies)