annotated mercurial notes



(some useful unix terminal commands (linux,cygwin,mac) can be found here.

from shell, to start your archive:

step 1:

install hg
ubuntu: (sudo apt-get install hg)...
windows: first install cygwin and work from your cygwin home directory
more info here.

step 2:

put key files (863.10 and 863.10.pub) somewhere, probably in ~/.ssh/keys/ (you might want to create this keys directory)
note that directories that start with a "." may be automatically hidden by your filesystem, you can see them by typing ls -a
example:
use the terminal and create a folder called .ssh in the home directory, then within the new .ssh directory create another directory called keys
download the (863.10 and 863.10.pub) files and place them in the keys directory (you will have to either enable hidden folders, or do this all through the terminal)

step 3:

set permissions for your private key so that only the user has read/write access (i.e. sudo chmod go-rw ~/.ssh/keys/863.10)
your private key permissions could be rw-------, and your public key and config file permissions could be rw-r--r--

step 4:

set the port that ssh uses to access fab.cba.mit.edu, by appending the following lines to ~/.ssh/config (you might have to create ~/.ssh/config, which is a text file with unix line endings and no .txt extension)

   host fab.cba.mit.edu
   port 846


step 5:

go to where you want the archive to be in your filesystem, and clone the archive
       note that local_archive_name will be a directory with the archive inside it
       ssh_path is the ssh application, including the path, if necessary

   hg clone -e "ssh_path -i ~/.ssh/key_path/key_name" ssh://hg@fab.cba.mit.edu/863.10 local_archive_name
   example:hg clone -e "ssh -i ~/.ssh/keys/863.10" ssh://hg@fab.cba.mit.edu/863.10 fabClassArchive

step 6:

append the following your archive's personal configuration file, .hg/hgrc with any text editor
       (the .hg directory is in the fabClassArchive directory, and is a text file with unix line endings and no .txt extension)

   [ui]
   username =
First Last <user@machine.domain>
   ssh =
ssh_path -i ~/.ssh/key_path/key_name -C

   [hooks]
   changegroup = hg update >&2

example:

[ui]
username = johnny cash <jcash@folsom.gov>
ssh = ssh -i ~/.ssh/keys/863.10 -C

[hooks]
changegroup = hg update >&2


(you will find this configuration file inside the new directory, eg. "//fabClassArchive//" (or whatever you called it); navigate in the terminal to this directory, then navigate to the directory .hg; then, use nano or vim to edit the file "hgrc" (past the bold items into that file and save it))


step 7:

try updating your archive by typing: hg pull
       you should see a response like this:

   pulling from ssh://hg@fab.cba.mit.edu/863.10
   searching for changes
   no changes found

if it asks for a password, then it can’t find the key or the key file permissions make it not look like a key (see step 3)
if it says something about port 22, then it can't find the config file (see step 4)

you're ready:


whenever you want to edit the archive, it is good practice to
1)first get the latest version of archive by typing: hg pull and hg update
2)make your changes / additions
3)add changes to the source archive with the following commands:

hg add .(add all new files)
hg commit -m message (alias ci)
hg push (push to archive)

example:

hg add .
hg commit -m “a message that briefly indicates what is being added”
hg push

if branches have diverged, you might need to:

hg pull
hg update
hg merge
hg add .
hg commit -m message
hg push

if there are multiple heads, then you might need to manually merge them back down to one...

hg heads (shows you all of the different heads, and their HEADNUMBERs)
hg merge HEADNUMBER
hg update -c
hg commit -m message
(repeat for however many extra heads you've created)

if incompatible changes have been made on diverged branches, then the simplest thing to do is to save your changed files to someplace on your computer that is outside of the archive (like on your desktop) and roll your archive back so that you can manually integrate your changes with those of whomever pushed their incompatible changes before you did!...

hg commit --close-branch -m message
hg update -c
hg pull
hg update
hg merge
hg add .
hg commit -m message
hg push
(repeat for however many extra heads you've created)