Patchwork D6042: py3: convert filtername to str if it's None

login
register
mail settings
Submitter phabricator
Date March 2, 2019, 12:13 a.m.
Message ID <differential-rev-PHID-DREV-ebdze65ahf5wsexnky5j-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/38987/
State Superseded
Headers show

Comments

phabricator - March 2, 2019, 12:13 a.m.
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  I have not called pycompat.bytestr() and rather converted the value there
  because I am starting to get concerned about the function call overhead of all
  this bytes to str or vive versa convert functions.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/branchmap.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel
Yuya Nishihara - March 2, 2019, 1:34 a.m.
> +        filtername = repo.filtername
> +        if filtername is None:
> +            filtername = 'None'
>          repo.ui.log('branchcache', 'updated %s branch cache in %.4f seconds\n',
> -                    repo.filtername, duration)
> +                    filtername, duration)

Perhaps, we can use %r instead. It's just logging, we wouldn't care the output
format. Or simply, `repo.filtername or b'None'`.
phabricator - March 2, 2019, 1:36 a.m.
yuja added a comment.


  > +        filtername = repo.filtername
  >  +        if filtername is None:
  >  +            filtername = 'None'
  > 
  >   repo.ui.log('branchcache', 'updated %s branch cache in %.4f seconds\n',
  > 
  > - repo.filtername, duration) +                    filtername, duration)
  
  Perhaps, we can use %r instead. It's just logging, we wouldn't care the output
  format. Or simply, `repo.filtername or b'None'`.

REPOSITORY
  rHG Mercurial

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

To: pulkit, #hg-reviewers
Cc: yuja, mercurial-devel

Patch

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -359,8 +359,11 @@ 
         self.filteredhash = scmutil.filteredhash(repo, self.tiprev)
 
         duration = util.timer() - starttime
+        filtername = repo.filtername
+        if filtername is None:
+            filtername = 'None'
         repo.ui.log('branchcache', 'updated %s branch cache in %.4f seconds\n',
-                    repo.filtername, duration)
+                    filtername, duration)
 
         self.write(repo)