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

[PATCH v2 08/18] remote-bzr: use branch variable when appropriate

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

There should be no functional changes. Basically we want to reserve the 'repo' variable.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/remote-helpers/git-remote-bzr | 35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)
diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr
index fdead31..0c67236 100755
--- a/contrib/remote-helpers/git-remote-bzr
+++ b/contrib/remote-helpers/git-remote-bzr
@@ -257,7 +257,8 @@ def export_branch(branch, name):
     tip = marks.get_tip(name)
 
     repo = branch.repository
-    repo.lock_read()
+
+    branch.lock_read()
     revs = branch.iter_merge_sorted_revisions(None, tip, 'exclude', 'forward')
     count = 0
 
@@ -325,7 +326,7 @@ def export_branch(branch, name):
             print "progress revision %s (%d/%d)" % (revid, count, len(revs))
             print "#############################################################"
 
-    repo.unlock()
+    branch.unlock()
 
     revid = branch.last_revision()
 
@@ -383,21 +384,21 @@ def parse_blob(parser):
 
 class CustomTree():
 
-    def __init__(self, repo, revid, parents, files):
+    def __init__(self, branch, revid, parents, files):
         global files_cache
 
         self.updates = {}
-        self.branch = repo
+        self.branch = branch
 
         def copy_tree(revid):
             files = files_cache[revid] = {}
-            repo.lock_read()
-            tree = repo.repository.revision_tree(revid)
+            branch.lock_read()
+            tree = branch.repository.revision_tree(revid)
             try:
                 for path, entry in tree.iter_entries_by_dir():
                     files[path] = [entry.file_id, None]
             finally:
-                repo.unlock()
+                branch.unlock()
             return files
 
         if len(parents) == 0:
@@ -587,20 +588,20 @@ def parse_commit(parser):
         path = c_style_unescape(path).decode('utf-8')
         files[path] = f
 
-    repo = parser.repo
+    branch = parser.repo
 
     committer, date, tz = committer
     parents = [str(mark_to_rev(p)) for p in parents]
     revid = bzrlib.generate_ids.gen_revision_id(committer, date)
     props = {}
-    props['branch-nick'] = repo.nick
+    props['branch-nick'] = branch.nick
 
-    mtree = CustomTree(repo, revid, parents, files)
+    mtree = CustomTree(branch, revid, parents, files)
     changes = mtree.iter_changes()
 
-    repo.lock_write()
+    branch.lock_write()
     try:
-        builder = repo.get_commit_builder(parents, None, date, tz, committer, props, revid)
+        builder = branch.get_commit_builder(parents, None, date, tz, committer, props, revid)
         try:
             list(builder.record_iter_changes(mtree, mtree.last_revision(), changes))
             builder.finish_inventory()
@@ -609,7 +610,7 @@ def parse_commit(parser):
             builder.abort()
             raise
     finally:
-        repo.unlock()
+        branch.unlock()
 
     parsed_refs[ref] = revid
     marks.new_mark(revid, commit_mark)
@@ -653,20 +654,20 @@ def do_export(parser):
         else:
             die('unhandled export command: %s' % line)
 
-    repo = parser.repo
+    branch = parser.repo
 
     for ref, revid in parsed_refs.iteritems():
         if ref == 'refs/heads/master':
-            repo.generate_revision_history(revid, marks.get_tip('master'))
+            branch.generate_revision_history(revid, marks.get_tip('master'))
             if peer:
                 try:
-                    repo.push(peer, stop_revision=revid)
+                    branch.push(peer, stop_revision=revid)
                 except bzrlib.errors.DivergedBranches:
                     print "error %s non-fast forward" % ref
                     continue
 
             try:
-                wt = repo.bzrdir.open_workingtree()
+                wt = branch.bzrdir.open_workingtree()
                 wt.update()
             except bzrlib.errors.NoWorkingTree:
                 pass
-- 
1.8.3.rc0.399.gc96a135
Previous: Felipe ContrerasNext: Felipe Contreras
Message 9 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.