Making the world safer for idiots like me [was Re: Add a cgi script that support multiple repositories]
Bryan O'Sullivan
bos at serpentine.com
Tue Jun 28 14:48:52 UTC 2005
On Tue, 2005-06-28 at 00:49 -0700, Matt Mackall wrote:
> - we want to store the repo name (and description) in .hg/hgrc
Could we expand this to "repo name", "description", and "uuid"?
There is currently no prohibition in Mercurial against merging two
completely unrelated trees, and I think this is a problem.
Consider:
hg clone http://www.selenic.com/hg my-hg
hg clone http://www.kernel.org/hg my-kernel
cd my-kernel
hg pull ../my-hg -> succeeds! aiieeee!
There are butterfingers types out there who will accidentally perform
pulls like this. I know this because I am the existence proof.
A certain other SCM package has saved my bacon several times by imposing
a notion of "package", which is "the logical project in this repo and
any clones of it".
Here's a scheme I propose to make hg a little safer, while still being
more flexible than the other SCM.
* "hg init" creates a UUID, and puts it into a set of UUIDs
in .hg/hgrc:
[uuids]
original = ae31-f015-49ae-130c
* "hg clone" copies the uuids section from the cloned repo, and
puts it into .hg/hgrc.
* By default, "hg pull" and "hg push" honour the uuids section of
hgrc. If the source repo's "original" UUID isn't in the list of
UUIDs on the destination side, the operation is aborted, unless
you use the "-f" flag.
* If you repeatedly want use an "unrelated" repo as a source, just
add its "original" UUID to the uuids section of .hg/hgrc in each
repo you want to pull/push into.
This adds a safety check, so that you can't pull from an "unrelated"
repo without deliberately deciding to do so.
Thoughts?
<b
More information about the Mercurial
mailing list