Author Topic: SVNInside : development of another SVN plugin for CodeBlocks  (Read 136500 times)

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6511
    • My Best Post
Re: SVNInside : development of another SVN plugin for CodeBlocks
« Reply #15 on: October 10, 2007, 01:13:17 am »
A patch that might help others to compile

Code: [Select]
Index: post_build_step.bat
===================================================================
--- post_build_step.bat (revision 5)
+++ post_build_step.bat (working copy)
@@ -1,10 +1,7 @@
-f:
-cd\
-cd "dev\CBPlugins\SVNInside_svn\trunk"
 zip -j9 -r SVNInside.zip resources\manifest.xml resources\*.xrc
 cd resources
 zip -0 -q ../SVNInside.zip images\*.ico images\*.png
 cd ..
 zip -j9 SVNInside.cbplugin SVNInside.dll SVNInside.zip
-xcopy /Y SVNInside.dll "F:\dev\CB_SVN\src\devel\share\CodeBlocks\plugins"
-xcopy /Y SVNInside.zip "F:\dev\CB_SVN\src\devel\share\codeblocks"
+xcopy /Y SVNInside.dll "..\..\..\devel\share\CodeBlocks\plugins\*"
+xcopy /Y SVNInside.zip "..\..\..\devel\share\codeblocks\*"
Index: SVNInside.cbp
===================================================================
--- SVNInside.cbp (revision 5)
+++ SVNInside.cbp (working copy)
@@ -36,7 +36,6 @@
  <Option compiler="gcc" />
  <Option host_application="codeblocks.exe" />
  <Compiler>
- <Add option="-O3" />
  <Add option="-pipe" />
  <Add option="-mthreads" />
  <Add option="-fmessage-length=0" />
@@ -57,12 +56,16 @@
  </Linker>
  </Target>
  </Build>
+ <VirtualTargets>
+ <Add alias="All" targets="debug;" />
+ </VirtualTargets>
  <Compiler>
  <Add directory="$(#cb)\include" />
  <Add directory="$(#cb)\include\wxscintilla\include" />
  <Add directory="$(#wx.include)" />
  <Add directory="$(#wx.lib)\gcc_dll\mswu" />
  <Add directory="$(#cb)\include\wxFlatNotebook\include" />
+ <Add directory="$(#cb)\include\tinyxml" />
  <Add directory="src" />
  <Add directory="src\SVNCommand" />
  <Add directory="src\Dialogs" />
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: SVNInside : development of another SVN plugin for CodeBlocks
« Reply #16 on: October 10, 2007, 02:11:18 am »
Since you are calling the command line svn, wxExecute should be fine for the job.
It is not. That's what I've been using in my RC2 Subversion plugin.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline orel

  • Multiple posting newcomer
  • *
  • Posts: 96
Re: SVNInside : development of another SVN plugin for CodeBlocks
« Reply #17 on: October 10, 2007, 03:14:01 am »
Since you are calling the command line svn, wxExecute should be fine for the job.
It is not. That's what I've been using in my RC2 Subversion plugin.

i am currently in the process of making some tests to see if i can replace my win32 (CreateProcess, DuplicateHandle, etc.) CConsoleProc implementation with one calling wxExecute. I'm not having too much problems for the moment although some little things seems stranges, particularly when configuring it to be asynchronous and working with a wxProcess.

What kinf of problem did you have with it? on unix-linux or windows?

if ::wxExecute is only working fine on linux, it's useless for me to rewrite the window implementation of my console output redirection.
windows XP SP2
mingw gcc 3.4.5
svn Code::Blocks and M$ Visual Studio 2005 and .NET to eat!! SVNInside plugin :http://forums.codeblocks.org/index.php/topic,7063.0.html

Offline JGM

  • Lives here!
  • ****
  • Posts: 518
  • Got to practice :)
Re: SVNInside : development of another SVN plugin for CodeBlocks
« Reply #18 on: October 10, 2007, 03:57:16 am »
if ::wxExecute is only working fine on linux, it's useless for me to rewrite the window implementation of my console output redirection.

I use it on windows and linux and it works fine. I don't know what could go wrong since for me is working. :?

Code: [Select]
bool QuerySvn(const wxString& workingDir, wxString& revision, wxString& date)

