[PATCH 2 of 3] registrar: add a method to merge registrar instances
Yuya Nishihara
yuya at tcha.org
Wed Jan 2 00:48:52 UTC 2019
On Sun, 30 Dec 2018 22:55:08 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison at yahoo.com>
> # Date 1546224746 18000
> # Sun Dec 30 21:52:26 2018 -0500
> # Node ID 94d4ffb62049c77f4631ae76732765b17033d2dd
> # Parent a567c612e90996a1a6410c0400634447405df996
> registrar: add a method to merge registrar instances
> + def _merge(self, registrarbase):
> + """Merge the entries of the given registrar object into this one.
> +
> + The other registrar object must not contain any entries already in the
> + current one, or a ProgrammmingError is raised. Additionally, the types
> + of the two registrars must match.
> + """
> + if type(self) != type(registrarbase):
Nit: isinstance(registrarbase, type(self)) is preferred unless we have to
require exact match.
> + dups = set(registrarbase._table.keys()).intersection(self._table.keys())
Nit: keys() can be omitted.
More information about the Mercurial-devel
mailing list