2010-07-04 MORITA Hajime <morrita@google.com>
authormorrita@google.com <morrita@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Jul 2010 10:50:58 +0000 (10:50 +0000)
committermorrita@google.com <morrita@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Jul 2010 10:50:58 +0000 (10:50 +0000)
        rebaseline-chromium-webkit-tests: UnicodeDecodeError
        https://bugs.webkit.org/show_bug.cgi?id=41589

        * run() method can result non-utf-8 bytes, that causes utf-8
          decoding fail.  Fixed to disable decoding.
        * Fixed Git.find_checkout_root() to make a test pass.

        * Scripts/webkitpy/common/checkout/scm.py:
        * Scripts/webkitpy/common/checkout/scm_unittest.py:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@62480 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKitTools/ChangeLog
WebKitTools/Scripts/webkitpy/common/checkout/scm.py
WebKitTools/Scripts/webkitpy/common/checkout/scm_unittest.py

index 4fa14a3..ae2cd87 100644 (file)
@@ -1,3 +1,15 @@
+2010-07-04  MORITA Hajime  <morrita@google.com>
+
+        rebaseline-chromium-webkit-tests: UnicodeDecodeError
+        https://bugs.webkit.org/show_bug.cgi?id=41589
+
+        * run() method can result non-utf-8 bytes, that causes utf-8
+          decoding fail.  Fixed to disable decoding.
+        * Fixed Git.find_checkout_root() to make a test pass.
+
+        * Scripts/webkitpy/common/checkout/scm.py:
+        * Scripts/webkitpy/common/checkout/scm_unittest.py:
+
 2010-07-03  Patrick Gansterer  <paroga@paroga.com>
 
         Reviewed by Simon Hausmann.
index 702e1a0..d7c621c 100644 (file)
@@ -460,7 +460,7 @@ class SVN(SCM):
             self._teardown_bogus_dir(log)
 
     def show_head(self, path):
-        return self.run(['svn', 'cat', '-r', 'BASE', path])
+        return self.run(['svn', 'cat', '-r', 'BASE', path], decode_output=False)
 
     def _repository_url(self):
         return self.value_from_svn_info(self.checkout_root, 'URL')
@@ -526,7 +526,7 @@ class Git(SCM):
     @classmethod
     def find_checkout_root(cls, path):
         # "git rev-parse --show-cdup" would be another way to get to the root
-        (checkout_root, dot_git) = os.path.split(run_command(['git', 'rev-parse', '--git-dir'], cwd=path))
+        (checkout_root, dot_git) = os.path.split(run_command(['git', 'rev-parse', '--git-dir'], cwd=(path or "./")))
         # If we were using 2.6 # checkout_root = os.path.relpath(checkout_root, path)
         if not os.path.isabs(checkout_root): # Sometimes git returns relative paths
             checkout_root = os.path.join(path, checkout_root)
@@ -662,7 +662,7 @@ class Git(SCM):
         return self.run(['git', 'diff', 'HEAD', '--', path])
 
     def show_head(self, path):
-        return self.run(['git', 'show', 'HEAD:' + self.to_object_name(path)])
+        return self.run(['git', 'show', 'HEAD:' + self.to_object_name(path)], decode_output=False)
 
     def committer_email_for_revision(self, revision):
         git_commit = self.git_commit_from_svn_revision(revision)
index f744e2a..eaa3b46 100644 (file)
@@ -64,8 +64,12 @@ def run_silent(args, cwd=None):
 
 
 def write_into_file_at_path(file_path, contents, encoding="utf-8"):
-    with codecs.open(file_path, "w", encoding) as file:
-        file.write(contents)
+    if encoding:
+        with codecs.open(file_path, "w", encoding) as file:
+            file.write(contents)
+    else:
+        with open(file_path, "w") as file:
+            file.write(contents)
 
 
 def read_from_path(file_path, encoding="utf-8"):
@@ -657,6 +661,13 @@ Q1dTBx0AAAB42itg4GlgYJjGwMDDyODMxMDw34GBgQEAJPQDJA==
         SVNTestRepository._svn_commit("fourth commit")
         self.assertEqual("Hello!", self.scm.show_head('test_file'))
 
+    def test_show_head_binary(self):
+        data = "\244"
+        write_into_file_at_path("binary_file", data, encoding=None)
+        self.scm.add("binary_file")
+        self.scm.commit_with_message("a test commit")
+        self.assertEqual(data, self.scm.show_head('binary_file'))
+
     def do_test_diff_for_file(self):
         write_into_file_at_path('test_file', 'some content')
         self.scm.commit_with_message("a test commit")
@@ -1169,6 +1180,14 @@ class GitSVNTest(SCMTest):
         self._two_local_commits()
         self.assertEqual("more test content", self.scm.show_head('test_file_commit1'))
 
+    def test_show_head_binary(self):
+        self._two_local_commits()
+        data = "\244"
+        write_into_file_at_path("binary_file", data, encoding=None)
+        self.scm.add("binary_file")
+        self.scm.commit_locally_with_message("a test commit")
+        self.assertEqual(data, self.scm.show_head('binary_file'))
+
     def test_diff_for_file(self):
         self._two_local_commits()
         write_into_file_at_path('test_file_commit1', "Updated", encoding=None)