git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 11/18] remote-bzr: add support for shared repo

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
May 1, 2013, 01:10 UTC
Message-ID
<1367370610-14250-12-git-send-email-felipe.contreras@gmail.com>
In-Reply-To
<1367370610-14250-1-git-send-email-felipe.contreras@gmail.com>

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>
---
 contrib/remote-helpers/git-remote-bzr | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr
index 38cec07..9fe830e 100755
--- a/contrib/remote-helpers/git-remote-bzr
+++ b/contrib/remote-helpers/git-remote-bzr
@@ -752,7 +752,20 @@ def get_repo(url, alias):
     origin = bzrlib.bzrdir.BzrDir.open(url)
     is_local = isinstance(origin.transport, bzrlib.transport.local.LocalTransport)
 
-    clone_path = os.path.join(dirname, 'clone')
+    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')
+        if not os.path.exists(clone_path):
+            os.mkdir(clone_path)
 
     try:
         repo = origin.open_repository()
@@ -763,8 +776,6 @@ def get_repo(url, alias):
         branch = origin.open_branch()
 
         if not is_local:
-            if not os.path.exists(clone_path):
-                os.mkdir(clone_path)
             peers[name] = branch
             branches[name] = get_remote_branch(origin, branch, name)
         else:
@@ -774,9 +785,6 @@ def get_repo(url, alias):
     else:
         # 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():
 
             name = repo.user_transport.relpath(branch.base)
@@ -800,7 +808,7 @@ def fix_path(alias, orig_url):
     subprocess.call(cmd)
 
 def main(args):
-    global marks, prefix, dirname
+    global marks, prefix, gitdir, dirname
     global tags, filenodes
     global blob_marks
     global parsed_refs
-- 
1.8.3.rc0.399.gc96a135
Previous: Felipe ContrerasNext: Felipe Contreras
Message 12 of 25 in “remote-bzr: massive changes”
  1. 00/18 remote-bzr: massive changesFelipe Contreras, May 1, 2013
  2. 01/18 remote-bzr: cleanup CustomTreeFelipe Contreras, May 1, 2013
  3. 02/18 remote-bzr: delay blob fetching until the very endFelipe Contreras, May 1, 2013
  4. 03/18 remote-bzr: fix order of locking in CustomTreeFelipe Contreras, May 1, 2013
  5. 04/18 remote-bzr: always try to update the worktreeFelipe Contreras, May 1, 2013
  6. 05/18 remote-bzr: add support to push mergesFelipe Contreras, May 1, 2013
  7. 06/18 remote-bzr: fixes for branch divergeFelipe Contreras, May 1, 2013
  8. 07/18 remote-bzr: fix partially pushed mergeFelipe Contreras, May 1, 2013
  9. 08/18 remote-bzr: use branch variable when appropriateFelipe Contreras, May 1, 2013
  10. 09/18 remote-bzr: add support for bzr reposFelipe Contreras, May 1, 2013
  11. 10/18 remote-bzr: fix branch namesFelipe Contreras, May 1, 2013
  12. 11/18 remote-bzr: add support for shared repoFelipe Contreras, May 1, 2013
  13. 12/18 remote-bzr: improve author sanitazionFelipe Contreras, May 1, 2013
  14. 13/18 remote-bzr: add custom method to find branchesFelipe Contreras, May 1, 2013
  15. 14/18 remote-bzr: add option to specify branchesFelipe Contreras, May 1, 2013
  16. 15/18 remote-bzr: improve progress reportingFelipe Contreras, May 1, 2013
  17. 16/18 remote-bzr: iterate revisions properlyFelipe Contreras, May 1, 2013
  18. 17/18 remote-bzr: delay peer branch usageFelipe Contreras, May 1, 2013
  19. 18/18 remote-bzr: access branches only when neededFelipe Contreras, May 1, 2013
  20. Junio C HamanoMay 1, 2013
  21. Felipe ContrerasMay 1, 2013
  22. Junio C HamanoMay 1, 2013
  23. Felipe ContrerasMay 1, 2013
  24. Junio C HamanoMay 1, 2013
  25. Ted ZlatanovJan 3, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.