D7732: convert: refactor authormap into separate function for outside use

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Mon Dec 30 08:19:16 EST 2019


pulkit added inline comments.

INLINE COMMENTS

> convcmd.py:479
>      def readauthormap(self, authorfile):
> -        afile = open(authorfile, b'rb')
> -        for line in afile:
> -
> -            line = line.strip()
> -            if not line or line.startswith(b'#'):
> -                continue
> -
> -            try:
> -                srcauthor, dstauthor = line.split(b'=', 1)
> -            except ValueError:
> -                msg = _(b'ignoring bad line in author map file %s: %s\n')
> -                self.ui.warn(msg % (authorfile, line.rstrip()))
> -                continue
> -
> -            srcauthor = srcauthor.strip()
> -            dstauthor = dstauthor.strip()
> -            if self.authors.get(srcauthor) in (None, dstauthor):
> -                msg = _(b'mapping author %s to %s\n')
> -                self.ui.debug(msg % (srcauthor, dstauthor))
> -                self.authors[srcauthor] = dstauthor
> -                continue
> -
> -            m = _(b'overriding mapping for author %s, was %s, will be %s\n')
> -            self.ui.status(m % (srcauthor, self.authors[srcauthor], dstauthor))
> -
> -        afile.close()
> +        self.authors = readauthormap(self.ui, authorfile)
>  

This will reassign `self.authors` instead of updating it. `readauthormap` is called twice in the `__init__()`.

REPOSITORY
  rHG Mercurial

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

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

To: joerg.sonnenberger, #hg-reviewers
Cc: pulkit, mercurial-devel


More information about the Mercurial-devel mailing list