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
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]
42qu.com , 找到给你答案的人Usage• Command line tool – Hg <command> <params>• Common commands: – clone commit push pull diff branches branch merge update rm forget help
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
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)
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
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.
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
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….
42qu.com , 找到给你答案的人Conflicts• When devC wants to push.• Branch at bitbucket has changed. He needs to pull.
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..
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
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