2

In the answer to this question on the kiln stack exchange site, there is a comment that mentions "if you commit from one consumer of the library, the other library consumers do not immediately see those changesets. You have to explicitly pull the changes on the library repo in other consumers."

i have added a few files to a repository which is referred to in a projects .hgsub & .hgsubstate files, but they are not showing up in the projects subrespository (because the project is quite rightly using the previous change-set it was earlier assigned)

I'd like to know how to edit which changeset a subrepo uses. do I just edit the .hgsubstate file (seems a little "hackish") or is there a command / kiln website option I can use?

unsynchronized
  • 4,828
  • 2
  • 31
  • 43
  • note: i have tried "hg pull" in the project and the actual subrepository folder, but to no avail. also the new files are showing up on the server, in the latest changeset, it's just not clear to me how i tell the subrepository of a given project to use the latest (or indeed any particular) changeset - apart from editing the .hgsubstate file, which doesn't seem like the right thing to do. – unsynchronized Jan 16 '12 at 02:15

1 Answers1

5

In the subrepository, hg update to the changeset you want the main repository to use. Then, in the main repository, issue hg ci to commit the subrepository change. Mercurial will automatically update the .hgsubstate file with the current parent changeset ID of the subrepository.

Example (Windows .bat file):

REM Create main repository
hg init Example
cd Example
echo >file1
hg ci -Am file1
cd ..

REM Create another repository
hg init Library
cd Library
echo >file2
hg ci -Am file2
cd ..

REM Clone the Library into the main repository
cd Example
hg clone ..\Library

REM and configure it as a subrepository.
echo Library=Library >.hgsub

REM Commit it.
hg ci -Am "Added Library sub repository."

REM Note .hgsubstate is updated with the current subrepo changeset.
type .hgsubstate
cd ..

REM Someone updates the original Library.
cd Library
echo >file3
hg ci -Am file3
cd ..

REM Main repo isn't affected.  It has a clone of Library.
cd Example
hg status -S

REM Update to the latest library
cd Library
hg pull -u
cd ..

REM View the changes to the library in the main repo.
hg status -S

REM Commit the library update in the main repo.
hg ci -m "Updated library."

REM Note .hgsubstate is updated.
type .hgsubstate
Community
  • 1
  • 1
Mark Tolonen
  • 166,664
  • 26
  • 169
  • 251
  • so are you saying cd into the subrepository under the project, and hg update there, then "cd ..", and issue "hg ci" in the project folder? – unsynchronized Jan 16 '12 at 02:35
  • resolved. thanks for going to the extra effort. I am on osx, however, win batch file was still useful as it showed my previous error. what i had not done was "hg pull -u" (i had simply done "hg pull"). it's my second day playing with hg, so it's a bit of a learning curve. thanks for you help. will upvote ..... – unsynchronized Jan 16 '12 at 03:02
  • 2
    Happy to help. The main idea to remember is committing in the main repo records the *current parents* of any subrepositories, so *you* control when to move to newer subrepo content. – Mark Tolonen Jan 16 '12 at 03:05