* Re: [PATCH] git-remote-hg: set stdout to binary mode on win32 [not found] <CAFGOX=V0A=2kMpxtNvsjgEtMt=zsm_-zX_DJo0qkV9y1_C4Haw@mail.gmail.com> @ 2013-05-19 5:33 ` Felipe Contreras 2013-05-19 7:48 ` Junio C Hamano 2013-05-19 11:23 ` Felipe Contreras 1 sibling, 1 reply; 3+ messages in thread From: Felipe Contreras @ 2013-05-19 5:33 UTC (permalink / raw) To: Amit Bakshi; +Cc: git Hi, Sorry Amit, I assumed this patch made it to the list, but I just realized it didn't; it doesn't allow HTML, and mails and silently dropped (I hate that). So I'm sending it so the list can see it: It seems OK for me, but I would like to try it, and so far I haven't managed to access Mercurial libraries at all from python scripts in Windows. What steps did you follow? On Mon, Jan 28, 2013 at 4:13 PM, Amit Bakshi <ambakshi@gmail.com> wrote: > git clone hangs on windows (msysgit/cygwin), and > file.write would return errno 22 inside of mercurial's > windows.winstdout wrapper class. This patch sets > stdout's mode to binary, fixing both issues. > --- > contrib/remote-helpers/git-remote-hg | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > > diff --git a/contrib/remote-helpers/git-remote-hg > b/contrib/remote-helpers/git-remote-hg > index 328c2dc..95f4c1f 100755 > --- a/contrib/remote-helpers/git-remote-hg > +++ b/contrib/remote-helpers/git-remote-hg > @@ -62,6 +62,24 @@ def get_config(config): > output, _ = process.communicate() > return output > > +# > +# On Windows (msysgit/cygwin) have to set stdout to binary > +# mode (_O_BINARY is 32768). Otherwise clone hangs, and pushing > +# to remote fails when doing a write to mercurial's wrapper > +# windows.winstdout wrapper class. > +# > +def set_binmode(fd): > + try: > + if sys.platform == "win32": > + import msvcrt > + msvcrt.setmode(fd, os.O_BINARY) > + elif sys.platform == 'cygwin': > + import ctypes > + msvcrt = ctypes.CDLL('msvcrt.dll') > + msvcrt._setmode(fd, 32768) # On Cygwin os.O_BINARY is different > + except OSError: > + pass > + > class Marks: > > def __init__(self, path): > @@ -764,6 +782,9 @@ def main(args): > else: > is_tmp = False > > + if sys.platform in ['win32','cygwin']: > + set_binmode(sys.stdout.fileno()) > + > gitdir = os.environ['GIT_DIR'] > dirname = os.path.join(gitdir, 'hg', alias) > branches = {} > -- > 1.8.1 -- Felipe Contreras ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] git-remote-hg: set stdout to binary mode on win32 2013-05-19 5:33 ` [PATCH] git-remote-hg: set stdout to binary mode on win32 Felipe Contreras @ 2013-05-19 7:48 ` Junio C Hamano 0 siblings, 0 replies; 3+ messages in thread From: Junio C Hamano @ 2013-05-19 7:48 UTC (permalink / raw) To: Felipe Contreras; +Cc: Amit Bakshi, git Felipe Contreras <felipe.contreras@gmail.com> writes: > Sorry Amit, I assumed this patch made it to the list, but I just > realized it didn't; it doesn't allow HTML, and mails and silently > dropped (I hate that). > > So I'm sending it so the list can see it: > > It seems OK for me, but I would like to try it, and so far I haven't > managed to access Mercurial libraries at all from python scripts in > Windows. What steps did you follow? Thanks for keeping an eye on this part of the system. It seems that having an extra -rc cycle turned out to be not so bad an idea. > On Mon, Jan 28, 2013 at 4:13 PM, Amit Bakshi <ambakshi@gmail.com> wrote: >> git clone hangs on windows (msysgit/cygwin), and >> file.write would return errno 22 inside of mercurial's >> windows.winstdout wrapper class. This patch sets >> stdout's mode to binary, fixing both issues. >> --- >> contrib/remote-helpers/git-remote-hg | 21 +++++++++++++++++++++ >> 1 file changed, 21 insertions(+) >> >> diff --git a/contrib/remote-helpers/git-remote-hg >> b/contrib/remote-helpers/git-remote-hg >> index 328c2dc..95f4c1f 100755 >> --- a/contrib/remote-helpers/git-remote-hg >> +++ b/contrib/remote-helpers/git-remote-hg >> @@ -62,6 +62,24 @@ def get_config(config): >> output, _ = process.communicate() >> return output >> >> +# >> +# On Windows (msysgit/cygwin) have to set stdout to binary >> +# mode (_O_BINARY is 32768). Otherwise clone hangs, and pushing >> +# to remote fails when doing a write to mercurial's wrapper >> +# windows.winstdout wrapper class. >> +# >> +def set_binmode(fd): >> + try: >> + if sys.platform == "win32": >> + import msvcrt >> + msvcrt.setmode(fd, os.O_BINARY) >> + elif sys.platform == 'cygwin': >> + import ctypes >> + msvcrt = ctypes.CDLL('msvcrt.dll') >> + msvcrt._setmode(fd, 32768) # On Cygwin os.O_BINARY is different >> + except OSError: >> + pass >> + >> class Marks: >> >> def __init__(self, path): >> @@ -764,6 +782,9 @@ def main(args): >> else: >> is_tmp = False >> >> + if sys.platform in ['win32','cygwin']: >> + set_binmode(sys.stdout.fileno()) >> + >> gitdir = os.environ['GIT_DIR'] >> dirname = os.path.join(gitdir, 'hg', alias) >> branches = {} >> -- >> 1.8.1 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] git-remote-hg: set stdout to binary mode on win32 [not found] <CAFGOX=V0A=2kMpxtNvsjgEtMt=zsm_-zX_DJo0qkV9y1_C4Haw@mail.gmail.com> 2013-05-19 5:33 ` [PATCH] git-remote-hg: set stdout to binary mode on win32 Felipe Contreras @ 2013-05-19 11:23 ` Felipe Contreras 1 sibling, 0 replies; 3+ messages in thread From: Felipe Contreras @ 2013-05-19 11:23 UTC (permalink / raw) To: Amit Bakshi; +Cc: git On Mon, Jan 28, 2013 at 4:13 PM, Amit Bakshi <ambakshi@gmail.com> wrote: > git clone hangs on windows (msysgit/cygwin), and > file.write would return errno 22 inside of mercurial's > windows.winstdout wrapper class. This patch sets > stdout's mode to binary, fixing both issues. > --- > contrib/remote-helpers/git-remote-hg | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > > diff --git a/contrib/remote-helpers/git-remote-hg > b/contrib/remote-helpers/git-remote-hg > index 328c2dc..95f4c1f 100755 > --- a/contrib/remote-helpers/git-remote-hg > +++ b/contrib/remote-helpers/git-remote-hg > @@ -62,6 +62,24 @@ def get_config(config): > output, _ = process.communicate() > return output > > +# > +# On Windows (msysgit/cygwin) have to set stdout to binary > +# mode (_O_BINARY is 32768). Otherwise clone hangs, and pushing > +# to remote fails when doing a write to mercurial's wrapper > +# windows.winstdout wrapper class. > +# > +def set_binmode(fd): > + try: > + if sys.platform == "win32": > + import msvcrt > + msvcrt.setmode(fd, os.O_BINARY) > + elif sys.platform == 'cygwin': > + import ctypes > + msvcrt = ctypes.CDLL('msvcrt.dll') > + msvcrt._setmode(fd, 32768) # On Cygwin os.O_BINARY is different > + except OSError: > + pass I tried many things, and it seems it's true that we need to set the binary mode in Windows, but it seemed to work fine cygwin. I saw in many places the workaround for 'win32', but I didn't find the one for 'cygwin'. Where did you find it? Did you test in cygwin? Is it needed there? Cheers. -- Felipe Contreras ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-05-19 11:24 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <CAFGOX=V0A=2kMpxtNvsjgEtMt=zsm_-zX_DJo0qkV9y1_C4Haw@mail.gmail.com> 2013-05-19 5:33 ` [PATCH] git-remote-hg: set stdout to binary mode on win32 Felipe Contreras 2013-05-19 7:48 ` Junio C Hamano 2013-05-19 11:23 ` Felipe Contreras
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).