[PATCH 06 of 15] commitctx: return a richer object from _prepare_files
Yuya Nishihara
yuya at tcha.org
Sat Aug 8 03:26:07 UTC 2020
On Wed, 29 Jul 2020 18:57:36 +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at octobus.net>
> # Date 1595684952 -7200
> # Sat Jul 25 15:49:12 2020 +0200
> # Node ID 88cc2b7a810243e8c101933fd99778ce772ac316
> # Parent 6b4ada6dca3ff5591c5dea32ffbe2fa22f4e5ed7
> # EXP-Topic files-change
> # Available At https://foss.heptapod.net/octobus/mercurial-devel/
> # hg pull https://foss.heptapod.net/octobus/mercurial-devel/ -r 88cc2b7a8102
> commitctx: return a richer object from _prepare_files
Queued the remainder, thanks.
> +class ChangingFiles(object):
> + """A class recording the changes made to a file by a revision
> + """
> +
> + def __init__(
> + self, touched=(), added=(), removed=(), p1_copies=(), p2_copies=(),
> + ):
> + self._added = set(added)
> + self._removed = set(removed)
> + self._touched = set(touched)
> + self._touched.update(self._added)
> + self._touched.update(self._removed)
> + self._p1_copies = dict(p1_copies)
> + self._p2_copies = dict(p2_copies)
> +
> + @property
> + def added(self):
> + return frozenset(self._added)
I generally avoid using @property function that does non-trivial work per call.
Does this frozenset business really matter?
> + def mark_added(self, filename):
> + self._added.add(filename)
> + self._touched.add(filename)
> + def mark_copied_from_p1(self, source, dest):
> + self._p1_copies[dest] = source
It doesn't make sense that mark_added() updates both added and touched,
but mark_copied() doesn't.
Since ChangingFiles is basically a data object, I think sanity check can be
split into a function, and called occasionally e.g. before serializing the
metadata.
More information about the Mercurial-devel
mailing list