Rev 505: Add some extra checks, fix issues with unicode. in file:///data/jelmer/bzr-svn/0.4/

Jelmer Vernooij jelmer at samba.org
Thu Jul 12 09:28:32 BST 2007


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

------------------------------------------------------------
revno: 505
revision-id: jelmer at samba.org-20070703003108-9dpwi3s0hl50xhld
parent: jelmer at samba.org-20070703003000-3js37ggc5tuv00ll
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: main
timestamp: Tue 2007-07-03 02:31:08 +0200
message:
  Add some extra checks, fix issues with unicode.
modified:
  branchprops.py                 branchprops.py-20061223204623-80lvm7pjrpsgk0dd-1
  fileids.py                     fileids.py-20060714013623-u5iiyqqnko11grcf-1
  logwalker.py                   logwalker.py-20060621215743-c13fhfnyzh1xzwh2-1
  repository.py                  repository.py-20060306123302-1f8c5069b3fe0265
=== modified file 'branchprops.py'
--- a/branchprops.py	2007-05-17 16:52:31 +0000
+++ b/branchprops.py	2007-07-03 00:31:08 +0000
@@ -36,11 +36,11 @@
         self.pool = Pool()
 
     def _get_dir_props(self, path, revnum):
-        assert path != None
+        assert isinstance(path, str)
         path = path.lstrip("/")
 
         try:
-            (_, _, props) = self.log.transport.get_dir(path.encode('utf8'), 
+            (_, _, props) = self.log.transport.get_dir(path, 
                 revnum, pool=self.pool)
         except SubversionException, (_, num):
             if num == svn.core.SVN_ERR_FS_NO_SUCH_REVISION:
@@ -51,6 +51,7 @@
 
     def get_properties(self, path, origrevnum):
         assert path is not None
+        assert isinstance(path, str)
         assert isinstance(origrevnum, int) and origrevnum >= 0
         proplist = {}
         revnum = self.log.find_latest_change(path, origrevnum)
@@ -73,7 +74,7 @@
 
     def get_property(self, path, revnum, name, default=None):
         assert isinstance(revnum, int)
-        assert isinstance(path, basestring)
+        assert isinstance(path, str)
         props = self.get_properties(path, revnum)
         if props.has_key(name):
             return props[name]
@@ -81,6 +82,7 @@
 
     def get_property_diff(self, path, revnum, name):
         """Returns the new lines that were added to a particular property."""
+        assert isinstance(path, 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):
@@ -91,7 +93,8 @@
         if prev_path is None and prev_revnum == -1:
             previous = ""
         else:
-            previous = self.get_property(prev_path, prev_revnum, name, "")
+            previous = self.get_property(prev_path.encode("utf-8"), 
+                                         prev_revnum, name, "")
         if len(previous) > len(current) or current[0:len(previous)] != previous:
             mutter('original part changed!')
             return ""

=== modified file 'fileids.py'
--- a/fileids.py	2007-06-24 14:08:49 +0000
+++ b/fileids.py	2007-07-03 00:31:08 +0000
@@ -61,8 +61,8 @@
                 if (crp == "" and new_p == ""):
                     data = ('M', None, None)
                 else:
-                    data = (data[0], crp, generate_revid(data[2], cbp, 
-                                                         str(scheme)))
+                    data = (data[0], crp, generate_revid(
+                                  data[2], cbp.encode("utf-8"), str(scheme)))
             except NotBranchError:
                 # Copied from outside of a known branch
                 # Make it look like the files were added in this revision
@@ -149,7 +149,8 @@
         # No history -> empty map
         for (bp, paths, rev) in self.repos.follow_branch_history(branch, 
                                              revnum, scheme):
-            revid = self.repos.generate_revision_id(rev, bp, scheme)
+            revid = self.repos.generate_revision_id(rev, bp.encode("utf-8"), 
+                                                    scheme)
             map = self.load(revid)
             if map != {}:
                 # found the nearest cached map

=== modified file 'logwalker.py'
--- a/logwalker.py	2007-06-26 20:07:24 +0000
+++ b/logwalker.py	2007-07-03 00:31:08 +0000
@@ -192,7 +192,7 @@
 
         paths = {}
         for p, act, cf, cr in self.db.execute(query):
-            paths[p] = (act, cf, cr)
+            paths[p.encode("utf-8")] = (act, cf, cr)
         return paths
 
     def get_revision_info(self, revnum):

=== modified file 'repository.py'
--- a/repository.py	2007-06-24 23:33:40 +0000
+++ b/repository.py	2007-07-03 00:31:08 +0000
@@ -444,6 +444,8 @@
 
         :return: New revision id.
         """
+        assert isinstance(path, str)
+
         # Look in the cache to see if it already has a revision id
         revid = self.revmap.lookup_branch_revnum(revnum, path, scheme)
         if revid is not None:
@@ -602,8 +604,8 @@
         :param scheme: Name of the branching scheme to use
         :return: iterator over the ancestors
         """
-
         assert branch_path is not None
+        assert isinstance(branch_path, str)
         assert isinstance(revnum, int) and revnum >= 0
         if not scheme.is_branch(branch_path) and \
            not scheme.is_tag(branch_path):
@@ -617,6 +619,7 @@
             # If something underneath branch_path changed, there is a 
             # revision there, so yield it.
             for p in paths:
+                assert isinstance(p, str)
                 if p.startswith(branch_path+"/") or branch_path == "":
                     yield (branch_path, revnum)
                     yielded = True
@@ -641,7 +644,7 @@
                     # for now, just make it look like the branch ended here
                     return
                 revnum = paths[branch_path][2]
-                branch_path = paths[branch_path][1]
+                branch_path = paths[branch_path][1].encode("utf-8")
                 continue
             
             # Make sure we get the right location for the next time if 
@@ -656,7 +659,7 @@
                     assert paths[p][1] is not None and paths[p][0] in ('A', 'R'), "Parent didn't exist yet, but child wasn't added !?"
 
                     revnum = paths[p][2]
-                    branch_path = paths[p][1] + branch_path[len(p):]
+                    branch_path = paths[p][1].encode("utf-8") + branch_path[len(p):]
 
     """Return all the changes that happened in a branch 
     between branch_path and revnum. 




More information about the bazaar-commits mailing list