mercurial for kittens

35
Mercurial for Kittens Shuhei Takahashi <[email protected]>

Upload: nya3jp

Post on 27-Jun-2015

828 views

Category:

Technology


1 download

DESCRIPTION

Introduction to Mercurial.

TRANSCRIPT

Page 1: Mercurial for Kittens

Mercurial for KittensShuhei Takahashi<[email protected]>

Page 2: Mercurial for Kittens

Mercurial

Page 3: Mercurial for Kittens

Features

Simple design Decentralized system High performance Extensible framework

Page 4: Mercurial for Kittens

Outline

History model Basic operations

Page 5: Mercurial for Kittens

History model

Page 6: Mercurial for Kittens

Checking out Mercurial repo

$ hg clone http://example.com/hg exampleupdating to branch default3 files updated, 0 files merged, 0 files removed,0 files unresolved$ ls -lA example/drwxr-xr-x 3 nya nya 4096 2011-05-22 20:59 .hg-rw-r--r-- 1 nya nya 14 2011-05-22 20:59 READMEdrwxr-xr-x 2 nya nya 4096 2011-05-22 20:59 src

Page 7: Mercurial for Kittens

Standard Mercurial repo

example/ .hg/ README src/ a.cc a.h

Working copy

Repository

Page 8: Mercurial for Kittens

Standard Mercurial repo

example/ .hg/ hgrc dirstate store/ ...

repo-local configworking copy statehistory

Page 9: Mercurial for Kittens

History.hg/

First commit

Implementing X Bugfix

Merge X

Implemented X

diff -r 000000... -r 39fca2... README--- /dev/null Thu Jan 01 00:00:00 1970 +0000+++ b/README Sun May 22 20:59:40 2011 +0900@@ -0,0 +1,1 @@+Hello, world!

Improve X

Page 10: Mercurial for Kittens

Commit

nodeid: 9e66e5ae2b...rev: 42branch: featureXauthor: "Shuhei Takahashi <[email protected]>"timestamp: 2011-06-02 11:59:28 +0900

implement feature X.

(patch...)

p1: 48334cb9e1... p2: 0000000000...

Page 11: Mercurial for Kittens

nodeid.hg/

4fcf85...

a87493... 048293...

384fca...

bcd055...8a9310...

SHA-1 hash Made from whole

commit information

Page 12: Mercurial for Kittens

parents (p1,p2).hg/

p1

p2

p1

p1

p1 p1

1 or 2 parents null = 000000...

Page 13: Mercurial for Kittens

rev.hg/

0

1 3

2

45

topological order no consistency

between repos just for

convenience!

Page 14: Mercurial for Kittens

branch.hg/

default

featureX default

featureX

defaultfeatureX

default is "default" all commits have

their branch name(c.f. git)

Page 15: Mercurial for Kittens

Notes for Git users

Different concept of branchesAll commits have their branch name

No reachability checkhg log shows all commits

Commits cannot be amended or erased (usually)

Page 16: Mercurial for Kittens

Commit

nodeid: 9e66e5ae2b...rev: 42branch: defaultauthor: "Shuhei Takahashi <[email protected]>"timestamp: 2011-06-02 11:59:28 +0900

implement feature X.

(patch...)

p1: 48334cb9e1... p2: 0000000000...

Page 17: Mercurial for Kittens

Referring commits

rev nodeid branch name

... commit in the branch with the largest rev "tip"

... commit in any branch with the largest rev "null" ... root commit tag

Page 18: Mercurial for Kittens

Referring commits

3 tip default featureX

.hg/

default

featureX

0

1 3

2

45

Page 19: Mercurial for Kittens

Basic operations

Page 20: Mercurial for Kittens

Check out a revision

$ hg update 3

.hg/

0

1 3

2

45

Working Copy

Page 21: Mercurial for Kittens

Making commit.hg/

Working Copy

$ hg add hoge.txt... edit working copy ...

Page 22: Mercurial for Kittens

Making commit .hg/Working Copy

$ hg commit

Page 23: Mercurial for Kittens

Making branch.hg/

default

featureX default

featureX

featureX

Working Copy

default

default

$ hg update default

Page 24: Mercurial for Kittens

Making branch.hg/

default

featureX default

featureX

featureX

Working Copy

default

release

$ hg branch release

Page 25: Mercurial for Kittens

Making branch.hg/

default

featureX default

featureX

featureX

Working Copy

default $ hg commit

release

Page 26: Mercurial for Kittens

Pulllocal remote

hg pull

Page 27: Mercurial for Kittens

Pushlocal remote

hg push

Page 28: Mercurial for Kittens

Pull / Push

Just makes union of two history graphs Merge operation is never performed

(c.f. Git) Can specify subgraph by a list of heads

Page 29: Mercurial for Kittens

Merge - "healthy" branch

One head per branches

default

featureX

Page 30: Mercurial for Kittens

Merge - "unhealthy" branch

"default" branch has two heads - multiple heads

Branch tip varies by rev order!

Push that will end up with multiple heads is rejected

default

?

?

Page 31: Mercurial for Kittens

Merge

default0

12

3

Checked out rev. 1 Pulled rev. 2, 3,

resulting multiple heads (1, 3)

Page 32: Mercurial for Kittens

Merge

default0

12

3

hg merge 3 Working copy now has

two parents (1, 3) Not yet committed!

hg merge is forbidden if WC has pending changes

p1

p2

Page 33: Mercurial for Kittens

Merge

default0

12

3

hg commit

p1

p2

4

Page 34: Mercurial for Kittens

More fun stuff

hgweb.cgi Extensions

Mercurial queue (MQ)Rebase...

Hooks Mercurial as a Python module

Page 35: Mercurial for Kittens

References

Mercurial: The Definitive GuideChapter 4. Behind the scenes

google:///hgbook or available from O'reilly