Rev 424: Add trivial test for PullResult(). in file:///home/jelmer/bzr-svn/0.3/

Jelmer Vernooij jelmer at samba.org
Mon Mar 19 16:14:37 GMT 2007


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

------------------------------------------------------------
revno: 424
revision-id: jelmer at samba.org-20070312225122-7uh34ah30dqupuov
parent: jelmer at samba.org-20070312222054-r4acr5mlbresckgi
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.3
timestamp: Mon 2007-03-12 23:51:22 +0100
message:
  Add trivial test for PullResult().
  Initial work on a fix for #54736.
modified:
  fetch.py                       fetch.py-20060625004942-x2lfaib8ra707a8p-1
  repository.py                  repository.py-20060306123302-1f8c5069b3fe0265
  tests/test_commit.py           test_commit.py-20060624213521-l5kcufywkh9mnilk-1
  tests/test_fileids.py          test_fileids.py-20060622131341-19gyrlgqy8yl2od5-1
  tests/test_repos.py            test_repos.py-20060508151940-ddc49a59257ca712
  tests/test_workingtree.py      test_workingtree.py-20060622191524-0di7bc3q1ckdbybb-1
=== modified file 'fetch.py'
--- a/fetch.py	2007-03-04 12:46:53 +0000
+++ b/fetch.py	2007-03-12 22:51:22 +0000
@@ -114,6 +114,7 @@
                 file_weave.add_lines(self.revid, self.dir_baserev[id], [])
 
     def add_directory(self, path, parent_id, copyfrom_path, copyfrom_revnum, pool):
+        path = path.decode("utf-8")
         file_id = self._get_new_id(parent_id, path)
 
         self.dir_baserev[file_id] = []

=== modified file 'repository.py'
--- a/repository.py	2007-03-11 01:19:31 +0000
+++ b/repository.py	2007-03-12 22:51:22 +0000
@@ -58,9 +58,12 @@
 
 def escape_svn_path(id, unsafe="%/-\t \n"):
     assert "%" in unsafe
