You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2012/09/25 20:03:42 UTC

[2/4] git commit: [#4933] ticket:170 added a test and fixed small bugs

[#4933] ticket:170 added a test and fixed small bugs


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/8048b372
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/8048b372
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/8048b372

Branch: refs/heads/master
Commit: 8048b372aeb8c2e59a8ee1fe36997e1196132042
Parents: 451c338
Author: Yuriy Arhipov <yu...@yandex.ru>
Authored: Fri Sep 21 20:56:01 2012 +0400
Committer: Dave Brondsema <db...@geek.net>
Committed: Tue Sep 25 18:02:01 2012 +0000

----------------------------------------------------------------------
 Allura/allura/lib/utils.py                         |    4 ++--
 Allura/allura/model/repo.py                        |    8 ++++----
 Allura/allura/model/repository.py                  |    8 ++++----
 .../tests/data/testrepo.hg/.hg/branchheads.cache   |    4 ++--
 .../tests/data/testrepo.hg/.hg/store/00changelog.i |  Bin 861 -> 1025 bytes
 .../tests/data/testrepo.hg/.hg/store/00manifest.i  |  Bin 598 -> 725 bytes
 .../data/testrepo.hg/.hg/store/data/bin__file.i    |  Bin 0 -> 9304 bytes
 .../tests/data/testrepo.hg/.hg/store/fncache       |    1 +
 .../forgehg/tests/data/testrepo.hg/.hg/store/undo  |  Bin 53 -> 53 bytes
 .../forgehg/tests/data/testrepo.hg/.hg/tags.cache  |    2 +-
 .../forgehg/tests/functional/test_controllers.py   |   13 ++++++++++---
 ForgeHg/forgehg/tests/model/test_repository.py     |   10 +++++-----
 12 files changed, 29 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8048b372/Allura/allura/lib/utils.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/utils.py b/Allura/allura/lib/utils.py
index 7ffa779..38383c5 100644
--- a/Allura/allura/lib/utils.py
+++ b/Allura/allura/lib/utils.py
@@ -442,7 +442,7 @@ def svn_path_exists(path):
 
 
 def is_text_file(file):
-    if (("text" in magic.from_buffer(file)) or
-        ("empty" in magic.from_buffer(file))):
+    msg = magic.from_buffer(file[:1024])
+    if ("text" in msg) or ("empty" in msg):
         return True
     return False

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8048b372/Allura/allura/model/repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repo.py b/Allura/allura/model/repo.py
index 2b7a490..b59cbaa 100644
--- a/Allura/allura/model/repo.py
+++ b/Allura/allura/model/repo.py
@@ -554,10 +554,10 @@ class Blob(object):
 
     @property
     def has_html_view(self):
-        if self.content_type.startswith('text/') or \
-           self.extension in VIEWABLE_EXTENSIONS or\
-           self.extension in self.repo._additional_viewable_extensions or\
-           utils.is_text_file(self.text):
+        if (self.content_type.startswith('text/') or
+            self.extension in VIEWABLE_EXTENSIONS or
+            self.extension in self.repo._additional_viewable_extensions or
+            utils.is_text_file(self.text)):
             return True
         return False
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8048b372/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 89fafde..3139b3c 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -974,10 +974,10 @@ class Blob(RepoObject):
 
     @property
     def has_html_view(self):
-        if self.content_type.startswith('text/') or\
-           self.extension in VIEWABLE_EXTENSIONS or\
-           self.extension in self.repo._additional_viewable_extensions or\
-           utils.is_text_file(self.text):
+        if (self.content_type.startswith('text/') or
+            self.extension in VIEWABLE_EXTENSIONS or
+            self.extension in self.repo._additional_viewable_extensions or
+            utils.is_text_file(self.text)):
             return True
         return False
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8048b372/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/branchheads.cache
----------------------------------------------------------------------
diff --git a/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/branchheads.cache b/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/branchheads.cache
index e179b4b..8d7c8ee 100644
--- a/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/branchheads.cache
+++ b/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/branchheads.cache
@@ -1,2 +1,2 @@
-4a7f7ec0dcf5f005eb5d177b3d8c00bfc8159843 4
-4a7f7ec0dcf5f005eb5d177b3d8c00bfc8159843 default
+5a0a993efa9bce7d1983344261393e841fcfd65d 5
+5a0a993efa9bce7d1983344261393e841fcfd65d default

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8048b372/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/store/00changelog.i
----------------------------------------------------------------------
diff --git a/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/store/00changelog.i b/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/store/00changelog.i
index ee70997..a737c49 100644
Binary files a/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/store/00changelog.i and b/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/store/00changelog.i differ

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8048b372/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/store/00manifest.i
----------------------------------------------------------------------
diff --git a/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/store/00manifest.i b/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/store/00manifest.i
index 87a81b7..04d6a7b 100644
Binary files a/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/store/00manifest.i and b/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/store/00manifest.i differ

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8048b372/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/store/data/bin__file.i
----------------------------------------------------------------------
diff --git a/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/store/data/bin__file.i b/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/store/data/bin__file.i
new file mode 100644
index 0000000..bf09e53
Binary files /dev/null and b/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/store/data/bin__file.i differ

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8048b372/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/store/fncache
----------------------------------------------------------------------
diff --git a/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/store/fncache b/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/store/fncache
index 2fc0d3c..c036206 100644
--- a/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/store/fncache
+++ b/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/store/fncache
@@ -1,3 +1,4 @@
 data/README.i
 data/a/b/c/hello.txt.i
 data/test.jpg.i
+data/bin_file.i

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8048b372/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/store/undo
----------------------------------------------------------------------
diff --git a/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/store/undo b/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/store/undo
index 410028c..1102d7a 100644
Binary files a/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/store/undo and b/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/store/undo differ

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8048b372/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/tags.cache
----------------------------------------------------------------------
diff --git a/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/tags.cache b/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/tags.cache
index 32dc671..45f9fad 100644
--- a/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/tags.cache
+++ b/ForgeHg/forgehg/tests/data/testrepo.hg/.hg/tags.cache
@@ -1,2 +1,2 @@
-4 4a7f7ec0dcf5f005eb5d177b3d8c00bfc8159843
+5 5a0a993efa9bce7d1983344261393e841fcfd65d
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8048b372/ForgeHg/forgehg/tests/functional/test_controllers.py
----------------------------------------------------------------------
diff --git a/ForgeHg/forgehg/tests/functional/test_controllers.py b/ForgeHg/forgehg/tests/functional/test_controllers.py
index 68e15e0..515b74e 100644
--- a/ForgeHg/forgehg/tests/functional/test_controllers.py
+++ b/ForgeHg/forgehg/tests/functional/test_controllers.py
@@ -116,14 +116,14 @@ class TestRootController(TestController):
     def test_commit_browser_data(self):
         resp = self.app.get('/src-hg/commit_browser_data')
         data = json.loads(resp.body);
-        assert data['max_row'] == 4
+        assert data['max_row'] == 5
         assert data['next_column'] == 1
         assert_equal(data['built_tree']['e5a0b44437be783c41084e7bf0740f9b58b96ecf'],
                 {u'url': u'/p/test/src-hg/ci/e5a0b44437be783c41084e7bf0740f9b58b96ecf/',
                  u'oid': u'e5a0b44437be783c41084e7bf0740f9b58b96ecf',
                  u'column': 0,
                  u'parents': [u'773d2f8e3a94d0d5872988b16533d67e1a7f5462'],
-                 u'message': u'Modify README', u'row': 3})
+                 u'message': u'Modify README', u'row': 4})
 
     def _get_ci(self):
         resp = self.app.get('/src-hg/').follow().follow()
