sorin
sorin

Reputation: 170498

How to easily redirect hg repositories?

On git there is an easy way to configure the client to use different servers and protocols, which is great because it allows you to move repositories without breaking complex build scripts.

git config --global url.https://oldserver.com/aaa/.insteadOf git://newserver.com/bbb/ccc/

I am looking for a similar feature to mercurial.... anyone?

Upvotes: 0

Views: 156

Answers (1)

Reimer Behrends
Reimer Behrends

Reputation: 8720

The closest alternatives that Mercurial offers are the paths config section and the schemes extension, which enables a schemes config section. Here, paths allows you to define aliases for URLs, while schemes allows you to define aliases for URL prefixes.

For example, if you add the following to your .hgrc or pass the config option on the command line:

[paths]
foo = ssh://example.com/path/to/real/foo

Then you can do:

hg clone foo
hg push foo
hg pull foo
etc.

Similarly, you can enable the scheme "extension" (it's actually built-in, you don't need to install anything, just turn it on) and use that to define a prefix:

[extensions]
scheme=
[schemes]
ourstuff = ssh://example.com/path/to/reporoot

And then you can do:

hg clone ourstuff://foo
hg push ourstuff://foo
hg pull ourstuff://foo
etc.

This is useful if you have multiple repositories underneath the same location. Note that you can also use paths and schemes combined, e.g.

[extensions]
scheme=
[schemes]
ourstuff = ssh://example.com/path/to/reporoot
[paths]
foo = ourstuff://foo

Upvotes: 1

Related Questions