Create test repository: $ hg init repo $ cd repo $ hg init foo $ cd foo $ hg init bar $ cd bar $ cd .. $ echo 'bar = bar' > .hgsub $ cd .. $ echo 'foo = foo' > .hgsub $ hg add -S .hgsub $ hg add -S foo/.hgsub !submatch foo, subpath foo $ hg -v commit -m "subrepos" -S committing subrepository foo committing subrepository foo\bar .hgsub .hgsubstate .hgsub .hgsubstate committed changeset 0:1dd824fba4e7 $ echo r > r $ cd foo $ echo f > f $ cd bar $ echo b > b $ mkdir y $ touch x y/z $ cd ../.. $ hg -v add -S adding r adding foo\f adding foo\bar\b adding foo\bar\x adding foo\bar\y\z $ echo r1 > r1 $ mkdir level $ touch level/level2 top2 $ cd foo $ echo f2 > f2 $ cd bar $ echo b1 > b1 $ touch x1 y/z2 $ cd ../.. $ echo hg -v add **/*2 -S hg -v add foo/f2 level/level2 -S $ hg -v add **/*2 -S adding level\level2 adding foo\f2