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. 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. 42qu.com , 找到给你答案的人
Usage
• Command line tool
– Hg <command> <params>
• Common commands:
– clone commit push pull diff branches branch
merge update rm forget help
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. 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)
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. 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.
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. 42qu.com , 找到给你答案的人
DevB does some work…
He decides some folders were badly named.
So he uses hg mv to rename them
And some files can be deleted.
So he uses hg rm to remove them
Now repo looks like this.
Then he rages at a block of code.
He wants to know who wrote them
hg blame shows it was all DevA’s work.
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. 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….
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. 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. 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