-    r = [((c in unsafe) and (u'%%%02x' % ord(c)) or c)
+    r = [((c in unsafe) and ('%%%02x' % ord(c)) or c)
          for c in id]
-    return unicode(''.join(r)).encode("utf-8")
+    ret = ''.join(r)
+    if isinstance(ret, unicode):
+        return ret.encode("utf-8")
+    return ret
 
 
 import urllib
@@ -108,7 +111,7 @@
     assert revnum >= 0
     if revnum == 0:
         return NULL_REVISION
-    return unicode("%s%d@%s-%s" % (REVISION_ID_PREFIX, revnum, uuid, escape_svn_path(path.strip("/")))).encode("utf-8")
+    return "%s%d@%s-%s" % (REVISION_ID_PREFIX, revnum, uuid, escape_svn_path(path.strip("/")))
 
 
 def svk_feature_to_revision_id(feature):

=== modified file 'tests/test_commit.py'
--- a/tests/test_commit.py	2007-03-11 23:29:25 +0000
+++ b/tests/test_commit.py	2007-03-12 22:51:22 +0000
@@ -14,7 +14,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-from bzrlib.branch import Branch, BranchReferenceFormat
+from bzrlib.branch import Branch, BranchReferenceFormat, PullResult
 from bzrlib.bzrdir import BzrDir, BzrDirFormat
 from bzrlib.errors import DivergedBranches
 from bzrlib.inventory import Inventory
@@ -112,16 +112,24 @@
         self.newdir = self.olddir.sprout("dc")
 
     def test_empty(self):
-        self.assertEqual(0, self.olddir.open_branch().pull(
-                                self.newdir.open_branch()))
+        self.assertEqual(0, int(self.olddir.open_branch().pull(
+                                self.newdir.open_branch())))
+
+    def test_empty_result(self):
+        result = self.olddir.open_branch().pull(self.newdir.open_branch())
+        self.assertIsInstance(result, PullResult)
+        self.assertEqual(result.old_revno, self.olddir.open_branch().revno())
+        self.assertEqual(result.master_branch, None)
+        self.assertEqual(result.target_branch.bzrdir.transport.base, self.olddir.transport.base)
+        self.assertEqual(result.source_branch.bzrdir.transport.base, self.newdir.transport.base)
 
     def test_child(self):
         self.build_tree({'sc/foo/bar': "data"})
         self.client_add("sc/foo/bar")
         self.client_commit("sc", "second message")
 
-        self.assertEqual(0, self.olddir.open_branch().pull(
-                                self.newdir.open_branch()))
+        self.assertEqual(0, int(self.olddir.open_branch().pull(
+                                self.newdir.open_branch())))
 
     def test_diverged(self):
         self.build_tree({'sc/foo/bar': "data"})

=== modified file 'tests/test_fileids.py'
--- a/tests/test_fileids.py	2007-03-11 01:19:31 +0000
+++ b/tests/test_fileids.py	2007-03-12 22:51:22 +0000
@@ -168,6 +168,19 @@
         self.assertEqual(u"svn-v2:2 at uuid-bp-mypath\x2c\x8a".encode("utf-8"), 
                          generate_file_id("svn-v2:2 at uuid-bp", u"mypath\x2c\x8a"))
 
+    def test_generate_svn_file_id(self):
+        self.assertEqual("svn-v2:2 at uuid-bp-path", 
+                generate_svn_file_id("uuid", 2, "bp", "path"))
+
+    def test_generate_svn_file_id_nordic(self):
+        self.assertEqual("svn-v2:2 at uuid-bp-\xc3\xa6\xc3\xb8\xc3\xa5", 
+                generate_svn_file_id("uuid", 2, "bp", u"\xe6\xf8\xe5"))
+
+    def test_generate_svn_file_id_nordic_branch(self):
+        self.assertEqual("svn-v2:2 at uuid-\xc3\xa6-\xc3\xa6\xc3\xb8\xc3\xa5", 
+                generate_svn_file_id("uuid", 2, u"\xe6", u"\xe6\xf8\xe5"))
+
+
 class TestFileMapping(TestCase):
     def apply_mappings(self, mappings, find_children=None, renames={}):
         map = {}

=== modified file 'tests/test_repos.py'
--- a/tests/test_repos.py	2007-01-16 03:56:05 +0000
+++ b/tests/test_repos.py	2007-03-12 22:51:22 +0000
@@ -749,6 +749,62 @@
         newrepos = dir.create_repository()
         oldrepos.copy_content_into(newrepos)
 
+    def test_fetch_replace_nordic(self):
+        filename = os.path.join(self.test_dir, "dumpfile")
+        open(filename, 'w').write("""SVN-fs-dump-format-version: 2
+
+UUID: 606c7b1f-987c-4826-b37d-eb556ceb87e1
+
+Revision-number: 0
+Prop-content-length: 56
+Content-length: 56
+
+K 8
+svn:date
+V 27
+2006-12-26T00:04:55.850520Z
+PROPS-END
+
+Revision-number: 1
+Prop-content-length: 103
+Content-length: 103
+
+K 7
+svn:log
+V 3
+add
+K 10
+svn:author
+V 6
+jelmer
+K 8
+svn:date
+V 27
+2006-12-26T00:05:15.504335Z
+PROPS-END
+
+Node-path: x\xc3\xa1
+Node-kind: dir
+Node-action: add
+Prop-content-length: 10
+Content-length: 10
+
+PROPS-END
+
+""")
+        os.mkdir("old")
+
+        load_dumpfile("dumpfile", "old")
+        oldrepos = Repository.open("old")
+        dir = BzrDir.create("f")
+        newrepos = dir.create_repository()
+        oldrepos.copy_content_into(newrepos)
+        self.assertTrue(newrepos.has_revision(
+            oldrepos.generate_revision_id(1, "")))
+        inv1 = newrepos.get_inventory(
+                oldrepos.generate_revision_id(1, ""))
+        self.assertTrue(inv1.has_filename(u"x\xe1"))
+
     def test_fetch_replace_with_subreplace(self):
         filename = os.path.join(self.test_dir, "dumpfile")
         open(filename, 'w').write("""SVN-fs-dump-format-version: 2
@@ -1914,6 +1970,10 @@
         self.assertEqual("svn-v%d:5 at myuuid-branch\x2c" % MAPPING_VERSION, 
                          generate_svn_revision_id("myuuid", 5, "branch\x2c"))
 
+    def test_generate_revid_nordic(self):
+        self.assertEqual("svn-v%d:5 at myuuid-branch\xc3\xa6" % MAPPING_VERSION, 
+                         generate_svn_revision_id("myuuid", 5, u"branch\xe6"))
+
     def test_parse_revid_simple(self):
         self.assertEqual(("uuid", "", 4),
                          parse_svn_revision_id(
@@ -1962,6 +2022,10 @@
     def test_unescape_svn_path_percent(self):
         self.assertEqual("foobar%b", unescape_svn_path("foobar%25b"))
 
+    def test_escape_svn_path_nordic(self):
+        self.assertEqual(u"foobar\xe6".encode("utf-8"), escape_svn_path(u"foobar\xe6"))
+
+
 class SvnRepositoryFormatTests(TestCase):
     def setUp(self):
         self.format = SvnRepositoryFormat()

=== modified file 'tests/test_workingtree.py'
--- a/tests/test_workingtree.py	2007-03-11 01:58:22 +0000
+++ b/tests/test_workingtree.py	2007-03-12 22:51:22 +0000
@@ -173,6 +173,7 @@
         self.build_tree({"dc/bl": "data"})
         self.client_add("dc/bl")
         self.client_commit("dc", "Bla")
+        self.client_update("dc")
         tree = WorkingTree.open("dc")
         os.remove("dc/bl")
         tree.revert(["bl"])




More information about the bazaar-commits mailing list