Code::Blocks

Developer forums (C::B DEVELOPMENT STRICTLY!) => Plugins development => Topic started by: Jan van den Borst on August 22, 2006, 04:42:05 pm

Title: TortoiseSVN plugin
Post by: Jan van den Borst on August 22, 2006, 04:42:05 pm
I wrote a litte plugin for subversion version control using TortoiseSVN. Maybe it is of use for others???

(windows only)

[attachment deleted by admin]
Title: Re: TortoiseSVN plugin
Post by: Szabadember on September 10, 2006, 01:43:00 pm
What do i need to compile this plugin?  :(
Title: Re: TortoiseSVN plugin
Post by: tiwag on September 10, 2006, 03:00:09 pm
I wrote a litte plugin for subversion version control using TortoiseSVN. Maybe it is of use for others???

(windows only)

work nice , thanks  :D


maybe a setup dialog would be nice, to setup the path to TortoiseProc.exe,
( for those which don't have the TortoiseSVN\bin not in their PATH , i think it isn't installed by default )
also you could get the path from the registry for first setup, but a dialog to change if necessary.
Title: Re: TortoiseSVN plugin
Post by: tiwag on September 10, 2006, 03:05:32 pm
What do i need to compile this plugin?  :(
you need to build CB itself from the svn sources (you need the CB sdk)
Title: Re: TortoiseSVN plugin
Post by: kisoft on September 28, 2006, 08:27:02 am
Thanx, very nice. I use this plugin successfull.
I modify this plugin for remove svn.exe using and adapt sources to new standart.
Now CBTortoiseSVN placed to my ContribPlugins.workplace.
Regards! 8)
Title: Re: TortoiseSVN plugin
Post by: orel on October 04, 2006, 10:01:19 pm
Hi,

i also modify the sources to adapt to the new cb sdk, but i don't know where to put the dll in order it's loaded into CB when it starts.

Maybe i missed something in CB docs or wiki but i can't figure what to do with the dll ?  i put it in  \share\CodeBlocks\plugins directory but i have no TortoiseSVN plugin in my plugin manager

It is also possible that i didn't modify well the TortoiseSVN plugin sources.

Maybe someone can post the new sources, working with the last nightly build or explain me?

Someone else could either post the dll directly, but i prefer to understand by myself.

Thanx !!!
Title: Re: TortoiseSVN plugin
Post by: Pecan on October 04, 2006, 11:00:13 pm
... i put it in  \share\CodeBlocks\plugins directory but i have no TortoiseSVN plugin in my plugin manager


Each plugin contains a zip file by the plugin name in .../share/codeblocks. Within the zip file is a manifest.xml file. Look at how the other plugins have done this. For example, look at keybinder.zip

The plugin .dll goes into .../share/codeblocks/plugins


Title: Re: TortoiseSVN plugin
Post by: MortenMacFly on October 04, 2006, 11:03:33 pm
Maybe someone can post the new sources, working with the last nightly build or explain me?
Here the are - modified and working with SVN trunk.
With regards, Morten.

[attachment deleted by admin]
Title: Re: TortoiseSVN plugin
Post by: Pecan on October 04, 2006, 11:29:40 pm
Maybe someone can post the new sources, working with the last nightly build or explain me?
Here the are - modified and working with SVN trunk.
With regards, Morten.

The manifest file is incorrect. It's name is not C::BTortoiseSVN but CBTortoiseSVN.
I believe it should read:
Code: [Select]
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_plugin_manifest_file>
    <SdkVersion major="1" minor="10" release="0" />
    <Plugin name="CBTortoiseSVN">
        <Value title="C::B TortoiseSVN" />
        <Value version="1.0" />
        <Value description="C::B TortoiseSVN" />
        <Value author="Jan van den Borst" />
        <Value authorEmail="" />
        <Value authorWebsite="http://www.codeblocks.org" />
        <Value thanksTo="Code::Blocks Development Team" />
        <Value license="GPL" />
    </Plugin>
</CodeBlocks_plugin_manifest_file>

Note line 4
Title: Re: TortoiseSVN plugin
Post by: MortenMacFly on October 04, 2006, 11:36:00 pm
Code: [Select]
    <Plugin name="CBTortoiseSVN">
Ooops - you are right... Darn Copy&Paste... :-( ;-)
Title: Re: TortoiseSVN plugin
Post by: Pecan on October 05, 2006, 01:25:07 am
For those who would like to append the CBTortoiseSVN menu onto the Tools menu (taking up less real estate) changing the code after the "else" will do so.
See "CBTortoiseSVN::BuildMenu(wxMenuBar *menuBar)".


Code: [Select]
int ToolsPos = menuBar->FindMenu(_("&Tools"));

 if ( ToolsPos == wxNOT_FOUND )
 menuBar->Append(TortoiseSVN_submenu,_("TortoiseSVN"));
 else
 { //menuBar->Insert(ToolsPos,TortoiseSVN_submenu,_("TortoiseSVN"));
    wxMenu* pToolsMenu = menuBar->GetMenu(ToolsPos);
    pToolsMenu->Append(idCBTortoiseSVN, _("TortoiseSVN"), TortoiseSVN_submenu, _("TortoiseSVN"));
 }

}

