remote-bzr: add support for shared repo
This way all the remotes share the same data, so adding multiple remotes, or renaming them doesn't create extra overhead. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
42b48ef25d
commit
c95c35f4b8
@ -752,7 +752,20 @@ def get_repo(url, alias):
|
|||||||
origin = bzrlib.bzrdir.BzrDir.open(url)
|
origin = bzrlib.bzrdir.BzrDir.open(url)
|
||||||
is_local = isinstance(origin.transport, bzrlib.transport.local.LocalTransport)
|
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)
|
||||||
|
except bzrlib.errors.NotBranchError:
|
||||||
|
shared_dir = bzrlib.bzrdir.BzrDir.create(shared_path)
|
||||||
|
try:
|
||||||
|
shared_repo = shared_dir.open_repository()
|
||||||
|
except bzrlib.errors.NoRepositoryPresent:
|
||||||
|
shared_repo = shared_dir.create_repository(shared=True)
|
||||||
|
|
||||||
|
if not is_local:
|
||||||
clone_path = os.path.join(dirname, 'clone')
|
clone_path = os.path.join(dirname, 'clone')
|
||||||
|
if not os.path.exists(clone_path):
|
||||||
|
os.mkdir(clone_path)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
repo = origin.open_repository()
|
repo = origin.open_repository()
|
||||||
@ -763,8 +776,6 @@ def get_repo(url, alias):
|
|||||||
branch = origin.open_branch()
|
branch = origin.open_branch()
|
||||||
|
|
||||||
if not is_local:
|
if not is_local:
|
||||||
if not os.path.exists(clone_path):
|
|
||||||
os.mkdir(clone_path)
|
|
||||||
peers[name] = branch
|
peers[name] = branch
|
||||||
branches[name] = get_remote_branch(origin, branch, name)
|
branches[name] = get_remote_branch(origin, branch, name)
|
||||||
else:
|
else:
|
||||||
@ -774,9 +785,6 @@ def get_repo(url, alias):
|
|||||||
else:
|
else:
|
||||||
# repository
|
# repository
|
||||||
|
|
||||||
if not is_local and not os.path.exists(clone_path):
|
|
||||||
clonedir = bzrlib.bzrdir.BzrDir.create(clone_path)
|
|
||||||
|
|
||||||
for branch in repo.find_branches():
|
for branch in repo.find_branches():
|
||||||
|
|
||||||
name = repo.user_transport.relpath(branch.base)
|
name = repo.user_transport.relpath(branch.base)
|
||||||
@ -800,7 +808,7 @@ def fix_path(alias, orig_url):
|
|||||||
subprocess.call(cmd)
|
subprocess.call(cmd)
|
||||||
|
|
||||||
def main(args):
|
def main(args):
|
||||||
global marks, prefix, dirname
|
global marks, prefix, gitdir, dirname
|
||||||
global tags, filenodes
|
global tags, filenodes
|
||||||
global blob_marks
|
global blob_marks
|
||||||
global parsed_refs
|
global parsed_refs
|
||||||
|
Loading…
Reference in New Issue
Block a user