Rev 442: Reduce the number of properties used. in file:///home/jelmer/bzr-svn/customrevids/

Jelmer Vernooij jelmer at samba.org
Fri May 18 16:11:31 BST 2007


At file:///home/jelmer/bzr-svn/customrevids/

------------------------------------------------------------
revno: 442
revision-id: jelmer at samba.org-20070518151130-cy22ujf5331vk8wr
parent: jelmer at samba.org-20070518124612-sisoj3464r5wteu1
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: customrevids
timestamp: Fri 2007-05-18 16:11:30 +0100
message:
  Reduce the number of properties used.
modified:
  checkout.py                    workingtree.py-20060306120941-b083cb0fdd4a69de
  commit.py                      commit.py-20060607190346-qvq128wgfubhhgm2-1
  errors.py                      errors.py-20061226172623-w1sbj8ynpo0eojqp-1
  fetch.py                       fetch.py-20060625004942-x2lfaib8ra707a8p-1
  fileids.py                     fileids.py-20060714013623-u5iiyqqnko11grcf-1
  mapping.txt                    mapping.txt-20060625151311-9ghaqrm71ajq593n-1
  repository.py                  repository.py-20060306123302-1f8c5069b3fe0265
  tests/test_branch.py           test_branch.py-20060508162215-74ffeb5d608f8e20
  tests/test_commit.py           test_commit.py-20060624213521-l5kcufywkh9mnilk-1
  tests/test_fileids.py          test_fileids.py-20060622131341-19gyrlgqy8yl2od5-1
  tests/test_push.py             test_push.py-20070201165715-g2ievcdfqi33wqsy-1
  tests/test_repos.py            test_repos.py-20060508151940-ddc49a59257ca712
  tree.py                        tree.py-20060624222557-dudlwqcmkf22lt2s-1
=== modified file 'checkout.py'
--- a/checkout.py	2007-05-18 11:06:06 +0000
+++ b/checkout.py	2007-05-18 15:11:30 +0000
@@ -31,6 +31,7 @@
 
 from branch import SvnBranch
 from convert import SvnConverter
+from errors import LocalCommitsUnsupported
 from repository import (SvnRepository, SVN_PROP_BZR_MERGE,
                         SVN_PROP_SVK_MERGE, SVN_PROP_BZR_FILEIDS, 
                         SVN_PROP_BZR_REVISION_ID,
@@ -405,10 +406,11 @@
         # FIXME: Use verbose
         # FIXME: Use reporter
         # FIXME: Use revprops
-        # FIXME: Raise exception when local is True
-        # FIXME: Use strct
+        # FIXME: Use strict
         assert timestamp is None
         assert timezone is None
+        if local:
+            raise LocalCommitsUnsupported()
 
         if specific_files:
             specific_files = [self.abspath(x).encode('utf8') for x in specific_files]

=== modified file 'commit.py'
--- a/commit.py	2007-05-18 12:22:57 +0000
+++ b/commit.py	2007-05-18 15:11:30 +0000
@@ -26,8 +26,9 @@
 from bzrlib.trace import mutter
 
 from repository import (SVN_PROP_BZR_MERGE, SVN_PROP_BZR_FILEIDS,
-                        SVN_PROP_SVK_MERGE, SVN_PROP_BZR_REVPROP_PREFIX, 
-                        SVN_PROP_BZR_REVISION_ID, revision_id_to_svk_feature)
+                        SVN_PROP_SVK_MERGE, SVN_PROP_BZR_REVISION_INFO, 
+                        SVN_PROP_BZR_REVISION_ID, revision_id_to_svk_feature,
+                        generate_revision_metadata)
 from revids import escape_svn_path
 
 import os
@@ -35,25 +36,27 @@
 class SvnCommitBuilder(RootCommitBuilder):
     """Commit Builder implementation wrapped around svn_delta_editor. """
 
