Showing posts with label mercurial. Show all posts
Showing posts with label mercurial. Show all posts

Nov 9, 2011

Mercurial HowTo

Tutorial
http://hginit.com/01.html

How to correctly close a feature branch in Mercurial?
hg up feature-x
hg ci -m 'branch closed' --close-branch

hg up default
hg merge feature-x
hg ci -m merge
To completely undo the uncommitted merge and discard all local modifications, you will need to issue a
# note the "dot" at the end of the command
hg update -C -r .

Merge or rebase with uncommitted changes

hg diff > somefile.diff
hg revert -a
hg import --no-commit somefile.diff

Undo not pushed commit

hg rollback

Jun 29, 2011

Hg or git branch in bash prompt

in ~/.bashrc (Ubuntu 12.04)
hg_branch() {
    hg branch 2> /dev/null | \
        awk -v "clrp=$txtpur" -v "clrr=$txtrst" \
            '{ print clrp "@hg:" $1 clrr}'
}
hg_dirty() {
    [ $(hg status 2> /dev/null | wc -l) != 0 ] && \
        echo -e "${txtred}*${txtrst}"
}

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\W$(hg_branch)$(hg_dirty)\$ '
fi
then your prompt will looks like:
someproject$ vi /home/alexey/.bashrc  # make changes above
someproject$ source /home/alexey/.bashrc 
someproject@hg:liveserver$  # liveserver is current brunch
someproject@hg:liveserver$ hg branch
liveserver
someproject@hg:liveserver$ touch blabla
someproject@hg:liveserver*$  # asterisk indicates that VCS has changes
someproject@hg:liveserver*$ hg st
? blabla
Also you can do the same for git:
git_branch() {
    git branch --no-color 2> /dev/null | grep "*" |\
        awk -v "clrp=$txtpur" -v "clrr=$txtrst" \
            '{ print clrp "@git:" $2 clrr}'
}
git_dirty() {
    [ $(git status --short 2> /dev/null | wc -l) != 0 ] && \
        echo -e "${txtred}*${txtrst}"
}