Rev 621: Merge 0.4, add Makefile. in file:///data/jelmer/bzr-svn/revprops/

Jelmer Vernooij jelmer at samba.org
Fri Feb 1 18:52:37 GMT 2008


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

------------------------------------------------------------
revno: 621
revision-id:jelmer at samba.org-20080201185236-5bp8q23j0qyttcfd
parent: jelmer at samba.org-20080201154204-cvfxae69hkcl3dh4
parent: jelmer at samba.org-20080201173447-3ecapklbladpzjp1
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: revprops
timestamp: Fri 2008-02-01 19:52:36 +0100
message:
  Merge 0.4, add Makefile.
added:
  Makefile                       makefile-20080201171722-sh3xq43ucs2x19cb-1
  svk.py                         svk.py-20080201171509-m2eg9m6jrmlbwxg5-1
  tests/test_svk.py              test_svk.py-20080201164711-h6p64zcglxpvygu2-1
modified:
  branchprops.py                 branchprops.py-20061223204623-80lvm7pjrpsgk0dd-1
  commit.py                      commit.py-20060607190346-qvq128wgfubhhgm2-1
  fetch.py                       fetch.py-20060625004942-x2lfaib8ra707a8p-1
  mapping.py                     mapping.py-20080128201303-6cp01phc0dmc0kiv-1
  repository.py                  repository.py-20060306123302-1f8c5069b3fe0265
  tests/__init__.py              __init__.py-20060508151940-e9f4d914801a2535
  tests/test_fetch.py            test_fetch.py-20070624210302-luvgwjmlfysk5qeq-1
  tests/test_revids.py           test_revids.py-20070516230044-d7x872cqi7xb4eow-1
  workingtree.py                 workingtree.py-20060306120941-b083cb0fdd4a69de
    ------------------------------------------------------------
    revno: 579.1.312
    revision-id:jelmer at samba.org-20080201173447-3ecapklbladpzjp1
    parent: jelmer at samba.org-20080201163357-y3vsiji4qvi3m4uq
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: 0.4
    timestamp: Fri 2008-02-01 18:34:47 +0100
    message:
      Move svk utility code into a separate file, move more functions into mapping.
    added:
      Makefile                       makefile-20080201171722-sh3xq43ucs2x19cb-1
      svk.py                         svk.py-20080201171509-m2eg9m6jrmlbwxg5-1
      tests/test_svk.py              test_svk.py-20080201164711-h6p64zcglxpvygu2-1
    modified:
      branchprops.py                 branchprops.py-20061223204623-80lvm7pjrpsgk0dd-1
      commit.py                      commit.py-20060607190346-qvq128wgfubhhgm2-1
      fetch.py                       fetch.py-20060625004942-x2lfaib8ra707a8p-1
      mapping.py                     mapping.py-20080128201303-6cp01phc0dmc0kiv-1
      repository.py                  repository.py-20060306123302-1f8c5069b3fe0265
      tests/__init__.py              __init__.py-20060508151940-e9f4d914801a2535
      tests/test_revids.py           test_revids.py-20070516230044-d7x872cqi7xb4eow-1
      workingtree.py                 workingtree.py-20060306120941-b083cb0fdd4a69de
    ------------------------------------------------------------
    revno: 579.1.311
    revision-id:jelmer at samba.org-20080201163357-y3vsiji4qvi3m4uq
    parent: jelmer at samba.org-20080201154001-9qtr3abggncffphn
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: 0.4
    timestamp: Fri 2008-02-01 17:33:57 +0100
    message:
      Fix number of arguments.
    modified:
      tests/test_fetch.py            test_fetch.py-20070624210302-luvgwjmlfysk5qeq-1
