Mercurial > hg
diff 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 |
line wrap: on
line diff
--- a/mercurial/metadata.py Sat Jul 25 15:55:09 2020 +0200 +++ b/mercurial/metadata.py Sat Jul 25 16:02:26 2020 +0200 @@ -254,6 +254,30 @@ return None +def encode_copies_sidedata(files): + sortedfiles = sorted(files.touched) + sidedata = {} + p1copies = files.copied_from_p1 + if p1copies: + p1copies = encodecopies(sortedfiles, p1copies) + sidedata[sidedatamod.SD_P1COPIES] = p1copies + p2copies = files.copied_from_p2 + if p2copies: + p2copies = encodecopies(sortedfiles, p2copies) + sidedata[sidedatamod.SD_P2COPIES] = p2copies + filesadded = files.added + if filesadded: + filesadded = encodefileindices(sortedfiles, filesadded) + sidedata[sidedatamod.SD_FILESADDED] = filesadded + filesremoved = files.removed + if filesremoved: + filesremoved = encodefileindices(sortedfiles, filesremoved) + sidedata[sidedatamod.SD_FILESREMOVED] = filesremoved + if not sidedata: + sidedata = None + return sidedata + + def _getsidedata(srcrepo, rev): ctx = srcrepo[rev] filescopies = computechangesetcopies(ctx)