carpat
carpat

Reputation: 871

Any way to pull/update all subrepos?

I'm looking into the viability of switching from svn to mercurial for my organization, but there's one hangup I can't seem to find a solution for.

Is there any way to pull and update a repo and all subrepos without manually pulling and updating each one?

I'd like to switch to mercurial, but if that's not possible then it's a no-go for us.

Edit: Good god I must be tired today... two questions on SO for which I find the answers minutes after asking...

Upvotes: 12

Views: 6863

Answers (4)

Stefan
Stefan

Reputation: 766

Mercurial has built-in support for doing basic operations on all subrepos, e.g. "pull and update all subrepos of the current directory"

hg subrepo -r pull
hg subrepo -r update

You can get more details here

hg help -c subrepo

There is no need to write a script or install any extensions since this is built in.

Upvotes: 0

Sébastien Pierre
Sébastien Pierre

Reputation: 441

You can define a simple shell alias like the following

alias hgsub='find . -name ".hg" -type d | grep -v "\./\.hg" | \
xargs -n1 dirname | xargs -n1 -iREPO hg -R REPO '

and then do

hgsub tip
hgsub pull -u

Upvotes: 3

carpat
carpat

Reputation: 871

Somehow missed this, and found it right after asking the question: https://www.mercurial-scm.org/wiki/OnsubExtension

Upvotes: 12

Stefan
Stefan

Reputation: 11

As an alterantive, a batch script might help:

@echo off
for /D %%d in (*) do (
  if exist %%d\.hg (
    echo Verzeichnis %%d
    cd %%d
    hg pull -u
    echo ----------------------------------------------
    cd ..  
  )
)
pause

Upvotes: 1

Related Questions