-    def __init__(self, repository, branch, parents, config, revprops, 
-                 revision_id, old_inv=None):
+    def __init__(self, repository, branch, parents, config, timestamp, 
+                 timezone, committer, revprops, revision_id, old_inv=None):
         """Instantiate a new SvnCommitBuilder.
 
         :param repository: SvnRepository to commit to.
         :param branch: SvnBranch to commit to.
         :param parents: List of parent revision ids.
         :param config: Branch configuration to use.
+        :param timestamp: Optional timestamp recorded for commit.
+        :param timezone: Optional timezone for timestamp.
+        :param committer: Optional committer to set for commit.
         :param revprops: Revision properties to set.
         :param revision_id: Revision id for the new revision.
         """
         super(SvnCommitBuilder, self).__init__(repository, parents, 
-            config, None, None, None, revprops, None)
+            config, timestamp, timezone, committer, revprops, revision_id)
         self.branch = branch
         self.pool = Pool()
 
         self._svnprops = {}
-        for prop in self._revprops:
-            self._svnprops[SVN_PROP_BZR_REVPROP_PREFIX+prop] = self._revprops[prop]
+        self._svnprops[SVN_PROP_BZR_REVISION_INFO] = generate_revision_metadata(timestamp, timezone, committer, revprops)
 
         self.merges = filter(lambda x: x != self.branch.last_revision(),
                              parents)

=== modified file 'errors.py'
--- a/errors.py	2007-05-17 16:52:31 +0000
+++ b/errors.py	2007-05-18 15:11:30 +0000
@@ -58,3 +58,8 @@
 class NoCheckoutSupport(BzrError):
 
     _fmt = 'Subversion version too old for working tree support.'
+
+
+class LocalCommitsUnsupported(BzrError):
+
+    _fmt = 'Local commits are not supported for lightweight Subversion checkouts.'

=== modified file 'fetch.py'
--- a/fetch.py	2007-05-18 12:46:12 +0000
+++ b/fetch.py	2007-05-18 15:11:30 +0000
@@ -33,7 +33,7 @@
 
 from fileids import generate_file_id
 from repository import (SvnRepository, SVN_PROP_BZR_MERGE, SVN_PROP_SVK_MERGE,
-                SVN_PROP_BZR_PREFIX, SVN_PROP_BZR_REVPROP_PREFIX, 
+                SVN_PROP_BZR_PREFIX, SVN_PROP_BZR_REVISION_INFO, 
                 SvnRepositoryFormat)
 from tree import apply_txdelta_handler
 
@@ -61,7 +61,7 @@
         self.weave_store = target.weave_store
         self.dir_baserev = {}
         self._parent_ids = None
-        self._revprops = {}
+        self._revinfo = None
         self._svn_revprops = svn_revprops
         self.pool = Pool()
 
@@ -90,7 +90,9 @@
             rev.committer = ""
         rev.message = self._svn_revprops[1] # message
 
-        rev.properties = self._revprops
+        if self._revinfo:
+            parse_revision_metadata(rev, self._revinfo)
+
         return rev
 
     def open_root(self, base_revnum, baton):
@@ -183,8 +185,12 @@
                 # Only set parents using svk:merge if no 
                 # bzr:merge set.
                 pass # FIXME 
-        elif name.startswith(SVN_PROP_BZR_REVPROP_PREFIX):
-            self._revprops[name[len(SVN_PROP_BZR_REVPROP_PREFIX):]] = value
+        elif name == SVN_PROP_BZR_REVISION_INFO:
+            if id != self.inventory.root.file_id:
+                mutter('rogue %r on non-root directory' % SVN_PROP_BZR_REVISION_INFO)
+                return
+ 
+            self._revinfo = value
         elif name in (svn.core.SVN_PROP_ENTRY_COMMITTED_DATE,
                       svn.core.SVN_PROP_ENTRY_COMMITTED_REV,
                       svn.core.SVN_PROP_ENTRY_LAST_AUTHOR,

=== modified file 'fileids.py'
--- a/fileids.py	2007-05-18 12:46:12 +0000
+++ b/fileids.py	2007-05-18 15:11:30 +0000
@@ -171,7 +171,8 @@
             i = 1
             for (revid, global_changes) in todo:
                 changes = get_local_changes(global_changes, self.repos.scheme,
-                                            uuid, self.repos._log.find_children)
+                                            self.repos.generate_revision_id, 
+                                            self.repos._log.find_children)
                 pb.update('generating file id map', i, len(todo))
 
                 def find_children(path, revid):

