GSto
GSto

Reputation: 42350

Create new HG project from clone of another

I'd like to have a repository that's a framework I use for several projects. I'd like to be able to clone the framework, then make that clone into a brand new project. I'd also like to still be able to push changesets from the framework, though it's not nessecary.

Upvotes: 1

Views: 116

Answers (2)

icabod
icabod

Reputation: 7074

I'm assuming you want changes to the framework-only files to get pushed to the framework repo, but of course you don't want other project-specific changes to get pushed.

If you are able to use the framework code as a separate entity, and just #include it (to use C++ terminology) into your project code, then I would suggest looking into subrepos.

Setting up the framework as a subrepo would mean that your new project would contain the framework as a sub-directory. If one of your projects updated the framework, you could push just that subrepo, and pull it in other projects, meaning they could all use the latest version, or be locked down to a specific version of the framework.

The documentation covers how it works, or there are likely some useful hints on setting them up here on StackOverflow.

Upvotes: 2

Rob Harrop
Rob Harrop

Reputation: 3473

You can clone the repository using the normal hg clone operation.

The default path for hg push will be the location you cloned from, but you can happily do an hg push <other_loc>.

If, as I suspect, you want to make the default path for push and pull something new, you can simply edit the [paths] section of .hg/hgrc. For example, if you started with this:

[paths]
default = ssh://hg@someserver/myrepo

You can change it to

[paths]
default = ssh://hg@someotherserver/mynewrepo
source  = ssh://hg@someserver/myrepo

This way you can pull from source if needed.

You can even configure different default push and pull paths, as documented here

Upvotes: 0

Related Questions