SCM
Git
→ Moved to Git
Mercurial
Update a local repository:
hg pull hg update # Or use -u at the pull command
$ hg update -C badbranch # update & switch to badbranch $ hg branches default 2922:c7fa97debb36 badbranch 2924:f58b9c023d3b $ hg commit --user "joe" --close-branch -m "bogus branch" $ hg update -C default # switch back to the default branch again.
View local changes
hg status
Delete everything but .hg* directories, then checkout a clean copy again
ls -A | grep -v .hg | xargs rm -rf hg checkout -C
There's also the Purge Extension. Although it's distributed along with Mercurial, it must be activated:
$ cat ~/.hgrc [extensions] hgext.purge =
Now hg purge
can be used to get rid of untracked objects.
Viewing a single commit is quite different from Git[1], but we can use aliases here:
$ cat ~/.hgrc [alias] show = log -p -r # show = diff -c # Shows only the diff, w/o the metadata
Bazaar
Bazaar seems to be tightly coupled to Launchpad. Checkout out source code requires magical URIs, e.g.:
$ bzr branch lp:beautifulsoup $ cat beautifulsoup/.bzr/branch/branch.conf parent_location = https://code.launchpad.net/~beautifulsoup-committers/beautifulsoup/trunk/
Clean untracked files can be done with Bzrtools:
$ sudo apt-get install bzrtools $ touch foo bar $ bzr clean-tree --dry-run deleting paths: bar foo $ bzr clean-tree --force
CVS
Checkout a module of a remote repository:
cvs -d anonymous@cvs.openssl.org:/openssl-cvs co openssl
Update the repository:
cvs update
List all tags in the repository:
cvs -q log -h | awk -F"[.:]" '/^\t/ && $(NF-1)!=0 {print $1}' | sort -u
List all branches in the repository:
cvs -q log -h | awk -F"[.:]" '/^\t/ && $(NF-1)==0 {print $1}' | sort -u
Setting up a CVS server
tbd...
$CVSROOT/CVRSROOT/passwd virtuser:pwcrypt:unixuser unixuser:pwcrypt anonymous::unixuser (no password) xinetd user = cvs passenv =
PAM, if compiled with --enable-pam /etc/pam.d/cvs @include common-auth @include common-account no $CVSROOT/CVRSROOT/passwd ! xinetd user = root passenv = client: CVSROOT=:pserver:evil:password@sheep:/var/lib/cvs cvs login cvs co . cvs ls -Rl ./
Subversion
branches & tags
List all branches of a repository by listing the /branches
URL. This is often below the same level as /trunk
$ svn info | grep ^URL URL: https://svn.example.com/svn/trunk $ svn ls https://svn.example.com/svn/branches/ 1.3/ 1.4/ 1.5/
List all tags:
$ svn ls ^/tags 1.3-release 1.4-release 1.5-release
Checkout[2] a different branch into a new directory:
svn checkout https://svn.example.com/svn/branches/1.5 ../project-version-1.5
Checkout a different tag into a new directory:
svn checkout https://svn.example.com/svn/tags/1.3-release ../project-1.3-release
switch
To change the repository URL, use "switch"
[3]:
$ svn info | grep ^URL URL: https://svn.example.com/branches/3.4 $ svn switch https://svn.example.com/branches/3.5
Or, using tag instead of branch:
$ svn ls ^/tags | tail -3 3.3/ 3.4/ 3.5/ $ svn switch https://svn.example.com/svn/tags/3.5
But what if the repository URL has changed in a more subtle way? E.g. we want to change the branch and the protocol[4]:
$ svn switch https://svn.example.com/branches/3.5 svn: 'https://svn.example.com/branches/3.4' is not the same repository as 'https://svn.example.com'
Hm, lets try relocate[5] then:
$ svn switch --relocate https://svn.example.com/branches/3.4 https://svn.example.com/branches/3.5 . svn: Relocate can only change the repository part of an URL
However, when we try this in two steps, it seems to work:
svn switch --relocate https://svn.example.com/branches/3.4 https://svn.example.com/branches/3.4 . svn switch https://svn.example.com/branches/3.5 $ svn info | grep ^URL URL: https://svn.example.com/branches/3.5
svn:externals
Adding an external repository to an SVN project-directory. For example, adding the WP-reCAPTCHA repo to the Wordpress source tree:
$ cd wp-content/plugins $ svn propedit svn:externals . > wp-recaptcha https://plugins.svn.wordpress.org/wp-recaptcha/trunk/ > :x $ svn update Fetching external item into 'wp-recaptcha' External at revision 255348.
To add the externals to the SVN root, use the relative path instead:
$ cd wordpress-svn $ svn propedit svn:externals . > wp-content/plugins/wp-recaptcha https://plugins.svn.wordpress.org/wp-recaptcha/trunk/ > :x $ svn update