sorin
sorin

Reputation: 170350

How to pull and update a mercurial repository and run a command if something changed?

I am looking for a bash solution that would allow me to run a command only if a hg pull && hg update did something.

I don't want to execute the command if pull or update did nothing.

How can I do this?

Upvotes: 0

Views: 60

Answers (1)

Ry4an Brase
Ry4an Brase

Reputation: 78330

What counts as "something" in your "did something" question?

If you mean 'new changesets arrived' you can most easily test for that in advance by doing:

if hg incoming ; then
    hg pull
    hg update
    ... other stuff here.
fi

If you mean 'files in the working directory were altered' then you need to check the output of hg update:

hg pull
if test "$(hg update)" != "0 files updated, 0 files merged, 0 files removed, 0 files unresolved"  ; then
    ... other stuff here ...

fi

Upvotes: 2

Related Questions