An Example of Mercurial Being a Distributed Version Control System
来源:互联网 发布:js unicode解码 编辑:程序博客网 时间:2024/03/29 02:15
又是英文的,不好意思哈。这篇讲的是我使用mercurial时候的一些有趣的发现。
We internally use mercurial as the source version control system.
Mercurial is a very useful and powerful source control system, the difference
from cvs/svn is that, mercurial is a distributed source control system, see
its official doc for more information about this feature.
Today I ran into a very interesting situation: I have a hg repository R on a server S,
and I cloned two copies from it, one is also on S, let's call it B; The other on
my PC, let's call it C. And I didn't know that I actually cloned C from B, rather
than R, as how people usually worked. I could do so because mercurial is a distributed
version control system, each copy of repository has enough and all information about
the entire repository of the group.
However, I could do hg pull/hg commit/hg push in C, though I have been doing so to
B rather than R, and it is OK, as explained above. And I sometime later discovered
this situation when I did "hg pull -u" on B, believing B's working copy would be
updated from R since I had already pushed to R from C, but B wasn't updated.
Then I realized my repo address in C may be wrong, and yes, it was not R but B.
Then, I did "hg commit" followed by "hg push" in B, the two actions pushed all
changes which were committed by C into B, into R this time. And since B already had the
changes in its local repo, I can do a "hg update" to update its working source,
so that now B's working source also have the latest code.
And then I update C's repo address to use R instead, then all C's commits goes to R, and
I can do "hg pull -u" in B to update B's local repo and working copy, as
people normally work.
That is to say, any mercurial repository can be a central repo, for other
repos to do hg clone, hg commit or hg push; each local repo is equal to the central repo,
all repos including the "central" repo are working as identical and equal peers,
rather than working in a "client/server" mode like cvs, where clients can't be
a server. Actually this "central" repo is only put there for ease of use in a group, the
group can work well if that "central" repo was some group member's local repo;
I think the above situation is a vivid example of mercurial's being a distributed
source control system.
PS:
1. Another important thing to note:
Although we can apply a patch generated from "hg diff" using the GNU patch utility, instead
of using hg import --no-commit, hg import --no-commit sometimes can not be replaced
by the GNU patch utility. For example, when a patch involves a change made by
"hg add", "hg remove" or "hg rename" commands.
When applying such a patch to the working source code, we must use "hg import --no-commit",
otherwise, the change may not appear in the working source directory.
2. We need to set the following to our local repo's .hg/hgrc file:
[diff]
git = 1
Without the above setting, when you do "hg rename F", the changes generated simply
consists of the changes which would be generated by "hg remove F" followed by "hg add F".
Such a change is not only lengthy, but also confusing.
With the above setting, the "hg rename" command won't be generating such stupid changeset,
it simply marks the file F's name has changed, only two lines in the changeset.
- An Example of Mercurial Being a Distributed Version Control System
- Git : Distributed version control system
- Mercurial -- An Excellent Version Control Tool
- Why Use Git Instead of a Legacy Version Control System
- an example of trajectory control about manipulators
- An algorithm for routing control of a tandem automated guided vehicle system
- This is an example of state transitions - for Transition System Semantics of DFL as a Scientific Workflow Language
- JavaEnv - Version Control System.
- Version Control System
- C++ Coding Standards Item 3: Use a version control system
- an example of repeater
- An example of how to do a simulation by LAMMPS
- What is a Distributed System?
- A Distributed, Scalable Monitoring System
- Synchronization in a Distributed System
- version control system 的后起之秀
- Distributed SCM - Mercurial
- 13.4. A Copy-Control Example
- .NET : 自定义TraceListener
- 关于六种Java异常处理程序的陋习
- System.map的符号说明
- 第二套房子
- ORACLE 11G 安装心得
- An Example of Mercurial Being a Distributed Version Control System
- JPA(Toplink) Error : Object: xxxxxx is not a known entity type. 解决
- 人生在外
- C#操作注册表 实现快捷启动程序
- 用js实现表格中鼠标移动行变色
- 扑克牌生成与洗牌程序
- debian下基本系统和gnome桌面安装
- 以乘代除之魔法数原理
- jsp页面静态化