setup: handle trust warnings when determining version
authorMartin Geisler <mg@lazybytes.net>
Tue, 26 May 2009 21:13:21 +0200
changeset 8628 4dd06ab9217c
parent 8627 4c5b46f736f1
child 8629 8e69a22f6792
setup: handle trust warnings when determining version
setup.py
--- a/setup.py	Tue May 26 21:07:41 2009 +0200
+++ b/setup.py	Tue May 26 21:13:21 2009 +0200
@@ -112,9 +112,15 @@
                                 stderr=subprocess.PIPE).communicate()
     os.environ['PYTHONPATH'] = pypath
 
+    # 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.
+    err = [e for e in err.splitlines()
+           if not e.startswith('Not trusting file')]
     if err:
         sys.stderr.write('warning: could not establish Mercurial '
-                         'version:\n%s\n' % err)
+                         'version:\n%s\n' % '\n'.join(err))
     else:
         l = out.split()
         while len(l) > 1 and l[-1][0].isalpha(): # remove non-numbered tags