110
113
return isinstance(target, DummyForeignVcsBranch)
112
115
def lossy_push(self, stop_revision=None):
116
result = branch.BranchPushResult()
117
result.source_branch = self.source
118
result.target_branch = self.target
119
result.old_revno, result.old_revid = self.target.last_revision_info()
113
120
self.source.lock_read()
115
122
# This just handles simple cases, but that's good enough for tests
129
136
(str(rev.timestamp), str(rev.timezone),
130
137
str(self.target.revno())))
131
138
parent_revno, parent_revid= self.target.last_revision_info()
132
builder = self.target.get_commit_builder([parent_revid],
139
if parent_revid == NULL_REVISION:
142
parent_revids = [parent_revid]
143
builder = self.target.get_commit_builder(parent_revids,
133
144
self.target.get_config(), rev.timestamp,
134
145
rev.timezone, rev.committer, rev.properties,
138
149
new_ie = ie.copy()
139
150
new_ie.revision = None
140
151
builder.record_entry_contents(new_ie,
141
[self.target.repository.get_inventory(parent_revid)],
152
[self.target.repository.revision_tree(parent_revid).inventory],
143
154
(ie.kind, ie.text_size, ie.executable, ie.text_sha1))
144
155
builder.finish_inventory()
372
385
dir = BzrDir.open("d")
373
386
newdir = dir.sprout("e")
374
387
self.assertNotEquals("A Dummy VCS Dir", newdir._format.get_format_string())
389
def test_lossy_push_empty(self):
390
source_tree = self.make_branch_and_tree("source")
391
target_tree = self.make_branch_and_tree("target",
392
format=DummyForeignVcsDirFormat())
393
pushresult = source_tree.branch.lossy_push(target_tree.branch)
394
self.assertEquals(NULL_REVISION, pushresult.old_revid)
395
self.assertEquals(NULL_REVISION, pushresult.new_revid)
396
self.assertEquals({}, pushresult.revidmap)
398
def test_lossy_push_simple(self):
399
source_tree = self.make_branch_and_tree("source")
400
self.build_tree(['source/a', 'source/b'])
401
source_tree.add(['a', 'b'])
402
revid1 = source_tree.commit("msg")
403
target_tree = self.make_branch_and_tree("target",
404
format=DummyForeignVcsDirFormat())
405
target_tree.branch.lock_write()
407
pushresult = source_tree.branch.lossy_push(target_tree.branch)
409
target_tree.branch.unlock()
410
self.assertEquals(NULL_REVISION, pushresult.old_revid)
411
self.assertEquals({revid1:target_tree.branch.last_revision()},
413
self.assertEquals(pushresult.revidmap[revid1], pushresult.new_revid)