Resgrp:comp-photo-version control example
This is an example of how one might use mercurial to work on the gaussian code.
Adding a feature you've already coded
You've got a set of changes that constitute some neat feature or bug fix, and you want to get it checked into a repository. It's based off some older version of Gaussian and you want to bring it up to date with the latest version.
First, check out a clone of the gaussian-inc-versions repository. We'll use
-u h21
to check out a working directory with a buildable and
locally bug-fixed H21 release in it.
$ hg clone -u h21 /home/gaussian-devel/repositories/gaussian-inc-versions myrepo
13578 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd myrepo
The repository only goes as far back as H01 (at the moment), so if you're based off a different release you'll have to either update it manually to h01 or work out how to import your earlier release into a mercurial repository.
Now copy your own code over the code in the working directory. Obviously routines for
L510 go in the l510 directory and so on. Util files go in either utilam, utilnz, osutil, putil, etc. You can see what files you've added or altered using hg stat
. If your
change requires that you remove files use hg rm
rather than regular rm
.
Once you're content that all your code is in the working directory you can do a:
$ hg addremove
This will mark to be added any files that you've added. Check you're not adding things like test jobs (we need these somewhere else -- where?), temporary files, etc.
Now check in your code:
$ hg commit
An editor will open and you can write a useful log message detailing what this code does. Be as verbose as you like, but make the first line be a useful summary. Now this repository holds your feature. Only your repository has this change; you may decide to work on it some more, or throw it away by deleting the repository. You may also want to update your code to the latest Gaussian version:
$ hg merge h23
or
$ hg merge
to update to the latest version, whatever that is.
Once the merge is done and you've resolved any conflicts commit again, noting in your log message that you've updated to a particular version:
$ hg commit -m 'Updated my feature to H23'
Again, you can share these changes with your other repositories (to combine your features) or with other people. You can also pull them into a local-dev-master (see below) repository to merge in other local group features.
Getting a version to code something new into
You've been told to grab the latest local development changeset and code in something new.
Start by cloning the latest development repository:
$ hg clone /home/gaussian-devel/repositories/local-dev-master
updating to branch default
13722 files updated, 0 files merged, 0 files removed, 0 files unresolved
This will create a clone of the repository in the current directory with the name 'local-dev-master'. You can override this if you want.
Use hg log
and hg sum
and check out the wiki page documenting code in this repository to get an idea of what
you're starting from. Generally this repository will hold features and bug fixes that the
group deems ready for prime time usage; code here is probably intended to go to Gaussian, Inc.
and is the correct starting point for new features.
As you code, commit your changes using hg commit
at appropriate points. This is
sort of up to you, but it would be nice if we could agree to check in code that compiles.
Really though, it doesn't matter too much, as we can combine sets of revisions should we need to.