@@ -140,7 +140,7 @@ class TestRootController(TestController):
     def test_tree(self):
         ci = self._get_ci()
         resp = self.app.get(ci + 'tree/')
-        assert len(resp.html.findAll('tr')) == 3, resp.showbrowser()
+        assert len(resp.html.findAll('tr')) == 4, resp.showbrowser()
         assert 'README' in resp, resp.showbrowser()
 
     def test_file(self):
@@ -166,6 +166,13 @@ class TestRootController(TestController):
         assert '+++' in resp, resp.showbrowser()
         assert '+Another line' in resp, resp.showbrowser()
 
+    def test_binary_diff(self):
+        ci = '/p/test/src-hg/ci/5a0a993efa9bce7d1983344261393e841fcfd65d/'
+        parent = '4a7f7ec0dcf5f005eb5d177b3d8c00bfc8159843'
+        resp = self.app.get(ci + 'tree/bin_file?barediff=' + parent,
+        validate_chunk=True)
+        assert 'Cannot display: file marked as a binary type.' in resp
+
 
 class TestLogPagination(TestController):
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8048b372/ForgeHg/forgehg/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeHg/forgehg/tests/model/test_repository.py b/ForgeHg/forgehg/tests/model/test_repository.py
index 13f068a..5c1dc71 100644
--- a/ForgeHg/forgehg/tests/model/test_repository.py
+++ b/ForgeHg/forgehg/tests/model/test_repository.py
@@ -55,13 +55,13 @@ class TestNewRepo(unittest.TestCase):
         self.rev.committer_url
         assert self.rev.tree._id == self.rev.tree_id
         assert self.rev.summary == self.rev.message.splitlines()[0]
-        assert self.rev.shorthand_id() == '[4a7f7e]'
+        assert self.rev.shorthand_id() == '[5a0a99]'
         assert self.rev.symbolic_ids == (['default'], ['tip'])
         assert self.rev.url() == (
             '/p/test/src-hg/ci/'
-            '4a7f7ec0dcf5f005eb5d177b3d8c00bfc8159843/')
+            '5a0a993efa9bce7d1983344261393e841fcfd65d/')
         all_cis = self.rev.log(0, 1000)
-        assert len(all_cis) == 5
+        assert len(all_cis) == 6
         assert self.rev.log(1,1000) == all_cis[1:]
         assert self.rev.log(0,3) == all_cis[:3]
         assert self.rev.log(1,2) == all_cis[1:3]
@@ -74,7 +74,7 @@ class TestNewRepo(unittest.TestCase):
         assert self.rev.tree.path() == '/'
         assert self.rev.tree.url() == (
             '/p/test/src-hg/ci/'
-            '4a7f7ec0dcf5f005eb5d177b3d8c00bfc8159843/'
+            '5a0a993efa9bce7d1983344261393e841fcfd65d/'
             'tree/')
         self.rev.tree.by_name['README']
         assert self.rev.tree.is_blob('README') == True
@@ -186,7 +186,7 @@ class TestHgCommit(unittest.TestCase):
         self.assertEqual(old_tree._id, new_tree._id)
 
     def test_url(self):
-        assert self.rev.url().endswith('159843/'), \
+        assert self.rev.url().endswith('cfd65d/'), \
             self.rev.url()
 
     def test_committer_url(self):