Patchwork [1,of,3,V2] py3: explicitly convert a list to bytes to pass in ui.debug

login
register
mail settings
Submitter Pulkit Goyal
Date May 15, 2017, 5:50 p.m.
Message ID <d186d8361d0526413dd1.1494870646@workspace>
Download mbox | patch
Permalink /patch/20628/
State Accepted
Headers show

Comments

Pulkit Goyal - May 15, 2017, 5:50 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1493837589 -19800
#      Thu May 04 00:23:09 2017 +0530
# Node ID d186d8361d0526413dd1399e92ccdb40f3ca2056
# Parent  1ada3d18e7fbc9069910f2c036992d2f2b28e058
py3: explicitly convert a list to bytes to pass in ui.debug

Here pats is a list obviously. Since we can't pass unicodes to ui.debug, we
have to pass this as bytes.
Augie Fackler - May 15, 2017, 5:56 p.m.
On Mon, May 15, 2017 at 11:20:46PM +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1493837589 -19800
> #      Thu May 04 00:23:09 2017 +0530
> # Node ID d186d8361d0526413dd1399e92ccdb40f3ca2056
> # Parent  1ada3d18e7fbc9069910f2c036992d2f2b28e058
> py3: explicitly convert a list to bytes to pass in ui.debug
>
> Here pats is a list obviously. Since we can't pass unicodes to ui.debug, we
> have to pass this as bytes.
>
> diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
> --- a/hgext/largefiles/overrides.py
> +++ b/hgext/largefiles/overrides.py
> @@ -17,6 +17,7 @@
>  from mercurial import (
>      archival,
>      cmdutil,
> +    encoding,

You add the encoding arg here, but never use it? I suspect there
should be a .encode somewhere in here or similar?

>      error,
>      hg,
>      match as matchmod,
> @@ -380,8 +381,8 @@
>              r = origmatchfn(f)
>              return r
>          m.matchfn = lfmatchfn
> -
> -        ui.debug('updated patterns: %s\n' % sorted(pats))
> +        bytespats = '[' + ', '.join(sorted(pats)) + ']'
> +        ui.debug('updated patterns: %s\n' % bytespats)
>          return m, pats
>
>      # For hg log --patch, the match object is used in two different senses:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Yuya Nishihara - May 16, 2017, 1:26 p.m.
On Mon, 15 May 2017 13:56:13 -0400, Augie Fackler wrote:
> On Mon, May 15, 2017 at 11:20:46PM +0530, Pulkit Goyal wrote:
> > # HG changeset patch
> > # User Pulkit Goyal <7895pulkit@gmail.com>
> > # Date 1493837589 -19800
> > #      Thu May 04 00:23:09 2017 +0530
> > # Node ID d186d8361d0526413dd1399e92ccdb40f3ca2056
> > # Parent  1ada3d18e7fbc9069910f2c036992d2f2b28e058
> > py3: explicitly convert a list to bytes to pass in ui.debug
> >
> > Here pats is a list obviously. Since we can't pass unicodes to ui.debug, we
> > have to pass this as bytes.
> >
> > diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
> > --- a/hgext/largefiles/overrides.py
> > +++ b/hgext/largefiles/overrides.py
> > @@ -17,6 +17,7 @@
> >  from mercurial import (
> >      archival,
> >      cmdutil,
> > +    encoding,
> 
> You add the encoding arg here, but never use it? I suspect there
> should be a .encode somewhere in here or similar?

Perhaps it's remainder of V1.

> > @@ -380,8 +381,8 @@
> >              r = origmatchfn(f)
> >              return r
> >          m.matchfn = lfmatchfn
> > -
> > -        ui.debug('updated patterns: %s\n' % sorted(pats))
> > +        bytespats = '[' + ', '.join(sorted(pats)) + ']'
> > +        ui.debug('updated patterns: %s\n' % bytespats)

This changes the test output, but I think that's okay. Maybe we can simply
remove '[' ']', too.

  $ hg --debug log -T '{rev}: {desc}\n' ../sub/anotherlarge
-  updated patterns: ['../.hglf/sub/../sub/anotherlarge', '../sub/anotherlarge']
+  updated patterns: [../.hglf/sub/../sub/anotherlarge, ../sub/anotherlarge]

Patch

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -17,6 +17,7 @@ 
 from mercurial import (
     archival,
     cmdutil,
+    encoding,
     error,
     hg,
     match as matchmod,
@@ -380,8 +381,8 @@ 
             r = origmatchfn(f)
             return r
         m.matchfn = lfmatchfn
-
-        ui.debug('updated patterns: %s\n' % sorted(pats))
+        bytespats = '[' + ', '.join(sorted(pats)) + ']'
+        ui.debug('updated patterns: %s\n' % bytespats)
         return m, pats
 
     # For hg log --patch, the match object is used in two different senses: