Mercurial: Difference between revisions
toooo much sudo |
|||
(6 intermediate revisions by 2 users not shown) | |||
Line 30: | Line 30: | ||
put key files (academy and academy.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 (academy and academy.pub) files and place them in the keys directory (you will have to either enable hidden folders, or do this all through the terminal) | put key files (academy and academy.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 (academy and academy.pub) files and place them in the keys directory (you will have to either enable hidden folders, or do this all through the terminal) | ||
mkdir ~/.ssh/keys | |||
Open the directory where the key files where downloaded to and move them to .ssh/keys directory | Open the directory where the key files where downloaded to and move them to .ssh/keys directory | ||
mv academy ~/.ssh/keys | |||
mv academy.pub ~/.ssh/keys | |||
=== Step 3: Permissions for the private key === | === Step 3: Permissions for the private key === | ||
Line 41: | Line 41: | ||
set permissions for your private key so that only the user has read/write access (i.e. sudo chmod go-rw ~/.ssh/keys/academy) your private key permissions could be rw-------, and your public key and config file permissions could be rw-r--r-- | set permissions for your private key so that only the user has read/write access (i.e. sudo chmod go-rw ~/.ssh/keys/academy) your private key permissions could be rw-------, and your public key and config file permissions could be rw-r--r-- | ||
~/.ssh/keys$ | ~/.ssh/keys$ chmod go-rw academy | ||
~/.ssh/keys$ | ~/.ssh/keys$ chmod go-rw-r--r-- academy.pub | ||
=== Step 4: Setting the port === | === Step 4: Setting the port === | ||
Line 49: | Line 49: | ||
step 4: set the port that ssh uses to access fab.cba.mit.edu, by appending the following lines to ~/.ssh/keys/config (you might have to create ~/.ssh/keys/config, which is a text file with unix line endings and no .txt extension) | step 4: set the port that ssh uses to access fab.cba.mit.edu, by appending the following lines to ~/.ssh/keys/config (you might have to create ~/.ssh/keys/config, which is a text file with unix line endings and no .txt extension) | ||
~/.ssh/keys$ | ~/.ssh/keys$gedit config | ||
Write this in the config file and save: | Write this in the config file and save: | ||
Line 58: | Line 58: | ||
<br> Write | <br> Write | ||
~/.ssh/keys$ | ~/.ssh/keys$ chmod go-rw-r--r-- config | ||
=== Step 5 Clone the archive === | === Step 5 Clone the archive === | ||
Line 68: | Line 68: | ||
Copy the text (after $ )to the terminal: | Copy the text (after $ )to the terminal: | ||
~/Documents/FabAcademy2014$ | ~/Documents/FabAcademy2014$ hg clone -e "ssh -p 846 -i ~/.ssh/keys/academy" ssh://hg@fabacademy.org/academy.2014 academy.2014 | ||
*Eddie (Manchester) - Need to include sudo before hg | *Eddie (Manchester) - Need to include sudo before hg | ||
*Bas (Reykajvik) - Don't include sudo before hg! | |||
<br> | <br> | ||
Line 79: | Line 78: | ||
*(the .hg directory is in the fabClassArchive directory, and is a text file with unix line endings and no .txt extension) | *(the .hg directory is in the fabClassArchive directory, and is a text file with unix line endings and no .txt extension) | ||
~/Documents/ | ~/Documents/FabAcademy2014$ sudo gedit .hg/hgrc | ||
Put this text in the file | Put this text in the file | ||
[paths] | [paths] | ||
default | default = ssh://hg@fabacademy.org/academy.content | ||
[ui] | [ui] | ||
username = First Last <user@machine.domain> | username = First Last <user@machine.domain> | ||
Line 95: | Line 94: | ||
try updating your archive by typing: | try updating your archive by typing: | ||
~/Documents/FabAcademy2013/academy.2013$ | ~/Documents/FabAcademy2013/academy.2013$ hg pull | ||
*Eddie (Manchester) - Need to include sudo before hg command | *Eddie (Manchester) - Need to include sudo before hg command (bas: no, don't use sudo) | ||
you should see a response like this: | you should see a response like this: | ||
Line 111: | Line 110: | ||
*To get all changes from another repository into the current one | *To get all changes from another repository into the current one | ||
~/Documents/FabAcademy/academy.2013$ | ~/Documents/FabAcademy/academy.2013$ hg pull | ||
*Update | *Update | ||
~/Documents/FabAcademy/academy.2013$ | ~/Documents/FabAcademy/academy.2013$ hg update | ||
<br> | <br> | ||
Line 121: | Line 120: | ||
*Add new files | *Add new files | ||
hg add | |||
*Commit changes | *Commit changes | ||
hg commit -m 'MESSAGE' | |||
*merge | *merge | ||
hg merge | |||
Push files to server | Push files to server | ||
hg push | |||
=== And also === | === And also === | ||
Line 187: | Line 186: | ||
==Links== | ==Links== | ||
*http://fabacademy.org/archives/2014/tutorials/mercurial_install_ubuntu.html | |||
*[http://www.as220.org/fabacademy/tutorials/mecurial_troubleshooting.html http://www.as220.org/fabacademy/tutorials/mecurial_troubleshooting.html] | *[http://www.as220.org/fabacademy/tutorials/mecurial_troubleshooting.html http://www.as220.org/fabacademy/tutorials/mecurial_troubleshooting.html] | ||
*[http://fab.cba.mit.edu/classes/MIT/863.10/people/natalie.freed/Mercurial_notes_notes.html http://fab.cba.mit.edu/classes/MIT/863.10/people/natalie.freed/Mercurial_notes_notes.html] | *[http://fab.cba.mit.edu/classes/MIT/863.10/people/natalie.freed/Mercurial_notes_notes.html http://fab.cba.mit.edu/classes/MIT/863.10/people/natalie.freed/Mercurial_notes_notes.html] |
Latest revision as of 00:23, 25 February 2015
Mercurial is a free, distributed source control management tool. It efficiently handles projects of any size and offers an easy and intuitive interface.
- http://academy.cba.mit.edu/content/tutorials/02_Project_Management/mercurial_install_ubuntu.html
- http://academy.cba.mit.edu/content/tutorials/02_Project_Management/mercurial_basics_and_resources.html
- http://academy.cba.mit.edu/content/tutorials/02_Project_Management/mercurial_troubleshooting.html
- http://mercurial.selenic.com/
- http://academy.cba.mit.edu/classes/project_management/archive.html
- http://fab.cba.mit.edu/classes/MIT/863.10/people/kenny.cheung/hgNotes.html, which this is mostly built on.
Mercurial on Ubuntu
Step 1: Install
Install .ssh
sudo apt-get install ssh
Download the academy and academy.pub files to your .ssh folder.
Linux packages
sudo apt-get install mercurial tortoisehg tortoisehg-nautilus
install Mercurial
sudo apt-get install mercurial
Step 2: Key files
put key files (academy and academy.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 (academy and academy.pub) files and place them in the keys directory (you will have to either enable hidden folders, or do this all through the terminal)
mkdir ~/.ssh/keys
Open the directory where the key files where downloaded to and move them to .ssh/keys directory
mv academy ~/.ssh/keys mv academy.pub ~/.ssh/keys
Step 3: Permissions for the private key
set permissions for your private key so that only the user has read/write access (i.e. sudo chmod go-rw ~/.ssh/keys/academy) your private key permissions could be rw-------, and your public key and config file permissions could be rw-r--r--
~/.ssh/keys$ chmod go-rw academy ~/.ssh/keys$ chmod go-rw-r--r-- academy.pub
Step 4: Setting the port
touch config
step 4: set the port that ssh uses to access fab.cba.mit.edu, by appending the following lines to ~/.ssh/keys/config (you might have to create ~/.ssh/keys/config, which is a text file with unix line endings and no .txt extension)
~/.ssh/keys$gedit config
Write this in the config file and save:
host fab.cba.mit.edu port 846
Write
~/.ssh/keys$ chmod go-rw-r--r-- config
Step 5 Clone the archive
- 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
Copy the text (after $ )to the terminal:
~/Documents/FabAcademy2014$ hg clone -e "ssh -p 846 -i ~/.ssh/keys/academy" ssh://hg@fabacademy.org/academy.2014 academy.2014
- Eddie (Manchester) - Need to include sudo before hg
- Bas (Reykajvik) - Don't include sudo before hg!
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)
~/Documents/FabAcademy2014$ sudo gedit .hg/hgrc
Put this text in the file
[paths] default = ssh://hg@fabacademy.org/academy.content [ui] username = First Last <user@machine.domain> ssh = ssh -p 846 -i ~/.ssh/keys/academy -C [hooks] changegroup = hg update >&2
Step 7
try updating your archive by typing:
~/Documents/FabAcademy2013/academy.2013$ hg pull
- Eddie (Manchester) - Need to include sudo before hg command (bas: no, don't use sudo)
you should see a response like this:
- pulling from ssh://hg@fab.cba.mit.edu/academy.2013
- 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)
To open Mercurial
- To get all changes from another repository into the current one
~/Documents/FabAcademy/academy.2013$ hg pull
- Update
~/Documents/FabAcademy/academy.2013$ hg update
- Add new files
hg add
- Commit changes
hg commit -m 'MESSAGE'
- merge
hg merge
Push files to server
hg push
And also
Work in process.... to be editied
in addition there are a couple of lines of code to run in the terminal which makes life so much easier:
to setup the config file with host and port:
echo -en "host fab.cba.mit.edu\nport 846" > ~/.ssh/config
to edit the hgrc file (change paths):
echo -en "\n\n[ui]\nusername = First Last <email@mit.edu>\nssh = ssh -i ~/.ssh/academy -C\n\n[extensions]\nconvert =\nfetch =\n\n[hooks]\n\nchangegroup = hg update >&2" >> ~/Desktop/Archive/.hg/hgrc
This tutorial is very well documented, both for Windows and Mac:
Mercurial Windows
- 1. Download TortoiseHg
- 2. Download the two key files academy (private key) and academy.pub
(the public key).
- 3. Next, we need to convert the OpenSSH version 2 keys to a
Putty-style key (.ppk format). Download puttygen.exe here: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html.
- 4. Run puttygen.exe and select File->Load Private Key to convert to a
.ppk format key. Save it as academy.ppk.
- 4. Find the directory where TortoiseHg was installed, probably in
c:\Program Files. Run the program Pageant, which will pop up in your task bar. Open Pageant, select "Add key" and give it the academy.ppk file.
- 5. In Windows Explorer, right click on the directory you want to
become the clone of the archive, and select TortoiseHg->Clone. In Source path type:
ssh://hg@academy.cba.mit.edu:846/academy
If it complains about not having the public key, that's ok.