[Changed Subscribers] D9090: changing-files: rework the way we store changed files in side-data

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Thu Oct 1 14:33:12 UTC 2020


pulkit added inline comments.

INLINE COMMENTS

> metadata.py:385
>  def encode_files_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
> +    touched = files.touched
> +    added = files.added

nit: I guess we can directly use `files.*` attributes.

> metadata.py:389
>  def decode_files_sidedata(changelogrevision, sidedata):
> -    """Return a ChangingFiles instance from a changelogrevision using sidata
> -    """

nit: we can preserve this line of documentation.

> metadata.py:480
>      filesremoved = computechangesetfilesremoved(ctx)
> -    sidedata = {}
> -    if any([filescopies, filesadded, filesremoved]):
> -        sortedfiles = sorted(ctx.files())
> -        p1copies, p2copies = filescopies
> -        p1copies = encodecopies(sortedfiles, p1copies)
> -        p2copies = encodecopies(sortedfiles, p2copies)
> -        filesadded = encodefileindices(sortedfiles, filesadded)
> -        filesremoved = encodefileindices(sortedfiles, filesremoved)
> -        if p1copies:
> -            sidedata[sidedatamod.SD_P1COPIES] = p1copies
> -        if p2copies:
> -            sidedata[sidedatamod.SD_P2COPIES] = p2copies
> -        if filesadded:
> -            sidedata[sidedatamod.SD_FILESADDED] = filesadded
> -        if filesremoved:
> -            sidedata[sidedatamod.SD_FILESREMOVED] = filesremoved
> -    return sidedata
> +    filesmerged = computechangesetfilesmerged(ctx)
> +    files = ChangingFiles()

This diff can ideally be in a different patch as it's not related to storage rework.

> sidedata.py:56
>  SD_FILESREMOVED = 11
> +SD_FILES = 12
>  

Coming from documenting mergestate constants, I think it will be nice to have documentation for all these keys as a followup.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D9090/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D9090

To: marmoute, #hg-reviewers
Cc: pulkit, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20201001/bc5d481f/attachment.html>


More information about the Mercurial-patches mailing list