# HG changeset patch # User Oleksandr Gavenko # Date 1316464301 -10800 # Node ID 4dd76ea12a6daefc10dc0f6aea4738d713f46ba6 # Parent e608e9bb8499f13ca12a6a7be4a923ac012740f5 Downgrade repository format. diff -r e608e9bb8499 -r 4dd76ea12a6d hg.rst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hg.rst Mon Sep 19 23:31:41 2011 +0300 @@ -0,0 +1,451 @@ +-*- coding: utf-8 -*- + +============ + Mercurial. +============ +.. contents:: + +About. +====== + + http://mercurial.selenic.com/wiki/ProjectsUsingMercurial + Some Projects that Use Mercurial + +User config. +============ + +Put to your ~/.hgrc:: + + [ui] + ; Editor for editing commit message. + editor = gvim + ; Who commit. + username = Oleksandr Gavenko + ; Use internal merge algorithm, which mark conflict like <<<<<< ====== >>>>>>. + ; Save previous file version in '*.orig' file, after merge must be marked as + ; resolved by running 'hg resolve -m '. + merge = internal:merge + [web] + ; Default encoding for file hosted by 'hg serv'. + encoding = utf-8 + +Multiline log message for log command. +-------------------------------------- + +By default 'hg log' show only first line of log message. To see all message +run:: + + $ hg log -v + +or put into ~/.hgrc:: + + [defaults] + log = -v + +Follow history ever when file copied. +------------------------------------- + +By default 'hg log' show only history after last file copy. To see log message +before copying run:: + + $ hg log -f + +or put into ~/.hgrc:: + + [defaults] + log = -f + +Useful extension. +================= + +Put to your ~/.hgrc: + + [extensions] + ; To allow 'fetch' command. + hgext.fetch = + ; To allow Mercurial Queues. + hgext.mq = + ; To import revisions from foreign VCS repositories into Mercurial. + hgext.convert = + ; Usage: hg glog + hgext.graphlog = + ; Enable '.hgeol' tracking (fix for CR/LF). + hgext.eol = + +Downgrade repository format. +============================ + +To get list of supported repo formats type:: + + $ hg help config + +and look for "format" section. To be Mercurial 0.9.4 compatible use:: + + $ hg clone -U --pull \ + --config format.usefncache=0 --config format.dotencode=0 $oldr $newr + +Clone specific branches. +======================== +:: + + $ hg clone http://your/repo -r $branch + +Closing branches. +================= +:: + + $ hg branches + $branch (inactive) + ... + $ hg branches -a + ... # no $branch + $ hg up -r $branch + $ hg ci --close-branch -m "Bla-bla-bla" + $ hg up -r default + $ hg branches + ... # no $branch + $ hg branches -c + $branch (inactive) + ... + +To reopen closed branch just update to it and commit anything! + +Remove/rename files history from repo. +====================================== +:: + + $ cat >filemap.txt <filemap1.txt <filemap2.txt < + description =

$proj allow make a BIG Thing. + # Do not use name, in this case you see dir name where project lcated. + # name = $proj + +To allow push in 'hg serv':: + + [web] + allow_push = * + push_ssl = false + +See: + + http://mercurial.selenic.com/wiki/PublishingRepositories + Publishing Mercurial Repositories + +init.d script. +-------------- +:: + + #!/bin/sh + CMD=/usr/bin/hg + + PORT=7878 + SRC=/srv/hg + CONGIG=/srv/hg/hgweb.config + PIDFILE=/var/run/hg.pid + + case "$1" in + start) + echo "Mecurial Server service starting." + (cd "$SRC"; $CMD serve -d -p $PORT --pid-file "$PIDFILE") + ;; + stop) + if [ -f "$PIDFILE" ]; then + PID=`cat "$PIDFILE"` + if [ "$PID" -gt 1 ]; then + kill -TERM $PID + echo "Stopping the Mercurial service PID=$PID." + else + echo Bad PID for Mercurial -- \"$PID\". + echo You may remove \"$PIDFILE\" manually. + fi + else + echo No PID file recorded for mercurial. + fi + ;; + *) + echo "$0 {start|stop}" + exit 1 + ;; + esac + +See: + + http://mercurial.selenic.com/wiki/hgserve + +Manage patches with MQ. +======================= + +First enable MQ, add following to your ~/.hgrc:: + + [extensions] + hgext.mq = + +Second get unpatched sources and put it to hg repository:: + + $ tar zxf proj-x.y.z.tar.gz + $ mv proj-x.y.z proj + $ cd proj + $ hg init + $ hg ci -m "Added x.y.z version of proj." + +Init MQ and take name for first patch:: + + $ hg qinit + $ hg qnew first.patch + +Next make changes by editing source and save it to patch:: + + $ $EDITOR file.c + ... + $ hg diff + ... + $ hg qrefresh + $ hg diff # <-- have zero diff + +You can make second patch by applying existing one:: + + $ hg qnew second.patch + $ patch -p1 .diff # save local changes + $ hg revert -a + $ hg fetch + $ patch -p1 <.diff + +See: + + http://mercurial.selenic.com/wiki/TipsAndTricks#Merge_or_rebase_with_uncommitted_changes + http://mercurial.selenic.com/wiki/ShelveExtension + +Hooks. +====== + +Check for bad branch names. +--------------------------- + +.hg/hgcheck.py:: + + import re + goodbranch_re = r'((bug|feature)#\d|release-1\.\d\.\d|default)$' + def precommit_badbranchname(ui, repo, hooktype, **kwargs): + ui.warn('"%s" hook failed\n' % hooktype) + for rev in repo: + branch = repo[rev].branch() + re_ = re.compile(goodbranch_re) + if not re_.match(branch): + ui.warn('Invalid branch name "%s".\nUse one of default, bug#ID, feature#ID or release-1.XX.XX.\n' % branch) + return True + return False + +.hg/hgrc:: + + [hooks] + precommit.badbranchname = python:.hg/hgcheck.py:precommit_badbranchname + # precommit.gg = python:my.hgcheck.py.precommit_badbranch + prechangegroup.badbranchname = python:.hg/hgcheck.py:precommit_badbranchname + +Read more: + + http://mercurial.selenic.com/wiki/HookExamples + +Ignore patterns. +---------------- +:: + + $ cat $proj/.hgignore + syntax: glob + *.o + .obj + *.exe +