Submitter | Yuya Nishihara |
---|---|
Date | July 27, 2017, 2:35 p.m. |
Message ID | <26e41875da7be30b96b9.1501166103@mimosa> |
Download | mbox | patch |
Permalink | /patch/22565/ |
State | Accepted |
Headers | show |
Comments
Looks good to me. I also have a local fix that ignores warnings in both places. It seems treating warnings as fatal might cause less surprises. Excerpts from Yuya Nishihara's message of 2017-07-27 23:35:03 +0900: > # HG changeset patch > # User Yuya Nishihara <yuya@tcha.org> > # Date 1500557557 -32400 > # Thu Jul 20 22:32:37 2017 +0900 > # Branch stable > # Node ID 26e41875da7be30b96b904ab3f52615cd19029b5 > # Parent 08f557c2b20e2ae98f57b76fcb2ea0d870cfdcba > setup: do not select hg executable that prints unexpected warnings > > Otherwise the subsequent hg.run() would fail. This factors out the filtering > function so the same rule should apply. > > diff --git a/setup.py b/setup.py > --- a/setup.py > +++ b/setup.py > @@ -202,21 +202,25 @@ class hgcommand(object): > def run(self, args): > cmd = self.cmd + args > returncode, out, err = runcmd(cmd, self.env) > - # If root is executing setup.py, but the repository is owned by > - # another user (as in "sudo python setup.py install") we will get > - # trust warnings since the .hg/hgrc file is untrusted. That is > - # fine, we don't want to load it anyway. Python may warn about > - # a missing __init__.py in mercurial/locale, we also ignore that. > - err = [e for e in err.splitlines() > - if not e.startswith(b'not trusting file') \ > - and not e.startswith(b'warning: Not importing') \ > - and not e.startswith(b'obsolete feature not enabled')] > + err = filterhgerr(err) > if err or returncode != 0: > printf("stderr from '%s':" % (' '.join(cmd)), file=sys.stderr) > - printf(b'\n'.join([b' ' + e for e in err]), file=sys.stderr) > + printf(err, file=sys.stderr) > return '' > return out > > +def filterhgerr(err): > + # If root is executing setup.py, but the repository is owned by > + # another user (as in "sudo python setup.py install") we will get > + # trust warnings since the .hg/hgrc file is untrusted. That is > + # fine, we don't want to load it anyway. Python may warn about > + # a missing __init__.py in mercurial/locale, we also ignore that. > + err = [e for e in err.splitlines() > + if (not e.startswith(b'not trusting file') > + and not e.startswith(b'warning: Not importing') > + and not e.startswith(b'obsolete feature not enabled'))] > + return b'\n'.join(b' ' + e for e in err) > + > def findhg(): > """Try to figure out how we should invoke hg for examining the local > repository contents. > @@ -240,7 +244,7 @@ def findhg(): > retcode, out, err = runcmd(hgcmd + check_cmd, hgenv) > except EnvironmentError: > retcode = -1 > - if retcode == 0: > + if retcode == 0 and not filterhgerr(err): > return hgcommand(hgcmd, hgenv) > > # Fall back to trying the local hg installation. > @@ -252,7 +256,7 @@ def findhg(): > retcode, out, err = runcmd(hgcmd + check_cmd, hgenv) > except EnvironmentError: > retcode = -1 > - if retcode == 0: > + if retcode == 0 and not filterhgerr(err): > return hgcommand(hgcmd, hgenv) > > raise SystemExit('Unable to find a working hg binary to extract the '
queued for stable thanks > On Jul 27, 2017, at 10:35, Yuya Nishihara <yuya@tcha.org> wrote: > > # HG changeset patch > # User Yuya Nishihara <yuya@tcha.org> > # Date 1500557557 -32400 > # Thu Jul 20 22:32:37 2017 +0900 > # Branch stable > # Node ID 26e41875da7be30b96b904ab3f52615cd19029b5 > # Parent 08f557c2b20e2ae98f57b76fcb2ea0d870cfdcba > setup: do not select hg executable that prints unexpected warnings > > Otherwise the subsequent hg.run() would fail. This factors out the filtering > function so the same rule should apply. > > diff --git a/setup.py b/setup.py > --- a/setup.py > +++ b/setup.py > @@ -202,21 +202,25 @@ class hgcommand(object): > def run(self, args): > cmd = self.cmd + args > returncode, out, err = runcmd(cmd, self.env) > - # If root is executing setup.py, but the repository is owned by > - # another user (as in "sudo python setup.py install") we will get > - # trust warnings since the .hg/hgrc file is untrusted. That is > - # fine, we don't want to load it anyway. Python may warn about > - # a missing __init__.py in mercurial/locale, we also ignore that. > - err = [e for e in err.splitlines() > - if not e.startswith(b'not trusting file') \ > - and not e.startswith(b'warning: Not importing') \ > - and not e.startswith(b'obsolete feature not enabled')] > + err = filterhgerr(err) > if err or returncode != 0: > printf("stderr from '%s':" % (' '.join(cmd)), file=sys.stderr) > - printf(b'\n'.join([b' ' + e for e in err]), file=sys.stderr) > + printf(err, file=sys.stderr) > return '' > return out > > +def filterhgerr(err): > + # If root is executing setup.py, but the repository is owned by > + # another user (as in "sudo python setup.py install") we will get > + # trust warnings since the .hg/hgrc file is untrusted. That is > + # fine, we don't want to load it anyway. Python may warn about > + # a missing __init__.py in mercurial/locale, we also ignore that. > + err = [e for e in err.splitlines() > + if (not e.startswith(b'not trusting file') > + and not e.startswith(b'warning: Not importing') > + and not e.startswith(b'obsolete feature not enabled'))] > + return b'\n'.join(b' ' + e for e in err) > + > def findhg(): > """Try to figure out how we should invoke hg for examining the local > repository contents. > @@ -240,7 +244,7 @@ def findhg(): > retcode, out, err = runcmd(hgcmd + check_cmd, hgenv) > except EnvironmentError: > retcode = -1 > - if retcode == 0: > + if retcode == 0 and not filterhgerr(err): > return hgcommand(hgcmd, hgenv) > > # Fall back to trying the local hg installation. > @@ -252,7 +256,7 @@ def findhg(): > retcode, out, err = runcmd(hgcmd + check_cmd, hgenv) > except EnvironmentError: > retcode = -1 > - if retcode == 0: > + if retcode == 0 and not filterhgerr(err): > return hgcommand(hgcmd, hgenv) > > raise SystemExit('Unable to find a working hg binary to extract the ' > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@mercurial-scm.org > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Patch
diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -202,21 +202,25 @@ class hgcommand(object): def run(self, args): cmd = self.cmd + args returncode, out, err = runcmd(cmd, self.env) - # If root is executing setup.py, but the repository is owned by - # another user (as in "sudo python setup.py install") we will get - # trust warnings since the .hg/hgrc file is untrusted. That is - # fine, we don't want to load it anyway. Python may warn about - # a missing __init__.py in mercurial/locale, we also ignore that. - err = [e for e in err.splitlines() - if not e.startswith(b'not trusting file') \ - and not e.startswith(b'warning: Not importing') \ - and not e.startswith(b'obsolete feature not enabled')] + err = filterhgerr(err) if err or returncode != 0: printf("stderr from '%s':" % (' '.join(cmd)), file=sys.stderr) - printf(b'\n'.join([b' ' + e for e in err]), file=sys.stderr) + printf(err, file=sys.stderr) return '' return out +def filterhgerr(err): + # If root is executing setup.py, but the repository is owned by + # another user (as in "sudo python setup.py install") we will get + # trust warnings since the .hg/hgrc file is untrusted. That is + # fine, we don't want to load it anyway. Python may warn about + # a missing __init__.py in mercurial/locale, we also ignore that. + err = [e for e in err.splitlines() + if (not e.startswith(b'not trusting file') + and not e.startswith(b'warning: Not importing') + and not e.startswith(b'obsolete feature not enabled'))] + return b'\n'.join(b' ' + e for e in err) + def findhg(): """Try to figure out how we should invoke hg for examining the local repository contents. @@ -240,7 +244,7 @@ def findhg(): retcode, out, err = runcmd(hgcmd + check_cmd, hgenv) except EnvironmentError: retcode = -1 - if retcode == 0: + if retcode == 0 and not filterhgerr(err): return hgcommand(hgcmd, hgenv) # Fall back to trying the local hg installation. @@ -252,7 +256,7 @@ def findhg(): retcode, out, err = runcmd(hgcmd + check_cmd, hgenv) except EnvironmentError: retcode = -1 - if retcode == 0: + if retcode == 0 and not filterhgerr(err): return hgcommand(hgcmd, hgenv) raise SystemExit('Unable to find a working hg binary to extract the '