hg.rst
author Oleksandr Gavenko <gavenkoa@gmail.com>
Sun, 07 Nov 2010 23:17:10 +0200
changeset 675 47d4ad70738f
parent 674 6429d14cfc2a
child 676 e7632a1fdeca
permissions -rw-r--r--
init.d script.

-*- mode: outline; coding: utf-8 -*-

* 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 <gavenkoa@gmail.com>
  ; 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 <file>'.
  merge = internal:merge
  [web]
  ; Default encoding for file hosted by 'hg serv'.
  encoding = utf-8

** Useful extension.

Put to your ~/.hgrc:

  [extensions]
  ; To allow fetch command.
  fetch =
  ; To allow Mercurial Queues.
  hgext.mq =

** 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

* Publishing config.

  http://mercurial.selenic.com/wiki/PublishingRepositories
                Publishing Mercurial Repositories

* Publish repos.

With static HTTP hosting you can copy via rsync, ftp, scp, etc., so long as all the files beneath
.hg are copied. Also since 1.1 pull protocol can detect static HTTP hosting:

  $ hg clone http://example.com/project

  http://mercurial.selenic.com/wiki/hgserve
  http://mercurial.selenic.com/wiki/StaticHTTP

** 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

  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 <bugfix.patch
  $ hg qrefresh

You can take list of patches (from old to new) and revert or apply patches by
qpop/qpush command:

  $ hg qseries   # <-- what patches have
  first.patch
  second.patch
  $ hg qapplied  # <-- what patches applied
  first.patch
  second.patch
  $ hg qpop
  $ hg qseries
  first.patch
  second.patch
  $ hg qapplied
  first.patch

You can revert or apply all patches by single command:

  $ hg qpop -a
  $ hg qpush -a

You can delete patch from patch list (before that you need de-apply patch):

  $ hg qpop -a
  $ hg qdelete first.patch

To add new version of source and fix patches for it first de apply patches,
then pull new changes and try apply patches on top of new sources:

  $ hg qpop -a
  $ rm *       # .hg dir not deleted because its name start with dot
  $ cd ..
  $ tar zxf proj-a.b.c.tar.gz
  $ cp -R proj-a.b.c/* proj
  $ cd proj
  $ hg addremove -s 70
  $ hg ci -m "Added a.b.c version of proj."
  $ hg qpush -a

To apply series of already done patches use:

  $ ls /path/to/bugfixes/*.patch | xargs hg qimport

* Proxy.

  $ hg clone --config http_proxy.host=$host:$port \
    --config http_proxy.user=$user --config http_proxy.passwd=$password  $addr

* Free Mercurial hosting.

  http://mercurial.selenic.com/wiki/MercurialHosting
                Free Hosting of Mercurial Repositories