Rev 952: Merge 0.4. in file:///data/jelmer/bzr-svn/revisionloader/

Jelmer Vernooij jelmer at samba.org
Sat Mar 22 20:45:12 GMT 2008


At file:///data/jelmer/bzr-svn/revisionloader/

------------------------------------------------------------
revno: 952
revision-id: jelmer at samba.org-20080322204504-1hasbdfffn3p24rj
parent: jelmer at samba.org-20080322001921-n16l7gpbv0r3npam
parent: jelmer at samba.org-20080322195846-mjnodu9ga5dyza6p
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: revisionloader
timestamp: Sat 2008-03-22 21:45:04 +0100
message:
  Merge 0.4.
modified:
  NEWS                           news-20061231030336-h9fhq245ie0de8bs-1
  branch.py                      svnbranch.py-20051017135706-11c749eb0dab04a7
  branchprops.py                 branchprops.py-20061223204623-80lvm7pjrpsgk0dd-1
  commit.py                      commit.py-20060607190346-qvq128wgfubhhgm2-1
  fetch.py                       fetch.py-20060625004942-x2lfaib8ra707a8p-1
  fileids.py                     fileids.py-20060714013623-u5iiyqqnko11grcf-1
  logwalker.py                   logwalker.py-20060621215743-c13fhfnyzh1xzwh2-1
  mapping.py                     mapping.py-20080128201303-6cp01phc0dmc0kiv-1
  pre-revprop-change.example     prerevpropchange.exa-20071214160928-9g7oevg3tlky780a-1
  repository.py                  repository.py-20060306123302-1f8c5069b3fe0265
  svk.py                         svk.py-20080201171509-m2eg9m6jrmlbwxg5-1
  tests/__init__.py              __init__.py-20060508151940-e9f4d914801a2535
  tests/test_branch.py           test_branch.py-20060508162215-74ffeb5d608f8e20
  tests/test_branchprops.py      test_branchprops.py-20061223210444-04xf5224zcg69m3w-1
  tests/test_fetch.py            test_fetch.py-20070624210302-luvgwjmlfysk5qeq-1
  tests/test_repos.py            test_repos.py-20060508151940-ddc49a59257ca712
  workingtree.py                 workingtree.py-20060306120941-b083cb0fdd4a69de
    ------------------------------------------------------------
    revno: 948.1.41
    revision-id: jelmer at samba.org-20080322195846-mjnodu9ga5dyza6p
    parent: jelmer at samba.org-20080322190412-1m7e7b14a5iucx4u
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: 0.4
    timestamp: Sat 2008-03-22 20:58:46 +0100
    message:
      Avoid fetching revision properties once extra for fileid renames.
    modified:
      fetch.py                       fetch.py-20060625004942-x2lfaib8ra707a8p-1
      fileids.py                     fileids.py-20060714013623-u5iiyqqnko11grcf-1
      repository.py                  repository.py-20060306123302-1f8c5069b3fe0265
    ------------------------------------------------------------
    revno: 948.1.40
    revision-id: jelmer at samba.org-20080322190412-1m7e7b14a5iucx4u
    parent: jelmer at samba.org-20080322190110-agrawwv6d2iieidk
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: 0.4
    timestamp: Sat 2008-03-22 20:04:12 +0100
    message:
      use lazy_dict.
    modified:
      commit.py                      commit.py-20060607190346-qvq128wgfubhhgm2-1
    ------------------------------------------------------------
    revno: 948.1.39
    revision-id: jelmer at samba.org-20080322190110-agrawwv6d2iieidk
    parent: jelmer at samba.org-20080322185908-399qhpr8eox3hn6l
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: 0.4
    timestamp: Sat 2008-03-22 20:01:10 +0100
    message:
      Remove unused function touches_property.
    modified:
      branchprops.py                 branchprops.py-20061223204623-80lvm7pjrpsgk0dd-1
      tests/test_branchprops.py      test_branchprops.py-20061223210444-04xf5224zcg69m3w-1
    ------------------------------------------------------------
    revno: 948.1.38
    revision-id: jelmer at samba.org-20080322185908-399qhpr8eox3hn6l
    parent: jelmer at samba.org-20080322182458-ka9mfwl038gc7v5n
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: 0.4
    timestamp: Sat 2008-03-22 19:59:08 +0100
    message:
      Save some calls retrieving branch properties.
    modified:
      workingtree.py                 workingtree.py-20060306120941-b083cb0fdd4a69de
    ------------------------------------------------------------
    revno: 948.1.37
    revision-id: jelmer at samba.org-20080322182458-ka9mfwl038gc7v5n
    parent: jelmer at samba.org-20080322173832-zv5dd3vgt6w9azwj
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: 0.4
    timestamp: Sat 2008-03-22 19:24:58 +0100
    message:
      Fix test.
    modified:
      branch.py                      svnbranch.py-20051017135706-11c749eb0dab04a7
    ------------------------------------------------------------
    revno: 948.1.36
    revision-id: jelmer at samba.org-20080322173832-zv5dd3vgt6w9azwj
    parent: jelmer at samba.org-20080322171858-wlp8hv9u4nwcqb0t
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: 0.4
    timestamp: Sat 2008-03-22 18:38:32 +0100
    message:
      share some code between logwalker and the follow_branch code.
    modified:
      logwalker.py                   logwalker.py-20060621215743-c13fhfnyzh1xzwh2-1
      repository.py                  repository.py-20060306123302-1f8c5069b3fe0265
    ------------------------------------------------------------
    revno: 948.1.35
    revision-id: jelmer at samba.org-20080322171858-wlp8hv9u4nwcqb0t
    parent: jelmer at samba.org-20080322171301-sqmaw9i9p1y0e9o3
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: 0.4
    timestamp: Sat 2008-03-22 18:18:58 +0100
    message:
      Add test for #183361
    modified:
      tests/test_repos.py            test_repos.py-20060508151940-ddc49a59257ca712
    ------------------------------------------------------------
    revno: 948.1.34
    revision-id: jelmer at samba.org-20080322171301-sqmaw9i9p1y0e9o3
    parent: jelmer at samba.org-20080322155912-2vyfnfggsovwkqr3
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: 0.4
    timestamp: Sat 2008-03-22 18:13:01 +0100
    message:
      Properly use current branching scheme when following branches.
    modified:
      NEWS                           news-20061231030336-h9fhq245ie0de8bs-1
      repository.py                  repository.py-20060306123302-1f8c5069b3fe0265
      tests/test_branch.py           test_branch.py-20060508162215-74ffeb5d608f8e20
    ------------------------------------------------------------
    revno: 948.1.33
    revision-id: jelmer at samba.org-20080322155912-2vyfnfggsovwkqr3
    parent: jelmer at samba.org-20080322155311-9ha78plxvrse7tay
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: 0.4
    timestamp: Sat 2008-03-22 16:59:12 +0100
    message:
      Remove experimental flag on v3 mapping.
    modified:
      mapping.py                     mapping.py-20080128201303-6cp01phc0dmc0kiv-1
    ------------------------------------------------------------
    revno: 948.1.32
    revision-id: jelmer at samba.org-20080322155311-9ha78plxvrse7tay
    parent: jelmer at samba.org-20080322140604-gr99ufb54gy6i9g4
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: 0.4
    timestamp: Sat 2008-03-22 16:53:11 +0100
    message:
      Add new utility function get_lhs_ancestry(), fix test failure for signature storage.
    modified:
      branch.py                      svnbranch.py-20051017135706-11c749eb0dab04a7
      fetch.py                       fetch.py-20060625004942-x2lfaib8ra707a8p-1
      repository.py                  repository.py-20060306123302-1f8c5069b3fe0265
    ------------------------------------------------------------
    revno: 948.1.31
    revision-id: jelmer at samba.org-20080322140604-gr99ufb54gy6i9g4
    parent: jelmer at samba.org-20080322133824-lxslia5p2n8e0lme
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: 0.4
    timestamp: Sat 2008-03-22 15:06:04 +0100
    message:
      Support storing commit message in bzr:log.
    modified:
      mapping.py                     mapping.py-20080128201303-6cp01phc0dmc0kiv-1
    ------------------------------------------------------------
    revno: 948.1.30
    revision-id: jelmer at samba.org-20080322133824-lxslia5p2n8e0lme
    parent: jelmer at samba.org-20080322132804-khp1h5o6o8jzx50s
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: 0.4
    timestamp: Sat 2008-03-22 14:38:24 +0100
    message:
      Support fetching revision properties from a svn repository.
    modified:
      commit.py                      commit.py-20060607190346-qvq128wgfubhhgm2-1
      fetch.py                       fetch.py-20060625004942-x2lfaib8ra707a8p-1
      tests/__init__.py              __init__.py-20060508151940-e9f4d914801a2535
      tests/test_fetch.py            test_fetch.py-20070624210302-luvgwjmlfysk5qeq-1
    ------------------------------------------------------------
    revno: 948.1.29
    revision-id: jelmer at samba.org-20080322132804-khp1h5o6o8jzx50s
    parent: jelmer at samba.org-20080322132203-bo1whwfys2dnqa5o
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: 0.4
    timestamp: Sat 2008-03-22 14:28:04 +0100
    message:
      Allow changing gpg signatures
    modified:
      pre-revprop-change.example     prerevpropchange.exa-20071214160928-9g7oevg3tlky780a-1
    ------------------------------------------------------------
    revno: 948.1.28
    revision-id: jelmer at samba.org-20080322132203-bo1whwfys2dnqa5o
    parent: jelmer at samba.org-20080322130529-jv7tf6lj3njw2sm7
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: 0.4
    timestamp: Sat 2008-03-22 14:22:03 +0100
    message:
      Support setting revision signatures in Subversion repositories.
    modified:
      NEWS                           news-20061231030336-h9fhq245ie0de8bs-1
      repository.py                  repository.py-20060306123302-1f8c5069b3fe0265
      tests/test_repos.py            test_repos.py-20060508151940-ddc49a59257ca712
    ------------------------------------------------------------
    revno: 948.1.27
    revision-id: jelmer at samba.org-20080322130529-jv7tf6lj3njw2sm7
    parent: jelmer at samba.org-20080322021233-ooblxnxj7944y27f
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: 0.4
    timestamp: Sat 2008-03-22 14:05:29 +0100
    message:
      Remove obsolete FIXME, allow passing in revision properties to Repository.get_revision().
    modified:
      mapping.py                     mapping.py-20080128201303-6cp01phc0dmc0kiv-1
      repository.py                  repository.py-20060306123302-1f8c5069b3fe0265
    ------------------------------------------------------------
    revno: 948.1.26
    revision-id: jelmer at samba.org-20080322021233-ooblxnxj7944y27f
    parent: jelmer at samba.org-20080322005103-zarm22bzsyjbwyd8
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: 0.4
    timestamp: Sat 2008-03-22 03:12:33 +0100
    message:
      Fix import of serializer.
    modified:
      repository.py                  repository.py-20060306123302-1f8c5069b3fe0265
    ------------------------------------------------------------
    revno: 948.1.25
    revision-id: jelmer at samba.org-20080322005103-zarm22bzsyjbwyd8
    parent: jelmer at samba.org-20080321233545-o06rh49csiw8k1pg
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: 0.4
    timestamp: Sat 2008-03-22 01:51:03 +0100
    message:
      Fix errors.
    modified:
      svk.py                         svk.py-20080201171509-m2eg9m6jrmlbwxg5-1
