Rev 606: Fix two more tests, simplify file id setting. in file:///data/jelmer/bzr-svn/revprops/
Jelmer Vernooij
jelmer at samba.org
Sat Dec 15 15:21:31 GMT 2007
At file:///data/jelmer/bzr-svn/revprops/
------------------------------------------------------------
revno: 606
revision-id:jelmer at samba.org-20071215152130-rwm2qf4r2z1pz8w9
parent: jelmer at samba.org-20071214234314-3ldj3arfomn51xeu
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: revprops
timestamp: Sat 2007-12-15 16:21:30 +0100
message:
Fix two more tests, simplify file id setting.
modified:
BRANCH.TODO branch.todo-20070721175243-w23kkak0gm2jbr8b-1
commit.py commit.py-20060607190346-qvq128wgfubhhgm2-1
repository.py repository.py-20060306123302-1f8c5069b3fe0265
=== modified file 'BRANCH.TODO'
--- a/BRANCH.TODO 2007-12-14 23:43:14 +0000
+++ b/BRANCH.TODO 2007-12-15 15:21:30 +0000
@@ -17,6 +17,4 @@
Needs more tests...:
- *
-
Make sure that bzr revprops set as bzr:* in svn properties don't get converted to svn:bzr: in bzr revprops.
=== modified file 'commit.py'
--- a/commit.py 2007-12-14 23:43:14 +0000
+++ b/commit.py 2007-12-15 15:21:30 +0000
@@ -104,16 +104,16 @@
timestamp, timezone, committer, revprops)
self._svnprops[SVN_PROP_BZR_FILEIDS] = ""
- self._svn_revprops = {
- SVN_REVPROP_BZR_FILEIDS: "",
- SVN_REVPROP_BZR_TIMESTAMP: str(timestamp),
- SVN_REVPROP_BZR_TIMEZONE: str(timezone),
- }
+ self._svn_revprops = {}
+
+ if timestamp is not None:
+ self._svn_revprops[SVN_REVPROP_BZR_TIMESTAMP] = str(timestamp)
+
+ if timezone is not None:
+ self._svn_revprops[SVN_REVPROP_BZR_TIMEZONE] = str(timezone)
if committer is not None:
self._svn_revprops[SVN_REVPROP_BZR_COMMITTER] = committer.encode("utf-8")
- else:
- self._svn_revprops[SVN_REVPROP_BZR_COMMITTER] = None
if revprops is not None:
for name, value in revprops.items():
@@ -288,7 +288,6 @@
# add them if they didn't exist in old_inv
if not child_ie.file_id in self.old_inv:
self.mutter('adding %s %r' % (child_ie.kind, new_child_path))
- self._record_file_id(child_ie, new_child_path)
child_baton = self.editor.add_file(
urlutils.join(self.branch.get_branch_path(),
new_child_path), baton, None, -1, self.pool)
@@ -300,7 +299,6 @@
self.mutter('copy %s %r -> %r' % (child_ie.kind,
self.old_inv.id2path(child_ie.file_id),
new_child_path))
- self._record_file_id(child_ie, new_child_path)
child_baton = self.editor.add_file(
urlutils.join(self.branch.get_branch_path(), new_child_path), baton,
urlutils.join(self.repository.transport.svn_url, self.base_path, self.old_inv.id2path(child_ie.file_id)),
@@ -363,7 +361,6 @@
# add them if they didn't exist in old_inv
if not child_ie.file_id in self.old_inv:
self.mutter('adding dir %r' % child_ie.name)
- self._record_file_id(child_ie, new_child_path)
child_baton = self.editor.add_directory(
urlutils.join(self.branch.get_branch_path(),
new_child_path), baton, None, -1, self.pool)
@@ -372,7 +369,6 @@
elif self.old_inv.id2path(child_ie.file_id) != new_child_path:
old_child_path = self.old_inv.id2path(child_ie.file_id)
self.mutter('copy dir %r -> %r' % (old_child_path, new_child_path))
- self._record_file_id(child_ie, new_child_path)
child_baton = self.editor.add_directory(
urlutils.join(self.branch.get_branch_path(), new_child_path),
baton,
@@ -461,10 +457,6 @@
"""
self.revision_metadata = revision_data
- # No point storing an empty revision property
- if self._svn_revprops[SVN_REVPROP_BZR_FILEIDS] == "":
- del self._svn_revprops[SVN_REVPROP_BZR_FILEIDS]
-
self._svn_revprops[SVN_REVPROP_BZR_ROOT] = self.branch.get_branch_path()
bp_parts = self.branch.get_branch_path().split("/")
repository_latest_revnum = self.repository.transport.get_latest_revnum()
@@ -472,6 +464,35 @@
set_revprops = self.repository.get_config().get_set_revprops()
remaining_revprops = self._svn_revprops # Keep track of the revprops that haven't been set yet
+ # Store file ids
+ def _dir_process_file_id(old_inv, new_inv, path, file_id):
+ for child_name in new_inv[file_id].children:
+ child_ie = new_inv.get_child(file_id, child_name)
+ new_child_path = new_inv.id2path(child_ie.file_id)
+ assert child_ie is not None
+
+ if (not child_ie.file_id in old_inv or
+ old_inv.id2path(child_ie.file_id) != new_child_path or
+ old_inv[child_ie.file_id].parent_id != child_ie.parent_id):
+ yield (child_ie.file_id, new_child_path)
+
+ if (child_ie.kind == 'directory' and
+ child_ie.file_id in self.modified_dirs):
+ _dir_process_file_id(old_inv, new_inv, new_child_path, child_ie.file_id)
+
+ fileids = []
+
+ if (self.old_inv.root is None or
+ self.new_inventory.root.file_id != self.old_inv.root.file_id):
+ fileids.append((self.new_inventory.root.file_id, ""))
+
+ fileids += list(_dir_process_file_id(self.old_inv, self.new_inventory, "", self.new_inventory.root.file_id))
+
+ if fileids != []:
+ file_id_text = "".join(["%s\t%s\n" % (urllib.quote(path), file_id) for (path, file_id) in fileids])
+ self._svn_revprops[SVN_REVPROP_BZR_FILEIDS] = file_id_text
+ self._svnprops[SVN_PROP_BZR_FILEIDS] = file_id_text
+
try:
existing_bp_parts = _check_dirs_exist(self.repository.transport,
bp_parts, -1)
@@ -506,11 +527,6 @@
existing_bp_parts, self.base_path, self.base_revnum,
replace_existing)
- # Make sure the root id is stored properly
- if (self.old_inv.root is None or
- self.new_inventory.root.file_id != self.old_inv.root.file_id):
- self._record_file_id(self.new_inventory.root, "")
-
self._dir_process("", self.new_inventory.root.file_id,
branch_batons[-1])
@@ -556,16 +572,6 @@
return revid
- def _record_file_id(self, ie, path):
- """Store the file id of an inventory entry in a file property.
-
- :param ie: Inventory entry.
- :param path: Path of the inventory entry.
- """
- file_id_entry = "%s\t%s\n" % (urllib.quote(path), ie.file_id)
- self._svnprops[SVN_PROP_BZR_FILEIDS] += file_id_entry
- self._svn_revprops[SVN_REVPROP_BZR_FILEIDS] += file_id_entry
-
def record_entry_contents(self, ie, parent_invs, path, tree,
content_summary):
"""Record the content of ie from tree into the commit if needed.
=== modified file 'repository.py'
--- a/repository.py 2007-12-06 17:53:20 +0000
+++ b/repository.py 2007-12-15 15:21:30 +0000
@@ -353,7 +353,7 @@
return ListBranchingScheme(parse_list_scheme_text(text))
def set_property_scheme(self, scheme):
- def done(revision, date, author):
+ def done(revmetadata, pool):
pass
editor = self.transport.get_commit_editor(
{svn.core.SVN_PROP_REVISION_LOG: "Updating branching scheme for Bazaar."},
More information about the bazaar-commits
mailing list