comparison mercurial/metadata.py @ 45325:c6eea5804551

commitctx: extract sidedata encoding inside its own function This part of the code is quite independent from the rest. Thank to the new ChangingFiles object, moving with the rest of the sidedata code (in metadata.py) is simple. The changelog.add method is simply passing the `files` object to the new function. It will be easy to increase/change the data we gather and encode without impacting the changelog method.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 25 Jul 2020 16:02:26 +0200
parents aea6a812f7cb
children 1f50bcc96595
comparison
equal deleted inserted replaced
45324:6c56277317c2 45325:c6eea5804551
250 return subset 250 return subset
251 except (ValueError, IndexError): 251 except (ValueError, IndexError):
252 # Perhaps someone had chosen the same key name (e.g. "added") and 252 # Perhaps someone had chosen the same key name (e.g. "added") and
253 # used different syntax for the value. 253 # used different syntax for the value.
254 return None 254 return None
255
256
257 def encode_copies_sidedata(files):
258 sortedfiles = sorted(files.touched)
259 sidedata = {}
260 p1copies = files.copied_from_p1
261 if p1copies:
262 p1copies = encodecopies(sortedfiles, p1copies)
263 sidedata[sidedatamod.SD_P1COPIES] = p1copies
264 p2copies = files.copied_from_p2
265 if p2copies:
266 p2copies = encodecopies(sortedfiles, p2copies)
267 sidedata[sidedatamod.SD_P2COPIES] = p2copies
268 filesadded = files.added
269 if filesadded:
270 filesadded = encodefileindices(sortedfiles, filesadded)
271 sidedata[sidedatamod.SD_FILESADDED] = filesadded
272 filesremoved = files.removed
273 if filesremoved:
274 filesremoved = encodefileindices(sortedfiles, filesremoved)
275 sidedata[sidedatamod.SD_FILESREMOVED] = filesremoved
276 if not sidedata:
277 sidedata = None
278 return sidedata
255 279
256 280
257 def _getsidedata(srcrepo, rev): 281 def _getsidedata(srcrepo, rev):
258 ctx = srcrepo[rev] 282 ctx = srcrepo[rev]
259 filescopies = computechangesetcopies(ctx) 283 filescopies = computechangesetcopies(ctx)