Author Topic: FileManager: Version Control Browsing  (Read 13605 times)

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
FileManager: Version Control Browsing
« on: January 30, 2015, 04:30:27 am »
20 hours of my life I'm not getting back... not sure whether it's useful or not but I've been building up the infrastructure to let users browse the commit history of their version control system. For now, It only works properly with git and is very bare boned.

Apply the attached path to C::B sources, build C::B + file manager plugin and run C::B. Flip to the "files" tab, enable git decorators (right click on an item in the tab then look under settings in the popup):



Then navigate to a folder that's under Git version control. That will show a wxChoice box, click it and choose "Select Commit"



Which will let you browse your commits.



Select one and click on the "Use Selected Commit" button and you should be able to browse the tree for that commit and open the files in C::B (they are saved to a temp folder)

Obviously still needs a ton of work and has a bunch of silly bugs. The intent is to be able to support browsing of GIT, SVN, HG and BZR (and hopefully then you'll all see how shitty SVN is and we can switch to GIT!!) and do nice things like search and diff views.

See last post for the current patch.
« Last Edit: February 10, 2015, 05:35:29 am by dmoore »

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5187
Re: FileManager: Version Control Browsing
« Reply #1 on: January 30, 2015, 07:24:51 am »
cool, please also add support for svn ;-)

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: FileManager: Version Control Browsing
« Reply #2 on: January 31, 2015, 05:21:56 am »
New patch attached supporting both GIT and SVN. This one updates the windows project file (but not the wx3.0 files) but hasn't been tested.  GIT/SVN must be in the system path for the feature to work correctly.
« Last Edit: February 09, 2015, 08:33:15 pm by dmoore »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9504
Re: FileManager: Version Control Browsing
« Reply #3 on: January 31, 2015, 07:04:21 am »
New patch attached supporting both GIT and SVN.
Very nice... :D
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 dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: FileManager: Version Control Browsing
« Reply #4 on: February 02, 2015, 03:33:36 am »
New patch. Crushes a bunch of bugs and implements browsing for Bazaar and Mercurial. Plan to add support for searching commits by name or revision, viewing diffs etc.

But more generally, having now played around with a few different VCS systems, I think I can see how to integrate support for all of them throughout C::B. So, for example, when you have a file open in an editor that's under a VCS, you will be able to see options to see its VCS status, history, and diffs. The same goes for files in the project tree.
« Last Edit: February 09, 2015, 08:34:13 pm by dmoore »

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: FileManager: Version Control Browsing
« Reply #5 on: February 09, 2015, 04:49:39 am »
New patch features searching for a particular commit. (Date ranges don't work properly yet.)

EDIT: Ooops. bad patch. new one cominng soon.
« Last Edit: February 09, 2015, 03:10:19 pm by dmoore »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9504
Re: FileManager: Version Control Browsing
« Reply #6 on: February 09, 2015, 08:41:37 am »
New patch features searching for a particular commit. (Date ranges don't work properly yet.)
Does it make sense to move this functionality to the project tree sooner or later?

What do you mean by:
But more generally, having now played around with a few different VCS systems, I think I can see how to integrate support for all of them throughout C::B.
?
Does it mean another plugin / the work you do... something else? :-)
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 dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: FileManager: Version Control Browsing
« Reply #7 on: February 09, 2015, 04:23:42 pm »
Does it make sense to move this functionality to the project tree sooner or later?

Yes. It's reasonably stable now, so as soon as I can. But still need to test on windows and fix the makefiles.

Quote
Does it mean another plugin / the work you do... something else? :-)

Not sure yet. Maybe just a separate VCS plugin, but that will be a little tricky to integrate with a separate file manager plugin. Otherwise a new manager/plugin combination, but I'd prefer not to do that. It will mean refactoring this patch quite a bit to separate out VCS specific code into separate classes.

Updated patch attached.
« Last Edit: February 09, 2015, 08:33:00 pm by dmoore »

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: FileManager: Version Control Browsing
« Reply #8 on: February 10, 2015, 05:34:58 am »
Now in SVN. I think I got the makefiles and windows stuff right, but not wx3.0 yet, and probably not PCH/non-PCH.

« Last Edit: February 10, 2015, 05:44:51 am by dmoore »

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5187
Re: FileManager: Version Control Browsing
« Reply #9 on: February 11, 2015, 10:48:24 am »
works nicely.


