remote-bzr: fix partially pushed merge

If part of the merge was already pushed, we don't have the blob_marks available, however, the commits are already stored in bazaar, so we can use the revision_tree to fetch the contents. We want to do this only when there's no other option. There's no easy way to test this. 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:09 UTC b25df87fad2b12349a55146d5c87625109a58221
1 file changed +13 -4
contrib/remote-helpers/git-remote-bzr
+13 -4
@@ -387,6 +387,7 @@ class CustomTree():
387 global files_cache
388
389 self.updates = {}
390 + self.branch = repo
391
392 def copy_tree(revid):
393 files = files_cache[revid] = {}
@@ -515,13 +516,21 @@ class CustomTree():
516
517 return changes
518
518 - def get_file_with_stat(self, file_id, path=None):
519 + def get_content(self, file_id):
520 path, mark = self.rev_files[file_id]
520 - return (StringIO.StringIO(blob_marks[mark]), None)
521 + if mark:
522 + return blob_marks[mark]
523 +
524 + # last resort
525 + tree = self.branch.repository.revision_tree(self.base_id)
526 + return tree.get_file_text(file_id)
527 +
528 + def get_file_with_stat(self, file_id, path=None):
529 + content = self.get_content(file_id)
530 + return (StringIO.StringIO(content), None)
531
532 def get_symlink_target(self, file_id):
523 - path, mark = self.rev_files[file_id]
524 - return blob_marks[mark]
533 + return self.get_content(file_id)
534
535 def id2path(self, file_id):
536 path, mark = self.rev_files[file_id]