开发者

Perforce like client specs mappings with Mercurial

We recently moved from Perf开发者_运维问答orce to Mercurial and love it!

One little problem: after much research we can't figure out how to map a special directory in the repository to some special place on the client. Here is an example of our hg repo:

/foo/source files
/bar/source files
/build
    /macosx/mac make files
    /win/windows make files

With Perforce, we were using client spec mappings to map //depot/build/macosx/... to just /build/... on the Mac client, and //depot/build/win/... to /build/... on the Windows dev box. Directories foo and bar are synced as is. Makefiles in /foo and /bar assume that our build makefiles are located in /build and we would like to keep them as is. The final client set of files should look like this:

/foo/source files
/bar/source files
/build/client specific make files

I've read about subrepos, but this solution does not seem to be client specific.

Any idea how to solve this problem will be very much appreciated!


You can't check out only portions of a repository with Mercurial.

You always get a clone containing everything, and the working directory will also contain everything.

With Mercurial you should strive to have 1 repository for 1 project, so that everything you get logically belongs together, and then you shouldn't have much need for just a portion of it.

This also means that whatever directory structure you have in your Mercurial repository will always match exactly the structure you have on disk.


You can't do this with Mercurial as it doesn't have the concept of a client separate from a depot.

However, you can use a symlink on Mac OS X (ln -s) and a junction on windows (mklink on Vista and up using the junction tool on XP http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx) to solve this problem on the file system level.

Alternatively you can use a variable in the Makefiles to refer to the build directory (eg $(BUILD)/something.ext instead of build/something.ext).


This sort of mapping cannot be done in Mercurial. There is an outstanding TODO item for 'narrow' clones so you can check out just a subdirectory. And I could see an implementation of that supporting that sort of functionality. But then again, I know that something like this would be considered a little too 'clever' (read complex) and there would be a lot of push-back on the idea.

In the meantime, I would suggest one of these two solutions.

  1. Symbolic links. Put the symbolic link to your build directory in your .hgignore file. Then each person can make their own symbolic link to the appropriate directory of build files. This has the disadvantage of not working on a platform without symbolic links.
  2. An environment variable that's used in a top level makefile to construct the path to the platform specific makefile it should be calling.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