=== modified file 'mapping.txt'
--- a/mapping.txt	2007-05-17 19:04:30 +0000
+++ b/mapping.txt	2007-05-18 15:11:30 +0000
@@ -188,8 +188,9 @@
 Revision properties
 ===================
 
-Bazaar revision properties are stored in the file properties of the 
-branch path in Subversion. Their names are prefixed with "bzr:revprop:"
+Bazaar revision metadata is stored in a Subversion revision property 
+``bzr:revision-info``. The format of this property is the same as used 
+by version 0.9 of the bundle format.
 
 ==========
 Signatures

=== modified file 'repository.py'
--- a/repository.py	2007-05-18 12:22:57 +0000
+++ b/repository.py	2007-05-18 15:11:30 +0000
@@ -19,7 +19,7 @@
 from bzrlib.branch import BranchCheckResult
 from bzrlib.config import config_dir, ensure_config_dir_exists
 from bzrlib.errors import (InvalidRevisionId, NoSuchRevision, 
-                           NotBranchError, UninitializableFormat)
+                           NotBranchError, UninitializableFormat, BzrError)
 from bzrlib.inventory import Inventory
 from bzrlib.lockable_files import LockableFiles, TransportLock
 import bzrlib.osutils as osutils
@@ -27,6 +27,7 @@
 from bzrlib.revisiontree import RevisionTree
 from bzrlib.revision import Revision, NULL_REVISION
 from bzrlib.transport import Transport
+from bzrlib.timestamp import unpack_highres_date, format_highres_date
 from bzrlib.trace import mutter
 
 from svn.core import SubversionException, Pool
@@ -50,10 +51,40 @@
 SVN_PROP_BZR_FILEIDS = 'bzr:file-ids'
 SVN_PROP_SVK_MERGE = 'svk:merge'
 SVN_PROP_BZR_FILEIDS = 'bzr:file-ids'
-SVN_PROP_BZR_REVPROP_PREFIX = 'bzr:revprop:'
+SVN_PROP_BZR_REVISION_INFO = 'bzr:revision-info'
 SVN_REVPROP_BZR_SIGNATURE = 'bzr:gpg-signature'
 SVN_PROP_BZR_REVISION_ID = 'bzr:revision-id-v%d' % MAPPING_VERSION
 
