hgbook / en / examples / tour

#!/bin/bash

#$ name: version

hg version

#$ name: help

hg help init

#$ name: clone

hg clone https://bitbucket.org/bos/hg-tutorial-hello

#$ name: ls
#$ ignore: ^drwx.*
#$ ignore: ^total \d+

ls -l
ls hello

#$ name: ls-a

cd hello
ls -a

#$ name: log

hg log

#$ name: log-r

hg log -r 3
hg log -r 0272e0d5a517
hg log -r 1 -r 4

#$ name: log.range

hg log -r 2:4

#$ name: log-v

hg log -v -r 3

#$ name: log-vp

hg log -v -p -r 2

#$ name: reclone

cd ..
hg clone hello my-hello
cd my-hello

#$ name: cat1
cat hello.c

#$ name:

sed -i '/printf/a\\tprintf("hello again!\\n");' hello.c

#$ name: cat2
# ... edit edit edit ...
cat hello.c

#$ name: status

ls
hg status

#$ name: diff

hg diff

#$ name:

export HGEDITOR='echo Added an extra line of output >'

#$ name: commit

hg commit

#$ name: merge.dummy1

hg log -r 5 | grep changeset | cut -c 16-19 2>/dev/null > /tmp/REV5.my-hello

#$ name: tip

hg tip -vp

#$ name: clone-pull

cd ..
hg clone hello hello-pull

#$ name: incoming

cd hello-pull
hg incoming ../my-hello

#$ name: pull

hg tip
hg pull ../my-hello
hg tip

#$ name: update

grep printf hello.c
hg update tip
grep printf hello.c

#$ name: parents

hg parents

#$ name: older

hg update 2
hg parents
hg update
hg parents

#$ name: clone-push

cd ..
hg clone hello hello-push

#$ name: outgoing

cd my-hello
hg outgoing ../hello-push

#$ name: push

hg push ../hello-push

#$ name: push.nothing

hg push ../hello-push

#$ name: outgoing.net

hg outgoing https://bitbucket.org/bos/hg-tutorial-hello

#$ name: push.net

hg push https://bitbucket.org/bos/hg-tutorial-hello

#$ name:
cp hello.c ../new-hello.c
sed -i '/printf("hello,/i\\tprintf("once more, hello.\\n");' ../new-hello.c

my-text-editor()
{
cp ../new-hello.c hello.c
}

#$ name: merge.clone

cd ..
hg clone hello my-new-hello
cd my-new-hello
# Make some simple edits to hello.c.
my-text-editor hello.c
hg commit -m 'A new hello for a new day.'

#$ name: merge.dummy2

hg log -r 5 | grep changeset | cut -c 16-19 2>/dev/null > /tmp/REV5.my-new-hello

#$ name: merge.cat1

cat hello.c

#$ name: merge.cat2

cat ../my-hello/hello.c

#$ name: merge.pull

hg pull ../my-hello

#$ name: merge.dummy3

hg log -r 6 | grep changeset | cut -c 16-19 2>/dev/null > /tmp/REV6.my-new-hello

#$ name: merge.heads

hg heads

#$ name: merge.update

hg update

#$ name: merge.merge

hg merge

#$ name: merge.parents

hg parents
cat hello.c

#$ name: merge.commit

hg commit -m 'Merged changes'

#$ name: merge.dummy4

hg log -r 7 | grep changeset | cut -c 16-19 2>/dev/null > /tmp/REV7.my-new-hello

#$ name: merge.tip

hg tip
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.