Posts Tagged terminal

Using Vault from the command line on OS X

These are directions for using SourceGear’s Vault version control from the command line on a Mac (OS X 10.5). You will need the Vault client installed (the client, not the server… you’ll be connecting to the server) as well as mono. I recommend using a package manager like MacPorts to handle mono (and any other unixy linuxy command line stuff you need to install). Oh, here is a useful link to the SourceGear support forums (well, kind of useful, Mac users are not exactly a priority as this app is really meant to be used with a Windows GUI client… oh, and don’t bother asking for a Mac GUI client. It ain’t happening).

The basic set of commands to use Vault from terminal on a Mac involve enough typing to wear your fingers out quick (note that I am using a very old version of the client software. This is because the server I am connecting to is old and won’t work with the latest versions of the client). Thus we will create aliases for everything. So the basic command to get into Vault is:
mono /usr/local/bin/VaultClientAPI_3_1_9/vault.exe -repository "My Repository"
Let’s alias that in .bash_login:
alias vault='mono /usr/local/bin/VaultClientAPI_3_1_9/vault.exe -repository "My Repository"'

Now we only have to type “vault”! In these following commands note the need to type backslash, dollar sign, forward slash ( \$/ ) before your repository project path. Weird but you gotta do it (I think that Vault expects $/ and that initial backslash is simply there to escape the dollar sign).

Get a project’s files:
vault get \$/projectname/
Checkout:
vault checkout \$/projectname/assets/css/main.css
Checkin:
vault checkin \$/projectname/assets/css/main.css
Checkin but no changes:
vault checkin -unchanged undocheckout \$/projectname/assets/css/main.css
Add a file and commit the add (all in one):
vault add -commit \$/projectname/assets/images/speakers/ /local/path/to/files/projectname/assets/images/speakers/schmitt.jpg
Rename and commit a file (all in one):
vault rename -commit \$/projectname/about/index.php index_2.php

Help! Vault is all $#^@%& up!

Sometimes errors will crop up. You may have commits that didn’t take or adds or other changes that did not go through for some reason. This will clutter your changeset (give it a look if you’ve been using Vault for a while… you may be surprised). You can view the changeset with:
vault listchangeset

To delete the changeset or to reset things when something goes wrong you can delete certain files. For example:
CacheMember_ChangeSetItems
CacheMember_CheckOutList

These are located on a path named something like:
/Users/yourusername/.config/SourceGear/Vault_1/Client/F8FB077F-8F3B-44B1-80B3-8BDC93CBC0F1/admin/

Great but it’s still too much typing, homes.

For further ease you can alias some of these commands. For example:
alias vci='vault checkin'
or
alias vciun='vault checkin -unchanged undocheckout'

So that the entire series of commands to checkin an file goes from:
mono /usr/local/bin/VaultClientAPI_3_1_9/vault.exe -repository "My Repository" checkin \$/projectname/index.php
to
vci \$/projectname/index.php
and for an unchanged checkin:
mono /usr/local/bin/VaultClientAPI_3_1_9/vault.exe -repository "My Repository" checkin -unchanged undocheckout \$/projectname/index.php
to
vciun \$/projectname/index.php

     

, ,

No Comments