Patchwork D3301: fix: use sysstrs for command template formatting

login
register
mail settings
Submitter phabricator
Date April 12, 2018, 9:16 p.m.
Message ID <differential-rev-PHID-DREV-4bgb4coc53c7g4zlezfo-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/30836/
State Superseded
Headers show

Comments

phabricator - April 12, 2018, 9:16 p.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This lets us keep using the .format() interface, which I think on the
  whole I'd like to keep because it makes the configuration a little
  nicer.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/fix.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel
phabricator - April 13, 2018, 12:51 p.m.
yuja requested changes to this revision.
yuja added a comment.
This revision now requires changes to proceed.


  sysstr -> sysbytes can't round trip, and `unicode.format(...=bytes)` wouldn't
  work as expected.
  
  Let me check if we can use templater here.

REPOSITORY
  rHG Mercurial

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

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

Patch

diff --git a/hgext/fix.py b/hgext/fix.py
--- a/hgext/fix.py
+++ b/hgext/fix.py
@@ -540,12 +540,14 @@ 
         May return None if there is no appropriate command to run for the given
         parameters.
         """
-        parts = [self._command.format(rootpath=path,
-                                      basename=os.path.basename(path))]
+        parts = [pycompat.sysstr(self._command).format(
+            rootpath=path,
+            basename=os.path.basename(path))]
         if self._linerange:
             if not ranges:
                 # No line ranges to fix, so don't run the fixer.
                 return None
             for first, last in ranges:
-                parts.append(self._linerange.format(first=first, last=last))
-        return ' '.join(parts)
+                parts.append(pycompat.sysstr(self._linerange).format(
+                    first=first, last=last))
+        return ' '.join(pycompat.sysbytes(b) for b in parts)