remote-bzr: use branch variable when appropriate

There should be no functional changes. Basically we want to reserve the 'repo' variable. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Felipe Contreras committed Apr 30, 2013 at 20:10 UTC 5df4fad31902ba449e25c22f490526e8022a692c
1 file changed +18 -17
contrib/remote-helpers/git-remote-bzr
+18 -17
@@ -257,7 +257,8 @@ def export_branch(branch, name):
257 tip = marks.get_tip(name)
258
259 repo = branch.repository
260 - repo.lock_read()
260 +
261 + branch.lock_read()
262 revs = branch.iter_merge_sorted_revisions(None, tip, 'exclude', 'forward')
263 count = 0
264
@@ -325,7 +326,7 @@ def export_branch(branch, name):
326 print "progress revision %s (%d/%d)" % (revid, count, len(revs))
327 print "#############################################################"
328
328 - repo.unlock()
329 + branch.unlock()
330
331 revid = branch.last_revision()
332
@@ -383,21 +384,21 @@ def parse_blob(parser):
384
385 class CustomTree():
386
386 - def __init__(self, repo, revid, parents, files):
387 + def __init__(self, branch, revid, parents, files):
388 global files_cache
389
390 self.updates = {}
390 - self.branch = repo
391 + self.branch = branch
392
393 def copy_tree(revid):
394 files = files_cache[revid] = {}
394 - repo.lock_read()
395 - tree = repo.repository.revision_tree(revid)
395 + branch.lock_read()
396 + tree = branch.repository.revision_tree(revid)
397 try:
398 for path, entry in tree.iter_entries_by_dir():
399 files[path] = [entry.file_id, None]
400 finally:
400 - repo.unlock()
401 + branch.unlock()
402 return files
403
404 if len(parents) == 0:
@@ -587,20 +588,20 @@ def parse_commit(parser):
588 path = c_style_unescape(path).decode('utf-8')
589 files[path] = f
590
590 - repo = parser.repo
591 + branch = parser.repo
592
593 committer, date, tz = committer
594 parents = [str(mark_to_rev(p)) for p in parents]
595 revid = bzrlib.generate_ids.gen_revision_id(committer, date)
596 props = {}
596 - props['branch-nick'] = repo.nick
597 + props['branch-nick'] = branch.nick
598
598 - mtree = CustomTree(repo, revid, parents, files)
599 + mtree = CustomTree(branch, revid, parents, files)
600 changes = mtree.iter_changes()
601
601 - repo.lock_write()
602 + branch.lock_write()
603 try:
603 - builder = repo.get_commit_builder(parents, None, date, tz, committer, props, revid)
604 + builder = branch.get_commit_builder(parents, None, date, tz, committer, props, revid)
605 try:
606 list(builder.record_iter_changes(mtree, mtree.last_revision(), changes))
607 builder.finish_inventory()
@@ -609,7 +610,7 @@ def parse_commit(parser):
610 builder.abort()
611 raise
612 finally:
612 - repo.unlock()
613 + branch.unlock()
614
615 parsed_refs[ref] = revid
616 marks.new_mark(revid, commit_mark)
@@ -653,20 +654,20 @@ def do_export(parser):
654 else:
655 die('unhandled export command: %s' % line)
656
656 - repo = parser.repo
657 + branch = parser.repo
658
659 for ref, revid in parsed_refs.iteritems():
660 if ref == 'refs/heads/master':
660 - repo.generate_revision_history(revid, marks.get_tip('master'))
661 + branch.generate_revision_history(revid, marks.get_tip('master'))
662 if peer:
663 try:
663 - repo.push(peer, stop_revision=revid)
664 + branch.push(peer, stop_revision=revid)
665 except bzrlib.errors.DivergedBranches:
666 print "error %s non-fast forward" % ref
667 continue
668
669 try:
669 - wt = repo.bzrdir.open_workingtree()
670 + wt = branch.bzrdir.open_workingtree()
671 wt.update()
672 except bzrlib.errors.NoWorkingTree:
673 pass