Using Hg

1,920 views

Published on

Published in: Self Improvement, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,920
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • 版本控制( Revision control )是维护工程蓝图的标准作法,能追踪工程蓝图从诞生一直到定案的过程。此外,版本控制也是一种软件工程技巧,借此能在软件开发的过程中,确保由不同人所编辑的同一程式档案都得到同步。 1) 版本控制工程技巧,在开发的过程中,确保由不同人所编辑的同一档案都得到更新 . 2) 返回到各个文件以前的修订版本,还可以比较任意两个版本以查看它们之间的变化 . (revert and diff) 3) 版本控制可以保留一个文件修订的可检索的准确历史日志 . (for review/blame...etc)
  • 1. 所有版本控制的工作在一个服务器进行,由中央权威管理存取权限“锁上”档案库中的档案,一次只让一个开发者工作。 2.(wiki) 或者使用合并模式 , 每次检查 repo 和本地的版本 , 如果版本低 , 则停止 commit, 要求用户 update 到最新地址 , 如果有冲突 , 则 resolve 后再允许提交 .
  • 每人都有其 本地沙盒 (local sandbox). 你可以在自己的工作空间中修改或恢复旧版 , 不需要大量的检入 (checkins). 你自己的工作记录都累积存在自己的 仓库 repository. 可离线工作 . 只有当你想分享修订时才需要上线 . 否则可一直在自己的工作机上独立作业 / 签入 (check in)/ 复原 (undo), 没有所谓 " 服务器 " 当掉或在飞机上的问题 . 速度很快 . 差异 (diff), 提交 (commit) 与恢复 (revert) 都在本端即可完成 . 没有因网络或服务器不稳而必须用一年前开发版本的问题 . 可妥善做变动的处理 . DVCS 针对分享的变更做建置 . 每个变更都有其独一无二的辨识码 (guids) 以方便追踪 . 分支 (Branching) 与合并 (merging) 很容易 . 因为每一开发人员 " 有自己的分支 ", 每一分享的变动就像交换整合 . 但 guids 让自动组合变更与避免重复动作简单容易 .
  • Help
  • Using Hg

    1. 1. 42qu.com , 找到给你答案的人42qu.com
    2. 2. 42qu.com , 找到给你答案的人Python 网站开发 入门班基于 新浪 SAE 和 Python Torando 的搭建短网址应用第三课 Hg 的用法郭浩川• wooparadog.42qu.com• guohaochuan@gmail.com
    3. 3. 42qu.com , 找到给你答案的人Mercurial(Hg)• BitKeeper, stopped free version.• Linux kernel needed an alternative.• Linus Torvalds made git.• Mackall built Mercurial
    4. 4. 42qu.com , 找到给你答案的人Who is using• Python• Vim• W3C• RabbitMQ• OpenJDK• Go Programing language• Mozilla• 豆瓣
    5. 5. 42qu.com , 找到给你答案的人Host servives• Bitbucket• Google Code• SourceForge• CodePlex
    6. 6. 42qu.com , 找到给你答案的人So what is Hg
    7. 7. 42qu.com , 找到给你答案的人The svn model:Central Version Control System(CVS) or client – server• Everything is on one server.• Devs commit to that server.• Need network connection.• Work flow: copy trunk -> dev in branch -> copy another trunk -> merge your branch -> merge to trunk
    8. 8. 42qu.com , 找到给你答案的人The hg model:Distributed Version Control System(DVCS) peer to peer• Many Repositories.• Devs commit to his local repo• Exchange patches.• Many development models. Develop/Release: Fork/branch release  develop in branch  [Merge trunk  trunk merge branch | trunk merge branch]
    9. 9. 42qu.com , 找到给你答案的人Usage• Command line tool – Hg <command> <params>• Common commands: – clone commit push pull diff branches branch merge update rm forget help
    10. 10. 42qu.com , 找到给你答案的人Gui Tools• Windows: – Tortoisehg: http://tortoisehg.bitbucket.org/• Linux: – hgtk
    11. 11. 42qu.com , 找到给你答案的人Configuration ( 工欲善其事 , 必先利其器 )• .hgrc – [ui] • username = wooparadog <guohaochuan@gmial.com> • Ssh = ssh –i ~/.ssh/id_rsa -C • Ignore = ~/.hgignore – [Extensions] • Hgext.fetch = • Color = – [Alias] • blame = annotate --user --number
    12. 12. 42qu.com , 找到给你答案的人
    13. 13. 42qu.com , 找到给你答案的人
    14. 14. 42qu.com , 找到给你答案的人So let’s do a walk through• Use bitbucket as project hoster• 3 people involved.• Use release/develop model• Include: – Build reop – Build branches – Resolve conficts
    15. 15. 42qu.com , 找到给你答案的人Release/develop model:• First commit to default branch. This is our release branch.• All other features/bugfixes etc. will be in another branch.• When they are ready(for production), merge them to default(release branch)
    16. 16. 42qu.com , 找到给你答案的人Make a repo in bitbucket
    17. 17. 42qu.com , 找到给你答案的人 Clone it down.hg clone ssh://hg@bitbucket.org/wooparadog/42qu-test .hg exists and exists only in repo root , in contrast to svn
    18. 18. 42qu.com , 找到给你答案的人Add files ( This is done by DevA) After some coding… 3.Check what’s changed 4.Add new file. (or add all files) 5.Check status again. Code is not committed at this stage.
    19. 19. 42qu.com , 找到给你答案的人Commit and push
    20. 20. 42qu.com , 找到给你答案的人DevB wants to work.• Clone it down from bitbucket.• Make a branch. What branches are there? Make a new branch, commit after braching, check current branch
    21. 21. 42qu.com , 找到给你答案的人DevB does some work…He decides some folders were badly named.So he uses hg mv to rename themAnd some files can be deleted.So he uses hg rm to remove themNow repo looks like this.Then he rages at a block of code.He wants to know who wrote themhg blame shows it was all DevA’s work.
    22. 22. 42qu.com , 找到给你答案的人Then DevB’s work is done.• He uses hg status to see what’s changed• Then reviews his changes with hg diff before committing to his branch. – Push should be: hg push --new-branch
    23. 23. 42qu.com , 找到给你答案的人DevC• Boss thinks DevB’s progress is too slow. DevC comes to save the day.• He cloned the repo, switch to DevB’s branch by hg update wooparadog_20120310_new_feature• Then he starts doing stuff…With DevB doing his on his computer….
    24. 24. 42qu.com , 找到给你答案的人Conflicts• When devC wants to push.• Branch at bitbucket has changed. He needs to pull.
    25. 25. 42qu.com , 找到给你答案的人Resolving conflicts• hg resolve -l• Use ack to find conflicts.• And resolve it ( hg resolve -m) Don‘t forget to commit and push it..
    26. 26. 42qu.com , 找到给你答案的人Revert• DevB pulls new version, after some time, he hates what devC has done.• Check log. – hg log -b <branch> – hg log -b .• Revert to version 5.• hg revert –r 5
    27. 27. 42qu.com , 找到给你答案的人Merge to release• DevA now thinks it’s ready to make this feature online. But first, he needs to review all the changes. hg diff –r <revision>:<revision>• What we would do: hg update default hg merge <branch> hg diff
    28. 28. 42qu.com , 找到给你答案的人Conclusion:• Add • Merge• Commit • Resolve• Push • Status• Pull • Rm• Update • Mv• Diff• Log ‘commit’ can be ‘com’, yeah, git, beat thath.
    29. 29. 42qu.com , 找到给你答案的人Last,• Hggit – hg clone git://github.com/schacon/munger.git• Hgsvn/hgsubversion
    30. 30. 42qu.com , 找到给你答案的人Naming revision• hg tag – hg tag –r <revision> <name>• hg tags• Update: – hg update <tag_name>
    31. 31. 42qu.com , 找到给你答案的人
    32. 32. 42qu.com , 找到给你答案的人References:• http://book.42qu.com/tool/hg.html – Hg 工作流介绍 – Pythonic Hg 使用 – 了解分布式版本管理系统 – Mercurial CheatSheet – Mercurial 权威指南 – Mercurial: The Definitive Guide – Hg Init: a Mercurial tutorial – Hg Git – Hg Svn – Hg 小技巧 – Hg & Git 口水战文章 • Git 和 Hg 面对面 • Git 和 Hg 面對面之我見 - Willie Wu

    ×