=== added file 'Makefile'
--- a/Makefile	1970-01-01 00:00:00 +0000
+++ b/Makefile	2008-02-01 17:34:47 +0000
@@ -0,0 +1,29 @@
+BZR ?= bzr
+SETUP ?= ./setup.py
+PYDOCTOR ?= pydoctor
+CTAGS = ?= ctags
+PYLINT ?= pylint
+
+all:: build
+
+build::
+	$(SETUP) build
+
+install::
+	$(SETUP) install
+
+clean::
+	$(SETUP) clean
+
+check::
+
+lint::
+	$(PYLINT) -f parseable *.py */*.py
+
+pydoctor::
+	$(PYDOCTOR) --make-html -c bzr-svn.cfg
+
+tags::
+	$(CTAGS) -R .
+
+ctags:: tags

=== modified file 'branchprops.py'
--- a/branchprops.py	2007-09-15 03:31:14 +0000
+++ b/branchprops.py	2008-02-01 17:34:47 +0000
@@ -90,6 +90,22 @@
 
         return proplist
 
+    def get_changed_property(self, path, revnum, name, default=None):
+        """Get the contents of a Subversion file property.
+
+        Will use the cache.
+
+        :param path: Subversion path.
+        :param revnum: Subversion revision number.
+        :param default: Default value to return if property wasn't found.
+        :return: Contents of property or default if property didn't exist.
+        """
+        assert isinstance(revnum, int)
+        assert isinstance(path, str)
+        if not self.touches_property(path, revnum, name):
+            return default
+        return self.get_property(path, revnum, name, default)
+
     def get_property(self, path, revnum, name, default=None):
         """Get the contents of a Subversion file property.
 

=== modified file 'commit.py'
--- a/commit.py	2008-02-01 15:42:04 +0000
+++ b/commit.py	2008-02-01 18:52:36 +0000
@@ -38,7 +38,8 @@
                      SVN_REVPROP_BZR_TIMESTAMP, SVN_REVPROP_BZR_MAPPING_VERSION,
                      MAPPING_VERSION, generate_revision_metadata)
 from repository import (revision_id_to_svk_feature, format_highres_date,
-                        SvnRepositoryFormat, SvnRepository, SVN_PROP_SVK_MERGE)
+                        SvnRepositoryFormat, SvnRepository)
+from svk import SVN_PROP_SVK_MERGE
 import urllib
 
 

=== modified file 'fetch.py'
--- a/fetch.py	2008-02-01 13:52:13 +0000
+++ b/fetch.py	2008-02-01 18:52:36 +0000
@@ -33,9 +33,10 @@
 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,
-                     MAPPING_VERSION, parse_revision_metadata, 
-                     parse_merge_property, revision_parse_svn_revprops)
-from repository import (SvnRepository, SvnRepositoryFormat, SVN_PROP_SVK_MERGE)
+                     SVN_PROP_BZR_FILEIDS, parse_merge_property, 
+                     default_mapping)
+from repository import (SvnRepository, SvnRepositoryFormat)
+from svk import SVN_PROP_SVK_MERGE
 from tree import apply_txdelta_handler
 
 
@@ -100,17 +101,15 @@
                               self.revnum, self.branch_path, changes, renames, 
                               self.scheme)
         self.dir_baserev = {}
-        self._revinfo = None
-        self._bzr_merges = []
-        self._svk_merges = []
         self._premature_deletes = set()
         self.pool = Pool()
         self.old_inventory = prev_inventory
         self.inventory = prev_inventory.copy()
+        self._branch_fileprops = {}
         self._start_revision()
 
     def _get_parent_ids(self):
-        return self.source.revision_parents(self.revid, self._bzr_merges)
+        return self.source.revision_parents(self.revid, self._branch_fileprops.get)
 
     def _get_revision(self, revid):
         """Creates the revision object.
@@ -122,10 +121,9 @@
         rev = Revision(revision_id=revid, parent_ids=self._get_parent_ids())
 
         svn_revprops = self.source._log._get_transport().revprop_list(self.revnum)
-        revision_parse_svn_revprops(rev, svn_revprops)
-
-        if self._revinfo and svn_revprops.get(SVN_REVPROP_BZR_MAPPING_VERSION) != str(MAPPING_VERSION):
-            parse_revision_metadata(self._revinfo, rev)
+        default_mapping.parse_svn_revision(svn_revprops, 
+                self._branch_fileprops.get, 
+                rev)
 
         return rev
 
@@ -252,6 +250,9 @@
         return (base_file_id, file_id)
 
     def change_dir_prop(self, (old_id, new_id), name, value, pool):
+        if new_id == self.inventory.root.file_id:
+            self._branch_fileprops[name] = value
+
         if name == SVN_PROP_BZR_BRANCHING_SCHEME:
             if new_id != self.inventory.root.file_id:
                 mutter('rogue %r on non-root directory' % name)
@@ -272,7 +273,6 @@
                 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 'mapping.py'
--- a/mapping.py	2008-02-01 15:42:04 +0000
+++ b/mapping.py	2008-02-01 18:52:36 +0000
@@ -15,13 +15,17 @@
 
 from bzrlib import osutils, registry
 from bzrlib.errors import InvalidRevisionId
+from bzrlib.trace import mutter
 
 import calendar
 import errors
 import sha
+import svn
 import time
 import urllib
 
+from svk import SVN_PROP_SVK_MERGE
+
 MAPPING_VERSION = 3
 
 SVN_PROP_BZR_PREFIX = 'bzr:'
@@ -133,6 +137,27 @@
 
     return filter(lambda x: x != "", line.split("\t"))
 
+def parse_svn_revprops(svn_revprops, rev):
+    if svn_revprops.has_key(svn.core.SVN_PROP_REVISION_AUTHOR):
+        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:
+        try:
+            rev.message = rev.message.decode("utf-8")
+        except UnicodeDecodeError:
+            pass
+
+    if svn_revprops.has_key(svn.core.SVN_PROP_REVISION_DATE):
+        rev.timestamp = 1.0 * svn.core.secs_from_timestr(svn_revprops[svn.core.SVN_PROP_REVISION_DATE], None)
+    else:
+        rev.timestamp = 0.0 # FIXME: Obtain repository creation time
+    rev.timezone = None
+    rev.properties = {}
+
 
 def parse_revision_metadata(text, rev):
     """Parse a revision info text (as set in bzr:revision-info).
@@ -202,36 +227,17 @@
     return text
 
 
-def revision_parse_svn_revprops(rev, props):
+def parse_bzr_svn_revprops(props, rev):
     """Update a Revision object from a set of Subversion revision properties.
     
+    :param props: Dictionary with Subversion revision properties.
     :param rev: Revision object
-    :param props: Dictionary with Subversion revision properties.
     """
-    rev.timezone = None
-
     if props.has_key(SVN_REVPROP_BZR_TIMESTAMP):
         (rev.timestamp, rev.timezone) = unpack_highres_date(props[SVN_REVPROP_BZR_TIMESTAMP])
-    elif props.has_key(svn.core.SVN_PROP_REVISION_DATE):
-        rev.timestamp = 1.0 * svn.core.secs_from_timestr(
-            props[svn.core.SVN_PROP_REVISION_DATE], None)
-    else:
-        rev.timestamp = 0 # FIXME: Obtain repository creation time
 
     if props.has_key(SVN_REVPROP_BZR_COMMITTER):
         rev.committer = props[SVN_REVPROP_BZR_COMMITTER].decode("utf-8")
-    elif props.has_key(svn.core.SVN_PROP_REVISION_AUTHOR):
-        rev.committer = props[svn.core.SVN_PROP_REVISION_AUTHOR]
-    else:
-        rev.committer = ""
-
-    rev.message = props.get(svn.core.SVN_PROP_REVISION_LOG)
-    if rev.message is not None:
-        assert isinstance(rev.message, str)
-        try:
-            rev.message = rev.message.decode("utf-8")
-        except UnicodeDecodeError:
-            pass
 
     for name, value in props.items():
         if name.startswith(SVN_REVPROP_BZR_REVPROP_PREFIX):
@@ -274,6 +280,30 @@
         """
         raise NotImplementedError(self.generate_file_id)
 
+    @staticmethod
+    def parse_svn_revision(revprops, get_branch_file_property, rev):
+        """Update a Revision object from Subversion revision and branch 
+        properties.
+
+        :param revprops: Dictionary with Subversion revision properties.
+        :param get_branch_file_property: Function that takes a string and
+            returns the value of the matching file property set on the branch 
+            path.
+        :param rev: Revision object to import data into.
+        """
+        raise NotImplementedError(self.parse_svn_revision)
+
+    @staticmethod
+    def get_rhs_parents(revprops, get_branch_file_property, scheme):
+        """Obtain the right-hand side parents for a revision.
+
+        """
+        raise NotImplementedError(self.get_rhs_parents)
+
+    @staticmethod
+    def get_fileid_map(revprops, get_branch_file_property):
+        raise NotImplementedError(self.get_fileid_map)
+
 
 class BzrSvnMappingv1(BzrSvnMapping):
     """This was the initial version of the mappings as used by bzr-svn
@@ -312,6 +342,14 @@
         return (uuid, branch_path, revnum, None)
 
 
+def parse_fileid_property(text):
+    ret = {}
+    for line in text.splitlines():
+        (path, key) = line.split("\t", 2)
+        ret[urllib.unquote(path)] = osutils.safe_file_id(key)
+    return ret
+
+
 class BzrSvnMappingv3(BzrSvnMapping):
     """The third version of the mappings as used in the 0.4.x series.
 
@@ -365,6 +403,61 @@
         assert isinstance(ret, str)
         return osutils.safe_file_id(ret)
 
+    @staticmethod
+    def parse_svn_revision(svn_revprops, get_branch_file_property, rev):
+        parse_svn_revprops(svn_revprops, rev)
+        parse_revision_metadata(
+                get_branch_file_property(SVN_PROP_BZR_REVISION_INFO, ""), rev)
+
+    @classmethod
+    def get_rhs_parents(cls, revprops, get_branch_file_property, scheme):
+        rhs_parents = []
+        bzr_merges = get_branch_file_property(SVN_PROP_BZR_ANCESTRY+str(scheme), None)
+        if bzr_merges is not None:
+            return parse_merge_property(bzr_merges.splitlines()[-1])
+
+        svk_merges = get_branch_file_property(SVN_PROP_SVK_MERGE, None)
+        if svk_merges is not None:
+            _merges = cls._svk_merged_revisions(branch, revnum, scheme)
+
+        return []
+
+    @classmethod
+    def get_fileid_map(cls, svn_revprops, get_branch_file_property):
+        fileids = get_branch_file_property(SVN_PROP_BZR_FILEIDS, None)
+        if fileids is None:
+            return {}
+        return parse_fileid_property(fileids)
+
+
+class BzrSvnMappingv4(BzrSvnMappingv3):
+    @staticmethod
+    def parse_svn_revision(svn_revprops, get_branch_file_property, rev):
+        parse_svn_revprops(svn_revprops, rev)
+        if svn_revprops.get(SVN_REVPROP_BZR_MAPPING_VERSION) == str(MAPPING_VERSION):
+            parse_bzr_svn_revprops(svn_revprops, rev)
+        elif not svn_revprops.has_key(SVN_REVPROP_BZR_MAPPING_VERSION):
+            parse_revision_metadata(get_branch_file_property(SVN_PROP_BZR_REVISION_INFO, ""), rev)
+
+    @classmethod
+    def get_fileid_map(cls, svn_revprops, get_branch_file_property):
+        if svn_revprops.has_key(SVN_REVPROP_BZR_MAPPING_VERSION):
+            if not svn_revprops.has_key(SVN_REVPROP_BZR_FILEIDS):
+                return {}
+            return parse_fileid_property(svn_revprops[SVN_REVPROP_BZR_FILEIDS])
+        else:
+            return BzrSvnMappingv3.get_fileid_map(svn_revprops, get_branch_file_property)
+
+    @classmethod
+    def get_rhs_parents(cls, svn_revprops, get_branch_file_property, scheme):
+        if svn_revprops.has_key(SVN_REVPROP_BZR_MAPPING_VERSION):
+            if svn_revprops[SVN_REVPROP_BZR_ROOT] != branch:
+                return parent_ids
+            if not svn_revprops.has_key(SVN_REVPROP_BZR_MERGE):
+                return parent_ids
+            return parent_ids + svn_revprops[SVN_REVPROP_BZR_MERGE].splitlines()
+        else:
+            return BzrSvnMappingv3.get_rhs_parents(svn_revprops, get_branch_file_property, scheme)
 
 
 class BzrSvnMappingRegistry(registry.Registry):

=== modified file 'repository.py'
--- a/repository.py	2008-02-01 14:53:39 +0000
+++ b/repository.py	2008-02-01 18:52:36 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006 Jelmer Vernooij <jelmer at samba.org>
+# Copyright (C) 2006-2008 Jelmer Vernooij <jelmer at samba.org>
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -39,31 +39,17 @@
 import errors
 import logwalker
 from mapping import (default_mapping, SVN_PROP_BZR_REVISION_ID, 
-                     SVN_PROP_BZR_REVISION_INFO, SVN_PROP_BZR_BRANCHING_SCHEME,
-                     SVN_PROP_BZR_ANCESTRY, SVN_PROP_BZR_FILEIDS,
+                     SVN_PROP_BZR_BRANCHING_SCHEME,
+                     SVN_PROP_BZR_ANCESTRY, 
                      parse_revision_metadata, parse_revid_property, 
-                     parse_merge_property, revision_parse_svn_revprops)
+                     parse_merge_property)
 from revids import RevidMap
 from scheme import (BranchingScheme, ListBranchingScheme, 
                     parse_list_scheme_text, guess_scheme_from_history)
+from svk import parse_svk_feature, SVN_PROP_SVK_MERGE
 from tree import SvnRevisionTree
 import urllib
 
-SVN_PROP_SVK_MERGE = 'svk:merge'
-
-def parse_svk_feature(feature):
-    """Parse a svk feature identifier.
-
-    :param feature: The feature identifier as string.
-    :return: tuple with uuid, branch path and revnum
-    """
-    try:
-        (uuid, branch, revnum) = feature.split(":", 3)
-    except ValueError:
-        raise errors.InvalidPropertyValue(SVN_PROP_SVK_MERGE, 
-                "not enough colons")
-    return (uuid, branch.strip("/"), int(revnum))
-
 
 def revision_id_to_svk_feature(revid):
     """Create a SVK feature identifier from a revision id.
@@ -78,7 +64,6 @@
     return "%s:/%s:%d" % (uuid, branch, revnum)
 
 
-
 class SvnRepositoryFormat(RepositoryFormat):
     """Repository format for Subversion repositories (accessed using svn_ra).
     """
@@ -362,24 +347,9 @@
         (path, revnum, _) = self.lookup_revision_id(revid)
 
         svn_revprops = self.transport.revprop_list(revnum)
-        if svn_revprops.has_key(SVN_REVPROP_BZR_MAPPING_VERSION):
-            if not svn_revprops.has_key(SVN_REVPROP_BZR_FILEIDS):
-                return {}
-            fileids = svn_revprops[SVN_REVPROP_BZR_FILEIDS]
-        else:
-            # Only consider bzr:file-ids if this is a bzr revision
-            if not self.branchprop_list.touches_property(path, revnum, 
-                    SVN_PROP_BZR_REVISION_INFO):
-                return {}
-            fileids = self.branchprop_list.get_property(path, revnum, 
-                                                        SVN_PROP_BZR_FILEIDS)
-            if fileids is None:
-                return {}
-        ret = {}
-        for line in fileids.splitlines():
-            (path, key) = line.split("\t", 2)
-            ret[urllib.unquote(path)] = osutils.safe_file_id(key)
-        return ret
+        return default_mapping.get_fileid_map(svn_revprops, 
+                lambda name, default: self.branchprop_list.get_changed_property(path, revnum, name, default)
+                )
 
     def _mainline_revision_parent(self, path, revnum, scheme):
         """Find the mainline parent of the specified revision.
@@ -412,22 +382,6 @@
             # The specified revision was the first one in the branch
             return None
 
-    def _bzr_merged_revisions(self, branch, revnum, scheme):
-        """Find out what revisions were merged by Bazaar in a revision.
-
-        :param branch: Subversion branch path.
-        :param revnum: Subversion revision number.
-        :param scheme: Branching scheme.
-        """
-        change = self.branchprop_list.get_property_diff(branch, revnum, 
-                                SVN_PROP_BZR_ANCESTRY+str(scheme)).splitlines()
-        if len(change) == 0:
-            return []
-
-        assert len(change) == 1
-
-        return parse_merge_property(change[0])
-
     def _svk_feature_to_revision_id(self, scheme, feature):
         """Convert a SVK feature to a revision id for this repository.
 
@@ -480,7 +434,7 @@
             parents_list.append(parents)
         return parents_list
 
-    def revision_parents(self, revision_id, bzr_merges=None, svk_merges=None):
+    def revision_parents(self, revision_id, get_branch_fileprop=None):
         """See Repository.revision_parents()."""
         parent_ids = []
         (branch, revnum, scheme) = self.lookup_revision_id(revision_id)
@@ -488,26 +442,12 @@
         if mainline_parent is not None:
             parent_ids.append(mainline_parent)
 
+        if get_branch_fileprop is None:
+            get_branch_fileprop = lambda name, default: self.branchprop_list.get_changed_property(branch, revnum, name, default)
+
         svn_revprops = self.transport.revprop_list(revnum)
-        if svn_revprops.has_key(SVN_REVPROP_BZR_MAPPING_VERSION):
-            if svn_revprops[SVN_REVPROP_BZR_ROOT] != branch:
-                return parent_ids
-            if not svn_revprops.has_key(SVN_REVPROP_BZR_MERGE):
-                return parent_ids
-            return parent_ids + svn_revprops[SVN_REVPROP_BZR_MERGE].splitlines()
-
-        # if the branch didn't change, bzr:merge or svk:merge can't have changed
-        if not self._log.touches_path(branch, revnum):
-            return parent_ids
- 
-        if bzr_merges is None:
-            bzr_merges = self._bzr_merged_revisions(branch, revnum, scheme)
-
-        parent_ids.extend(bzr_merges)
-
-        if bzr_merges == [] and svk_merges is None:
-            svk_merges = self._svk_merged_revisions(branch, revnum, scheme)
-            parent_ids.extend(svk_merges)
+
+        parent_ids.extend(default_mapping.get_rhs_parents(svn_revprops, get_branch_fileprop, scheme))
 
         return parent_ids
 
@@ -525,15 +465,10 @@
             inventory_sha1 = property(lambda rev: self.get_inventory_sha1(rev.revision_id))
 
         rev = LazySvnRevision(revision_id=revision_id, parent_ids=parent_ids)
-        rev.properties = {}
-
         svn_revprops = self.transport.revprop_list(revnum)
-        revision_parse_svn_revprops(rev, svn_revprops)
 
-        if svn_revprops.get(SVN_REVPROP_BZR_MAPPING_VERSION) != str(MAPPING_VERSION):
-            parse_revision_metadata(
-                self.branchprop_list.get_property(path, revnum, 
-                     SVN_PROP_BZR_REVISION_INFO, ""), rev)
+        default_mapping.parse_svn_revision(svn_revprops, 
+                lambda name, default: self.branchprop_list.get_changed_property(path, revnum, name, default), rev)
 
         return rev
 

=== added file 'svk.py'
--- a/svk.py	1970-01-01 00:00:00 +0000
+++ b/svk.py	2008-02-01 17:34:47 +0000
@@ -0,0 +1,30 @@
+# Copyright (C) 2005-2008 Jelmer Vernooij <jelmer at samba.org>
+ 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+SVN_PROP_SVK_MERGE = 'svk:merge'
+
+def parse_svk_feature(feature):
+    """Parse a svk feature identifier.
+
+    :param feature: The feature identifier as string.
+    :return: tuple with uuid, branch path and revnum
+    """
+    try:
+        (uuid, branch, revnum) = feature.split(":", 3)
+    except ValueError:
+        raise errors.InvalidPropertyValue(SVN_PROP_SVK_MERGE, 
+                "not enough colons")
+    return (uuid, branch.strip("/"), int(revnum))
+

=== modified file 'tests/__init__.py'
--- a/tests/__init__.py	2008-02-01 13:15:45 +0000
+++ b/tests/__init__.py	2008-02-01 17:34:47 +0000
@@ -296,6 +296,7 @@
             'test_revids',
             'test_revspec',
             'test_scheme', 
+            'test_svk',
             'test_transport',
             'test_tree',
             'test_upgrade',

=== modified file 'tests/test_fetch.py'
--- a/tests/test_fetch.py	2008-02-01 00:02:46 +0000
+++ b/tests/test_fetch.py	2008-02-01 16:33:57 +0000
@@ -1447,7 +1447,7 @@
         self.client_add("dc/mylink")
         self.client_commit("dc", "My Message")
         ra = SvnRaTransport(repos_url)
-        def done(rev, date, author):
+        def done(info, pool):
             pass
         editor = ra.get_commit_editor({"svn:log": "msg"}, done, None, False)
         root_baton = editor.open_root(1)

=== modified file 'tests/test_revids.py'
--- a/tests/test_revids.py	2008-02-01 13:22:16 +0000
+++ b/tests/test_revids.py	2008-02-01 17:34:47 +0000
@@ -19,7 +19,7 @@
 from bzrlib.tests import TestCase
 
 from mapping import default_mapping, MAPPING_VERSION
-from repository import (parse_svk_feature, revision_id_to_svk_feature)
+from repository import revision_id_to_svk_feature
 from revids import RevidMap
 from tests import TestCaseWithSubversionRepository
 
@@ -127,14 +127,6 @@
                          default_mapping.parse_revision_id(
                      "svn-v%d-undefined:uuid:bp%%2Fdata:4" % MAPPING_VERSION))
 
-    def test_parse_svk_feature_root(self):
-        self.assertEqual(("auuid", "", 6), 
-                 parse_svk_feature("auuid:/:6"))
-
-    def test_svk_revid_map_nested(self):
-        self.assertEqual(("auuid", "bp", 6),
-                         parse_svk_feature("auuid:/bp:6"))
-
     def test_revid_svk_map(self):
         self.assertEqual("auuid:/:6", 
               revision_id_to_svk_feature("svn-v%d-undefined:auuid::6" % MAPPING_VERSION))

=== added file 'tests/test_svk.py'
--- a/tests/test_svk.py	1970-01-01 00:00:00 +0000
+++ b/tests/test_svk.py	2008-02-01 17:34:47 +0000
@@ -0,0 +1,28 @@
+# Copyright (C) 2005-2008 Jelmer Vernooij <jelmer at samba.org>
+ 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+from bzrlib.tests import TestCase
+from svk import parse_svk_feature
+
+class SvkTests(TestCase):
+    def test_parse_svk_feature_root(self):
+        self.assertEqual(("auuid", "", 6), 
+                 parse_svk_feature("auuid:/:6"))
+
+    def test_svk_revid_map_nested(self):
+        self.assertEqual(("auuid", "bp", 6),
+                         parse_svk_feature("auuid:/bp:6"))
+
+

=== modified file 'workingtree.py'
--- a/workingtree.py	2008-02-01 13:15:45 +0000
+++ b/workingtree.py	2008-02-01 17:34:47 +0000
@@ -39,8 +39,8 @@
                      SVN_PROP_BZR_REVISION_ID, SVN_PROP_BZR_REVISION_INFO,
                      generate_revision_metadata)
 from remote import SvnRemoteAccess
-from repository import (SvnRepository, revision_id_to_svk_feature, 
-                        SVN_PROP_SVK_MERGE) 
+from repository import (SvnRepository, revision_id_to_svk_feature)
+from svk import SVN_PROP_SVK_MERGE
 from mapping import escape_svn_path
 from scheme import BranchingScheme
 from transport import (SvnRaTransport, bzr_to_svn_url, create_svn_client,




More information about the bazaar-commits mailing list