Last year at Fab Academy we used Bazaar for distributed version control. This year we are using Mercurial.
Mercurial Troubleshooting / Notes From 02.02.2011 Session With Neil Gershenfeld:
- TAKE NOTE: If you try to push and Mercurial mentions:
- multiple branches
- multiple heads
- outstanding uncommitted changes
- archive has diverged
- or any other similar message
- and then asks if you want to push anyway..
DON’T DO IT! This creates multiple heads.
After you give Mercurial a command, look at the output, read all the messages and respond to them.
These notes should help with some common problems we have all been having.
|General Command Meanings:|
|pull||pulls down current state of the archive (brings changes)|
|merge||remote hg directory has new changes, if your local copy is an older version, merge reconciles them.|
|commit||stores a “snapshot” of your copy of the archive|
|push||sends changes back to central server we are all using (MIT copy)|
|update||takes the changes and puts them in the working copy of the directory|
- if you added new work to your directory:
hg add hg commit -m "your commit message here" hg pull
- if you get new stuff (files added) when / after pulling
- you need to merge:
hg merge hg push
If You Delete a Local File / Directory in Your “firstname_lastname” folder:
- You will need to tell Mercurial to “record a delete for missing files”
- You will run into problems if you don’t do this!
hg add hg rm -A
- You will get a very long listing both of removed files and files that Mercurial says “still exist and will not be removed”.
[many files listed above as "not removing"............]
not removing Web/videos/video/module_02.html: file still exists (use -f to force removal)
- >>> do not force remove anything
- This is what should happen.
- Mercural is updating.
hg commit -m "your commit message here" hg pull
Errors and Issues:
If the Archive Has Diverged:
You try to push and get any of the following:
- “archive has diverged” message
- “abort: push creates new remote heads on branch ‘default’!”
- “abort: crosses branches”
- or something similar to the above messages
- You need to Pull and Merge. DO NOT FORCE PUSH.
- First, pull to make sure you have an up to date copy of the archive.
hg commit -m "your commit message here"
- You should check status:
- if you have a “!” in front front of a file or directory name in the status listing, it means you deleted a file that Mercurial is tracking.
- Mercurial gets confused.
- To fix this –> do the following:
- tell Mercurial to record a delete for missing files
hg rm -A hg commit -m "your commit message here" hg pull
- if you get a message about “multiple heads” –> see next topic below.
If Mercurial Mentions “Multiple Heads”:
$ hg pull
pulling from ssh://email@example.com/academysearching for changes
adding file changes
added 50 changesets with 162 changes to 113 files (+1 heads)
abort: crosses branches (merge branches or use –check to force update)
warning: changegroup hook exited with status 255
(run ‘hg heads’ to see heads, ‘hg merge’ to merge)
- to remove heads, list heads:
- Mercurial will list heads .
$ hg heads
user: Kinga Kubowicz <firstname.lastname@example.org>
date: Thu Feb 03 13:40:38 2011 +0100
user: Anna Kaziunas France <email@example.com>
date: Thu Feb 03 08:23:21 2011 -0500
summary: created external css for resources page
- To merge with one of these heads (you can have many heads) –> type the number after “changeset:”
- I have shown the number in bold so you can see them more easily.
- For example, to merge with head –>changeset: 480:00cdd8eef593
hg merge 480
- If there are multiple heads (more than one listed as the output of hg heads) you wil need to repeat the merge for each head until there is only one left
- Then commit your changes:
hg commit -m "commit message" hg push
- don”t push if it says you shouldn’t – “archive has diverged” – then pull instead.
hg pull hg update hg heads
- if you can’t get all the heads resolved or the error messages – re-clone the archive.
To Re-Clone The Archive:
- if you have new work in your firstname_lastname directory, make a copy and save in a directory outside of the “academy” directory
- delete the “academy” directory
- re-initialize the hg repository:
The rest of the instructions are here: http://academy.cba.mit.edu/tutorials/mercurial/ follow steps 5 to the end of the tutorial.
If You Get a “waiting for log on working directory” Message:
- use CONTROL + C to interrupt
.DS_Store Error – MAC only
- If you try to merge and get the following:
$ hg merge
local changed Web/labs/.DS_Store which remote deleted
(d)elete? ged version or
–> hit the <ENTER> key.
- Then commit the changes
hg commit -m "removed .DSstore file"