automatic "last upstream pull"?

Brendan Cully brendan at kublai.com
Tue Sep 12 17:47:33 UTC 2006


On Tuesday, 12 September 2006 at 11:15, Hollis Blanchard wrote:
> Hi, is there a way to automatically answer the question "what was the
> last upstream pull?" If I want to see the complete diff between my tree
> and the "upstream" tree, I do this:
> 	hg diff -r <last upstream changeset>
> I want to automate finding that changeset.

something like this should work to find that revision:

hg --debug outgoing --template "{parents}\n" /url/to/upstream |
head -n3|tail -n1| cut -d: -f1

though it might be worth checking whether the rev is a merge revision
(second parent != -1) and just using it instead of its parent in that
case:

hg --debug outgoing --template "{parents} {rev}\n" /url/to/upstream |
head -n3|tail -n1|read p1 p2 rev
if test `echo $p2|cut -d: -f1` != '-1'; then
  baserev=$rev
else
  baserev=$p1
fi



More information about the Mercurial mailing list