threads / discuss / 21367

git vs hg commit counts?

Subject: git vs hg commit counts?

## tl;dr

6 messages between Oct 27, 2009 and Oct 27, 2009.

replies: 5people: 4as markdown or json

Joe Perches· Oct 27, 2009, 00:08 UTC · lore
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?
Junio C Hamano· Oct 27, 2009, 00:18 UTC · re: Joe Perches · lore

Re: git vs hg commit counts?

Joe Perches <joe@perches.com> writes:
Show 17 quoted lines
> 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?

Joe Perches· Oct 27, 2009, 00:23 UTC · re: Junio C Hamano · lore

Re: git vs hg commit counts?

On Mon, 2009-10-26 at 17:18 -0700, Junio C Hamano wrote:
Show 9 quoted lines
> > $ 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?
Marti Raudsepp· Oct 27, 2009, 01:16 UTC · re: Junio C Hamano · lore

Re: git vs hg commit counts?

On Tue, Oct 27, 2009 at 2:18 AM, Junio C Hamano <gitster@pobox.com> 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
Joe Perches· Oct 27, 2009, 04:14 UTC · re: Marti Raudsepp · lore

Re: git vs hg commit counts?

On Tue, 2009-10-27 at 03:16 +0200, Marti Raudsepp wrote:
Show 11 quoted lines
> On Tue, Oct 27, 2009 at 2:18 AM, Junio C Hamano <gitster@pobox.com> 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".

Jakub Narebski· Oct 27, 2009, 01:14 UTC · re: Joe Perches · lore

Re: git vs hg commit counts?

Joe Perches <joe@perches.com> writes:
Show 17 quoted lines
> 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

← back to recent threads