2009-10-27 00:08:44

by Joe Perches

[permalink] [raw]
Subject: git vs hg commit counts?

I'm comparing linux-kernel git vs hg repositories.

While testing some changes to scripts/get_maintainer.pl,
I noticed that git and hg have different commit counts
for the same files.

For instance:

$ git log --since=1-year-ago -- MAINTAINERS | \
grep -P "^commit [0-9a-f]{40,40}$" | wc -l
514

$ hg log --template="commit {node}\n" --date -365 -- MAINTAINERS | \
grep -P "^commit [0-9a-f]{40,40}$" | wc -l
601

Anyone have any understanding why?


2009-10-27 00:18:43

by Junio C Hamano

[permalink] [raw]
Subject: Re: git vs hg commit counts?

Joe Perches <[email protected]> writes:

> I'm comparing linux-kernel git vs hg repositories.
>
> While testing some changes to scripts/get_maintainer.pl,
> I noticed that git and hg have different commit counts
> for the same files.
>
> For instance:
>
> $ git log --since=1-year-ago -- MAINTAINERS | \
> grep -P "^commit [0-9a-f]{40,40}$" | wc -l
> 514
>
> $ hg log --template="commit {node}\n" --date -365 -- MAINTAINERS | \
> grep -P "^commit [0-9a-f]{40,40}$" | wc -l
> 601
>
> Anyone have any understanding why?

We simplify a merge history by discarding one branch when the merge result
matches one of the parents. Does "hg" know how to do that as well?

2009-10-27 00:23:03

by Joe Perches

[permalink] [raw]
Subject: Re: git vs hg commit counts?

On Mon, 2009-10-26 at 17:18 -0700, Junio C Hamano wrote:
> > $ git log --since=1-year-ago -- MAINTAINERS | \
> > grep -P "^commit [0-9a-f]{40,40}$" | wc -l
> > 514
> > $ hg log --template="commit {node}\n" --date -365 -- MAINTAINERS | \
> > grep -P "^commit [0-9a-f]{40,40}$" | wc -l
> > 601
> > Anyone have any understanding why?
> We simplify a merge history by discarding one branch when the merge result
> matches one of the parents.

Thanks Junio.

> Does "hg" know how to do that as well?

I don't know.

I was hoping to get equivalent results though.

Anyone know how?

2009-10-27 01:14:45

by Jakub Narebski

[permalink] [raw]
Subject: Re: git vs hg commit counts?

Joe Perches <[email protected]> writes:

> I'm comparing linux-kernel git vs hg repositories.
>
> While testing some changes to scripts/get_maintainer.pl,
> I noticed that git and hg have different commit counts
> for the same files.
>
> For instance:
>
> $ git log --since=1-year-ago -- MAINTAINERS | \
> grep -P "^commit [0-9a-f]{40,40}$" | wc -l
> 514
>
> $ hg log --template="commit {node}\n" --date -365 -- MAINTAINERS | \
> grep -P "^commit [0-9a-f]{40,40}$" | wc -l
> 601
>
> Anyone have any understanding why?

It *might* be caused by the fact that in Mercurial commit can have
only up to two parents. This means that octopus merges (merge commits
with more than two parents: there are a few of them in linux-kernel
history) have to be represented as a set of two-parent merges.

--
Jakub Narebski

http://stackoverflow.com/questions/1598759/git-and-mercurial-compare-and-contrast/1599930#1599930

2009-10-27 01:16:49

by Marti Raudsepp

[permalink] [raw]
Subject: Re: git vs hg commit counts?

On Tue, Oct 27, 2009 at 2:18 AM, Junio C Hamano <[email protected]> wrote:
> We simplify a merge history by discarding one branch when the merge result
> matches one of the parents.  Does "hg" know how to do that as well?

57 of the differing changesets are normal merges (probably what Junio explained)
3 are duplicate changesets in hg, probably also related to that
27 changesets are octopus merge fixups

wrt octopus merges: in git, one merge commit can have an arbitrary
number of parents, but in hg a merge changeset always has 2 parents --
so a octopus merge is represented as multiple distinct changesets.

Marti

2009-10-27 04:14:27

by Joe Perches

[permalink] [raw]
Subject: Re: git vs hg commit counts?

On Tue, 2009-10-27 at 03:16 +0200, Marti Raudsepp wrote:
> On Tue, Oct 27, 2009 at 2:18 AM, Junio C Hamano <[email protected]> wrote:
> > We simplify a merge history by discarding one branch when the merge result
> > matches one of the parents. Does "hg" know how to do that as well?
>
> 57 of the differing changesets are normal merges (probably what Junio explained)
> 3 are duplicate changesets in hg, probably also related to that
> 27 changesets are octopus merge fixups
>
> wrt octopus merges: in git, one merge commit can have an arbitrary
> number of parents, but in hg a merge changeset always has 2 parents --
> so a octopus merge is represented as multiple distinct changesets.

Thanks.

For hg support in get_maintainers, it's probably
simplest to ignore the delta in number of commits
as "close enough".