This is an archive of the discontinued Mercurial Phabricator instance.

convert: refactor authormap into separate function for outside use
ClosedPublic

Authored by joerg.sonnenberger on Dec 27 2019, 3:10 PM.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

pulkit added a subscriber: pulkit.Dec 30 2019, 8:19 AM
pulkit added inline comments.
hgext/convert/convcmd.py
481

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

pulkit added inline comments.Jan 8 2020, 7:06 AM
hgext/convert/convcmd.py
58

We disallow usage of default mutable arguments. Hence test-check-code.t says hi.

+  hgext/convert/convcmd.py:58:
+   > def readauthormap(ui, authorfile, authors={}):
+   don't use mutable default arguments
pulkit accepted this revision.Jan 17 2020, 9:42 AM
This revision is now accepted and ready to land.Jan 17 2020, 9:42 AM

Amending the following in flight to make test-check-format.t (or black) happy:

diff --git a/hgext/convert/convcmd.py b/hgext/convert/convcmd.py
--- a/hgext/convert/convcmd.py
+++ b/hgext/convert/convcmd.py
@@ -55,6 +55,7 @@ svn_source = subversion.svn_source
 
 orig_encoding = b'ascii'
 
+
 def readauthormap(ui, authorfile, authors=None):
     if authors is None:
         authors = {}
@@ -84,6 +85,7 @@ def readauthormap(ui, authorfile, author
             ui.status(m % (srcauthor, authors[srcauthor], dstauthor))
     return authors
 
+
 def recode(s):
     if isinstance(s, pycompat.unicode):
         return s.encode(pycompat.sysstr(orig_encoding), 'replace')