Rev 839: Consistently handle unicode characters. in file:///data/jelmer/bzr-svn/0.4/

Jelmer Vernooij jelmer at samba.org
Fri Jan 18 04:05:55 GMT 2008


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

------------------------------------------------------------
revno: 839
revision-id:jelmer at samba.org-20080117234221-gfh2qw3y5h8xv087
parent: jelmer at samba.org-20080117231919-xc808a0zydd2fz9a
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Fri 2008-01-18 00:42:21 +0100
message:
  Consistently handle unicode characters.
modified:
  NEWS                           news-20061231030336-h9fhq245ie0de8bs-1
  errors.py                      errors.py-20061226172623-w1sbj8ynpo0eojqp-1
  fetch.py                       fetch.py-20060625004942-x2lfaib8ra707a8p-1
  scheme.py                      scheme.py-20060516195850-95181aae6b272f9e
  tests/test_fetch.py            test_fetch.py-20070624210302-luvgwjmlfysk5qeq-1
=== modified file 'NEWS'
--- a/NEWS	2008-01-08 21:41:03 +0000
+++ b/NEWS	2008-01-17 23:42:21 +0000
@@ -1,5 +1,8 @@
 bzr-svn 0.4.7	UNRELEASED
 
+  BUGS
+
+   * Consistently handle unicode characters. (#129334)
 
 bzr-svn 0.4.6	2008-01-08
 

=== modified file 'errors.py'
--- a/errors.py	2007-12-21 22:32:10 +0000
+++ b/errors.py	2008-01-17 23:42:21 +0000
@@ -20,6 +20,7 @@
                            DependencyNotPresent, NoRepositoryPresent,
                            TransportError, UnexpectedEndOfContainerError)
 
+import urllib
 import svn.core
 
 # APR define, not in svn.core
@@ -35,6 +36,18 @@
         self.scheme = scheme
 
 
+class InvalidSvnBranchPath(NotBranchError):
+    """Error raised when a path was specified that is not a child of or itself
+    a valid branch path in the current branching scheme."""
+    _fmt = """%(path)s is not a valid Subversion branch path in the current 
+branching scheme. See 'bzr help svn-branching schemes' for details."""
+
+    def __init__(self, path, scheme):
+        assert isinstance(path, str)
+        NotBranchError.__init__(self, urllib.quote(path))
+        self.scheme = scheme
+
+
 class NoSvnRepositoryPresent(NoRepositoryPresent):
 
     def __init__(self, url):

=== modified file 'fetch.py'
--- a/fetch.py	2008-01-17 23:19:19 +0000
+++ b/fetch.py	2008-01-17 23:42:21 +0000
@@ -77,7 +77,8 @@
     :param path: Path to check
     :raises InvalidFileName:
     """
-    if "\\" in path:
+    assert isinstance(path, unicode)
+    if u"\\" in path:
         raise InvalidFileName(path)
 
 

=== modified file 'scheme.py'
--- a/scheme.py	2008-01-17 23:19:19 +0000
+++ b/scheme.py	2008-01-17 23:42:21 +0000
@@ -16,9 +16,11 @@
 """Branching scheme implementations."""
 
 from bzrlib import ui
-from bzrlib.errors import NotBranchError, BzrError
+from bzrlib.errors import BzrError
 from bzrlib.trace import mutter
 
+from errors import InvalidSvnBranchPath
+
 from base64 import urlsafe_b64decode, urlsafe_b64encode
 import bz2
 
@@ -161,12 +163,13 @@
 
     def unprefix(self, path):
         """See BranchingScheme.unprefix()."""
+        assert isinstance(path, str)
         parts = path.strip("/").split("/")
         for pattern in self.split_branch_list:
             if self._pattern_cmp(parts[:len(pattern)], pattern):
                 return ("/".join(parts[:len(pattern)]), 
                         "/".join(parts[len(pattern):]))
-        raise NotBranchError(path=path)
+        raise InvalidSvnBranchPath(path=path, scheme=self)
 
     def __eq__(self, other):
         return self.branch_list == other.branch_list
@@ -203,6 +206,7 @@
 
     def unprefix(self, path):
         """See BranchingScheme.unprefix()."""
+        assert isinstance(path, str)
         return ("", path.strip("/"))
 
     def __str__(self):
@@ -248,9 +252,10 @@
 
     def unprefix(self, path):
         """See BranchingScheme.unprefix()."""
+        assert isinstance(path, str)
         parts = path.strip("/").split("/")
         if len(parts) == 0 or self.level >= len(parts):
-            raise NotBranchError(path=path)
+            raise InvalidSvnBranchPath(path=path, scheme=self)
 
         if parts[self.level] == "trunk" or parts[self.level] == "hooks":
             return ("/".join(parts[0:self.level+1]).strip("/"), 
@@ -260,7 +265,7 @@
             return ("/".join(parts[0:self.level+2]).strip("/"), 
                     "/".join(parts[self.level+2:]).strip("/"))
         else:
-            raise NotBranchError(path=path)
+            raise InvalidSvnBranchPath(path=path, scheme=self)
 
     def __str__(self):
         return "trunk%d" % self.level
@@ -303,9 +308,10 @@
 
     def unprefix(self, path):
         """See BranchingScheme.unprefix()."""
+        assert isinstance(path, str)
         path = path.strip("/")
         if not path.startswith(self.path):
-            raise NotBranchError(path=path)
+            raise InvalidSvnBranchPath(path=path, scheme=self)
 
         return (path[0:len(self.path)].strip("/"), 
                 path[len(self.path):].strip("/"))

=== modified file 'tests/test_fetch.py'
--- a/tests/test_fetch.py	2008-01-17 23:19:19 +0000
+++ b/tests/test_fetch.py	2008-01-17 23:42:21 +0000
@@ -142,7 +142,6 @@
         oldrepos.copy_content_into(newrepos)
 
     def test_fetch_special_char_child(self):
-        raise KnownFailure
         repos_url = self.make_client('d', 'dc')
         self.build_tree({u'dc/trunk/é/f\x2cle': "data"})
         self.client_add("dc/trunk")
@@ -154,7 +153,6 @@
         oldrepos.copy_content_into(newrepos)
 
     def test_fetch_special_char_modify(self):
-        raise KnownFailure
         repos_url = self.make_client('d', 'dc')
         self.build_tree({u'dc/trunk/€\x2c': "data"})
         self.client_add("dc/trunk")




More information about the bazaar-commits mailing list