update subrepos rev id in .hgsubstate?

Dan Huff dan.huff at gmail.com
Mon Mar 8 11:43:50 CST 2010


What is the best way--or is there a way--to update the global revision
id of a subrepo in the .hgsubstate file when the subrepo it describes
has newer changesets?

(Currently, the only method I've discovered is hand-editing the
.hgsubstate file.)

Background:

My desired workflow includes several "project" repositories, which are
mostly just collections of other repositories.  For a simple example,
an "app" that depends on several "library" sub-repositories.

Here's an illustration:

project1/
    .hg/
    .hgsub
    .hgsubstate
    lib1/
        .hg/
        foo/
        bar/
    lib2/
        .hg/
        spam/
        eggs/
    app1/
        .hg/
        myapp1/

project2/
    .hg/
    .hgsub
    .hgsubstate
    lib1/
        .hg/
        foo/
        bar/
    lib2/
        .hg/
        spam/
        eggs/
    app2/
        .hg/
        myapp2/

With version 1.5, the default paths for the subrepos in .hg/hgrc are
updated on clone, so I can easily push library changes (bugfixes, say)
made within a working copy of project back to a "master" copy of the
project, and then back to the "master" copy of the library repository,
if desired.  (By "master", I mean the one that's backed up.  :D)

However, it seems that in order to get the project repository's
.hgsubstate in sync with the "library"- or "app"- level development
that I've done, I have to manually determine that a library's state
does not match .hgsubstate, and update .hgsubstate manually.

specifically, I could issue the commands:

$ grep lib1 project1/.hgsubstate

$ hg id -i --debug -R project1/lib1

If the hash doesn't match, I edit and commit project1/.hgsubstate

I'm tempted to write a script to automate this process, but don't want
to develop a workflow that is significantly different from where the
mercurial subrepo implementation is headed in next version(s).  My
eventual goal is to use a stock mercurial install without custom
scripts.  I've searched the mailing list and wiki a bit for clues, but
haven't really found what I'm looking for.  Pointers and/or
suggestions would be much appreciated!

thanks,
-Dan Huff


More information about the Mercurial mailing list