=== modified file 'NEWS'
--- a/NEWS	2008-03-21 22:41:48 +0000
+++ b/NEWS	2008-03-22 17:13:01 +0000
@@ -10,6 +10,8 @@
 
    * --prefix is now determined from the specified url in svn-import. (#160335)
 
+   * Support storing revision signatures.
+
   BUGS
   
    * Fix compatibility with bzr 1.3.
@@ -18,6 +20,8 @@
 
    * More correct implementation of Repository.get_ancestry(). 
 
+   * Properly use current branching scheme when following branches. (#183361)
+
   INTERNALS
 
    * Allow multiple mappings to be available at the same time.

=== modified file 'branch.py'
--- a/branch.py	2008-03-18 19:45:50 +0000
+++ b/branch.py	2008-03-22 18:24:58 +0000
@@ -21,7 +21,7 @@
 from bzrlib.errors import (NoSuchFile, DivergedBranches, NoSuchRevision, 
                            NotBranchError)
 from bzrlib.inventory import (Inventory)
-from bzrlib.revision import ensure_null
+from bzrlib.revision import ensure_null, NULL_REVISION
 from bzrlib.workingtree import WorkingTree
 
 import svn.client, svn.core
@@ -200,12 +200,7 @@
        
     def _generate_revision_history(self, last_revnum):
         """Generate the revision history up until a specified revision."""
-        revhistory = []
-        for (branch, rev) in self.repository.follow_branch(
-                self.get_branch_path(last_revnum), last_revnum, self.mapping):
-            revhistory.append(
-                self.repository.generate_revision_id(rev, branch, 
-                    self.mapping))
+        revhistory = list(self.repository.iter_lhs_ancestry(self.generate_revision_id(last_revnum)))
         revhistory.reverse()
         return revhistory
 
@@ -401,7 +396,7 @@
 
     def get_parent(self):
         """See Branch.get_parent()."""
-        return self.base
+        return None
 
     def set_parent(self, url):
         """See Branch.set_parent()."""

=== modified file 'branchprops.py'
--- a/branchprops.py	2008-02-04 04:05:41 +0000
+++ b/branchprops.py	2008-03-22 19:01:10 +0000
@@ -136,24 +136,6 @@
             return props[name]
         return default
 
-    def touches_property(self, path, revnum, name):
-        """Check whether a property was modified in a revision."""
-        assert isinstance(path, str)
-        assert isinstance(revnum, int)
-        assert isinstance(name, str)
-        # If the path this property is set on didn't change, then 
-        # the property can't have changed.
-        if not self.log.touches_path(path, revnum):
-            return ""
-
-        current = self.get_property(path, revnum, name, None)
-        (prev_path, prev_revnum) = self.log.get_previous(path, revnum)
-        if prev_path is None and prev_revnum == -1:
-            return (current is not None)
-        previous = self.get_property(prev_path.encode("utf-8"), 
-                                     prev_revnum, name, None)
-        return (previous != current)
-
     def get_property_diff(self, path, revnum, name):
         """Returns the new lines that were added to a particular property."""
         assert isinstance(path, str)

=== modified file 'commit.py'
--- a/commit.py	2008-03-21 23:35:45 +0000
+++ b/commit.py	2008-03-22 19:04:12 +0000
@@ -33,7 +33,7 @@
 from svk import (generate_svk_feature, serialize_svk_features, 
                  parse_svk_features, SVN_PROP_SVK_MERGE)
 from mapping import parse_revision_id
-from repository import (SvnRepositoryFormat, SvnRepository)
+from repository import (SvnRepositoryFormat, SvnRepository, lazy_dict)
 import urllib
 
 
@@ -150,7 +150,7 @@
         if self.base_revid is None:
             base_branch_props = {}
         else:
-            base_branch_props = self.repository.branchprop_list.get_properties(self.base_path, self.base_revnum)
+            base_branch_props = lazy_dict(lambda: self.repository.branchprop_list.get_properties(self.base_path, self.base_revnum))
         (self._svn_revprops, self._svnprops) = self.base_mapping.export_revision(self.branch.get_branch_path(), timestamp, timezone, committer, revprops, revision_id, self.base_revno+1, merges, base_branch_props)
 
         if len(merges) > 0:
@@ -713,6 +713,8 @@
     except ChangesRootLHSHistory:
         raise BzrError("Unable to push revision %r because it would change the ordering of existing revisions on the Subversion repository root. Use rebase and try again or push to a non-root path" % revision_id)
 
+    # FIXME: copy revisions signature
+
     if 'validate' in debug.debug_flags:
         crev = target.repository.get_revision(revision_id)
         ctree = target.repository.revision_tree(revision_id)
@@ -776,6 +778,8 @@
                              
                 replay_delta(builder, base_tree, old_tree)
                 builder.commit(rev.message)
+
+                # FIXME: Copy revision signature for rev
         finally:
             self.source.unlock()
  

=== modified file 'fetch.py'
--- a/fetch.py	2008-03-22 00:19:21 +0000
+++ b/fetch.py	2008-03-22 20:45:04 +0000
@@ -32,7 +32,8 @@
 from mapping import (SVN_PROP_BZR_ANCESTRY, SVN_PROP_BZR_MERGE, 
                      SVN_PROP_BZR_PREFIX, SVN_PROP_BZR_REVISION_INFO, 
                      SVN_PROP_BZR_BRANCHING_SCHEME, SVN_PROP_BZR_REVISION_ID,
-                     SVN_PROP_BZR_FILEIDS, parse_merge_property,
+                     SVN_PROP_BZR_FILEIDS, SVN_REVPROP_BZR_SIGNATURE,
+                     parse_merge_property,
                      parse_revision_metadata)
 from repository import (SvnRepository, SvnRepositoryFormat)
 from svk import SVN_PROP_SVK_MERGE
@@ -101,8 +102,10 @@
     def start_revision(self, revid, prev_inventory):
         self.revid = revid
         (self.branch_path, self.revnum, self.mapping) = self.source.lookup_revision_id(revid)
+        self.svn_revprops = self.source._log._get_transport().revprop_list(self.revnum)
         changes = self.source._log.get_revision_paths(self.revnum, self.branch_path)
-        renames = self.source.revision_fileid_renames(revid)
+        renames = self.source.revision_fileid_renames(self.branch_path, self.revnum, self.mapping, 
+                                                      revprops=self.svn_revprops)
         self.id_map = self.source.transform_fileid_map(self.source.uuid, 
                               self.revnum, self.branch_path, changes, renames, 
                               self.mapping)
@@ -129,10 +132,11 @@
         # Commit SVN revision properties to a Revision object
         rev = Revision(revision_id=revid, parent_ids=self._get_parent_ids())
 
-        svn_revprops = self.source._log._get_transport().revprop_list(self.revnum)
-        self.mapping.import_revision(svn_revprops, self._branch_fileprops, rev)
-
-        return rev
+        self.mapping.import_revision(self.svn_revprops, self._branch_fileprops, rev)
+
+        signature = self.svn_revprops.get(SVN_REVPROP_BZR_SIGNATURE)
+
+        return (rev, signature)
 
     def open_root(self, base_revnum, baton):
         if self.old_inventory.root is None:
@@ -459,12 +463,15 @@
             file_weave.add_lines(self.revid, parents, lines)
 
     def _finish_commit(self):
-        rev = self._get_revision(self.revid)
+        (rev, signature) = self._get_revision(self.revid)
+        self.inventory.revision_id = self.revid
         # Escaping the commit message is really the task of the serialiser
         rev.message = _escape_commit_message(rev.message)
         rev.inventory_sha1 = osutils.sha_string(
                 self.target.serialise_inventory(self.inventory))
         self.target.add_revision(self.revid, rev, self.inventory)
+        if signature is not None:
+            self.target.add_signature_text(self.revid, signature)
         self.target.commit_write_group()
         self._write_group_active = False
 
@@ -603,15 +610,11 @@
         """
         needed = []
         parents = {}
-        (path, until_revnum, mapping) = self.source.lookup_revision_id(revision_id)
 
         prev_revid = None
         pb = ui.ui_factory.nested_progress_bar()
         try:
-            for (branch, revnum) in self.source.follow_branch(path, 
-                                                              until_revnum, mapping):
-                pb.update("determining revisions to fetch", until_revnum-revnum, until_revnum)
-                revid = self.source.generate_revision_id(revnum, branch, mapping)
+            for revid in self.source.iter_lhs_ancestry(revision_id, pb):
 
                 if prev_revid is not None:
                     parents[prev_revid] = revid

=== modified file 'fileids.py'
--- a/fileids.py	2008-03-21 18:36:14 +0000
+++ b/fileids.py	2008-03-22 19:58:46 +0000
@@ -208,7 +208,7 @@
 
                 (revnum, branch) = quickrevidmap[revid]
                 (idmap, changes) = self.actual.apply_changes(self.repos.uuid, revnum, branch, 
-                                          global_changes, renames_cb(revid), mapping,
+                                          global_changes, renames_cb(branch, revnum, mapping), mapping,
                                           log_find_children)
                 pb.update('generating file id map', i, len(todo))
 

=== modified file 'logwalker.py'
--- a/logwalker.py	2008-03-21 22:41:48 +0000
+++ b/logwalker.py	2008-03-22 17:38:32 +0000
@@ -28,6 +28,45 @@
 
 LOG_CHUNK_LIMIT = 0
 
+def changes_find_prev_location(paths, branch_path, revnum):
+    if revnum == 0:
+        assert branch_path == ""
+        return
+    # If there are no special cases, just go try the 
+    # next revnum in history
+    revnum -= 1
+
+    # Make sure we get the right location for next time, if 
+    # the branch itself was copied
+    if (paths.has_key(branch_path) and 
+        paths[branch_path][0] in ('R', 'A')):
+        if paths[branch_path][1] is None: 
+            return None # Was added here
+        revnum = paths[branch_path][2]
+        branch_path = paths[branch_path][1].encode("utf-8")
+        return (branch_path, revnum)
+    
+    # Make sure we get the right location for the next time if 
+    # one of the parents changed
+
+    # Path names need to be sorted so the longer paths 
+    # override the shorter ones
+    for p in sorted(paths.keys(), reverse=True):
+        if paths[p][0] == 'M':
+            continue
+        if branch_path.startswith(p+"/"):
+            assert paths[p][0] in ('A', 'R'), "Parent wasn't added"
+            assert paths[p][1] is not None, \
+                "Empty parent added, but child wasn't added !?"
+
+            revnum = paths[p][2]
+            branch_path = paths[p][1].encode("utf-8") + branch_path[len(p):]
+            return (branch_path, revnum)
+
+    return (branch_path, revnum)
+
+
+
 class LogWalker(object):
     """Easy way to access the history of a Subversion repository."""
     def __init__(self, transport, cache_db=None, limit=None):
@@ -144,29 +183,12 @@
             if revpaths != {}:
                 yield (path, copy(revpaths), revnum)
 
-            if path == "":
-                revnum -= 1
-                continue
-
-            if revpaths.has_key(path):
-                if revpaths[path][1] is None:
-                    if revpaths[path][0] in ('A', 'R'):
-                        # this path didn't exist before this revision
-                        return
-                else:
-                    # In this revision, this path was copied from 
-                    # somewhere else
-                    revnum = revpaths[path][2]
-                    path = revpaths[path][1]
-                    assert path == "" or revnum > 0
-                    continue
-            revnum -= 1
-            for p in sorted(revpaths.keys()):
-                if path.startswith(p+"/") and revpaths[p][0] in ('A', 'R'):
-                    assert revpaths[p][1]
-                    path = path.replace(p, revpaths[p][1])
-                    revnum = revpaths[p][2]
-                    break
+            next = changes_find_prev_location(revpaths, path, revnum)
+
+            if next is None:
+                break
+
+            (path, revnum) = next
 
     def get_revision_paths(self, revnum, path=None, recurse=False):
         """Obtain dictionary with all the changes in a particular revision.

=== modified file 'mapping.py'
--- a/mapping.py	2008-03-21 22:41:48 +0000
+++ b/mapping.py	2008-03-22 15:59:12 +0000
@@ -48,6 +48,7 @@
 SVN_REVPROP_BZR_SCHEME = 'bzr:scheme'
 SVN_REVPROP_BZR_SIGNATURE = 'bzr:gpg-signature'
 SVN_REVPROP_BZR_TIMESTAMP = 'bzr:timestamp'
+SVN_REVPROP_BZR_LOG = 'bzr:log'
 
 
 def escape_svn_path(x):
@@ -144,7 +145,7 @@
         rev.committer = svn_revprops[svn.core.SVN_PROP_REVISION_AUTHOR]
     else:
         rev.committer = ""
-
+    
     rev.message = svn_revprops.get(svn.core.SVN_PROP_REVISION_LOG)
 
     if rev.message:
@@ -241,6 +242,9 @@
     if props.has_key(SVN_REVPROP_BZR_COMMITTER):
         rev.committer = props[SVN_REVPROP_BZR_COMMITTER].decode("utf-8")
 
+    if props.has_key(SVN_REVPROP_BZR_LOG):
+        rev.message = props[SVN_REVPROP_BZR_LOG]
+
     for name, value in props.items():
         if name.startswith(SVN_REVPROP_BZR_REVPROP_PREFIX):
             rev.properties[name[len(SVN_REVPROP_BZR_REVPROP_PREFIX):]] = value
@@ -430,7 +434,7 @@
     """The third version of the mappings as used in the 0.4.x series.
 
     """
-    experimental = True
+    experimental = False
     upgrade_suffix = "-svn3"
     revid_prefix = "svn-v3-"
 
@@ -794,12 +798,9 @@
     """
     if not revid.startswith("svn-"):
         raise InvalidRevisionId(revid, None)
-    try:
-        mapping_version = revid[len("svn-"):len("svn-vx")]
-        mapping = mapping_registry.get(mapping_version)
-        return mapping.parse_revision_id(revid)
-    except KeyError:
-        pass
+    mapping_version = revid[len("svn-"):len("svn-vx")]
+    mapping = mapping_registry.get(mapping_version)
+    return mapping.parse_revision_id(revid)
 
 
 def get_default_mapping():

=== modified file 'pre-revprop-change.example'
--- a/pre-revprop-change.example	2008-02-03 19:41:38 +0000
+++ b/pre-revprop-change.example	2008-03-22 13:28:04 +0000
@@ -17,7 +17,9 @@
 
 if [ "$ACTION" = "M" -a "$PROPNAME" = "svn:log" ]; then exit 0; fi
 
-# Allow adding bzr-svm revision properties:
+if [ "$ACTION" = "M" -a "$PROPNAME" = "bzr:gpg-signature" ]; then exit 0; fi
+
+# Allow adding bzr-svn revision properties:
 if [ "$ACTION" = "A" -a "`echo "$PROPNAME" | cut -d : -f 1`" = "bzr" ]; then exit 0; fi
 
 echo "Changing revision properties other than svn:log or bzr:* is prohibited" >&2

=== modified file 'repository.py'
--- a/repository.py	2008-03-21 22:41:48 +0000
+++ b/repository.py	2008-03-22 19:58:46 +0000
@@ -15,7 +15,7 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 """Subversion repository access."""
 
-import bzrlib
+import bzrlib, bzrlib.xml5
 from bzrlib import osutils, ui, urlutils
 from bzrlib.branch import Branch, BranchCheckResult
 from bzrlib.errors import (InvalidRevisionId, NoSuchRevision, NotBranchError, 
@@ -39,7 +39,7 @@
 from config import SvnRepositoryConfig
 import errors
 import logwalker
-from mapping import (SVN_PROP_BZR_REVISION_ID, 
+from mapping import (SVN_PROP_BZR_REVISION_ID, SVN_REVPROP_BZR_SIGNATURE,
                      SVN_PROP_BZR_BRANCHING_SCHEME, BzrSvnMappingv3FileProps,
                      parse_revision_metadata, parse_revid_property, 
                      parse_merge_property, BzrSvnMapping,
@@ -120,6 +120,19 @@
     def check_conversion_target(self, target_repo_format):
         return target_repo_format.rich_root_data
 
+
+def changes_path(changes, path):
+    """Check if one of the specified changes applies 
+    to path or one of its children.
+    """
+    for p in changes:
+        assert isinstance(p, str)
+        if p == path or p.startswith(path+"/") or path == "":
+            return True
+    return False
+
+
+
 CACHE_DB_VERSION = 3
 
 cachedbs = {}
@@ -365,18 +378,20 @@
 
         return SvnRevisionTree(self, revision_id)
 
-    def revision_fileid_renames(self, revid):
+    def revision_fileid_renames(self, path, revnum, mapping,
+                                revprops=None, fileprops=None):
         """Check which files were renamed in a particular revision.
         
-        :param revid: Id of revision to look up.
+        :param path: Branch path
+        :
         :return: dictionary with paths as keys, file ids as values
         """
-        (path, revnum, mapping) = self.lookup_revision_id(revid)
-
-        svn_revprops = lazy_dict(lambda: self.transport.revprop_list(revnum))
-        svn_fileprops = lazy_dict(lambda: self.branchprop_list.get_changed_properties(path, revnum))
-
-        return mapping.import_fileid_map(svn_revprops, svn_fileprops)
+        if revprops is None:
+            revprops = lazy_dict(lambda: self._log.transport.revprop_list(revnum))
+        if fileprops is None:
+            fileprops = lazy_dict(lambda: self.branchprop_list.get_changed_properties(path, revnum))
+
+        return mapping.import_fileid_map(revprops, fileprops)
 
     def _mainline_revision_parent(self, path, revnum, mapping):
         """Find the mainline parent of the specified revision.
@@ -444,8 +459,7 @@
             if revid is not None:
                 yield revid
 
-    def revision_parents(self, revision_id, svn_fileprops=None, 
-                         svn_revprops=None):
+    def revision_parents(self, revision_id, svn_fileprops=None, svn_revprops=None):
         """See Repository.revision_parents()."""
         parent_ids = ()
         (branch, revnum, mapping) = self.lookup_revision_id(revision_id)
@@ -467,15 +481,17 @@
 
         return parent_ids
 
-    def get_revision(self, revision_id):
+    def get_revision(self, revision_id, svn_revprops=None, svn_fileprops=None):
         """See Repository.get_revision."""
         if not revision_id or not isinstance(revision_id, str):
             raise InvalidRevisionId(revision_id=revision_id, branch=self)
 
         (path, revnum, mapping) = self.lookup_revision_id(revision_id)
         
-        svn_revprops = lazy_dict(lambda: self.transport.revprop_list(revnum))
-        svn_fileprops = lazy_dict(lambda: self.branchprop_list.get_changed_properties(path, revnum))
+        if svn_revprops is None:
+            svn_revprops = lazy_dict(lambda: self.transport.revprop_list(revnum))
+        if svn_fileprops is None:
+            svn_fileprops = lazy_dict(lambda: self.branchprop_list.get_changed_properties(path, revnum))
         parent_ids = self.revision_parents(revision_id, svn_fileprops=svn_fileprops, svn_revprops=svn_revprops)
 
         # Commit SVN revision properties to a Revision object
@@ -546,7 +562,6 @@
 
         # Try a simple parse
         try:
-            # FIXME: Also try to parse with the other formats..
             (uuid, branch_path, revnum, mapping) = parse_revision_id(revid)
             assert isinstance(branch_path, str)
             assert isinstance(mapping, BzrSvnMapping)
@@ -678,6 +693,13 @@
                     pass
             revnum -= 1
 
+    def iter_lhs_ancestry(self, revid, pb=None):
+        (branch_path, revnum, mapping) = self.lookup_revision_id(revid)
+        for (bp, rev) in self.follow_branch(branch_path, revnum, mapping):
+            if pb is not None:
+                pb.update("determining revision ancestry", revnum-rev, revnum)
+            yield self.generate_revision_id(rev, bp, mapping)
+
     def follow_branch(self, branch_path, revnum, mapping):
         """Follow the history of a branch. Will yield all the 
         left-hand side ancestors of a specified revision.
@@ -697,60 +719,24 @@
             assert revnum > 0 or branch_path == ""
             paths = self._log.get_revision_paths(revnum)
 
-            yielded = False
             # If something underneath branch_path changed, there is a 
             # revision there, so yield it.
-            for p in paths:
-                assert isinstance(p, str)
-                if (p == branch_path or 
-                    p.startswith(branch_path+"/") or 
-                    branch_path == ""):
-                    yield (branch_path, revnum)
-                    yielded = True
-                    break
-            
-            # If there are no special cases, just go try the 
-            # next revnum in history
-            revnum -= 1
-
-            # Make sure we get the right location for next time, if 
-            # the branch itself was copied
-            if (paths.has_key(branch_path) and 
-                paths[branch_path][0] in ('R', 'A')):
-                if not yielded:
-                    yield (branch_path, revnum+1)
-                if paths[branch_path][1] is None:
-                    return
-                if not mapping.is_branch(paths[branch_path][1]) and \
-                   not mapping.is_tag(paths[branch_path][1]):
-                    # FIXME: if copyfrom_path is not a branch path, 
-                    # should simulate a reverse "split" of a branch
-                    # for now, just make it look like the branch ended here
-                    return
-                revnum = paths[branch_path][2]
-                branch_path = paths[branch_path][1].encode("utf-8")
-                continue
-            
-            # Make sure we get the right location for the next time if 
-            # one of the parents changed
-
-            # Path names need to be sorted so the longer paths 
-            # override the shorter ones
-            for p in sorted(paths.keys(), reverse=True):
-                if paths[p][0] == 'M':
-                    continue
-                if branch_path.startswith(p+"/"):
-                    assert paths[p][0] in ('A', 'R'), "Parent wasn't added"
-                    assert paths[p][1] is not None, \
-                        "Empty parent added, but child wasn't added !?"
-
-                    revnum = paths[p][2]
-                    branch_path = paths[p][1].encode("utf-8") + branch_path[len(p):]
-                    break
-
+            if changes_path(paths, branch_path):
+                yield (branch_path, revnum)
+            next = logwalker.changes_find_prev_location(paths, branch_path, revnum)
+            if next is None:
+                break
+            (branch_path, revnum) = next
+            if not mapping.is_branch(branch_path) and \
+               not mapping.is_tag(branch_path):
+                # FIXME: if copyfrom_path is not a branch path, 
+                # should simulate a reverse "split" of a branch
+                # for now, just make it look like the branch ended here
+                break
+        
     def follow_branch_history(self, branch_path, revnum, mapping):
         """Return all the changes that happened in a branch 
-        between branch_path and revnum. 
+        until branch_path,revnum. 
 
         :return: iterator that returns tuples with branch path, 
             changed paths and revision number.
@@ -796,10 +782,12 @@
         :return: False, as no signatures are stored for revisions in Subversion 
             at the moment.
         """
-        # TODO: Retrieve from SVN_PROP_BZR_SIGNATURE 
-        return False # SVN doesn't store GPG signatures. Perhaps 
-                     # store in SVN revision property?
-
+        try:
+            (path, revnum, mapping) = self.lookup_revision_id(revision_id)
+        except NoSuchRevision:
+            return False
+        revprops = self.transport.revprop_list(revnum)
+        return revprops.has_key(SVN_REVPROP_BZR_SIGNATURE)
 
     def get_signature_text(self, revision_id):
         """Return the signature text for a particular revision.
@@ -808,9 +796,16 @@
                             signature.
         :raises NoSuchRevision: Always
         """
-        # TODO: Retrieve from SVN_PROP_BZR_SIGNATURE 
-        # SVN doesn't store GPG signatures
-        raise NoSuchRevision(self, revision_id)
+        (path, revnum, mapping) = self.lookup_revision_id(revision_id)
+        revprops = self.transport.revprop_list(revnum)
+        try:
+            return revprops[SVN_REVPROP_BZR_SIGNATURE]
+        except KeyError:
+            raise NoSuchRevision(self, revision_id)
+
+    def add_signature_text(self, revision_id, signature):
+        (path, revnum, mapping) = self.lookup_revision_id(revision_id)
+        self.transport.change_rev_prop(revnum, SVN_REVPROP_BZR_SIGNATURE, signature)
 
     def get_revision_graph(self, revision_id=None):
         """See Repository.get_revision_graph()."""

=== modified file 'svk.py'
--- a/svk.py	2008-02-08 17:56:00 +0000
+++ b/svk.py	2008-03-22 00:51:03 +0000
@@ -15,6 +15,8 @@
 
 """Utility functions for dealing with SVK properties."""
 
+import errors
+
 SVN_PROP_SVK_MERGE = 'svk:merge'
 
 parse_svk_features = lambda text: set(text.splitlines())

=== modified file 'tests/__init__.py'
--- a/tests/__init__.py	2008-03-21 22:41:48 +0000
+++ b/tests/__init__.py	2008-03-22 13:38:24 +0000
@@ -148,6 +148,12 @@
         rev.kind = svn.core.svn_opt_revision_number
         rev.value.number = revnum
         return svn.client.revprop_get(name, url, rev, self.client_ctx)[0]
+
+    def client_set_revprop(self, url, revnum, name, value):
+        rev = svn.core.svn_opt_revision_t()
+        rev.kind = svn.core.svn_opt_revision_number
+        rev.value.number = revnum
+        svn.client.revprop_set(name, value, url, rev, True, self.client_ctx)
         
     def client_commit(self, dir, message=None, recursive=True):
         """Commit current changes in specified working copy.

=== modified file 'tests/test_branch.py'
--- a/tests/test_branch.py	2008-02-04 16:16:22 +0000
+++ b/tests/test_branch.py	2008-03-22 17:13:01 +0000
@@ -139,7 +139,7 @@
     def test_get_parent(self):
         repos_url = self.make_client('a', 'dc')
         branch = Branch.open("svn+"+repos_url)
-        self.assertEqual("svn+"+repos_url, branch.get_parent())
+        self.assertEqual(None, branch.get_parent())
 
     def test_append_revision(self):
         repos_url = self.make_client('a', 'dc')

=== modified file 'tests/test_branchprops.py'
--- a/tests/test_branchprops.py	2008-02-04 03:21:32 +0000
+++ b/tests/test_branchprops.py	2008-03-22 19:01:10 +0000
@@ -141,20 +141,6 @@
         self.assertEquals("newdata\n", 
                           bp.get_changed_properties("", 3)["myp2"])
 
-    def test_touches_property(self):
-        repos_url = self.make_client('d', 'dc')
-        self.client_set_prop("dc", "myprop", "data\n")
-        self.client_commit("dc", "My Message")
-        self.client_set_prop("dc", "myprop", "data\ndata2\n")
-        self.client_commit("dc", "My Message")
-
-        logwalk = LogWalker(transport=SvnRaTransport(repos_url))
-
-        bp = BranchPropertyList(logwalk, self.db)
-        self.assertTrue(bp.touches_property("", 2, "myprop"))
-        self.assertTrue(bp.touches_property("", 1, "myprop"))
-        self.assertFalse(bp.touches_property("", 1, "nonexistant-property"))
-
     def test_get_property_diff_ignore_origchange(self):
         repos_url = self.make_client('d', 'dc')
         self.client_set_prop("dc", "myprop", "foodata\n")

=== modified file 'tests/test_fetch.py'
--- a/tests/test_fetch.py	2008-03-12 15:01:25 +0000
+++ b/tests/test_fetch.py	2008-03-22 13:38:24 +0000
@@ -189,6 +189,19 @@
         newrepos = dir.create_repository()
         oldrepos.copy_content_into(newrepos)
 
+    def test_fetch_signature(self):
+        repos_url = self.make_client('d', 'dc')
+        self.build_tree({'dc/trunk/bar': "data"})
+        self.client_add("dc/trunk")
+        self.client_commit("dc", "My Message")
+        self.client_set_revprop(repos_url, 1, "bzr:gpg-signature", "SIGNATURE")
+        oldrepos = Repository.open(repos_url)
+        oldrepos.set_branching_scheme(TrunkBranchingScheme(0))
+        dir = BzrDir.create("f", format.get_rich_root_format())
+        newrepos = dir.create_repository()
+        oldrepos.copy_content_into(newrepos)
+        self.assertEquals("SIGNATURE", newrepos.get_signature_text(oldrepos.generate_revision_id(1, "trunk", oldrepos.get_mapping())))
+
     def test_fetch_special_char_edit(self):
         repos_url = self.make_client('d', 'dc')
         self.build_tree({u'dc/trunk/IöC': None})

=== modified file 'tests/test_repos.py'
--- a/tests/test_repos.py	2008-03-21 22:41:48 +0000
+++ b/tests/test_repos.py	2008-03-22 17:18:58 +0000
@@ -37,7 +37,7 @@
 from mapping import (escape_svn_path, unescape_svn_path, 
                      SVN_PROP_BZR_REVISION_ID, SVN_PROP_BZR_BRANCHING_SCHEME)
 from scheme import (TrunkBranchingScheme, NoBranchingScheme, 
-                    ListBranchingScheme)
+                    ListBranchingScheme, SingleBranchingScheme)
 from transport import SvnRaTransport
 from tests import TestCaseWithSubversionRepository
 from repository import SvnRepositoryFormat
@@ -133,11 +133,22 @@
         self.assertRaises(NotImplementedError, repos.add_revision, "revid", 
                 None)
 
-    def test_has_signature_for_revision_id(self):
+    def test_has_signature_for_revision_id_no(self):
         repos_url = self.make_client("a", "dc")
         repos = Repository.open(repos_url)
         self.assertFalse(repos.has_signature_for_revision_id("foo"))
 
+    def test_set_signature(self):
+        repos_url = self.make_client("a", "dc")
+        repos = Repository.open(repos_url)
+        self.build_tree({"dc/foo": "bar"})
+        self.client_add("dc/foo")
+        self.client_commit("dc", "msg")
+        revid = repos.get_mapping().generate_revision_id(repos.uuid, 1, "")
+        repos.add_signature_text(revid, "TEXT")
+        self.assertTrue(repos.has_signature_for_revision_id(revid))
+        self.assertEquals(repos.get_signature_text(revid), "TEXT")
+
     def test_repr(self):
         repos_url = self.make_client("a", "dc")
         self.build_tree({'dc/foo': "data"})
@@ -170,6 +181,18 @@
         self.assertEquals([('pygments/trunk', 3), ('pykleur/trunk', 2), ('pykleur/trunk', 1)], 
                 list(repos.follow_branch("pygments/trunk", 3, TrunkBranchingScheme(1))))
 
+    def test_follow_branch_move_single(self):
+        repos_url = self.make_client('a', 'dc')
+        self.build_tree({'dc/pykleur/bla': None})
+        self.client_add("dc/pykleur")
+        self.client_commit("dc", "initial")
+        self.client_copy("dc/pykleur", "dc/pygments", 1)
+        self.client_update("dc")
+        self.client_commit("dc", "commit")
+        repos = Repository.open(repos_url)
+        self.assertEquals([('pygments', 2)], 
+                list(repos.follow_branch("pygments", 2, SingleBranchingScheme("pygments"))))
+
     def test_history_all(self):
         repos_url = self.make_client("a", "dc")
         self.build_tree({'dc/trunk/file': "data", "dc/foo/file":"data"})

=== modified file 'workingtree.py'
--- a/workingtree.py	2008-03-21 17:22:56 +0000
+++ b/workingtree.py	2008-03-22 18:59:08 +0000
@@ -442,7 +442,7 @@
         wc = self._get_wc(write_lock=True)
         try:
             svn.wc.prop_set(SVN_PROP_BZR_REVISION_ID+str(self.branch.mapping.scheme), 
-                             self._get_bzr_revids() + extra,
+                             self._get_bzr_revids(self._get_base_branch_props()) + extra,
                              self.basedir, wc)
             svn.wc.prop_set(SVN_PROP_BZR_REVISION_INFO, 
                              generate_revision_metadata(timestamp, 
@@ -465,14 +465,12 @@
             # Reset properties so the next subversion commit won't 
             # accidently set these properties.
             wc = self._get_wc(write_lock=True)
+            base_branch_props = self._get_base_branch_props()
             svn.wc.prop_set(SVN_PROP_BZR_REVISION_ID+str(self.branch.mapping.scheme), 
-                             self._get_bzr_revids(), self.basedir, wc)
+                             self._get_bzr_revids(base_branch_props), self.basedir, wc)
             svn.wc.prop_set(SVN_PROP_BZR_REVISION_INFO, 
-                self.branch.repository.branchprop_list.get_property(
-                self.branch.get_branch_path(self.base_revnum), 
-                self.base_revnum, 
-                SVN_PROP_BZR_REVISION_INFO, ""), 
-                self.basedir, wc)
+                              base_branch_props.get(SVN_PROP_BZR_REVISION_INFO, ""),
+                              self.basedir, wc)
             svn.wc.adm_close(wc)
             raise
 
@@ -614,14 +612,14 @@
         return dict(map(lambda x: str(x).split("\t"), 
             existing.splitlines()))
 
-    def _get_bzr_revids(self):
-        return self._get_base_branch_props().get(SVN_PROP_BZR_REVISION_ID+str(self.branch.mapping.scheme), "")
-
-    def _get_bzr_merges(self):
-        return self._get_base_branch_props().get(SVN_PROP_BZR_ANCESTRY+str(self.branch.mapping.scheme), "")
-
-    def _get_svk_merges(self):
-        return self._get_base_branch_props().get(SVN_PROP_SVK_MERGE, "")
+    def _get_bzr_revids(self, base_branch_props):
+        return base_branch_props.get(SVN_PROP_BZR_REVISION_ID+str(self.branch.mapping.scheme), "")
+
+    def _get_bzr_merges(self, base_branch_props):
+        return base_branch_props.get(SVN_PROP_BZR_ANCESTRY+str(self.branch.mapping.scheme), "")
+
+    def _get_svk_merges(self, base_branch_props):
+        return base_branch_props.get(SVN_PROP_SVK_MERGE, "")
 
     def set_pending_merges(self, merges):
         """See MutableTree.set_pending_merges()."""
@@ -634,10 +632,10 @@
                 bzr_merge = ""
 
             svn.wc.prop_set(SVN_PROP_BZR_ANCESTRY+str(self.branch.mapping.scheme), 
-                                 self._get_bzr_merges() + bzr_merge, 
+                                 self._get_bzr_merges(self._get_base_branch_props()) + bzr_merge, 
                                  self.basedir, wc)
             
-            svk_merges = parse_svk_features(self._get_svk_merges())
+            svk_merges = parse_svk_features(self._get_svk_merges(self._get_base_branch_props()))
 
             # Set svk:merge
             for merge in merges:
@@ -658,7 +656,7 @@
         self.set_pending_merges(merges)
 
     def pending_merges(self):
-        merged = self._get_bzr_merges().splitlines()
+        merged = self._get_bzr_merges(self._get_base_branch_props()).splitlines()
         wc = self._get_wc()
         try:
             merged_data = svn.wc.prop_get(




More information about the bazaar-commits mailing list