46
53
raise NoPushSupport()
55
def import_revision_gist(self, revid, parent_lookup):
56
"""Import the gist of a revision into this Git repository.
60
rev = self.source.get_revision(revid)
61
for sha, object, path in inventory_to_tree_and_blobs(
62
self.source.get_inventory(revid), self.source.texts, None):
65
objects.append((object, path))
66
commit = revision_to_commit(rev, tree_sha, parent_lookup)
67
objects.append((commit, None))
68
self.target._git.object_store.add_objects(objects)
69
return commit.sha().hexdigest()
71
def missing_revisions(self, stop_revision=None, ghosts=False):
72
if stop_revision is not None:
73
ancestry = [x for x in self.source.get_ancestry(stop_revision) if x is not None]
75
ancestry = self.source.all_revision_ids()
77
graph = self.source.get_graph()
78
for revid in graph.iter_topo_order(ancestry):
79
if not self.target.has_revision(revid):
85
def dfetch(self, stop_revision=None, fetch_ghosts=False):
86
"""Import the gist of the ancestry of a particular revision."""
89
def parent_lookup(revid):
91
return gitidmap[revid]
93
return self.target.lookup_git_revid(revid)[0]
94
mapping = self.target.get_mapping()
95
self.source.lock_write()
97
todo = self.missing_revisions(stop_revision, ghosts=fetch_ghosts)
98
pb = ui.ui_factory.nested_progress_bar()
100
for i, revid in enumerate(todo):
101
pb.update("pushing revisions", i, len(todo))
102
git_commit = self.import_revision_gist(revid, parent_lookup)
103
gitidmap[revid] = git_commit
104
git_revid = mapping.revision_id_foreign_to_bzr(git_commit)
105
revidmap[revid] = git_revid
109
self.source.fetch(self.target,
110
revision_id=revidmap[stop_revision])
49
116
def is_compatible(source, target):
50
117
"""Be compatible with GitRepository."""