[MonoDevelop] VersionControl Add-in for Perforce

Michael Hutchinson m.j.hutchinson at gmail.com
Tue Jul 1 22:05:10 EDT 2008


On Tue, Jul 1, 2008 at 7:56 PM, Casey Marshall
<cmarshall at pacificbiosciences.com> wrote:
> Hi.
>
> I'm looking to implement a VersionControl Add-in for MonoDevelop that
> uses Perforce as the back-end, and had a few questions about VC and
> Add-in development:
>
>   - First, has someone already written such a thing? (I'm assuming not,
> given Google's silence).

Nope. the only (successful/released) version control addin that I know
of is the SVN one in trunk.

>   - It doesn't look like there's any way for MonoDevelop to figure out
> that a particular solution/project/file/etc. is already under version
> control -- I only see hooks to "checkout" and "publish" code. If this
> doesn't exist, that would obviously be a neat feature.

It does do that. The real fun is all in the Repository instances that
the VersionControlSystem returns, which has (among many other things)
an IsVersioned (string localPath) method.

Take a look at http://anonsvn.mono-project.com/viewcvs/trunk/monodevelop/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Repository.cs?view=markup
and the SVN implementation:
http://anonsvn.mono-project.com/viewcvs/trunk/monodevelop/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionRepository.cs?view=markup

>   - Related to that, how does the VC add-in know that a solution is
> under version control?

By asking the version control addins if the project file is under
version control GetRepositoryReference in VersionControlService, and
using the first one that returns a non-null Repository.

>   - I'd like to add a simple preference pane, which lets you globally
> enable the Add-in. I presume this is easy to do, I just haven't looked
> hard enough yet at how to do it.

Yes, that's pretty easy, but why can't it just be enabled with the
addin manager?

>   - Does RequestWritePermission do what I hope it does? As in, if a file
> needs to be written by MonoDevelop, will this be called if the file is
> not writable? This is clearly desirable, here, since Perforce leaves
> un-checked-out files read-only. I don't see any other command in
> Repository that ties to a "check out this file for editing." (which, of
> course, VC systems that are better than Perforce don't usually have, but
> I'm working with what I'm stuck with)

That's a good question. The Repository does have Lock/Unlock methods,
but I ahve no idea if they are actually used. I'm pretty sure that a
lot of code in MD wouldn't respect this.

That said, any patches needed to make it work properly would be welcome :)

[I can't actually find RequestWritePermission]

>   - Is there a simple way to get a "console," or some way to print out
> what p4 commands are being run? I think the IProgressMonitor plugs into
> one, but I don't get passed one with every command -- I'm implementing
> this by just using the `p4' command-line program, and I'd like to have
> this for debugging and monitoring.

Well, there's MonoDevelop.LoggingService.LogDebug (which can be
enabled using environemnt variables and directed to the console, a
file, and/or the internal message pad)
System.Diagnostics.Debug.WriteLine might be more approprate since
references to it get ignored if you compile without /d:DEBUG.

Also, if you can P/Invoke into some stable library, that'll be a *lot*
faster than constantly forking command-line processes. Dunno if
perforce supports this or not.

> Also, if the community is interested in this add-in, we might be able to
> release it as open source.

That's be nice. We'd certainly appreciate validation that the APIs
work with something other than SVN :)

-- 
Michael Hutchinson
http://mjhutchinson.com


More information about the Monodevelop-list mailing list