Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Mercurial for Kittens

1,202 views

Published on

Introduction to Mercurial.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Mercurial for Kittens

  1. 1. Mercurial for Kittens<br />Shuhei Takahashi<takahashi.shuhei@gmail.com><br />
  2. 2. Mercurial<br />
  3. 3. Features<br />Simple design<br />Decentralized system<br />High performance<br />Extensible framework<br />
  4. 4. Outline<br />History model<br />Basic operations<br />
  5. 5. History model<br />
  6. 6. Checking out Mercurial repo<br />$ hg clone http://example.com/hg example<br />updating to branch default<br />3 files updated, 0 files merged, 0 files removed,<br />0 files unresolved<br />$ ls -lA example/<br />drwxr-xr-x 3 nya nya 4096 2011-05-22 20:59 .hg<br />-rw-r--r-- 1 nya nya 14 2011-05-22 20:59 README<br />drwxr-xr-x 2 nya nya 4096 2011-05-22 20:59 src<br />
  7. 7. Standard Mercurial repo<br />example/<br /> .hg/<br /> README<br />src/<br /> a.cc<br />a.h<br />Repository<br />Working copy<br />
  8. 8. Standard Mercurial repo<br />example/<br /> .hg/<br />hgrc<br />dirstate<br /> store/<br /> ...<br />repo-local config<br />working copy state<br />history<br />
  9. 9. History<br />.hg/<br />Merge X<br />Improve X<br />diff -r 000000... -r 39fca2... README<br />--- /dev/null Thu Jan 01 00:00:00 1970 +0000<br />+++ b/README Sun May 22 20:59:40 2011 +0900<br />@@ -0,0 +1,1 @@<br />+Hello, world!<br />Implemented X<br />Implementing X<br />Bugfix<br />First commit<br />
  10. 10. Commit<br />nodeid: 9e66e5ae2b...<br />rev: 42<br />branch: featureX<br />author: "Shuhei Takahashi <nya@example.com>"<br />timestamp: 2011-06-02 11:59:28 +0900<br />implement feature X.<br />(patch...)<br /> p1: 48334cb9e1... p2: 0000000000...<br />
  11. 11. nodeid<br />.hg/<br />bcd055...<br />8a9310...<br />SHA-1 hash<br />Made from whole commit information<br />384fca...<br />a87493...<br />048293...<br />4fcf85...<br />
  12. 12. parents (p1,p2)<br />.hg/<br />p2<br />p1<br />p1<br /><ul><li>1 or 2 parents
  13. 13. null = 000000...</li></ul>p1<br />p1<br />p1<br />
  14. 14. rev<br />.hg/<br />4<br />5<br /><ul><li>topological order
  15. 15. no consistency between repos
  16. 16. just for convenience!</li></ul>2<br />1<br />3<br />0<br />
  17. 17. branch<br />.hg/<br />default<br />featureX<br /><ul><li>default is "default"
  18. 18. all commitshave their branch name(c.f. git)</li></ul>featureX<br />featureX<br />default<br />default<br />
  19. 19. Notes for Git users<br />Different concept of branches<br />All commits have their branch name<br />No reachability check<br />hg log shows all commits<br />Commits cannot be amended or erased (usually)<br />
  20. 20. Commit<br />nodeid: 9e66e5ae2b...<br />rev: 42<br />branch: default<br />author: "Shuhei Takahashi <nya@example.com>"<br />timestamp: 2011-06-02 11:59:28 +0900<br />implement feature X.<br />(patch...)<br /> p1: 48334cb9e1... p2: 0000000000...<br />
  21. 21. Referring commits<br />rev<br />nodeid<br />branch name... commit in the branch with the largest rev<br />"tip" ... commit in any branch with the largest rev<br />"null" ... root commit<br />tag<br />
  22. 22. Referring commits<br />.hg/<br />4<br />5<br />3<br />tip<br />default<br />featureX<br />2<br />featureX<br />1<br />3<br />default<br />0<br />
  23. 23. Basic operations<br />
  24. 24. Check out a revision<br />.hg/<br />4<br />5<br />Working Copy<br />2<br />1<br />3<br />$ hg update 3<br />0<br />
  25. 25. Making commit<br />Working Copy<br />.hg/<br />$ hg add hoge.txt<br />... edit working copy ...<br />
  26. 26. Making commit<br />Working Copy<br />.hg/<br />$ hg commit<br />
  27. 27. Making branch<br />Working Copy<br />.hg/<br />default<br />featureX<br />default<br />$ hg update default<br />featureX<br />featureX<br />default<br />default<br />
  28. 28. Making branch<br />Working Copy<br />.hg/<br />release<br />featureX<br />default<br />$ hg branch release<br />featureX<br />featureX<br />default<br />default<br />
  29. 29. Making branch<br />Working Copy<br />.hg/<br />release<br />$ hg commit<br />featureX<br />default<br />featureX<br />featureX<br />default<br />default<br />
  30. 30. Pull<br />hg pull<br />local<br />remote<br />
  31. 31. Push<br />hg push<br />local<br />remote<br />
  32. 32. Pull / Push<br />Just makes union of two history graphs<br />Merge operation is never performed(c.f. Git)<br />Can specify subgraph by a list of heads<br />
  33. 33. Merge - "healthy" branch<br />One head per branches<br />featureX<br />default<br />
  34. 34. Merge - "unhealthy" branch<br />"default" branch has two heads - multiple heads<br />Branch tip varies by rev order!<br />Push that will end up with multiple heads is rejected<br />?<br />?<br />default<br />
  35. 35. Merge<br />Checked out rev. 1<br />Pulled rev. 2, 3, resulting multiple heads (1, 3)<br />3<br />1<br />2<br />default<br />0<br />
  36. 36. Merge<br />hg merge 3<br />Working copy now has two parents (1, 3)<br />Not yet committed!<br />hg merge is forbidden if WC has pending changes<br />p2<br />p1<br />3<br />1<br />2<br />default<br />0<br />
  37. 37. Merge<br />hg commit<br />4<br />p2<br />p1<br />3<br />1<br />2<br />default<br />0<br />
  38. 38. More fun stuff<br />hgweb.cgi<br />Extensions<br />Mercurial queue (MQ)<br />Rebase<br />...<br />Hooks<br />Mercurial as a Python module<br />
  39. 39. References<br />Mercurial: The Definitive Guide<br />Chapter 4. Behind the scenes<br /> google:///hgbook or available from O'reilly<br />

×