Edit
Attach
Printable
topic end
<!-- * Set TOPICTITLE = #define private public - <nop>NetBeans vs. Cygwin vs. Subversion (24 Apr 2010) --> <style type="text/css"> pre {background-color:#ffeecc;} </style> %STARTINCLUDE% <a name="24"></a> ---+++ [[DefinePrivatePublic20100424NetBeansVersusCygwin][<nop>NetBeans vs. Cygwin vs. Subversion]] (24 Apr 2010) <summary> <nop>NetBeans, Subversion, Cygwin: Pick any two of them, and you will sail smoothly. Use all three, and you're in for a slightly less agreeable ride. The <nop>NetBeans folks <a href="http://netbeans.org/kb/docs/ide/subversion.html">make no secret out of it</a>: <i>"Please note that <nop>NetBeans Subversion support does not work when used with Cygwin."</i> </summary> First things first: I'm both a <nop>NetBeans newbie and a fanboy. This is not an attempt to (pardon the pun) bash the IDE; just trying to iron out a few wrinkles. <nop>NetBeans autodetects Subversion clients on your system and will use them automagically, which is very convenient. However, <nop>NetBeans will also happily use the =svn= version compiled for Cygwin when it finds it in your =PATH= - and that's where trouble starts. Some related bug reports: [[http://netbeans.org/bugzilla/show_bug.cgi?id=108577][108577]], [[http://netbeans.org/bugzilla/show_bug.cgi?id=108536][108536]], [[http://netbeans.org/bugzilla/show_bug.cgi?id=124537][124537]], [[http://netbeans.org/bugzilla/show_bug.cgi?id=124343][124343]], [[http://netbeans.org/bugzilla/show_bug.cgi?id=108069][108069]], [[http://netbeans.org/bugzilla/show_bug.cgi?id=144021][144021]]. Fortunately, it is simple to work around the problem, as <nop>NetBeans can either download an integrated SVN client, or you can configure it to use [[http://subversion.apache.org/packages.html#windows][plain vanilla Windows versions]] of =svn=. <img src="%ATTACHURLPATH%/netbeans_idelog.jpg" alt="netbeans_idelog.jpg" width="250" height="117" style="float:right;" /> That, of course, was _way_ too simple for me. I wanted to know what really kept my preferred IDE from having polite conversations with Cygwin executables. As a first step, I ran tests with the "IDE Log" window open (accessible from <nop>NetBeans' "View" menu). I also cranked up <nop>NetBeans logging levels; example: <pre> netbeans.exe -J-Dorg.netbeans.modules.subversion.level=1 </pre> From the logging output, it looked like the Cygwin version of the =svn= client fails because <nop>NetBeans passes file paths in Windows notation, i.e. the paths contain backslashes. I didn't want to mess with <nop>NetBeans code, so just for laughs, I built a trivial interceptor tool which converts paths into UNIX notation and then calls the original Cygwin =svn.exe=. This took me a little further, but it wasn't sufficient. For example, <nop>NetBeans often runs the svn client like this: <pre> svn info --targets sometempfile --non-interactive.... </pre> And the temporary file =sometempfile= contains additional file specifications (in Windows notation). I hacked those temp files in my interceptor as well - and now I'm getting results from <nop>NetBeans! Whoopee! Yeah, I know, this is totally a waste of time, since using an alternative Subversion client implementation on Windows is a) trivial to accomplish and b) so much safer than this nightmarish hack of mine, but hey, at least I learned a couple of things about <nop>NetBeans and its SVN integration while geeking out. A safer fix would be for <nop>NetBeans to detect if the version of =svn.exe= in use is a Cygwin version, and if so, produce UNIX paths. That fix would probably affect [[http://hg.netbeans.org/main/file/def56dd2429a/subversion/src/org/netbeans/modules/subversion/client/cli/SvnCommand.java][<nop>SvnCommand.java]], maybe also some other files. Without further ado, here's the [[%ATTACHURL%/svn.cpp][code]] of the interceptor. Obligatory warnings: Makes grown men cry. Riddled with bugs. Platform-dependent in more ways than I probably realize. And largely untested. <pre> <font color="#a020f0">#include </font><font color="#ff00ff"><malloc.h></font> <font color="#a020f0">#include </font><font color="#ff00ff"><process.h></font> <font color="#a020f0">#include </font><font color="#ff00ff"><stdio.h></font> <font color="#a020f0">#include </font><font color="#ff00ff"><string.h></font> <font color="#a020f0">#include </font><font color="#ff00ff"><syslimits.h></font> <font color="#a020f0">#include </font><font color="#ff00ff"><sys/cygwin.h></font> <font color="#a020f0">#include </font><font color="#ff00ff"><unistd.h></font> <font color="#0000ff">// Experimental svn interceptor, to help debugging</font> <font color="#0000ff">// debug NetBeans vs. Cygwin svn problems. See</font> <font color="#0000ff">// <a href="http://www.clausbrod.de/Blog/DefinePrivatePublic20100424NetBeansVersusCygwin">http://www.clausbrod.de/Blog/DefinePrivatePublic20100424NetBeansVersusCygwin</a></font> <font color="#0000ff">// for details.</font> <font color="#0000ff">//</font> <font color="#0000ff">// Claus Brod, April 2010</font> <font color="#2e8b57"><b>char</b></font> *convpath(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *from) { <font color="#804040"><b>if</b></font> (<font color="#ff00ff">0</font> == strchr(from, <font color="#6a5acd">'\\'</font>)) { <font color="#804040"><b>return</b></font> strdup(from); } <font color="#2e8b57"><b>ssize_t</b></font> len = cygwin_conv_path(CCP_WIN_A_TO_POSIX, from, <font color="#ff00ff">NULL</font>, <font color="#ff00ff">0</font>); <font color="#2e8b57"><b>char</b></font> *to = (<font color="#2e8b57"><b>char</b></font> *) malloc(len); <font color="#804040"><b>if</b></font> (<font color="#ff00ff">0</font> == cygwin_conv_path(CCP_WIN_A_TO_POSIX, from, to, len)) { <font color="#804040"><b>return</b></font> to; } free(to); <font color="#804040"><b>return</b></font> <font color="#ff00ff">NULL</font>; } <font color="#2e8b57"><b>char</b></font> *patchfile(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *from) { <font color="#2e8b57"><b>FILE</b></font> *ffrom = fopen(from, <font color="#ff00ff">"r"</font>); <font color="#804040"><b>if</b></font> (!ffrom) <font color="#804040"><b>return</b></font> <font color="#ff00ff">NULL</font>; <font color="#a020f0">#define SUFFIX </font><font color="#ff00ff">"__hungo"</font> <font color="#2e8b57"><b>char</b></font> *to = (<font color="#2e8b57"><b>char</b></font> *) malloc(PATH_MAX + <font color="#804040"><b>sizeof</b></font> (SUFFIX)); strncpy(to, from, PATH_MAX); strcat(to, SUFFIX); <font color="#2e8b57"><b>FILE</b></font> *fto = fopen(to, <font color="#ff00ff">"w"</font>); <font color="#804040"><b>if</b></font> (!fto) { fclose(ffrom); <font color="#804040"><b>return</b></font> <font color="#ff00ff">NULL</font>; } <font color="#2e8b57"><b>char</b></font> buf[<font color="#ff00ff">2048</font>]; <font color="#804040"><b>while</b></font> (<font color="#ff00ff">NULL</font> != fgets(buf, <font color="#804040"><b>sizeof</b></font> (buf), ffrom)) { <font color="#2e8b57"><b>char</b></font> *converted = convpath(buf); <font color="#804040"><b>if</b></font> (converted) { fputs(converted, fto); free(converted); } } fclose(fto); fclose(ffrom); <font color="#804040"><b>return</b></font> to; } <font color="#2e8b57"><b>int</b></font> main(<font color="#2e8b57"><b>int</b></font> argc, <font color="#2e8b57"><b>char</b></font> *argv[]) { <font color="#2e8b57"><b>char</b></font> **args = (<font color="#2e8b57"><b>char</b></font> **) calloc(argc + <font color="#ff00ff">1</font>, <font color="#804040"><b>sizeof</b></font> (<font color="#2e8b57"><b>char</b></font>*)); <font color="#0000ff">// original svn client is in /bin</font> args[<font color="#ff00ff">0</font>] = <font color="#ff00ff">"/bin/svn.exe"</font>; <font color="#804040"><b>for</b></font> (<font color="#2e8b57"><b>int</b></font> i = <font color="#ff00ff">1</font>; i < argc; i++) { args[i] = convpath(argv[i]); } <font color="#0000ff">// look for --targets</font> <font color="#804040"><b>for</b></font> (<font color="#2e8b57"><b>int</b></font> i = <font color="#ff00ff">0</font>; i < argc; i++) { <font color="#804040"><b>if</b></font> (<font color="#ff00ff">0</font> == strcmp(args[i], <font color="#ff00ff">"--targets"</font>)) { <font color="#2e8b57"><b>char</b></font> *to = patchfile(args[i + <font color="#ff00ff">1</font>]); <font color="#804040"><b>if</b></font> (to) args[i + <font color="#ff00ff">1</font>] = to; } } <font color="#2e8b57"><b>int</b></font> ret = spawnv(_P_WAIT, args[<font color="#ff00ff">0</font>], args); <font color="#0000ff">// Remove temporary --targets</font> <font color="#804040"><b>for</b></font> (<font color="#2e8b57"><b>int</b></font> i = <font color="#ff00ff">0</font>; i < argc; i++) { <font color="#804040"><b>if</b></font> (<font color="#ff00ff">0</font> == strcmp(args[i], <font color="#ff00ff">"--targets"</font>)) { unlink(args[i + <font color="#ff00ff">1</font>]); } } <font color="#804040"><b>return</b></font> ret; } </pre> <img src="%ATTACHURLPATH%/netbeans_svn.jpg" alt="netbeans_svn.jpg" width="600" height="287" style="float:right;" /> Usage instructions: * Compile into =svn.exe=, using Cygwin version of gcc * Point <nop>NetBeans to the interceptor (Tools/Options/Miscellaneous/Versioning/Subversion) The interceptor assumes that Cygwin is installed, along with a Cygwin version of =svn= in =/bin=. This is a _debugging tool_. Using this in a production environment is a recipe for failure and data loss. (Did I really have to mention this? :D ) --- %STOPINCLUDE% %COMMENT{type="below" nonotify="on"}% ---
to top
End of topic
Skip to action links
|
Back to top
Edit
|
Attach image or document
|
Printable version
|
Raw text
|
Refresh
|
More topic actions
Revisions: | r1.4 |
>
|
r1.3
|
>
|
r1.2
|
Total page history
|
Backlinks
You are here:
Blog
>
DefinePrivatePublic20100424NetBeansVersusCygwin
r1.4 - 04 May 2010 - 07:41 -
ClausBrod
to top
Blog
This site
2017
:
12
-
11
-
10
2016
:
10
-
7
-
3
2015
:
11
-
10
-
9
-
4
-
1
2014
:
5
2013
:
9
-
8
-
7
-
6
-
5
2012
:
2
-
10
2011
:
1
-
8
-
9
-
10
-
12
2010
:
11
-
10
-
9
-
4
2009
:
11
-
9
-
8
-
7
-
6
-
5
-
4
-
3
2008
:
5
-
4
-
3
-
1
2007:
12
-
8
-
7
-
6
-
5
-
4
-
3
-
1
2006:
4
-
3
-
2
-
1
2005:
12
-
6
-
5
-
4
2004:
12
-
11
-
10
C++
CoCreate Modeling
COM & .NET
Java
Mac
Lisp
OpenSource
Scripting
Windows
Stuff
Changes
Index
Search
Maintenance
Impressum
Datenschutzerklärung
Home
Webs
Atari
Blog
Claus
CoCreateModeling
Klassentreffen
Main
Sandbox
Sommelier
TWiki
Xplm
Jump:
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback