view hggit/ @ 254:07c7697e2aaa

Added tag 0.1.0 for changeset 505d7cdca198
author Augie Fackler <>
date Sat, 17 Oct 2009 20:12:19 -0400
parents 505d7cdca198
children 6977263c4d80
line wrap: on
line source

# - git server bridge
# Copyright 2008 Scott Chacon <schacon at gmail dot com>
#   also some code (and help) borrowed from durin42
# This software may be used and distributed according to the terms
# of the GNU General Public License, incorporated herein by reference.

'''push and pull from a Git server

This extension lets you communicate (push and pull) with a Git server.
This way you can use Git hosting for your project or collaborate with a
project that is in Git.  A bridger of worlds, this plugin be.

Try hg clone git:// or hg clone git+ssh://

from mercurial import commands, extensions, hg, util
from mercurial.i18n import _

from dulwich.repo import Repo
from dulwich.errors import NotGitRepository

import gitrepo, hgrepo
from git_handler import GitHandler

# support for `hg clone git://`
# also hg clone git+ssh://
hg.schemes['git'] = gitrepo
hg.schemes['git+ssh'] = gitrepo

_oldlocal = hg.schemes['file']

def _local(path):
    p = util.drop_scheme('file', path)
        return gitrepo
    except NotGitRepository:
        return _oldlocal(path)

hg.schemes['file'] = _local

def reposetup(ui, repo):
    klass = hgrepo.generate_repo_subclass(repo.__class__)
    repo.__class__ = klass

def gimport(ui, repo, remote_name=None):
    git = GitHandler(repo, ui)

def gexport(ui, repo):
    git = GitHandler(repo, ui)

def gclear(ui, repo):
    repo.ui.status(_("clearing out the git cache data\n"))
    git = GitHandler(repo, ui)

cmdtable = {
        (gimport, [], _('hg gimport')),
        (gexport, [], _('hg gexport')),
      (gclear, [], _('Clears out the Git cached data')),