[PATCH] RE: New standalone Windows release

Maquelin, Olivier olivier.maquelin at intel.com
Mon Sep 26 18:29:02 CDT 2005


> From: mercurial-bounces at selenic.com 
> [mailto:mercurial-bounces at selenic.com] On Behalf Of Zbynek Winkler
> Sent: Monday, September 26, 2005 5:44 AM
> To: mercurial at selenic.com
> Subject: Re: New standalone Windows release
[...]
> >If you can make a function that wraps both the select and peek
> >versions in util.py, I can integrate it.
> >  
> >
> How is this doing? I'd love to see this integrated. I don't 
> myself use 
> windows but some of my colleagues do. I've decided to give 
> mercurial a 
> shot in our group but for that I need push from windows to work... Is 
> there any other way except ssh to 'push' that is know to work 
> on windows?

We had a piece of code that would allow Windows to work, but I did not
like it too much. First of all it required Windows-specific code and it
used win32file and win32pipe, which may not be available on some Python
installs. It also failed when a password was needed to establish the ssh
connection. In fact, even under Linux Mercurial would hang when ssh was
trying to get input from the user (e.g. to confirm a new public key).

I tried to create a separate thread to handle the error stream, but
sadly was unable to get that code to work properly. After a while I got
frustrated with all this and decided that the easiest way to solve the
problem was to get rid of the "offending code" entirely. After all, the
only job of the readerr() function is to add the text "remote: " before
each line coming from the error stream. Maybe we can live without that
functionality.

Unless somebody comes up with a better solution, here is a patch that
gets rid of readerr() and replaces popen3 with popen2. This not only
solves the Windows compatibility issue but also allows ssh to interact
with the user (to ask for a password or confirm a new public key).

-- Olivier


# HG changeset patch
# User olivier.maquelin at intel.com
# Node ID 203e52f697954f25952b7e5d09fec8fc25ca4f6b
# Parent  3729e2773cca26a4c76a60e903a55b034e64ad89
Got rid of sshrepository.readerr() and replaced popen3 with popen2.

The readerr() function was using select(), which does not work under
Windows. Moreover, because readerr() was not a separate process and
was not called in all the right places, Mercurial would sometimes
hang when ssh tried to interact with the user.

diff -r 3729e2773cca -r 203e52f69795 mercurial/sshrepo.py
--- a/mercurial/sshrepo.py	Mon Sep 26 14:01:18 2005 -0700
+++ b/mercurial/sshrepo.py	Mon Sep 26 16:08:19 2005 -0700
@@ -8,7 +8,7 @@
 from node import *
 from remoterepo import *
 from demandload import *
-demandload(globals(), "hg os re select")
+demandload(globals(), "hg os re")
 
 class sshrepository(remoterepository):
     def __init__(self, ui, path):
@@ -33,23 +33,12 @@
         cmd = cmd % (sshcmd, args, remotecmd, self.path)
 
         ui.note('running %s\n' % cmd)
-        self.pipeo, self.pipei, self.pipee = os.popen3(cmd, 'b')
-
-    def readerr(self):
-        while 1:
-            r,w,x = select.select([self.pipee], [], [], 0)
-            if not r: break
-            l = self.pipee.readline()
-            if not l: break
-            self.ui.status("remote: ", l)
+        self.pipeo, self.pipei = os.popen2(cmd, 'b')
 
     def __del__(self):
         try:
             self.pipeo.close()
             self.pipei.close()
-            for l in self.pipee:
-                self.ui.status("remote: ", l)
-            self.pipee.close()
         except:
             pass
 
@@ -69,7 +58,6 @@
     def call(self, cmd, **args):
         r = self.do_cmd(cmd, **args)
         l = r.readline()
-        self.readerr()
         try:
             l = int(l)
         except:
@@ -122,10 +110,8 @@
             d = cg.read(4096)
             if not d: break
             self.pipeo.write(d)
-            self.readerr()
 
         self.pipeo.flush()
 
-        self.readerr()
         l = int(self.pipei.readline())
         return self.pipei.read(l) != ""



More information about the Mercurial mailing list