summaryrefslogtreecommitdiff
path: root/contrib/remote-helpers
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/remote-helpers')
-rwxr-xr-xcontrib/remote-helpers/git-remote-bzr26
-rwxr-xr-xcontrib/remote-helpers/git-remote-hg25
2 files changed, 36 insertions, 15 deletions
diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr
index 42cec58..054161a 100755
--- a/contrib/remote-helpers/git-remote-bzr
+++ b/contrib/remote-helpers/git-remote-bzr
@@ -682,7 +682,8 @@ def do_export(parser):
branch.generate_revision_history(revid, marks.get_tip(name))
if name in peers:
- peer = bzrlib.branch.Branch.open(peers[name])
+ peer = bzrlib.branch.Branch.open(peers[name],
+ possible_transports=transports)
try:
peer.bzrdir.push_branch(branch, revision_id=revid)
except bzrlib.errors.DivergedBranches:
@@ -749,22 +750,24 @@ def do_list(parser):
def clone(path, remote_branch):
try:
- bdir = bzrlib.bzrdir.BzrDir.create(path)
+ bdir = bzrlib.bzrdir.BzrDir.create(path, possible_transports=transports)
except bzrlib.errors.AlreadyControlDirError:
- bdir = bzrlib.bzrdir.BzrDir.open(path)
+ bdir = bzrlib.bzrdir.BzrDir.open(path, possible_transports=transports)
repo = bdir.find_repository()
repo.fetch(remote_branch.repository)
return remote_branch.sprout(bdir, repository=repo)
def get_remote_branch(name):
- remote_branch = bzrlib.branch.Branch.open(branches[name])
+ remote_branch = bzrlib.branch.Branch.open(branches[name],
+ possible_transports=transports)
if isinstance(remote_branch.user_transport, bzrlib.transport.local.LocalTransport):
return remote_branch
branch_path = os.path.join(dirname, 'clone', name)
try:
- branch = bzrlib.branch.Branch.open(branch_path)
+ branch = bzrlib.branch.Branch.open(branch_path,
+ possible_transports=transports)
except bzrlib.errors.NotBranchError:
# clone
branch = clone(branch_path, remote_branch)
@@ -799,14 +802,16 @@ def find_branches(repo):
def get_repo(url, alias):
normal_url = bzrlib.urlutils.normalize_url(url)
- origin = bzrlib.bzrdir.BzrDir.open(url)
+ origin = bzrlib.bzrdir.BzrDir.open(url, possible_transports=transports)
is_local = isinstance(origin.transport, bzrlib.transport.local.LocalTransport)
shared_path = os.path.join(gitdir, 'bzr')
try:
- shared_dir = bzrlib.bzrdir.BzrDir.open(shared_path)
+ shared_dir = bzrlib.bzrdir.BzrDir.open(shared_path,
+ possible_transports=transports)
except bzrlib.errors.NotBranchError:
- shared_dir = bzrlib.bzrdir.BzrDir.create(shared_path)
+ shared_dir = bzrlib.bzrdir.BzrDir.create(shared_path,
+ possible_transports=transports)
try:
shared_repo = shared_dir.open_repository()
except bzrlib.errors.NoRepositoryPresent:
@@ -819,7 +824,8 @@ def get_repo(url, alias):
else:
# check and remove old organization
try:
- bdir = bzrlib.bzrdir.BzrDir.open(clone_path)
+ bdir = bzrlib.bzrdir.BzrDir.open(clone_path,
+ possible_transports=transports)
bdir.destroy_repository()
except bzrlib.errors.NotBranchError:
pass
@@ -876,6 +882,7 @@ def main(args):
global files_cache
global is_tmp
global branches, peers
+ global transports
alias = args[1]
url = args[2]
@@ -888,6 +895,7 @@ def main(args):
marks = None
branches = {}
peers = {}
+ transports = []
if alias[5:] == url:
is_tmp = True
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index 3db7bd1..92d994e 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -391,11 +391,24 @@ def get_repo(url, alias):
os.makedirs(dirname)
else:
shared_path = os.path.join(gitdir, 'hg')
- if not os.path.exists(shared_path):
- try:
- hg.clone(myui, {}, url, shared_path, update=False, pull=True)
- except:
- die('Repository error')
+
+ # check and upgrade old organization
+ hg_path = os.path.join(shared_path, '.hg')
+ if os.path.exists(shared_path) and not os.path.exists(hg_path):
+ repos = os.listdir(shared_path)
+ for x in repos:
+ local_hg = os.path.join(shared_path, x, 'clone', '.hg')
+ if not os.path.exists(local_hg):
+ continue
+ if not os.path.exists(hg_path):
+ shutil.move(local_hg, hg_path)
+ shutil.rmtree(os.path.join(shared_path, x, 'clone'))
+
+ # setup shared repo (if not there)
+ try:
+ hg.peer(myui, {}, shared_path, create=True)
+ except error.RepoError:
+ pass
if not os.path.exists(dirname):
os.makedirs(dirname)
@@ -1129,7 +1142,7 @@ def do_option(parser):
def fix_path(alias, repo, orig_url):
url = urlparse.urlparse(orig_url, 'file')
- if url.scheme != 'file' or os.path.isabs(url.path):
+ if url.scheme != 'file' or os.path.isabs(os.path.expanduser(url.path)):
return
abs_url = urlparse.urljoin("%s/" % os.getcwd(), orig_url)
cmd = ['git', 'config', 'remote.%s.url' % alias, "hg::%s" % abs_url]