//******************************************************************************

void CBTortoiseSVN::RemoveMenu(wxMenuBar *menuBar)
{
    //(pecan 2006/10/04)
    // It is not necessary to remove menu items and can cause a 3 to 10
    // second delay durling program termination
    return;

 wxMenu *menu = 0;

Title: Re: TortoiseSVN plugin
Post by: mandrav on October 05, 2006, 05:14:56 pm
For those who would like to append the CBTortoiseSVN menu onto the Tools menu (taking up less real estate) changing the code after the "else" will do so.

Keep in mind though that the Tools menu is recreated from scratch each time you modify the tools...
Title: Re: TortoiseSVN plugin
Post by: orel on October 05, 2006, 05:29:26 pm
Thanks everyone

I'm going to try that at the moment i'm at home...!
Title: Re: TortoiseSVN plugin
Post by: Pecan on October 05, 2006, 07:07:26 pm
This plugin is trying to execute something called TortoiseProc which I don't have in my TortoiseSVN distribution (XP).

What is it. And why is the plugin trying to execute it?

Edit: Found it.
It seems I have two TortoiseSVNs on my system. Now how did that happen?

Edit: Evidently this plugin requires both the TortoiseSVN gui *and* the command line Subversion version available on the system path.
Title: Re: TortoiseSVN plugin
Post by: orel on October 06, 2006, 01:41:11 pm
Soory guys to bother you but...

It seems that i can not make it work. I don't know what i am missing but nowhere i can see something about the plugin, i'm sure it's not even loaded.

However, i did all these things :

_ put CBTortoiseSVN.dll in \share\CodeBlocks\plugins of the freshly downloaded nightly build version. (that is revsion 3004)
_ created a zip file with the manifest.xml you guys have just post

And nothing appeared anywhere about the plugin, and the Code::Blocks debug message pane doesn't notice about it having been loaded or failed or ... existing

I must have missed a very big point, but which?

 :cry::cry::cry::cry:
it may helps :

WinXP SP2 on Centrino Duo : 1,6 gHz x 2

Title: Re: TortoiseSVN plugin
Post by: David Perfors on October 06, 2006, 02:49:50 pm
same problem here... I thought that the plugin was surging for tortoise before it showed the menu, but that isn't the case (as far as I can see in the source.)
Title: Re: TortoiseSVN plugin
Post by: Pecan on October 06, 2006, 03:42:22 pm
I too have had this problem. But not just with CBTortoiseSVN. Once in a while CB just does not load a plugin. I cannot catch the cause.

But It always says "invalid manifest" in the debug log when it does this.

I then copy the same .zip file over the old .zip manifest file and it works. wierd!

I noticed this happens to me when updating the manifest.xml.
When I stopped updating the manifest, the problem only happens when installing a new plugin.

I've stepped through the code, but can find no cause unless the .zip handler  is failing.

Anyway, try simply recopying the CBTortoiseSVB.zip into .../share/codeblocks . I'm aware that this is voodoo....

Edit: I've found this new manifest method of loading plugins to be very tricky to get right. It take a lot of time and seldom works for me the first time or two.

CBTortoiseSVN does work however. I have it running on XPsp2.
It took about an hour to get CB to recognize it, dicking with the manifest, but I don't know why.
I've just learned, once working, never to touch a manifest ever again.
Title: Re: TortoiseSVN plugin
Post by: David Perfors on October 06, 2006, 04:42:53 pm
That doesn't work :S The plugin name in the manifest file is wrong :S
<Plugin name="C::B TortoiseSVN"> should be <Plugin name="CBTortoiseSVN">

but this was already told, could someone post the changed version?
Title: Re: TortoiseSVN plugin
Post by: Pecan on October 06, 2006, 05:10:30 pm
That doesn't work :S The plugin name in the manifest file is wrong :S
<Plugin name="C::B TortoiseSVN"> should be <Plugin name="CBTortoiseSVN">

but this was already told, could someone post the changed version?

What doesn't work? This works (posted previously)
Code: [Select]
?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_plugin_manifest_file>
    <SdkVersion major="1" minor="10" release="0" />
    <Plugin name="CBTortoiseSVN">
        <Value title="C::B TortoiseSVN" />
        <Value version="1.0" />
        <Value description="C::B TortoiseSVN" />
        <Value author="Jan van den Borst" />
        <Value authorEmail="" />
        <Value authorWebsite="http://www.codeblocks.org" />
        <Value thanksTo="Code::Blocks Development Team" />
        <Value license="GPL" />
    </Plugin>
</CodeBlocks_plugin_manifest_file>

And the plugin posted previously works.

Title: Re: TortoiseSVN plugin
Post by: David Perfors on October 06, 2006, 05:21:21 pm
What doesn't work? This works (posted previously)
Code: [Select]
?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_plugin_manifest_file>
    <SdkVersion major="1" minor="10" release="0" />
    <Plugin name="CBTortoiseSVN">
        <Value title="C::B TortoiseSVN" />
        <Value version="1.0" />
        <Value description="C::B TortoiseSVN" />
        <Value author="Jan van den Borst" />
        <Value authorEmail="" />
        <Value authorWebsite="http://www.codeblocks.org" />
        <Value thanksTo="Code::Blocks Development Team" />
        <Value license="GPL" />
    </Plugin>
</CodeBlocks_plugin_manifest_file>

And the plugin posted previously works.
This manifest file is working indeed, but ths is not in the previously posted zip file..
Title: Re: TortoiseSVN plugin
Post by: Pecan on October 06, 2006, 07:19:44 pm
For those who would like to commit a complete folder/directory rather than just a single file, the following patch will do so.

Code: [Select]
Index: CBTortoiseSVN.cpp
===================================================================
--- CBTortoiseSVN.cpp (revision 42)
+++ CBTortoiseSVN.cpp (working copy)
@@ -5,6 +5,7 @@
 //* Copyright: (c) Jan van den Borst
 //* License:   GPL
 //******************************************************************************
+#include <wx/filedlg.h>
 
 #include "CBTortoiseSVN.h"
 #include "cbeditor.h"
@@ -17,6 +18,7 @@
 static int idCBTortoiseSVN = wxNewId();
 static int idAdd           = wxNewId();
 static int idCommit        = wxNewId();
+static int idCommitPath    = wxNewId();
 static int idDiffWithBase  = wxNewId();
 static int idLog           = wxNewId();
 static int idRepobrowser   = wxNewId();
@@ -36,6 +38,7 @@
 BEGIN_EVENT_TABLE(CBTortoiseSVN, cbPlugin)
 EVT_MENU(idAdd,                 CBTortoiseSVN::OnAdd)
 EVT_MENU(idCommit,              CBTortoiseSVN::OnCommit)
+EVT_MENU(idCommitPath,          CBTortoiseSVN::OnCommitPath)
 EVT_MENU(idDiffWithBase,        CBTortoiseSVN::OnDiffWithBase)
 EVT_MENU(idLog,                 CBTortoiseSVN::OnLog)
 EVT_MENU(idRepobrowser,         CBTortoiseSVN::OnRepobrowser)
@@ -102,6 +105,7 @@
     TortoiseSVN_submenu->Append(idDiffWithBase,  _("Diff with base..."),   _("Diff with base"));
     TortoiseSVN_submenu->Append(idAdd,           _("Add..."),              _("Add"));
     TortoiseSVN_submenu->Append(idCommit,        _("Commit..."),           _("Commit"));
+    TortoiseSVN_submenu->Append(idCommitPath,    _("Commit Path..."),      _("Commit Path"));
     TortoiseSVN_submenu->Append(idLog,           _("Log..."),              _("Log"));
     TortoiseSVN_submenu->Append(idRepobrowser,   _("Repobrowser..."),      _("Repobowser"));
     TortoiseSVN_submenu->Append(idRevisiongraph, _("Revisiongraph..."),    _("Revisiongraph"));
@@ -125,6 +129,11 @@
 
 void CBTortoiseSVN::RemoveMenu(wxMenuBar *menuBar)
 {
+    //(pecan 2006/10/04)
+    // It is not necessary to remove menu items and can cause a 3 to 10
+    // second delay durling program termination
+    return;
+
     wxMenu *menu = 0;
     wxMenuItem *item = menuBar->FindItem(idCBTortoiseSVN, &menu);
 
@@ -279,7 +288,43 @@
 {
     RunSimpleTortoiseSVNCommand(_("commit"));
 }
+//******************************************************************************
+// ----------------------------------------------------------------------------
+void CBTortoiseSVN::OnCommitPath(wxCommandEvent &event)  //(pecan 2006/10/05)
+// ----------------------------------------------------------------------------
+{
+    wxString filename;
+    if (!GetCurrentFilename(filename))
+        return;
 
+    // Ask user for path to commit
+    wxString pathName;
+    pathName = AskForPathName();
+    if ( pathName.IsEmpty() ) return;
+
+    if (!FileUnderVersionControl(pathName))
+    {
+        wxMessageBox(pathName + _("\nPath is not a working copy."), _("Info"),
+                     wxOK | wxICON_INFORMATION);
+        return;
+    }
+
+    wxString command = wxT("commit");
+    wxString commandline =
+        _("TortoiseProc /command:")
+        + command
+        + _(" /path:\"")
+        + pathName
+        +_("\" /notempfile");
+
+    //-wxMessageBox( commandline,wxT("commit Project"));
+
+    DWORD exit_code;
+    if (!Run(false, false, commandline, exit_code))
+        wxMessageBox(_("Command \"") + commandline + _("\" failed"), _("Info"),
+                     wxOK | wxICON_ERROR);
+}
+
 //******************************************************************************
 
 void CBTortoiseSVN::OnDiffWithBase(wxCommandEvent &event)
@@ -331,3 +376,44 @@
 
 //******************************************************************************
 // End of file
+// ----------------------------------------------------------------------------
+wxString CBTortoiseSVN::AskForFileName()       //(pecan 2006/10/06)
+// ----------------------------------------------------------------------------
+{
+    wxString newFileName = wxEmptyString;
+
+    // Ask user for filename
+    wxFileDialog dlg(::wxGetTopLevelParent(0),  //parent  window
+                 _("Select path "),             //message
+                 wxEmptyString,                 //default directory
+                 wxEmptyString,                 //default file
+                 wxT("*.*"),                    //wildcards
+                 wxOPEN | wxFILE_MUST_EXIST );  //style
+
+   // move dialog into the parents frame space
+    wxPoint mousePosn = ::wxGetMousePosition();
+    (&dlg)->Move(mousePosn.x, mousePosn.y);
+
+    if (dlg.ShowModal() != wxID_OK) return wxEmptyString;
+    return newFileName = dlg.GetPath();
+}
+// ----------------------------------------------------------------------------
+wxString CBTortoiseSVN::AskForPathName()       //(pecan 2006/10/06)
+// ----------------------------------------------------------------------------
+{
+    wxString newPathName = wxEmptyString;
+
+    // Ask user for filename
+    wxDirDialog dlg(::wxGetTopLevelParent(0),   //parent  window
+                 _("Select path "),             //message
+                 ::wxGetCwd(),                  //default directory
+                 wxDD_DEFAULT_STYLE );          //style
+
+   // move dialog into the parents frame space
+    wxPoint mousePosn = ::wxGetMousePosition();
+    (&dlg)->Move(mousePosn.x, mousePosn.y);
+
+    if (dlg.ShowModal() != wxID_OK) return wxEmptyString;
+    return newPathName = dlg.GetPath();
+}
+
Index: CBTortoiseSVN.h
===================================================================
--- CBTortoiseSVN.h (revision 41)
+++ CBTortoiseSVN.h (working copy)
@@ -47,6 +47,12 @@
         void OnLock(wxCommandEvent &event);
         void OnUnLock(wxCommandEvent &event);
         void OnUpdateUI(wxUpdateUIEvent &event);
+
+        void     OnCommitPath(wxCommandEvent &event);           //(pecan 2006/10/05)
+        wxString AskForFileName();                              //(pecan 2006/10/06)
+        wxString AskForPathName();                              //(pecan 2006/10/06)
+
+
     private:
         bool FileUnderVersionControl(const wxString& filename);
         bool Run(bool blocked, bool hidden, const wxString& command, DWORD& exit_code );
@@ -59,4 +65,10 @@
 };
 
 #endif // _CBTORTOISESVN_H
+// ----------------------------------------------------------------------------
+//  commit  1.0.01 2006/10/6
+//          Placed menu under CB Tools menu item
+//  commit  1.0.02 2006/10/6
+//          Added OnCommitPath menu & routine
+// ----------------------------------------------------------------------------
 


This is a very nice plugin. I think it's gonna get a lot of use. Could we add it to the contribs?
Title: Re: TortoiseSVN plugin
Post by: orel on October 07, 2006, 01:33:22 am
No luck....

I definitely can't make CBTortoiseSVN work. I even tried 'the voodoo way' (i.e trying to recopy the same zip on itself).

Did you guys have compile CB by yourselves or are you using nightly builds.  I am using nightly builds, do you think this may have an influence on the plugin ?

I know it must be useless, but can someone working on win32 post his dll AND his zip file, and also tell me if he compiled CB or used the nighlty build ?

That would be really nice... :D

I am using CB and Tortoise everyday, so it would be really stupid not to have them embedded each other...
Title: Re: TortoiseSVN plugin
Post by: Pecan on October 07, 2006, 03:50:01 am
I know it must be useless, but can someone working on win32 post his dll AND his zip file, and also tell me if he compiled CB or used the nighlty build ?

Ok, the following url points to CBTortoiseSVN.zip on SaveFile.com.
It contains both the debug and release versions of the dll along with the code and mainifest built with SVN 3001.

Note: this version has been modified to allow commits from a path, and places the menu as a submenu under Tools.

http://savefile.com/files/136874 (http://savefile.com/files/136874)
Title: Re: TortoiseSVN plugin
Post by: orel on October 07, 2006, 12:22:03 pm
Thank you very much Pecan, very kind of you

but....

I just put the dll and the zip file where they must be.

And this time, there is an improvement :

I have something written about the plugin in the debug log :

the problem is that it is written that the plugin was not loaded, saying that maybe symbols are missing.

I also have a message after this saying that the plugin might be built for a different version of the sdk...

This is the same with the debug and release version of the plugin

i have the latest nightly build (revision 3023).... I don't understand anything.
Title: Re: TortoiseSVN plugin
Post by: Pecan on October 07, 2006, 02:05:05 pm
but....
the problem is that it is written that the plugin was not loaded, saying that maybe symbols are missing.
I also have a message after this saying that the plugin might be built for a different version of the sdk...
i have the latest nightly build (revision 3023).... I don't understand anything.

Ok. Hold on. I'll update and re-compile. I'll post a message when it's done.

Edit: Here is a url for CBTortoise.zip build from SVN 3029 containing code, debug and release .dll's along with the manifest & manifest in a CBTortoiseSVN.zip file.

If this does not work with your nightly build, then you are out of luck until the devs include it in the nightly build.

Secondly, I do not understand why it does not work with your nightly unless you are using the Ansi build. This is a Unicode build. It will not work with the Ansi.

http://savefile.com/files/138509 (http://savefile.com/files/138509)
Title: Re: TortoiseSVN plugin
Post by: orel on October 07, 2006, 08:40:02 pm
Quote
If this does not work with your nightly build, then you are out of luck until the devs include it in the nightly build.[/quote

I must be unlucky because everything is the same with this new version, even with both last nightly builds.
And yes, i'm on C::B Unicode.

However, I have to thank you, Pecan, for helping me out with all that stange stuff.

So  Devs !!! :D 

CAN YOU INCLUDE THIS SO USEFUL TORTOISESVN PLUGIN FOR EVERYBODY IN NEXT BUILDS...  :lol:

'til that time, I'll try again to find where that problem is coming from...
Title: Re: TortoiseSVN plugin
Post by: Jan van den Borst on December 11, 2006, 11:56:52 am
Made a new version with new functions added...


[attachment deleted by admin]
Title: Re: TortoiseSVN plugin
Post by: dwmcqueen on June 28, 2007, 07:56:30 pm
This plugin fully functional in latest CB SVN?
Title: Re: TortoiseSVN plugin
Post by: Pecan on June 28, 2007, 11:17:30 pm
This plugin fully functional in latest CB SVN?

I use it almost everyday, but it's for MSwindows only.
Title: Re: TortoiseSVN plugin
Post by: kurapix on June 29, 2007, 05:12:18 am
By reading the topic ... this plugin seems good :D ... but I can't use it since I'm using Ubuntu 7.04 >.< .

Kurapix
Title: Re: TortoiseSVN plugin
Post by: dmoore on June 29, 2007, 12:23:54 pm
you can setup virtually the same thing for linux using my Interpreted Languages plugin to call the standard svn client:
http://forums.codeblocks.org/index.php/topic,6297.msg48252.html#msg48252
(of course you won't get Tortoise's pretty front end for commits, diffs etc)