Rev 1647: Fix graphs, tests. in http://people.samba.org/bzr/jelmer/bzr-svn/trunk
Jelmer Vernooij
jelmer at samba.org
Mon Aug 25 01:05:18 BST 2008
At http://people.samba.org/bzr/jelmer/bzr-svn/trunk
------------------------------------------------------------
revno: 1647
revision-id: jelmer at samba.org-20080825000515-tt361na3wn5crg0k
parent: jelmer at samba.org-20080824231858-wywzsxzzghwspebv
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Mon 2008-08-25 02:05:15 +0200
message:
Fix graphs, tests.
modified:
branch.py svnbranch.py-20051017135706-11c749eb0dab04a7
commit.py commit.py-20060607190346-qvq128wgfubhhgm2-1
mapping.py mapping.py-20080128201303-6cp01phc0dmc0kiv-1
mapping3/__init__.py __init__.py-20080502174630-9324zh25kka98vlw-1
tests/test_push.py test_push.py-20070201165715-g2ievcdfqi33wqsy-1
=== modified file 'branch.py'
--- a/branch.py 2008-08-24 20:41:08 +0000
+++ b/branch.py 2008-08-25 00:05:15 +0000
@@ -253,7 +253,8 @@
if (rev_history == [] or
not self.repository.has_revision(rev_history[-1])):
raise NotImplementedError("set_revision_history can't add ghosts")
- push(self, self.repository, rev_history[-1])
+ push(self.repository.get_graph(),
+ self, self.repository, rev_history[-1])
self._clear_cached_state()
def set_last_revision_info(self, revno, revid):
@@ -409,11 +410,11 @@
self.last_revision() == other.last_revision()):
return
if graph is None:
- my_graph = self.repository.get_graph()
+ graph = self.repository.get_graph()
other_graph = other.repository.get_graph()
if not other_graph.is_ancestor(self.last_revision(),
stop_revision):
- if my_graph.is_ancestor(stop_revision, self.last_revision()):
+ if graph.is_ancestor(stop_revision, self.last_revision()):
return
if not overwrite:
raise DivergedBranches(self, other)
@@ -425,9 +426,10 @@
raise DivergedBranches(self, other)
if _push_merged is None:
_push_merged = self.layout.push_merged_revisions(self.project)
- self._push_missing_revisions(other, other_graph, todo, _push_merged)
+ self._push_missing_revisions(graph, other, other_graph, todo,
+ _push_merged)
- def _push_missing_revisions(self, other, other_graph, todo,
+ def _push_missing_revisions(self, my_graph, other, other_graph, todo,
push_merged=False):
pb = ui.ui_factory.nested_progress_bar()
try:
@@ -437,7 +439,7 @@
if push_merged:
parent_revids = other_graph.get_parent_map([revid])[revid]
push_ancestors(self.repository, other.repository, self.layout, self.project, parent_revids, other_graph)
- push(self, other.repository, revid)
+ push(my_graph, self, other.repository, revid)
self._clear_cached_state()
finally:
pb.finished()
=== modified file 'commit.py'
--- a/commit.py 2008-08-24 23:18:58 +0000
+++ b/commit.py 2008-08-25 00:05:15 +0000
@@ -129,7 +129,8 @@
def __init__(self, repository, branch, parents, config, timestamp,
timezone, committer, revprops, revision_id, old_inv=None,
- push_metadata=True):
+ push_metadata=True,
+ graph=None):
"""Instantiate a new SvnCommitBuilder.
:param repository: SvnRepository to commit to.
@@ -158,7 +159,8 @@
else:
self.base_revid = parents[0]
- graph = self.repository.get_graph()
+ if graph is None:
+ graph = self.repository.get_graph()
self.base_revno = graph.find_distance_to_null(self.base_revid, [])
if self.base_revid == NULL_REVISION:
self.base_revnum = -1
@@ -675,7 +677,7 @@
revnum, self.get_branch_path(revnum),
self.repository.get_mapping())
- push(ImaginaryBranch(target_repository), source, start_revid, push_metadata=push_metadata)
+ push(target_repository.get_graph(), ImaginaryBranch(target_repository), source, start_revid, push_metadata=push_metadata)
def dpush(target, source, stop_revision=None):
@@ -706,8 +708,8 @@
for revid in todo:
pb.update("pushing revisions", todo.index(revid),
len(todo))
- revid_map[revid] = push(target, source.repository, revid,
- push_metadata=False)
+ revid_map[revid] = push(graph, target, source.repository,
+ revid, push_metadata=False)
source.repository.fetch(target.repository,
revision_id=revid_map[revid])
target._clear_cached_state()
@@ -718,8 +720,8 @@
source.unlock()
-def push_revision_tree(target, config, source_repo, base_revid, revision_id,
- rev, push_metadata=True):
+def push_revision_tree(graph, target, config, source_repo, base_revid,
+ revision_id, rev, push_metadata=True):
old_tree = source_repo.revision_tree(revision_id)
base_tree = source_repo.revision_tree(base_revid)
@@ -733,7 +735,8 @@
config, rev.timestamp,
rev.timezone, rev.committer, rev.properties,
revision_id, base_tree.inventory,
- push_metadata=push_metadata)
+ push_metadata=push_metadata,
+ graph=graph)
replay_delta(builder, base_tree, old_tree)
try:
@@ -751,7 +754,7 @@
return revid
-def push(target, source_repo, revision_id, push_metadata=True):
+def push(graph, target, source_repo, revision_id, push_metadata=True):
"""Push a revision into Subversion.
This will do a new commit in the target branch.
@@ -776,7 +779,7 @@
source_repo.lock_read()
try:
- revid = push_revision_tree(target, target.get_config(),
+ revid = push_revision_tree(graph, target, target.get_config(),
source_repo, base_revid, revision_id,
rev, push_metadata=push_metadata)
finally:
@@ -848,8 +851,8 @@
push_ancestors(self.target, self.source, layout, "", rev.parent_ids, graph)
target_config = target_branch.get_config()
- push_revision_tree(target_branch, target_config, self.source,
- parent_revid, revision_id, rev)
+ push_revision_tree(graph, target_branch, target_config,
+ self.source, parent_revid, revision_id, rev)
finally:
self.source.unlock()
=== modified file 'mapping.py'
--- a/mapping.py 2008-08-24 16:47:02 +0000
+++ b/mapping.py 2008-08-25 00:05:15 +0000
@@ -33,6 +33,7 @@
SVN_PROP_BZR_REVISION_INFO = 'bzr:revision-info'
SVN_PROP_BZR_REVISION_ID = 'bzr:revision-id:v%d-' % MAPPING_VERSION
SVN_PROP_BZR_TEXT_PARENTS = 'bzr:text-parents'
+SVN_PROP_BZR_LOG = 'bzr:log'
SVN_REVPROP_BZR_COMMITTER = 'bzr:committer'
SVN_REVPROP_BZR_FILEIDS = 'bzr:file-ids'
@@ -483,6 +484,8 @@
def import_revision(self, svn_revprops, fileprops, uuid, branch, revnum, rev):
parse_svn_revprops(svn_revprops, rev)
+ if SVN_PROP_BZR_LOG in fileprops:
+ rev.message = fileprops[SVN_PROP_BZR_LOG]
metadata = fileprops.get(SVN_PROP_BZR_REVISION_INFO)
if metadata is not None:
parse_revision_metadata(metadata, rev)
@@ -547,6 +550,9 @@
return ({}, fileprops)
+ def export_message(self, can_use_custom_revprops, message, revprops, fileprops):
+ fileprops[SVN_PROP_BZR_LOG] = message.encode("utf-8")
+
def is_bzr_revision(self, revprops, fileprops):
return fileprops.has_key(SVN_PROP_BZR_REVISION_ID+str(self.scheme))
=== modified file 'mapping3/__init__.py'
--- a/mapping3/__init__.py 2008-08-24 16:44:14 +0000
+++ b/mapping3/__init__.py 2008-08-25 00:05:15 +0000
@@ -353,7 +353,9 @@
self.revprop_map.export_fileid_map(can_use_custom_revprops, fileids, revprops, fileprops)
def export_message(self, can_use_custom_revprops, log, revprops, fileprops):
- self.revprop_map.export_message(can_use_custom_revprops, log, revprops, fileprops)
+ mapping.BzrSvnMappingFileProps.export_message(self, can_use_custom_revprops, log, revprops, fileprops)
+ if can_use_custom_revprops:
+ self.revprop_map.export_message(can_use_custom_revprops, log, revprops, fileprops)
class BzrSvnMappingv3RevProps(mapping.BzrSvnMappingRevProps, BzrSvnMappingv3):
=== modified file 'tests/test_push.py'
--- a/tests/test_push.py 2008-08-23 15:14:26 +0000
+++ b/tests/test_push.py 2008-08-25 00:05:15 +0000
@@ -434,12 +434,14 @@
self.build_tree({'mybranch/foo': 'bladata'})
wt = self.bzrdir.open_workingtree()
revid = wt.commit(message="Commit from Bzr")
- push(Branch.open("%s/trunk" % self.repos_url), wt.branch.repository,
+ b = Branch.open("%s/trunk" % self.repos_url)
+ push(b.repository.get_graph(), b, wt.branch.repository,
wt.branch.revision_history()[-2])
mutter('log %r' % self.client_log("%s/trunk" % self.repos_url, 0, 4)[4][0])
self.assertEquals('M',
self.client_log("%s/trunk" % self.repos_url, 0, 4)[4][0]['/trunk'][0])
- push(Branch.open("%s/trunk" % self.repos_url), wt.branch.repository, wt.branch.last_revision())
+ b = Branch.open("%s/trunk" % self.repos_url)
+ push(b.repository.get_graph(), b, wt.branch.repository, wt.branch.last_revision())
mutter('log %r' % self.client_log("%s/trunk" % self.repos_url, 0, 5)[5][0])
self.assertEquals("/branches/mybranch",
self.client_log("%s/trunk" % self.repos_url, 0, 5)[5][0]['/trunk'][1])
More information about the bazaar-commits
mailing list