views:

42

answers:

2

So I'm pretty new to version control but I'm trying to use Mercurial on my Mac to keep a large Python data analysis program organized. I typically clone my main repository, tweak the clone's code a bit, and run the code on my data. If the changes were successful I commit and eventually push the changes back to my main repository. I guess that's a pretty typical workflow under version control.

My problem is that my code is run on the command-line, with several command-line arguments that refer to data files in the current working directory (and I have many such directories I need to test the code in, and they're outside of version control). So before using Mercurial I just kept my code in one ~/bin directory which was part of my PATH environment variable. Now, with version control, I need to either (1) after each edit, copy my current clone's executables to the ~/bin directory before running the code on the command line, or (2) each time I clone my code, add my current clone's path to the PATH, or (3) specify the entire/path/to/my/programs on the command line each time I run the code. None of these are very convenient, and I'm left feeling like there must be an elegant solution that I just don't know. Maybe something involving Mercurial's hooks? I want my under-revision code to be runnable on the command line between commits, so this seemed to rule out hooks, but I don't know... Many thanks for any suggestions!

A: 

What I do in such a case is set up a two deep chain of symlinks to my binary in my current clone. For example I'll have:

/usr/bin/myappname

which is a symlink to

/home/me/repos/CURRENT/bin/myappname

where /home/me/repos/CURRENT is a symlink to whatever my current working clone is, for example:

/home/me/repos/myproject-expirment

After setting up the initial /usr/bin/myappname symlink all I have to do is update the CURRENT symlink when I create a new clone on which I'm working.

Ry4an
Thanks Ry4an, symlinks hadn't occurred to me but they'd definitely be an improvement over what I do now (copying of current binaries to my bin directory).
wgrover
A: 

Ry4an's answer is good if you want to continue with the multiple-clones workflow. But it's also worth being aware that Mercurial's powerful enough to allow you most of the benefits of that workflow without ever leaving your single "main" repo. I.e. you can create branches (named or anonymous) for experimental features, easily "hg update" to whatever version of the code you want to test, even use the mq extension to prune branches that didn't work out.

Carl Meyer
Thanks Carl, I didn't appreciate the differences between branching and cloning. In case anyone else is at the same place on the Mercurial learning curve, here's a nice comparison of the different ways to branch code:http://stevelosh.com/blog/entry/2009/8/30/a-guide-to-branching-in-mercurial/I'm thinking that "branching with named branches" best suits my workflow - the single working directory can be in my PATH; the various code iterations I'm testing get names to keep me organized, and I can "hg update" to whatever I want and prune my failures with mq as you suggest. Thanks again!
wgrover