[PATCH] repo-convert: Convert current git branch into hg named branch

John Goerzen jgoerzen at complete.org
Thu Mar 15 11:33:50 CDT 2007


I'm trying this out, and it seems to work well.  BUT... tags aren't
coming across from git into hg.  I don't know if this is particular to
this patch, or if it would have been that way anyway.  I just know there
is no .hgtags file and hg log .hgtags shows nothing in the history
either.

-- John

On 2007-03-15, Rocco Rutte <pdmef at gmx.net> wrote:
> We now simply parse the output of git-branch(1) to get the current
> branch and use it for for the commit() function.
>
> This patch also uses git-rev-parse(1) with that branch name instead of
> HEAD as preparation to allow specifying the source branch via command
> line since there's no technical reason to have it checkout out on the
> git side.
> ---
>  Note: please CC me in any replies as I'm not subscribed to the list.
>
>  contrib/convert-repo |   12 ++++++++++--
>  1 files changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/contrib/convert-repo b/contrib/convert-repo
> index 6fd189e..6b6b672 100755
> --- a/contrib/convert-repo
> +++ b/contrib/convert-repo
> @@ -296,8 +296,16 @@ class convert_git:
>          if not os.path.exists(path + "/objects"):
>              raise NoRepo("couldn't open GIT repo %s" % path)
>  
> +        fh = os.popen("GIT_DIR=%s git-branch" % self.path)
> +        self.branch = 'master'
> +        for branch in fh.readlines():
> +          if branch[0] == '*':
> +            self.branch = branch[2:-1]
> +
> +        status("importing git branch '%s'...\n" % self.branch)
> +
>      def getheads(self):
> -        fh = os.popen("GIT_DIR=%s git-rev-parse --verify HEAD" % self.path)
> +        fh = os.popen("GIT_DIR=%s git-rev-parse --verify %s" % (self.path, self.branch))
>          return [fh.read()[:-1]]
>  
>      def catfile(self, rev, type):
> @@ -355,7 +363,7 @@ class convert_git:
>          tz = -int(tzs) * (int(tzh) * 3600 + int(tzm))
>          date = tm + " " + str(tz)
>  
> -        c = commit(parents=parents, date=date, author=author, desc=message)
> +        c = commit(parents=parents, date=date, author=author, desc=message, branch=self.branch)
>          return c
>  
>      def gettags(self):


-- 
John Goerzen
Author, Foundations of Python Network Programming
http://www.amazon.com/exec/obidos/tg/detail/-/1590593715



More information about the Mercurial-devel mailing list