Samaursa
Samaursa

Reputation: 17241

Mercurial batch pull operation

I have several repositories for personal use and I back them up on my main server. There are quite a few and it takes quite a bit of time to perform a pull operation on every single repository.

Does mercurial support batch pull of several repositories? If so, how do I go about it? If not, is there a relatively simple solution?

I am using Windows and use TortoiseHg (but I have no problem with using the command line).

Upvotes: 0

Views: 1595

Answers (3)

adrianm
adrianm

Reputation: 14726

I have a top level repository where I have a few batch files and a textfile containing all repositories.

i.e. repolist.txt

Repo1
# Comment
Folder\Repo2
Repo3

and the batch file hgrpull.bat looks like:

REM First pull top level repository to get updated repolist etc
hg pull --update --quiet

REM Find path to server repository
FOR /F %%x IN ('hg showconfig paths.default') DO SET HGSERVER=%%x

REM Now pull or clone each repository
FOR /F "delims=; eol=#" %%x IN (repolist.txt) DO (
    If EXIST "%%x\.hg" (
        ECHO Pull %%x
        hg pull --update --quiet --repository "%%x"
    ) ELSE (
        ECHO Clone %%x
        IF NOT EXIST "%%x" MKDIR "%%x"
        hg clone --pull "%HGSERVER%\%%x" "%%x"
    )
)

I also got some batch files to perform actions on all repositories. (status/incoming/outgoing etc). They are all based on the following hgr.bat:

FOR /F "delims=; eol=#" %%x IN (repolist.txt) DO (
    ECHO ** %%x
    hg %1 --repository "%%x" %2 %3 %4 %5 %6
)

Pull/clone all repositories: hgrpull

Check status on all repositories: hgr st -mard

Upvotes: 0

Urda
Urda

Reputation: 5411

Why not use a hook on the Master server to push to a slave server? Add this to the project's hgrc:

[hooks]
changegroup = hg push -f https://hg.server2.com/TheRepo

FYI about changegroup from the hgrc help file:

changegroup: Run after a changegroup has been added via push, pull or unbundle. ID of the first new changeset is in $HG_NODE. URL from which changes came is in $HG_URL.

So when a change group comes in on the server, it will hg push the changes to yet another server.

Upvotes: 0

E-K
E-K

Reputation: 1491

If the repositories are static, a simple solution would be to write a batch file to pull from all those repositories. But no, mercurial does not support this directly.

Upvotes: 2

Related Questions