Some requests ? suggestions ?  (doing this via svn)

- can a history entry be made (now it is available, via the diff against)
- but the diff, when you get it via right click context menu is containing all commits, would be more nice to have only the commits impacting this file
- in the history (diff), select 2 revisions and see the diff between those 2
- some way of instructing that the diff  should be send to meld (instead of the patch diff notation)

Is there a way when in the project tree to end up directly to the integration which is now in the Files tab ? Or as step in between : right click on a file in the project tree, and tell it to go to the corresponding place in the files tree (so no need to search there for the file first) ?

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: FileManager: Version Control Browsing
« Reply #10 on: February 11, 2015, 02:58:19 pm »
Some requests ? suggestions ?  (doing this via svn)

Of course. SVN is the problem child. For example, I still need to figure out how to handle password prompts every time I browse the log  ???

Quote
- can a history entry be made (now it is available, via the diff against)

As in the history of commits? Not sure what you have in mind.

Quote
- but the diff, when you get it via right click context menu is containing all commits, would be more nice to have only the commits impacting this file

Yes, planning to add the feature to specify changes only affecting a certain file in the commit browser dialog and to use that by default for the diff.

Quote
- in the history (diff), select 2 revisions and see the diff between those 2
- some way of instructing that the diff  should be send to meld (instead of the patch diff notation)

Yes, eventually

Quote
Is there a way when in the project tree to end up directly to the integration which is now in the Files tab ? Or as step in between : right click on a file in the project tree, and tell it to go to the corresponding place in the files tree (so no need to search there for the file first) ?

I do plan to integrate something into the project tree, but not sure how extensive that will be just yet. Right now you can right click on a project and open the corresponding directory in the file browser and I could probably do something similar for individual files. The logic is trickier if the repo is say, /projects, the project file is as project/project1/project1.cbp, but the file is /project1/src/module1/module1.cpp.  Should the filemanager set the root to /projects and then expand the subdirectories to show and center on the location of the file? The logic for that is a little tricky because you need to figure out which repo the file is in.

By the way, the show changed files only also makes it easier to find changed files.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9504
Re: FileManager: Version Control Browsing
« Reply #11 on: February 11, 2015, 05:45:51 pm »
My 2 cents for today...:
1.) I don't understand the "favourites" system: I can setup favourites (that works nice), but how do I access them?
2.) Crash: Whenever I try to set some folder to be the root folder I get a crash pointing to the FileManager plugin.
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 MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9504
Re: FileManager: Version Control Browsing
« Reply #12 on: February 11, 2015, 05:50:53 pm »
2.) Crash: Whenever I try to set some folder to be the root folder I get a crash pointing to the FileManager plugin.
Some more details:
It happens in the marked line:
Updater::~Updater()
{
    if(m_exec_proc)
    {
        m_exec_timer->Stop(); // << crash here!
        delete m_exec_timer;
        m_exec_proc->Detach();
        m_exec_cond->Signal();
        m_exec_mutex->Unlock();
    }
    if(IsRunning())
    {
        m_kill=true;
        Wait();
    }
}

...and m_exec_timer is "0xbaadf00d" -> unallocated.

It happens on folders that are under version control and where the VCS executables are not found (in the debug build I see: "Execution of command XXXX failed...").
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 MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9504
Re: FileManager: Version Control Browsing
« Reply #13 on: February 11, 2015, 05:58:09 pm »
...and m_exec_timer is "0xbaadf00d" -> unallocated.
Naaah... fixed in SVN.

You'd better remember to ALWAYS initialise pointer variables in the constructor in the future... ;-)
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 MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9504
Re: FileManager: Version Control Browsing
« Reply #14 on: February 11, 2015, 06:20:09 pm »
Naaah... fixed in SVN.
...but I'll give you another one: If in debug mode, a missing VCS executable will raise a wxExecute error dialog that freezes C::B completely.

My suggestion:
If you handle the wxExecute result yourself (which seems to be the case), use wxLogNull to avoid such freezes, like:

{
  wxLogNull ln;
  h_result = wxExecute(...)
}

To handle all the different wxExecute calls across the plugin (I counted at least 15) you should put them into one place/method which you call with a parameter what command to call exactly.

Maybe you share my thoughts...?!
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