from bzrlib.trace import warning, mutter
from bzrlib.transport import register_lazy_transport, register_transport_proto
-from bzrlib.plugins.svn import format
-from bzrlib.plugins.svn import revspec
+from bzrlib.plugins.svn import format, revspec
# versions ending in 'exp' mean experimental mappings
# versions ending in 'dev' mean development version
register_command(cmd_svn_push)
class cmd_dpush(Command):
- """Push revisions to Subversion without setting any magic Bazaar-specific
- properties.
+ """Push diffs into Subversion avoiding the use of any Bazaar-specific properties.
This will afterwards rebase the local Bazaar branch on the Subversion
- branch.
+ branch unless the --no-rebase option is used, in which case
+ the two branches will be out of sync.
"""
takes_args = ['location?']
takes_options = ['remember', Option('directory',
def dpush(target, source, stop_revision=None):
- source.lock_read()
+ source.lock_write()
try:
if stop_revision is None:
stop_revision = ensure_null(source.last_revision())
pb.update("pushing revisions", todo.index(revid),
len(todo))
revid_map[revid] = push(target, source, revid, push_metadata=False)
+ source.repository.fetch(target.repository, revision_id=revid_map[revid])
target._clear_cached_state()
finally:
pb.finished()
old_tree = source_repo.revision_tree(revision_id)
base_tree = source_repo.revision_tree(base_revid)
- builder = SvnCommitBuilder(target.repository, target, rev.parent_ids,
+ builder = SvnCommitBuilder(target.repository, target,
+ rev.parent_ids if push_metadata else [base_revid],
config, rev.timestamp,
rev.timezone, rev.committer, rev.properties,
revision_id, base_tree.inventory,
mutter('pushing %r (%r)', revision_id, rev.parent_ids)
# revision on top of which to commit
- if rev.parent_ids == []:
- base_revid = None
+ if push_metadata:
+ if rev.parent_ids == []:
+ base_revid = None
+ else:
+ base_revid = rev.parent_ids[0]
else:
- base_revid = rev.parent_ids[0]
+ base_revid = target.last_revision()
source.lock_read()
try:
if target_branch.get_branch_path() != bp:
target_branch.set_branch_path(bp)
- push_revision_tree(target_branch, target_branch.get_config(), self.source, parent_revid, revision_id, rev)
+ push_revision_tree(target_branch, target_branch.get_config(), self.source,
+ parent_revid, revision_id, rev)
finally:
self.source.unlock()
def commit_editor(self):
return self.get_commit_editor(self.repos_url)
- def test_change(self):
+ def test_change_single(self):
self.build_tree({'dc/foo/bla': 'other data'})
wt = self.bzrdir.open_workingtree()
newid = wt.commit(message="Commit from Bzr")
c.get_latest_revnum(),
"",
r.get_mapping())], revid_map.values())
+
+ def test_change_multiple(self):
+ self.build_tree({'dc/foo/bla': 'other data'})
+ wt = self.bzrdir.open_workingtree()
+ self.build_tree({'dc/foo/bla': 'other data'})
+ newid1 = wt.commit(message="Commit from Bzr")
+ self.build_tree({'dc/foo/bla': 'yet other data'})
+ newid2 = wt.commit(message="Commit from Bzr")
+
+ revid_map = dpush(self.svndir.open_branch(), self.bzrdir.open_branch())
+
+ self.assertEquals(set([newid1, newid2]), set(revid_map.keys()))
+
+ c = ra.RemoteAccess(self.repos_url)
+ (entries, fetch_rev, props) = c.get_dir("", c.get_latest_revnum())
+ self.assertEquals(set(['svn:entry:committed-rev',
+ 'svn:entry:last-author', 'svn:entry:uuid',
+ 'svn:entry:committed-date']), set(props.keys()))
+
+ r = self.svndir.find_repository()
+ self.assertEquals(set([r.generate_revision_id(
+ rev,
+ "",
+ r.get_mapping()) for rev in (c.get_latest_revnum()-1, c.get_latest_revnum())]),
+ set(revid_map.values()))
class TestPush(TestCaseWithSubversionRepository):