2009-02-21 05:27:51 +03:00
|
|
|
# git.py - 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.
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
2009-05-10 18:20:58 +04:00
|
|
|
from mercurial import commands
|
|
|
|
from mercurial import hg
|
2009-06-04 21:07:05 +04:00
|
|
|
from mercurial import util
|
|
|
|
from mercurial import bundlerepo
|
2009-02-21 05:27:51 +03:00
|
|
|
from mercurial.i18n import _
|
2009-06-04 21:07:05 +04:00
|
|
|
import os
|
2009-04-24 02:26:10 +04:00
|
|
|
from git_handler import GitHandler
|
2009-02-21 05:27:51 +03:00
|
|
|
|
2009-04-29 11:54:13 +04:00
|
|
|
# support for `hg clone git://github.com/defunkt/facebox.git`
|
2009-06-02 07:17:11 +04:00
|
|
|
# also hg clone git+ssh://git@github.com/schacon/simplegit.git
|
2009-06-02 01:57:19 +04:00
|
|
|
import gitrepo, hgrepo
|
2009-04-29 11:54:13 +04:00
|
|
|
hg.schemes['git'] = gitrepo
|
2009-06-02 07:17:11 +04:00
|
|
|
hg.schemes['git+ssh'] = gitrepo
|
2009-06-04 21:07:05 +04:00
|
|
|
|
|
|
|
def _local(path):
|
|
|
|
return (os.path.isfile(util.drop_scheme('file', path)) and
|
|
|
|
bundlerepo or hgrepo)
|
|
|
|
|
|
|
|
hg.schemes['file'] = _local
|
2009-04-29 11:54:13 +04:00
|
|
|
|
2009-05-15 02:48:24 +04:00
|
|
|
def gimport(ui, repo, remote_name=None):
|
|
|
|
git = GitHandler(repo, ui)
|
|
|
|
git.import_commits(remote_name)
|
|
|
|
|
2009-05-10 17:14:36 +04:00
|
|
|
def gexport(ui, repo):
|
|
|
|
git = GitHandler(repo, ui)
|
2009-05-15 02:43:38 +04:00
|
|
|
git.export_commits()
|
2009-05-10 17:14:36 +04:00
|
|
|
|
2009-04-29 03:56:05 +04:00
|
|
|
def gclear(ui, repo):
|
|
|
|
repo.ui.status(_("clearing out the git cache data\n"))
|
|
|
|
git = GitHandler(repo, ui)
|
|
|
|
git.clear()
|
2009-04-30 00:55:22 +04:00
|
|
|
|
2009-02-21 05:27:51 +03:00
|
|
|
commands.norepo += " gclone"
|
|
|
|
cmdtable = {
|
2009-05-15 02:48:24 +04:00
|
|
|
"gimport":
|
|
|
|
(gimport, [], _('hg gimport')),
|
2009-05-10 17:14:36 +04:00
|
|
|
"gexport":
|
|
|
|
(gexport, [], _('hg gexport')),
|
2009-04-29 03:56:05 +04:00
|
|
|
"gclear":
|
|
|
|
(gclear, [], _('Clears out the Git cached data')),
|
2009-06-08 22:15:58 +04:00
|
|
|
}
|