Skip to content

Commit c95c35f

Browse files
felipecgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 42b48ef commit c95c35f

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

contrib/remote-helpers/git-remote-bzr

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,20 @@ def get_repo(url, alias):
752752
origin = bzrlib.bzrdir.BzrDir.open(url)
753753
is_local = isinstance(origin.transport, bzrlib.transport.local.LocalTransport)
754754

755-
clone_path = os.path.join(dirname, 'clone')
755+
shared_path = os.path.join(gitdir, 'bzr')
756+
try:
757+
shared_dir = bzrlib.bzrdir.BzrDir.open(shared_path)
758+
except bzrlib.errors.NotBranchError:
759+
shared_dir = bzrlib.bzrdir.BzrDir.create(shared_path)
760+
try:
761+
shared_repo = shared_dir.open_repository()
762+
except bzrlib.errors.NoRepositoryPresent:
763+
shared_repo = shared_dir.create_repository(shared=True)
764+
765+
if not is_local:
766+
clone_path = os.path.join(dirname, 'clone')
767+
if not os.path.exists(clone_path):
768+
os.mkdir(clone_path)
756769

757770
try:
758771
repo = origin.open_repository()
@@ -763,8 +776,6 @@ def get_repo(url, alias):
763776
branch = origin.open_branch()
764777

765778
if not is_local:
766-
if not os.path.exists(clone_path):
767-
os.mkdir(clone_path)
768779
peers[name] = branch
769780
branches[name] = get_remote_branch(origin, branch, name)
770781
else:
@@ -774,9 +785,6 @@ def get_repo(url, alias):
774785
else:
775786
# repository
776787

777-
if not is_local and not os.path.exists(clone_path):
778-
clonedir = bzrlib.bzrdir.BzrDir.create(clone_path)
779-
780788
for branch in repo.find_branches():
781789

782790
name = repo.user_transport.relpath(branch.base)
@@ -800,7 +808,7 @@ def fix_path(alias, orig_url):
800808
subprocess.call(cmd)
801809

802810
def main(args):
803-
global marks, prefix, dirname
811+
global marks, prefix, gitdir, dirname
804812
global tags, filenodes
805813
global blob_marks
806814
global parsed_refs

0 commit comments

Comments
 (0)