{

    revision = _T("0");

    date = _T("unknown date");

    wxString svncmd = _T("svn info --xml --non-interactive ");

    svncmd.Append(_T("\"") + workingDir + _T("\""));

    wxArrayString xmlOutput;



    if (wxExecute(svncmd, xmlOutput) != -1)

    {



        wxString buf = _T("");



        for(unsigned int i=0; i<xmlOutput.GetCount(); ++i){

            buf << xmlOutput[i];

        }



        TiXmlDocument doc;

        doc.Parse(ws2s(buf).c_str());



        if (doc.Error())

            return 0;



        TiXmlHandle hCommit(&doc);

        hCommit = hCommit.FirstChildElement("info").FirstChildElement("entry").FirstChildElement("commit");

if(const TiXmlElement* e = hCommit.ToElement())

        {

            revision = e->Attribute("revision") ? s2ws(e->Attribute("revision")) : _T("");

            const TiXmlElement* d = e->FirstChildElement("date");

            if(d && d->GetText())

                date = s2ws(d->GetText());



            return 1;

        }

    }

    return 0;

}

thats a function to retrieve the svn revision using wxExecute and it works pretty well on both platforms.

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: SVNInside : development of another SVN plugin for CodeBlocks
« Reply #19 on: October 10, 2007, 05:32:41 am »
And i have a question to ask : i am trying to implement a way to block modifications on a file locked by another person. My wish is to add a msgbox when the cbEVT_EDITOR_MODIFIED event is sent that kind of file, asking for the user to choose among two options :
  • continue modyfing the file locally as if it wasn't locked, despite the fact that it won't be able to be commited until it is unlocked
  • revert the modification which generated the event and wait until the file it is unlocked

For the second option, i can't manage to undo the action just after the messazge box has been closed, i tried different ways :

Code: [Select]
cbStyledTextCtrl* pControl = pEditor->GetControl();
if (pControl)
{
     //pControl->BeginUndoAction();    with those 2 lines commented or not
     pControl->Undo();
     //pControl->EndUndoAction();
}

And i tried this:
Code: [Select]
EditorBase* ed = Manager::Get()->GetEditorManager()->GetActiveEditor();
if (ed) ed->Undo();

with no success, can someone help me about that ?

EditorBase::Undo() is an empty virtual function which has been implemented in cbEditor. Try the following code.
Code: [Select]
// Code to catch cbEVT_EDITOR_MODIFIED event
void foo::OnEditorModified(CodeBlocksEvent& event)
{
    cbEditor* ed = (cbEditor*)event.GetEditor();
    ed->Undo();
}

Or

Code: [Select]
cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
ed->Undo();

HTH. :)
« Last Edit: October 10, 2007, 10:18:48 am by Biplab »
Be a part of the solution, not a part of the problem.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6511
    • My Best Post
Re: SVNInside : development of another SVN plugin for CodeBlocks
« Reply #20 on: October 10, 2007, 08:24:10 am »
Patch to Fix compiling under Windows without using Precompiled Headers.
Also, fixes some rules that killerbot has passed on to me.

killerbot inspired ones.
1. If possible, headers should use forward declarations instead of includes.
2. Headers should never include pre-compiled headers like [sdk.h] or [wxprec.h].
    Do not include sdk.h in headers
    Do not include wxprec.h in headers
    Do not use WX_PRECOMP in headers
    Do not use CB_PRECOMP in headers

