git pull vs hg pull

Shawn Hoover shawn.hoover at gmail.com
Thu Oct 29 15:13:44 UTC 2015


On Thu, Oct 29, 2015 at 6:30 AM, Simon King <simon at simonking.org.uk> wrote:

> On Thu, Oct 29, 2015 at 10:11 AM, Uwe Brauer <oub at mat.ucm.es> wrote:
> >
> >    > On Wed, Oct 28, 2015 at 2:43 PM, Uwe Brauer <oub at mat.ucm.es> wrote:
> >
> >    > Right.  Pay close attention to what Matt said.  git pull brings in
> new
> >    > commits, merges them with commits in your clone, and creates a new
> >    > commit.  It's probably showing you what files were changed in that
> new
> >    > commit?  hg pull does not do a merge or create a new commit, it just
> >    > pulls in commits.  There is no new merge commit created in the
> process
> >    > to summarize for you.  If you want to see what files were modified
> by
> >    > the commits you are about to pull in, you could try something like
> >    > this:
> >
> >    > hg incoming --stat
> >
> > This is *precisely* the command I was looking for! Thanks a lot.
> >
> > Is there any way to run it automatically after every pull?
> > (IMHO: I would even recommend it to make it the default behavior)
> >
>
> "hg incoming" shows you changes which are in the remote repository,
> but aren't yet in yours. Running it immediately after "hg pull" would
> be pointless, as there wouldn't be any changes to display. Also, "hg
> incoming" actually transfers most of the same data as "hg pull", but
> then throws it away, so it is a fairly inefficient command to use.
>
> The other suggestion (to run "hg diff --stat" the pull) is more
> sensible - you just need to figure out which revision you want to diff
> against. "hg pull" can potentially pull multiple branches into your
> local repository, so "tip" is not necessarily the right thing.
>

Thanks for that point. Looking into that revealed that in fact neither is
-r %HG_NODE% doing the right thing for those wishing to stat the pulled
changes. It would work for hg log, but for diff we need to start with a
parent of the first pulled node.

Something like this should do what the command in the wiki intended while
ensuring a descendant head is used:

hg diff --stat -r "p1(%HG_NODE%)" -r "max(descendants(%HG_NODE%))"

I suppose there's not much to be done about multiple pulled heads in this
case other than ignoring extras. Even if you wanted to run multiple diff
commands to diff changes on all pulled heads, the changegroup hook only
provides the first node and the URL.

Shawn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial/attachments/20151029/0bd9ae25/attachment-0002.html>


More information about the Mercurial mailing list