[PATCH] Updated convert-repo script (1/3 Git 1.3.0 fix)

Alexis S. L. Carvalho alexis at cecm.usp.br
Tue May 2 15:04:54 CDT 2006


Thus spake Sébastien Pierre:
> # HG changeset patch
> # User sebastien at localhost.localdomain

As was mentioned, please set the username variable in the [ui] section
of hgrc to your name.

> # Node ID c2a90145c7034f4cd4d59092ffc76f65e83f3524
> # Parent  0ce3cd330996e49ac3292aac4bfa4d4cd3f0a47a
> Fixed the `getheads` function to work with git-1.3.0. I think this is
> backwards-compatible, but did not test with previous git versions.

minor nit: since hg shows only the first line of the commit message in
the default output of hg log, try to set it to just a concise
description of the change.

> diff -r 0ce3cd330996 -r c2a90145c703 contrib/convert-repo
> --- a/contrib/convert-repo	Fri Apr 28 12:38:11 2006 +0200
> +++ b/contrib/convert-repo	Mon May 01 16:50:04 2006 -0400
> @@ -28,7 +28,12 @@ class convert_git:
>          self.path = path
>  
>      def getheads(self):
> -        return [file(self.path + "/HEAD").read()[:-1]]
> +        # On some versions of git, the HEAD file last line is like
> +        # ref: refs/heads/master
> +        # And we only want "master" here
> +        head = file(self.path + "/HEAD").read()[:-1]
> +        head = head.split("/")[-1]
> +        return [head]

I'm still not up to speed with git, but I'm reasonably sure that you
just want to call "git-rev-parse HEAD" here (setting GIT_DIR like the
other calls in this file).

Looking at gitk, it looks like this program was added in June, so it
should be backwards compatible enough.

Alexis


More information about the Mercurial mailing list