Mercurial for Kittens
Upcoming SlideShare
Loading in...5
×
 

Mercurial for Kittens

on

  • 923 views

Introduction to Mercurial.

Introduction to Mercurial.

Statistics

Views

Total Views
923
Views on SlideShare
922
Embed Views
1

Actions

Likes
0
Downloads
2
Comments
0

1 Embed 1

https://twitter.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Mercurial for Kittens Mercurial for Kittens Presentation Transcript

  • Mercurial for Kittens
    Shuhei Takahashi<takahashi.shuhei@gmail.com>
  • Mercurial
  • Features
    Simple design
    Decentralized system
    High performance
    Extensible framework
    View slide
  • Outline
    History model
    Basic operations
    View slide
  • History model
  • Checking out Mercurial repo
    $ hg clone http://example.com/hg example
    updating to branch default
    3 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 README
    drwxr-xr-x 2 nya nya 4096 2011-05-22 20:59 src
  • Standard Mercurial repo
    example/
    .hg/
    README
    src/
    a.cc
    a.h
    Repository
    Working copy
  • Standard Mercurial repo
    example/
    .hg/
    hgrc
    dirstate
    store/
    ...
    repo-local config
    working copy state
    history
  • History
    .hg/
    Merge X
    Improve 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!
    Implemented X
    Implementing X
    Bugfix
    First commit
  • Commit
    nodeid: 9e66e5ae2b...
    rev: 42
    branch: featureX
    author: "Shuhei Takahashi <nya@example.com>"
    timestamp: 2011-06-02 11:59:28 +0900
    implement feature X.
    (patch...)
    p1: 48334cb9e1... p2: 0000000000...
  • nodeid
    .hg/
    bcd055...
    8a9310...
    SHA-1 hash
    Made from whole commit information
    384fca...
    a87493...
    048293...
    4fcf85...
  • parents (p1,p2)
    .hg/
    p2
    p1
    p1
    • 1 or 2 parents
    • null = 000000...
    p1
    p1
    p1
  • rev
    .hg/
    4
    5
    • topological order
    • no consistency between repos
    • just for convenience!
    2
    1
    3
    0
  • branch
    .hg/
    default
    featureX
    • default is "default"
    • all commitshave their branch name(c.f. git)
    featureX
    featureX
    default
    default
  • Notes for Git users
    Different concept of branches
    All commits have their branch name
    No reachability check
    hg log shows all commits
    Commits cannot be amended or erased (usually)
  • Commit
    nodeid: 9e66e5ae2b...
    rev: 42
    branch: default
    author: "Shuhei Takahashi <nya@example.com>"
    timestamp: 2011-06-02 11:59:28 +0900
    implement feature X.
    (patch...)
    p1: 48334cb9e1... p2: 0000000000...
  • 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
  • Referring commits
    .hg/
    4
    5
    3
    tip
    default
    featureX
    2
    featureX
    1
    3
    default
    0
  • Basic operations
  • Check out a revision
    .hg/
    4
    5
    Working Copy
    2
    1
    3
    $ hg update 3
    0
  • Making commit
    Working Copy
    .hg/
    $ hg add hoge.txt
    ... edit working copy ...
  • Making commit
    Working Copy
    .hg/
    $ hg commit
  • Making branch
    Working Copy
    .hg/
    default
    featureX
    default
    $ hg update default
    featureX
    featureX
    default
    default
  • Making branch
    Working Copy
    .hg/
    release
    featureX
    default
    $ hg branch release
    featureX
    featureX
    default
    default
  • Making branch
    Working Copy
    .hg/
    release
    $ hg commit
    featureX
    default
    featureX
    featureX
    default
    default
  • Pull
    hg pull
    local
    remote
  • Push
    hg push
    local
    remote
  • 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
  • Merge - "healthy" branch
    One head per branches
    featureX
    default
  • 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
  • Merge
    Checked out rev. 1
    Pulled rev. 2, 3, resulting multiple heads (1, 3)
    3
    1
    2
    default
    0
  • Merge
    hg merge 3
    Working copy now has two parents (1, 3)
    Not yet committed!
    hg merge is forbidden if WC has pending changes
    p2
    p1
    3
    1
    2
    default
    0
  • Merge
    hg commit
    4
    p2
    p1
    3
    1
    2
    default
    0
  • More fun stuff
    hgweb.cgi
    Extensions
    Mercurial queue (MQ)
    Rebase
    ...
    Hooks
    Mercurial as a Python module
  • References
    Mercurial: The Definitive Guide
    Chapter 4. Behind the scenes
    google:///hgbook or available from O'reilly