+def parse_revision_metadata(text, rev):
+    in_properties = False
+    for l in text.splitlines():
+        try:
+            key, value = l.split(": ", 2)
+        except ValueError:
+            raise BzrError("Missing : in revision metadata")
+        if key == "committer":
+            rev.committer = value
+        elif key == "timestamp":
+            (rev.timestamp, rev.timezone) = unpack_highres_date(value)
+        elif key == "properties":
+            in_properties = True
+        elif key[0] == "\t" and in_properties:
+            rev.properties[key[1:]] = value
+        else:
+            raise BzrError("Invalid key %r" % key)
+
+def generate_revision_metadata(timestamp, timezone, committer, revprops):
+    text = ""
+    if timestamp is not None:
+        text += "timestamp: %s\n" % format_highres_date(timestamp, timezone) 
+    if committer is not None:
+        text += "committer: %s\n" % committer
+    if revprops is not None and revprops != {}:
+        text += "properties: \n"
+        for k, v in revprops.items():
+            text += "\t%s: %s\n" % (k, v)
+    return text
+
 def svk_feature_to_revision_id(feature):
     """Create a revision id from a svk feature identifier.
 
@@ -330,14 +361,6 @@
         # Commit SVN revision properties to a Revision object
         rev = Revision(revision_id=revision_id, parent_ids=parent_ids)
 
-        svn_props = self.branchprop_list.get_properties(path, revnum)
-        bzr_props = {}
-        for name in svn_props:
-            if not name.startswith(SVN_PROP_BZR_REVPROP_PREFIX):
-                continue
-
-            bzr_props[name[len(SVN_PROP_BZR_REVPROP_PREFIX):]] = svn_props[name]
-
         (rev.committer, rev.message, date) = self._log.get_revision_info(revnum)
         if rev.committer is None:
             rev.committer = ""
@@ -347,7 +370,11 @@
         else:
             rev.timestamp = 0.0 # FIXME: Obtain repository creation time
         rev.timezone = None
-        rev.properties = bzr_props
+        rev.properties = {}
+        parse_revision_metadata(
+                self.branchprop_list.get_property(path, revnum, 
+                     SVN_PROP_BZR_REVISION_INFO, ""), rev)
+
         rev.inventory_sha1 = property(lambda: self.get_inventory_sha1(revision_id))
 
         return rev
@@ -694,20 +721,8 @@
     def get_commit_builder(self, branch, parents, config, timestamp=None, 
                            timezone=None, committer=None, revprops=None, 
                            revision_id=None):
-        if timestamp != None:
-            raise NotImplementedError(self.get_commit_builder, 
-                "timestamp can not be user-specified for Subversion repositories")
-
-        if timezone != None:
-            raise NotImplementedError(self.get_commit_builder, 
-                "timezone can not be user-specified for Subversion repositories")
-
-        if committer != None:
-            raise NotImplementedError(self.get_commit_builder, 
-                "committer can not be user-specified for Subversion repositories")
-
         from commit import SvnCommitBuilder
-        return SvnCommitBuilder(self, branch, parents, config, revprops,
-                                revision_id)
+        return SvnCommitBuilder(self, branch, parents, config, timestamp, 
+                timezone, committer, revprops, revision_id)
 
 

=== modified file 'tests/test_branch.py'
--- a/tests/test_branch.py	2007-05-18 02:01:15 +0000
+++ b/tests/test_branch.py	2007-05-18 15:11:30 +0000
@@ -192,7 +192,8 @@
 
         self.build_tree({'dc/foo': "data"})
         self.client_add("dc/foo")
-        self.client_set_prop("dc", "bzr:revprop:branch-nick", "mybranch")
+        self.client_set_prop("dc", "bzr:revision-info", 
+                "properties: \n\tbranch-nick: mybranch\n")
         self.client_commit("dc", "My Message")
 
         branch = Branch.open("svn+"+repos_url)

=== modified file 'tests/test_commit.py'
--- a/tests/test_commit.py	2007-05-18 12:46:12 +0000
+++ b/tests/test_commit.py	2007-05-18 15:11:30 +0000
@@ -18,7 +18,7 @@
 
 from bzrlib.branch import Branch, PullResult
 from bzrlib.bzrdir import BzrDir
-from bzrlib.errors import DivergedBranches
+from bzrlib.errors import DivergedBranches, BzrError
 from bzrlib.workingtree import WorkingTree
 
 from copy import copy
@@ -71,6 +71,14 @@
                             wt.branch.last_revision())
         self.assertEqual(wt.branch.last_revision(), new_revision.revision_id)
 
+    def test_commit_local(self):
+        self.make_client('d', 'dc')
+        self.build_tree({'dc/foo/bla': "data"})
+        self.client_add("dc/foo")
+        wt = self.open_checkout("dc")
+        self.assertRaises(BzrError, wt.commit, 
+                message="data", local=True)
+
     def test_commit_message_nordic(self):
         self.make_client('d', 'dc')
         self.build_tree({'dc/foo/bla': "data"})
@@ -117,17 +125,47 @@
         wt.commit(message="data")
 
         branch = Branch.open(repos_url)
-        builder = branch.get_commit_builder([branch.last_revision()], revision_id="my-revision-id")
-        tree = branch.repository.revision_tree(branch.last_revision())
-        new_tree = copy(tree)
-        ie = new_tree.inventory.root
-        ie.revision = None
-        builder.record_entry_contents(ie, [tree.inventory], '', new_tree)
-        builder.finish_inventory()
-        builder.commit("foo")
-
-        self.assertEqual("my-revision-id\n", 
-                self.client_get_prop("dc", "bzr:revision-id-v%d" % MAPPING_VERSION, 2))
+        builder = branch.get_commit_builder([branch.last_revision()], 
+                revision_id="my-revision-id")
+        tree = branch.repository.revision_tree(branch.last_revision())
+        new_tree = copy(tree)
+        ie = new_tree.inventory.root
+        ie.revision = None
+        builder.record_entry_contents(ie, [tree.inventory], '', new_tree)
+        builder.finish_inventory()
+        builder.commit("foo")
+
+        self.assertEqual("my-revision-id\n", 
+                self.client_get_prop("dc", "bzr:revision-id-v%d" % MAPPING_VERSION, 2))
+
+    def test_commit_metadata(self):
+        repos_url = self.make_client('d', 'dc')
+        wt = self.open_checkout("dc")
+        self.build_tree({'dc/foo/bla': "data", 'dc/bla': "otherdata"})
+        wt.add('bla')
+        wt.commit(message="data")
+
+        branch = Branch.open(repos_url)
+        builder = branch.get_commit_builder([branch.last_revision()], 
+                timestamp=4534, timezone=2, committer="fry",
+                revision_id="my-revision-id")
+        tree = branch.repository.revision_tree(branch.last_revision())
+        new_tree = copy(tree)
+        ie = new_tree.inventory.root
+        ie.revision = None
+        builder.record_entry_contents(ie, [tree.inventory], '', new_tree)
+        builder.finish_inventory()
+        builder.commit("foo")
+
+        self.assertEqual("my-revision-id\n", 
+                self.client_get_prop("dc", "bzr:revision-id-v%d" % MAPPING_VERSION, 2))
+
+        self.assertEqual("fry", 
+                self.client_get_prop("dc", "bzr:committer", 2))
+
+        self.assertEqual("4534T2", 
+                self.client_get_prop("dc", "bzr:timestamp", 2))
+
 
     def test_mwh(self):
         repo = self.make_client('d', 'sc')

=== modified file 'tests/test_fileids.py'
--- a/tests/test_fileids.py	2007-05-17 16:52:31 +0000
+++ b/tests/test_fileids.py	2007-05-18 15:11:30 +0000
@@ -25,9 +25,17 @@
 
 from fileids import SimpleFileIdMap, generate_file_id, generate_svn_file_id
 from repository import generate_svn_revision_id
+from revids import parse_svn_revision_id
 from scheme import TrunkBranchingScheme
 from tests import TestCaseWithSubversionRepository, RENAMES
 
+class MockRepo:
+    uuid = "uuid"
+    def lookup_revision_id(self, revid):
+        ret = parse_svn_revision_id(revid)
+        return ret[1], ret[2]
+
+
 class TestComplexFileids(TestCaseWithSubversionRepository):
     # branchtagcopy.dump
     # changeaftercp.dump
@@ -151,25 +159,29 @@
     return sha.new(text).hexdigest()
 
 class TestFileIdGenerator(TestCase):
+    def setUp(self):
+        super(TestCase, self).setUp()
+        self.repos = MockRepo()
+
     def test_generate_file_id_root(self):
-        self.assertEqual("2 at uuid:bp:", generate_file_id(generate_svn_revision_id("uuid", 2, "bp"), ""))
+        self.assertEqual("2 at uuid:bp:", generate_file_id(self.repos, generate_svn_revision_id("uuid", 2, "bp"), ""))
 
     def test_generate_file_id_path(self):
         self.assertEqual("2 at uuid:bp:mypath", 
-                generate_file_id(generate_svn_revision_id("uuid", 2, "bp"), "mypath"))
+                generate_file_id(self.repos, generate_svn_revision_id("uuid", 2, "bp"), "mypath"))
 
     def test_generate_file_id_long(self):
         dir = "this/is/a" + ("/very"*40) + "/long/path/"
         self.assertEqual("2 at uuid:bp;" + sha1(dir+"filename"), 
-                generate_file_id(generate_svn_revision_id("uuid", 2, "bp"), dir+"filename"))
+                generate_file_id(self.repos, generate_svn_revision_id("uuid", 2, "bp"), dir+"filename"))
 
     def test_generate_revid_special_char_ascii(self):
         self.assertEqual("2 at uuid:bp:mypath%2C%8A", 
-                generate_file_id(generate_svn_revision_id("uuid", 2, "bp"), "mypath\x2c\x8a"))
+                generate_file_id(self.repos, generate_svn_revision_id("uuid", 2, "bp"), "mypath\x2c\x8a"))
 
     def test_generate_file_id_special_char(self):
         self.assertEqual("2 at uuid:bp:mypath%2C%C2%8A",
-                         generate_file_id(generate_svn_revision_id("uuid", 2, "bp"), u"mypath\x2c\x8a"))
+                         generate_file_id(self.repos, generate_svn_revision_id("uuid", 2, "bp"), u"mypath\x2c\x8a"))
 
     def test_generate_svn_file_id(self):
         self.assertEqual("2 at uuid:bp:path", 
@@ -193,7 +205,7 @@
             def new_file_id(x):
                 if renames.has_key(r) and renames[r].has_key(x):
                     return renames[r][x]
-                return generate_file_id(r, x)
+                return generate_file_id(MockRepo(), r, x)
             revmap = SimpleFileIdMap._apply_changes(new_file_id, mappings[r], find_children)
             map.update(dict([(x, (revmap[x],r)) for x in revmap]))
         return map

=== modified file 'tests/test_push.py'
--- a/tests/test_push.py	2007-05-18 12:46:12 +0000
+++ b/tests/test_push.py	2007-05-18 15:11:30 +0000
@@ -156,6 +156,19 @@
         self.assertEqual("some-rid\n", 
                 self.client_get_prop("sc", SVN_PROP_BZR_REVISION_ID))
 
+    def test_commit_check_rev_equal(self):
+        self.build_tree({'dc/file': 'data'})
+        wt = self.bzrdir.open_workingtree()
+        wt.add('file')
+        wt.commit(message="Commit from Bzr")
+
+        self.svndir.open_branch().pull(self.bzrdir.open_branch())
+
+        rev1 = self.svndir.find_repository().get_revision(wt.branch.last_revision())
+        rev2 = self.bzrdir.find_repository().get_revision(wt.branch.last_revision())
+
+        self.assertEqual(rev1, rev2)
+
     def test_multiple_merged(self):
         self.build_tree({'dc/file': 'data'})
         wt = self.bzrdir.open_workingtree()

=== modified file 'tests/test_repos.py'
--- a/tests/test_repos.py	2007-05-18 12:22:57 +0000
+++ b/tests/test_repos.py	2007-05-18 15:11:30 +0000
@@ -21,7 +21,7 @@
 from bzrlib.errors import NoSuchRevision, UninitializableFormat
 from bzrlib.inventory import Inventory
 from bzrlib.repository import Repository
-from bzrlib.revision import NULL_REVISION
+from bzrlib.revision import NULL_REVISION, Revision
 from bzrlib.tests import TestCase
 
 import os
@@ -35,7 +35,8 @@
 from transport import SvnRaTransport
 from tests import TestCaseWithSubversionRepository
 from repository import (svk_feature_to_revision_id, revision_id_to_svk_feature,
-                        SvnRepositoryFormat, SVN_PROP_BZR_REVISION_ID)
+                        SvnRepositoryFormat, SVN_PROP_BZR_REVISION_ID,
+                        generate_revision_metadata, parse_revision_metadata)
 from revids import (MAPPING_VERSION, escape_svn_path, unescape_svn_path,
                     parse_svn_revision_id, generate_svn_revision_id)
 
@@ -2232,7 +2233,8 @@
                 self.repos.generate_revision_id(2, ""))
 
         self.assertEqual('symlink', inventory[inventory.path2id("bar")].kind)
-        self.assertEqual('foo/bla', inventory[inventory.path2id("bar")].symlink_target)
+        self.assertEqual('foo/bla', 
+                inventory[inventory.path2id("bar")].symlink_target)
 
     def test_not_executable(self):
         self.assertFalse(self.inventory[
@@ -2281,3 +2283,53 @@
     def test_get_format_description(self):
         self.assertEqual("Subversion Repository", 
                          self.format.get_format_description())
+
+class MetadataMarshallerTests(TestCase):
+    def test_generate_revision_metadata_none(self):
+        self.assertEquals("", 
+                generate_revision_metadata(None, None, None, None))
+
+    def test_generate_revision_metadata_committer(self):
+        self.assertEquals("committer: bla\n", 
+                generate_revision_metadata(None, None, "bla", None))
+
+    def test_generate_revision_metadata_timestamp(self):
+        self.assertEquals("timestamp: Thu 2005-06-30 17:38:52 +0000\n", 
+                generate_revision_metadata('1120153132.350850105', 0, 
+                    None, None))
+            
+    def test_generate_revision_metadata_properties(self):
+        self.assertEquals("properties:\n" + 
+                "\tpropfoo: bla\n" + 
+                "\tpropbla: bloe\n",
+                generate_revision_metadata(None, None,
+                    None, {"propfoo": "bla", "propbla": "bloe"}))
+
+    def test_parse_revision_metadata_empty(self):
+        parse_revision_metadata("", None)
+
+    def test_parse_revision_metadata_committer(self):
+        rev = Revision()
+        parse_revision_metadata("committer: somebody\n", rev)
+        self.assertEquals("somebody", rev.committer)
+
+    def test_parse_revision_metadata_timestamp(self):
+        rev = Revision()
+        parse_revision_metadata("timestamp: Thu 2005-06-30 12:38:52.350850105 -0500\n", rev)
+        self.assertEquals(1120153132.3508501, rev.timestamp)
+        self.assertEquals(-18000, rev.timezone)
+
+    def test_parse_revision_metadata_properties(self):
+        rev = Revision()
+        parse_revision_metadata("properties: \n" + 
+                                "\tfoo: bar\n" + 
+                                "\tha: ha\n", rev)
+        self.assertEquals({"foo": "bar", "ha": "ha"}, rev.revprops)
+
+    def test_parse_revision_metadata_no_colon(self):
+        rev = Revision()
+        self.assertRaises(BzrError, lambda: parse_revision_metadata("bla", rev))
+
+    def test_parse_revision_metadata_invalid_name(self):
+        rev = Revision()
+        self.assertRaises(BzrError, lambda: parse_revision_metadata("bla: b", rev))

=== modified file 'tree.py'
--- a/tree.py	2007-05-18 12:22:57 +0000
+++ b/tree.py	2007-05-18 15:11:30 +0000
@@ -97,7 +97,7 @@
 
     def change_dir_prop(self, id, name, value, pool):
         from repository import (SVN_PROP_BZR_MERGE, SVN_PROP_SVK_MERGE, 
-                        SVN_PROP_BZR_PREFIX, SVN_PROP_BZR_REVPROP_PREFIX, 
+                        SVN_PROP_BZR_PREFIX, SVN_PROP_BZR_REVISION_INFO, 
                         SVN_PROP_BZR_FILEIDS, SVN_PROP_BZR_REVISION_ID)
 
         if name == svn.core.SVN_PROP_ENTRY_COMMITTED_REV:
@@ -120,9 +120,7 @@
             pass
         elif name.startswith(svn.core.SVN_PROP_WC_PREFIX):
             pass
-        elif name.startswith(SVN_PROP_BZR_REVPROP_PREFIX):
-            pass
-        elif name == SVN_PROP_BZR_REVISION_ID:
+        elif name in (SVN_PROP_BZR_REVISION_ID, SVN_PROP_BZR_REVISION_INFO):
             pass
         elif (name.startswith(svn.core.SVN_PROP_PREFIX) or
               name.startswith(SVN_PROP_BZR_PREFIX)):




More information about the bazaar-commits mailing list