1

I have a mercurial repository (main repo) with several sub repositories.

I need a mercurial command to show if the revision of a sub repo changed (including information on old and new revision) in the working copy or if the sub repo state is dirty.

How can I do this?

wewa
  • 1,628
  • 1
  • 16
  • 35
  • What do you mean with "revision of the sub-repo changed"? Should is sufficei f new revisions have been added, or only if the working active revision changed (that's what matters for the parent repo as it records only the sub-repos rev which it depends on) – planetmaker Dec 22 '16 at 09:02
  • I try to describe the use case: I update to a certain main repo revision, thus leads to a certain revision for every sub repo. Afterwards I can update some sub repos to a different revision (than the sub repo revision fixed in the main repo revision). Finally I'd like to generate a report where these changes are listed. Does this help you? – wewa Dec 22 '16 at 09:47

1 Answers1

2

Most mercurial commands accept the -S or --subrepos flag. Thus by calling hg st -S you get a list of all changed files which include those in the sub-repos, if their state differs from the state recorded in the .hgsubstate file:

$ cd opengfx/
$ hg st
$ hg id
10065545725a tip
$ cd ..
$ hg st -S
M opengfx/.hgtags
M opengfx/Makefile
A opengfx/lang/japanese.lng
$ cat .hgsubstate 
785bc42adf236f077333c55c58490cce16367e92 opengfx

As to your wish to obtain the actual revisions, that's AFAIK not possible with one command. However you can always check the status of the individual sub-repos like above or can check them from the main repo by giving mercurial another path to operate on:

$ hg id -R opengfx
10065545725a tip

In order to get the status of each repo compared to what is required by the parent repo, I'd resort to some simple bash:

for i in $(cat .hgsubstate | cut -d\  -f2); do echo $i is at $(hg id -R $i) but parent requires $(cat .hgsubstate | grep $i | cut -d\  -f1); done

which gives output like

opengfx is at 10065545725a tip but parent requires 785bc42adf236f077333c55c58490cce16367e92

In a similar fashion you can also check whether the state is modified by using hg st instead of hg id.

planetmaker
  • 5,884
  • 3
  • 28
  • 37