Mercurial Subrepos, how to control which changeset I want to use for a subrepo?

Posted by Lasse V. Karlsen on Stack Overflow See other posts from Stack Overflow or by Lasse V. Karlsen
Published on 2010-05-19T16:20:19Z Indexed on 2010/05/19 16:50 UTC
Read the original article Hit count: 218

Filed under:
|
|

I am reading up on subrepos, and have been running some tests locally, seems to work OK so far, but I have one question.

How do I specify/control which changeset I want to use for a particular subrepo?

For instance, let's say I have the following two projects:

class library                    application
o    fourth commit               o   second commit, added a feature
|                                |
o    third commit                o   initial commit
| 
| o  second commit
|/
o    initial commit

Now, I want the class library as a subrepo of my application, but due to the immaturity of the longest branch (the one ending up as fourth commit), I want to temporarily use the "second commit" tip.

How do I go about configuring that, assuming it is even possible?

Here's a batch file that sets up the above two repos + adds the library as a subrepo.

If you run the batch file, it will output:

[C:\Temp] :test
...
v4

As you can see from that last line there, it verifies the contents of the file in the class library, which is "v4" from the fourth commit. I'd like it to be "v2", and persist as "v2" until I'm ready to pull down a newer version from the class library repository.

Can anyone tell me if it is possible to do what I want, and if so, what I need to do in order to lock my subrepo to the right changeset?

Batch-file:

@echo off
if exist app rd /s /q app
if exist lib rd /s /q lib
if exist app-clone rd /s /q app-clone


rem == app ==
hg init app
cd app
echo program>main.txt
hg add main.txt
hg commit -m "initial commit"
echo program+feature1>main.txt
hg commit -m "second commit, added a feature"
cd ..

rem == lib ==
hg init lib
cd lib
echo v1>lib.txt
hg add lib.txt
hg commit -m "initial commit"
echo v2>lib.txt
hg commit -m "second commit"
hg update 0
echo v3>lib.txt
hg commit -m "third commit"
echo v4>lib.txt
hg commit -m "fourth commit"
cd ..

rem == subrepos ==
cd app
hg clone ..\lib lib
echo lib = ..\lib >.hgsub
hg add .hgsub
hg commit -m "added subrepo"
cd ..

rem == clone ==
hg clone app app-clone

type app-clone\lib\lib.txt

© Stack Overflow or respective owner

Related posts about mercurial

Related posts about subrepos