[TxMt Plugins] Version Control Plugins

Chris Thomas chris at cjack.com
Fri Oct 28 14:19:10 UTC 2005


Just some quick notes while I'm idly thinking about this.
...
For maximum flexibility, probably most version control operations  
should still be handled through the current bundle system. However,  
there are two very desirable things we can't do with the bundles:

(1) a context-sensitive version control menu (perhaps a "Version  
Control" submenu for the context menu)
(2) a graphical indication for each file of the current version  
control state - another icon in the newly mousable status bar :)

To implement those features, TM should be able to lazily:

(a) Discover which version control system is in use for a given  
filesystem node
(b) Given the version control system, use it to find the state of a  
given file or folder
(c) Given the version control system, discover which bundle commands  
should be appear in the version control submenu

The simple plugin interface proposed here should permit this. One  
thing it doesn't do is disable SCM menu items based on the state of  
the file.

It's possible to implement this same interface with scripts, one  
could set a "this is a VCS" bit in the version control bundles, and  
have special hook scripts for "Is this in your version control  
system", "What state is this file in", etc, but I wonder about  
performance. It wouldn't be as efficient; would it be good enough,  
though? The real performance hit for remote SCM is the network query,  
so probably it would be fine.

// bitmap
typedef UInt32 TMSCMState;
enum
{
     kTMVCReadOnly = 0x01,                // Some VC systems need you  
to explicitly unlock the file for editing, this is the locked state  
for that case
     kTMVCModifiable = 0x02,
     kTMVCExclusiveLocked = 0x04,    // if exclusive locked by the  
current user, state is kTMVCModifiable | kTMVCModifiable
     kTMVCLocallyModified = 0x08,
     kTMVCServerModified = etc,      // newer rev of this file on server
     kTMVCUnknown                // this file is not known to the VC
     kTMVCIgnored                // this file is known but ignored by  
the VC (svn:ignore)

// Distributed VCS systems (such as Darcs, Arch, git, baz,  
Mercurial...) will probably only return Modifiable or LocallyModified.
};

@interface TMVCController
- (void) registerVC:(id<TMVCSystem>) vc;
@end

@protocol TMVCSystem
- (NSString *) VCBundleID;    // GUID for the version control bundle  
used to populate the context menu
- (BOOL) isUnderVCControl:(NSURL *)folderPath;    // query to  
determine if this is the right VC system for the given folder
- (TMVCState) stateForLocation:(NSURL *)fileOrFolder;
@end

@implementation TMVCSubversion
- (BOOL) underVCControl:(NSURL *)path
{
     // braindead implementation, not future-proof
     return [... fileExistsAtPath:[path  
stringByAppendingPath:@"/.svn"]];
}
@end




More information about the textmate-plugins mailing list