Patchwork D6623: py3: store _origdoc as str

login
register
mail settings
Submitter phabricator
Date July 9, 2019, 7:16 a.m.
Message ID <differential-rev-PHID-DREV-uh2rx4khygezgahtjxxc-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/40846/
State Superseded
Headers show

Comments

phabricator - July 9, 2019, 7:16 a.m.
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Since __doc__ is str, it seems natural that _origdoc also is.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/show.py
  mercurial/registrar.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel
phabricator - July 10, 2019, 4:32 p.m.
martinvonz added inline comments.

INLINE COMMENTS

> show.py:463
>      for key in sorted(showview._table.keys()):
> -        entries.append(pycompat.sysstr('    %s   %s' % (
> -            key.ljust(longest), showview._table[key]._origdoc)))
> +        entries.append(pycompat.sysstr('    %s   %s') % (
> +            pycompat.sysstr(key.ljust(longest)), showview._table[key]._origdoc))

Hmm, I guess I should have just used r'' here. I'll update that.

REPOSITORY
  rHG Mercurial

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

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

To: martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/registrar.py b/mercurial/registrar.py
--- a/mercurial/registrar.py
+++ b/mercurial/registrar.py
@@ -64,8 +64,8 @@ 
             raise error.ProgrammingError(msg)
 
         if func.__doc__ and not util.safehasattr(func, '_origdoc'):
-            doc = pycompat.sysbytes(func.__doc__).strip()
-            func._origdoc = doc
+            func._origdoc = func.__doc__.strip()
+            doc = pycompat.sysbytes(func._origdoc)
             func.__doc__ = pycompat.sysstr(self._formatdoc(decl, doc))
 
         self._table[name] = func
diff --git a/hgext/show.py b/hgext/show.py
--- a/hgext/show.py
+++ b/hgext/show.py
@@ -460,8 +460,8 @@ 
     longest = max(map(len, showview._table.keys()))
     entries = []
     for key in sorted(showview._table.keys()):
-        entries.append(pycompat.sysstr('    %s   %s' % (
-            key.ljust(longest), showview._table[key]._origdoc)))
+        entries.append(pycompat.sysstr('    %s   %s') % (
+            pycompat.sysstr(key.ljust(longest)), showview._table[key]._origdoc))
 
     cmdtable['show'][0].__doc__ = pycompat.sysstr('%s\n\n%s\n    ') % (
         cmdtable['show'][0].__doc__.rstrip(),