Ones I decided on by myself.
3. Used system includes in plugins for C::B SDK and wxWidgets includes.
   In plugins, use [#include <sdk.h>] instead of [#include "sdk.h"]

4. Do not use [#include <wx/wx.h>] in either production headers or source code.

Code: [Select]
Index: src/Dialogs/wxSVNTreeCtrl.h
===================================================================
--- src/Dialogs/wxSVNTreeCtrl.h (revision 7)
+++ src/Dialogs/wxSVNTreeCtrl.h (working copy)
@@ -1,13 +1,7 @@
 #ifndef WXSVNTREECTRL_H
 #define WXSVNTREECTRL_H
 
-// For compilers that support precompilation, includes <wx/wx.h>
-#include <wx/wxprec.h>
 
-#ifndef WX_PRECOMP
-    #include <wx/wx.h>
-#endif
-
 #include <cbplugin.h>
 #include <wx/treectrl.h>
 
Index: src/Dialogs/ConfigDialog.cpp
===================================================================
--- src/Dialogs/ConfigDialog.cpp (revision 7)
+++ src/Dialogs/ConfigDialog.cpp (working copy)
@@ -21,7 +21,13 @@
 #endif
 
 #ifndef WX_PRECOMP
-#include "wx/wx.h"
+#include <wx/checkbox.h>
+#include <wx/dialog.h>
+#include <wx/dirdlg.h>
+#include <wx/filedlg.h>
+#include <wx/log.h>
+#include <wx/stattext.h>
+#include <wx/window.h>
 #endif
 
 ////@begin includes
@@ -30,6 +36,7 @@
 #include "ConfigDialog.h"
 #include "wx/file.h"
 #include "wx/dir.h"
+#include <wx/sizer.h>
 #include "wx/textctrl.h"
 #include "SVNInside_globals.h"
 
Index: src/Dialogs/SVNFileSelect.cpp
===================================================================
--- src/Dialogs/SVNFileSelect.cpp (revision 7)
+++ src/Dialogs/SVNFileSelect.cpp (working copy)
@@ -1,7 +1,7 @@
 /////////////////////////////////////////////////////////////////////////////
 // Name:        SVNFileSelect.cpp
 // Purpose:
-// Author:      Aurélien Rainone
+// Author:      Aurélien Rainone
 // Modified by:
 // Created:     02/10/2007 22:45:30
 // RCS-ID:
@@ -21,7 +21,12 @@
 #endif
 
 #ifndef WX_PRECOMP
-#include "wx/wx.h"
+#include <wx/button.h>
+#include <wx/checklst.h>
+#include <wx/log.h>
+#include <wx/sizer.h>
+#include <wx/stattext.h>
+#include <wx/textctrl.h>
 #endif
 
 ////@begin includes
Index: src/Dialogs/ConfigDialog.h
===================================================================
--- src/Dialogs/ConfigDialog.h (revision 7)
+++ src/Dialogs/ConfigDialog.h (working copy)
@@ -32,7 +32,10 @@
  */
 
 ////@begin forward declarations
+class wxStaticText;
 class wxToggleButton;
+class wxTextCtrl;
+class wxCheckBox;
 ////@end forward declarations
 
 /*!
Index: src/Dialogs/wxSVNTreeCtrl.cpp
===================================================================
--- src/Dialogs/wxSVNTreeCtrl.cpp (revision 7)
+++ src/Dialogs/wxSVNTreeCtrl.cpp (working copy)
@@ -1,4 +1,8 @@
 #include <sdk.h> // Code::Blocks SDK
+#ifndef CB_PRECOMP
+    #include <configmanager.h>
+    #include <cbproject.h>
+#endif
 #include <wx/menu.h>
 #include <wx/imaglist.h>
 
Index: src/Dialogs/SVNFileSelect.h
===================================================================
--- src/Dialogs/SVNFileSelect.h (revision 7)
+++ src/Dialogs/SVNFileSelect.h (working copy)
@@ -22,6 +22,7 @@
 
 ////@begin includes
 #include "wx/xrc/xmlres.h"
+#include <wx/dialog.h>
 #include "SVNInside_globals.h"
 ////@end includes
 
@@ -30,6 +31,10 @@
  */
 
 ////@begin forward declarations
+class wxButton;
+class wxCheckListBox;
+class wxStaticText;
+class wxTextCtrl;
 ////@end forward declarations
 
 /*!
Index: src/SVNInside.cpp
===================================================================
--- src/SVNInside.cpp (revision 7)
+++ src/SVNInside.cpp (working copy)
@@ -1,4 +1,9 @@
 #include <sdk.h> // Code::Blocks SDK
+#ifndef CB_PRECOMP
+    #include <projectmanager.h>
+    #include <cbproject.h>
+#endif
+
 #include <configurationpanel.h>
 
 #include "SVNInside.h"
Index: src/SVNCommand/CSVNcommand.h
===================================================================
--- src/SVNCommand/CSVNcommand.h (revision 7)
+++ src/SVNCommand/CSVNcommand.h (working copy)
@@ -1,13 +1,8 @@
 #ifndef CSVNCOMMAND_H
 #define CSVNCOMMAND_H
 
-// For compilers that support precompilation, includes <wx/wx.h>
-#include <wx/wxprec.h>
+#include <wx/string.h>
 
-#ifndef WX_PRECOMP
-    #include <wx/wx.h>
-#endif
-
 #include <string>
 
 #include "ConsoleProc.h"
Index: src/SVNInside.h
===================================================================
--- src/SVNInside.h (revision 7)
+++ src/SVNInside.h (working copy)
@@ -10,13 +10,8 @@
 #ifndef SVNINSIDE_H_INCLUDED
 #define SVNINSIDE_H_INCLUDED
 
-// For compilers that support precompilation, includes <wx/wx.h>
-#include <wx/wxprec.h>
+#include <wx/process.h>     // for "class wxProcess"
 
-#ifndef WX_PRECOMP
-    #include <wx/wx.h>
-#endif
-
 #include <cbplugin.h>       // for "class cbPlugin"
 #include <tinyxml.h>        // for "tinyxml API"
 #include <string>
« Last Edit: October 10, 2007, 08:30:59 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9490
Re: SVNInside : development of another SVN plugin for CodeBlocks
« Reply #21 on: October 10, 2007, 10:51:38 am »
There is a loigical issue in wxSVNTreeCtrl.cpp which leads to a crash:
Code: [Select]
    SVNTreeItemData * pdata = 0; wxTreeItemData * ptr = this->GetItemData(id);
    if (ptr)
    {
        pdata = static_cast<SVNTreeItemData*>(ptr); if (!pdata) return 0;
    }
    [...]
    if (pdata->m_bIsFile)
At the last line pdata can still be "0" (and in fact it is if you right-click in svninside on the message "project not under version control". If it is the case the plugin crashes C::B. I suggest adding a null pointer check or changing the logic in the code above that "if" construct.
With regards, Morten.

Edit:
I have changed the code to the foillowing which works OK:
Code: [Select]
    // get item data
    SVNTreeItemData * pdata = 0; wxTreeItemData * ptr = this->GetItemData(id);
    if (ptr)
    {
        pdata = static_cast<SVNTreeItemData*>(ptr);
    }
    if (!pdata) return 0;
    [...]
This may make sense, too:
Code: [Select]
    // get item data
    SVNTreeItemData * pdata = 0; wxTreeItemData * ptr = this->GetItemData(id);
    if (!ptr) return 0;
    else
    {
        pdata = static_cast<SVNTreeItemData*>(ptr);
    }
    if (!pdata) return 0;
    [...]
« Last Edit: October 10, 2007, 10:59:25 am by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline Jan van den Borst

  • Multiple posting newcomer
  • *
  • Posts: 99
Re: SVNInside : development of another SVN plugin for CodeBlocks
« Reply #22 on: October 10, 2007, 11:59:05 am »
Once CB 1.0 is out, we gonna try to create a common interface for version control system in CB (like M$ does).
Is there something like a preliminary source control interface description?

Jan

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: SVNInside : development of another SVN plugin for CodeBlocks
« Reply #23 on: October 10, 2007, 12:42:38 pm »
I use it on windows and linux and it works fine. I don't know what could go wrong since for me is working. :?
[...]
thats a function to retrieve the svn revision using wxExecute and it works pretty well on both platforms.
Yes, and that is a function that will make the GUI unresponsive for as long as Subversion is running. It is also a function that can have 500 other problems, including lock-up and stale processes, and crashes on exit, if a subprocess is still running. wxExecute is one big pile of crap. In particular, you'll be having a lot of fun if you try to get it to work asynchronously, and if you want to process the events. Apart from the abysmal performance, pointers being held in int variables are a lot of fun, especially if you run your code on a 64 bit platform for the first time. Let's not talk about reading data from a pipe in a tight spinloop and making 3-4 data copies...  :)

I had implemented a Subversion plugin for RC2 that worked exactly the way Orel described (except for using the project file tree, instead of its own, and running asynchronously). It was due for a rewrite, but I never did it, mostly because it's so frustrating to work with wxExecute.
I've written a replacement class with a Windows implementation, and Jonas Thedering contributed the POSIX implementation. Somehow, nobody was really interested in it, and no one would even wager to look at it, so... that thing is still in the attic (for nearly 2 years now).
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5149
Re: SVNInside : development of another SVN plugin for CodeBlocks
« Reply #24 on: October 10, 2007, 01:33:47 pm »
I must say I have seen a ClearCase command not returning in the wxExecute call, and indeed then the GUI of CB is locked. But overall I found it working ok.

@Thomas : so what are you still doing in the basement, get up there on that attic ;-)

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: SVNInside : development of another SVN plugin for CodeBlocks
« Reply #25 on: October 10, 2007, 01:50:02 pm »
I must say I have seen a ClearCase command not returning in the wxExecute call, and indeed then the GUI of CB is locked. But overall I found it working ok.
It is like everything in wxWidgets, it looks like it is working ok at first. But then, you get random crashes that you can't explain, and after weeks, you find out it only happnens when you have more than 127 commandline parameters. So you look at the code and find that wxExecute stores them in a static array that's hardcoded to 127 entries... leaving it to chance whether the 128th or 129th write will cross a page boundary and give a segfault...
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline JGM

  • Lives here!
  • ****
  • Posts: 518
  • Got to practice :)
Re: SVNInside : development of another SVN plugin for CodeBlocks
« Reply #26 on: October 10, 2007, 02:43:42 pm »
So you look at the code and find that wxExecute stores them in a static array that's hardcoded to 127 entries... leaving it to chance whether the 128th or 129th write will cross a page boundary and give a segfault...

Well, is good to know the perspective of someone who has a more advanced experience using this function, and knows the resulting problems from different situations.

There should be a fix then or a different way to work with the function to stop or suppress as much possible problems.

Offline Keyla

  • Multiple posting newcomer
  • *
  • Posts: 48
Re: SVNInside : development of another SVN plugin for CodeBlocks
« Reply #27 on: October 10, 2007, 04:21:36 pm »
Wow thanks for your commitment!

Offline orel

  • Multiple posting newcomer
  • *
  • Posts: 96
Re: SVNInside : development of another SVN plugin for CodeBlocks
« Reply #28 on: October 10, 2007, 05:11:37 pm »
Well, is good to know the perspective of someone who has a more advanced experience using this function, and knows the resulting problems from different situations.

I totally agree with that. It will save me a lot of troubles, trying something to get something to work when i already have a working  solution for this problem, ok a windows-only one.

I've written a replacement class with a Windows implementation, and Jonas Thedering contributed the POSIX implementation. Somehow, nobody was really interested in it, and no one would even wager to look at it, so... that thing is still in the attic (for nearly 2 years now).

I didn'h hear about that and would be glad to look at your windows and posix substitutions for wxExecute.


I had implemented a Subversion plugin for RC2 that worked exactly the way Orel described

I would also be glad to look at this.
windows XP SP2
mingw gcc 3.4.5
svn Code::Blocks and M$ Visual Studio 2005 and .NET to eat!! SVNInside plugin :http://forums.codeblocks.org/index.php/topic,7063.0.html

Offline orel

  • Multiple posting newcomer
  • *
  • Posts: 96
Re: SVNInside : development of another SVN plugin for CodeBlocks
« Reply #29 on: October 10, 2007, 05:25:18 pm »

I have changed the code to the foillowing which works OK:
Code: [Select]
    // get item data
    SVNTreeItemData * pdata = 0; wxTreeItemData * ptr = this->GetItemData(id);
    if (ptr)
    {
        pdata = static_cast<SVNTreeItemData*>(ptr);
    }
    if (!pdata) return 0;
    [...]
This may make sense, too:
Code: [Select]
    // get item data
    SVNTreeItemData * pdata = 0; wxTreeItemData * ptr = this->GetItemData(id);
    if (!ptr) return 0;
    else
    {
        pdata = static_cast<SVNTreeItemData*>(ptr);
    }
    if (!pdata) return 0;
    [...]

OOps  :lol:  Thank you very much.

Patch to Fix compiling under Windows without using Precompiled Headers.
Also, fixes some rules that killerbot has passed on to me.

killerbot inspired ones.
1. If possible, headers should use forward declarations instead of includes.
2. Headers should never include pre-compiled headers like [sdk.h] or [wxprec.h].
    Do not include sdk.h in headers
    Do not include wxprec.h in headers
    Do not use WX_PRECOMP in headers
    Do not use CB_PRECOMP in headers

Ones I decided on by myself.
3. Used system includes in plugins for C::B SDK and wxWidgets includes.
   In plugins, use [#include <sdk.h>] instead of [#include "sdk.h"]

4. Do not use [#include <wx/wx.h>] in either production headers or source code.

I will commit all of this as soon as i 'm not at work ;-)

 For Biplab

I thought i had already tried that (casting to cbEditor*), but maybe i hadn't.


Thank you everybody for contributing. As soon as the project is a little bit more robust and featured, i will open my svn team for anybody who wish to contribute, either by porting SVNInside to linux or other platfroms, or by addng new features.
« Last Edit: October 10, 2007, 08:34:57 pm by orel »
windows XP SP2
mingw gcc 3.4.5
svn Code::Blocks and M$ Visual Studio 2005 and .NET to eat!! SVNInside plugin :http://forums.codeblocks.org/index.php/topic,7063.0.html