Patchwork [07,of,10] py3: convert bool variables to bytes before passing into ui.debug()

login
register
mail settings
Submitter Pulkit Goyal
Date May 31, 2017, 9:47 p.m.
Message ID <25320a995bedaaabc4e7.1496267223@workspace>
Download mbox | patch
Permalink /patch/21102/
State Accepted
Headers show

Comments

Pulkit Goyal - May 31, 2017, 9:47 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1496263466 -19800
#      Thu Jun 01 02:14:26 2017 +0530
# Node ID 25320a995bedaaabc4e7a7f40651d07a9bfb4803
# Parent  471f42c23f0c8793ee8bcd589940eb28a6d32106
py3: convert bool variables to bytes before passing into ui.debug()

We can't pass unicodes to ui.debug() and hence we need to convert things to
bytes before passing them.
Augie Fackler - June 1, 2017, 2:30 p.m.
On Thu, Jun 01, 2017 at 03:17:03AM +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1496263466 -19800
> #      Thu Jun 01 02:14:26 2017 +0530
> # Node ID 25320a995bedaaabc4e7a7f40651d07a9bfb4803
> # Parent  471f42c23f0c8793ee8bcd589940eb28a6d32106
> py3: convert bool variables to bytes before passing into ui.debug()

Queued 1-3, 5-7. Waiting on the rest since I had comments on 4, and
the last three add tests that I assume would be broken without 4. Thanks!

>
> We can't pass unicodes to ui.debug() and hence we need to convert things to
> bytes before passing them.
>
> diff --git a/mercurial/merge.py b/mercurial/merge.py
> --- a/mercurial/merge.py
> +++ b/mercurial/merge.py
> @@ -807,9 +807,12 @@
>          ret = copies.mergecopies(repo, wctx, p2, pa)
>          copy, movewithdir, diverge, renamedelete, dirmove = ret
>
> +    boolbm = pycompat.sysbytes(bool(branchmerge))
> +    boolf = pycompat.sysbytes(bool(force))
> +    boolm = pycompat.sysbytes(bool(matcher))
>      repo.ui.note(_("resolving manifests\n"))
>      repo.ui.debug(" branchmerge: %s, force: %s, partial: %s\n"
> -                  % (bool(branchmerge), bool(force), bool(matcher)))
> +                  % (boolbm, boolf, boolm))
>      repo.ui.debug(" ancestor: %s, local: %s, remote: %s\n" % (pa, wctx, p2))
>
>      m1, m2, ma = wctx.manifest(), p2.manifest(), pa.manifest()
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -807,9 +807,12 @@ 
         ret = copies.mergecopies(repo, wctx, p2, pa)
         copy, movewithdir, diverge, renamedelete, dirmove = ret
 
+    boolbm = pycompat.sysbytes(bool(branchmerge))
+    boolf = pycompat.sysbytes(bool(force))
+    boolm = pycompat.sysbytes(bool(matcher))
     repo.ui.note(_("resolving manifests\n"))
     repo.ui.debug(" branchmerge: %s, force: %s, partial: %s\n"
-                  % (bool(branchmerge), bool(force), bool(matcher)))
+                  % (boolbm, boolf, boolm))
     repo.ui.debug(" ancestor: %s, local: %s, remote: %s\n" % (pa, wctx, p2))
 
     m1, m2, ma = wctx.manifest(), p2.manifest(), pa.manifest()