From f5d11b750ecc982541d1f936488248f0b42d75d3 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Sun, 16 Nov 2014 20:15:50 +0100 Subject: pep8 linting (whitespaces) W191 indentation contains tabs E221 multiple spaces before operator E222 multiple spaces after operator E225 missing whitespace around operator E271 multiple spaces after keyword W292 no newline at end of file W293 blank line contains whitespace W391 blank line at end of file --- git/test/test_fun.py | 80 ++++++++++++++++++++++++++-------------------------- 1 file changed, 40 insertions(+), 40 deletions(-) (limited to 'git/test/test_fun.py') diff --git a/git/test/test_fun.py b/git/test/test_fun.py index 096cd368..129df3b9 100644 --- a/git/test/test_fun.py +++ b/git/test/test_fun.py @@ -24,7 +24,7 @@ from git.index import IndexFile from cStringIO import StringIO class TestFun(TestBase): - + def _assert_index_entries(self, entries, trees): index = IndexFile.from_tree(self.rorepo, *[self.rorepo.tree(bin_to_hex(t)) for t in trees]) assert entries @@ -32,22 +32,22 @@ class TestFun(TestBase): for entry in entries: assert (entry.path, entry.stage) in index.entries # END assert entry matches fully - + def test_aggressive_tree_merge(self): # head tree with additions, removals and modification compared to its predecessor odb = self.rorepo.odb HC = self.rorepo.commit("6c1faef799095f3990e9970bc2cb10aa0221cf9c") H = HC.tree B = HC.parents[0].tree - + # entries from single tree trees = [H.binsha] self._assert_index_entries(aggressive_tree_merge(odb, trees), trees) - + # from multiple trees trees = [B.binsha, H.binsha] self._assert_index_entries(aggressive_tree_merge(odb, trees), trees) - + # three way, no conflict tree = self.rorepo.tree B = tree("35a09c0534e89b2d43ec4101a5fb54576b577905") @@ -55,14 +55,14 @@ class TestFun(TestBase): M = tree("1f2b19de3301e76ab3a6187a49c9c93ff78bafbd") trees = [B.binsha, H.binsha, M.binsha] self._assert_index_entries(aggressive_tree_merge(odb, trees), trees) - + # three-way, conflict in at least one file, both modified B = tree("a7a4388eeaa4b6b94192dce67257a34c4a6cbd26") H = tree("f9cec00938d9059882bb8eabdaf2f775943e00e5") M = tree("44a601a068f4f543f73fd9c49e264c931b1e1652") trees = [B.binsha, H.binsha, M.binsha] self._assert_index_entries(aggressive_tree_merge(odb, trees), trees) - + # too many trees self.failUnlessRaises(ValueError, aggressive_tree_merge, odb, trees*2) @@ -73,7 +73,7 @@ class TestFun(TestBase): sio.seek(0) istream = odb.store(IStream(str_tree_type, len(sio.getvalue()), sio)) return istream.binsha - + @with_rw_repo('0.1.6') def test_three_way_merge(self, rwrepo): def mkfile(name, sha, executable=0): @@ -84,111 +84,111 @@ class TestFun(TestBase): assert len(entries) == num_entries assert has_conflict == (len([e for e in entries if e.stage != 0]) > 0) mktree = self.mktree - + shaa = "\1"*20 shab = "\2"*20 shac = "\3"*20 - + odb = rwrepo.odb - + # base tree bfn = 'basefile' fbase = mkfile(bfn, shaa) tb = mktree(odb, [fbase]) - + # non-conflicting new files, same data fa = mkfile('1', shab) th = mktree(odb, [fbase, fa]) fb = mkfile('2', shac) tm = mktree(odb, [fbase, fb]) - + # two new files, same base file trees = [tb, th, tm] assert_entries(aggressive_tree_merge(odb, trees), 3) - + # both delete same file, add own one fa = mkfile('1', shab) th = mktree(odb, [fa]) fb = mkfile('2', shac) tm = mktree(odb, [fb]) - + # two new files trees = [tb, th, tm] assert_entries(aggressive_tree_merge(odb, trees), 2) - + # same file added in both, differently fa = mkfile('1', shab) th = mktree(odb, [fa]) fb = mkfile('1', shac) tm = mktree(odb, [fb]) - + # expect conflict trees = [tb, th, tm] assert_entries(aggressive_tree_merge(odb, trees), 2, True) - + # same file added, different mode fa = mkfile('1', shab) th = mktree(odb, [fa]) fb = mkcommit('1', shab) tm = mktree(odb, [fb]) - + # expect conflict trees = [tb, th, tm] assert_entries(aggressive_tree_merge(odb, trees), 2, True) - + # same file added in both fa = mkfile('1', shab) th = mktree(odb, [fa]) fb = mkfile('1', shab) tm = mktree(odb, [fb]) - + # expect conflict trees = [tb, th, tm] assert_entries(aggressive_tree_merge(odb, trees), 1) - + # modify same base file, differently fa = mkfile(bfn, shab) th = mktree(odb, [fa]) fb = mkfile(bfn, shac) tm = mktree(odb, [fb]) - + # conflict, 3 versions on 3 stages trees = [tb, th, tm] assert_entries(aggressive_tree_merge(odb, trees), 3, True) - - + + # change mode on same base file, by making one a commit, the other executable # no content change ( this is totally unlikely to happen in the real world ) fa = mkcommit(bfn, shaa) th = mktree(odb, [fa]) fb = mkfile(bfn, shaa, executable=1) tm = mktree(odb, [fb]) - + # conflict, 3 versions on 3 stages, because of different mode trees = [tb, th, tm] assert_entries(aggressive_tree_merge(odb, trees), 3, True) - + for is_them in range(2): # only we/they change contents fa = mkfile(bfn, shab) th = mktree(odb, [fa]) - + trees = [tb, th, tb] if is_them: trees = [tb, tb, th] entries = aggressive_tree_merge(odb, trees) assert len(entries) == 1 and entries[0].binsha == shab - + # only we/they change the mode fa = mkcommit(bfn, shaa) th = mktree(odb, [fa]) - + trees = [tb, th, tb] if is_them: trees = [tb, tb, th] entries = aggressive_tree_merge(odb, trees) assert len(entries) == 1 and entries[0].binsha == shaa and entries[0].mode == fa[1] - + # one side deletes, the other changes = conflict fa = mkfile(bfn, shab) th = mktree(odb, [fa]) @@ -199,16 +199,16 @@ class TestFun(TestBase): # as one is deleted, there are only 2 entries assert_entries(aggressive_tree_merge(odb, trees), 2, True) # END handle ours, theirs - + def _assert_tree_entries(self, entries, num_trees): for entry in entries: assert len(entry) == num_trees paths = set(e[2] for e in entry if e) - + # only one path per set of entries assert len(paths) == 1 # END verify entry - + def test_tree_traversal(self): # low level tree tarversal odb = self.rorepo.odb @@ -216,29 +216,29 @@ class TestFun(TestBase): M = self.rorepo.tree('e14e3f143e7260de9581aee27e5a9b2645db72de') # merge tree B = self.rorepo.tree('f606937a7a21237c866efafcad33675e6539c103') # base tree B_old = self.rorepo.tree('1f66cfbbce58b4b552b041707a12d437cc5f400a') # old base tree - + # two very different trees entries = traverse_trees_recursive(odb, [B_old.binsha, H.binsha], '') self._assert_tree_entries(entries, 2) - + oentries = traverse_trees_recursive(odb, [H.binsha, B_old.binsha], '') assert len(oentries) == len(entries) self._assert_tree_entries(oentries, 2) - + # single tree is_no_tree = lambda i, d: i.type != 'tree' entries = traverse_trees_recursive(odb, [B.binsha], '') assert len(entries) == len(list(B.traverse(predicate=is_no_tree))) self._assert_tree_entries(entries, 1) - + # two trees entries = traverse_trees_recursive(odb, [B.binsha, H.binsha], '') self._assert_tree_entries(entries, 2) - + # tree trees entries = traverse_trees_recursive(odb, [B.binsha, H.binsha, M.binsha], '') self._assert_tree_entries(entries, 3) - + def test_tree_traversal_single(self): max_count = 50 count = 0 -- cgit v1.2.3 From be34ec23c48d6d5d8fd2ef4491981f6fb4bab8e6 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Sun, 16 Nov 2014 20:51:04 +0100 Subject: pep8 linting (blank lines expectations) E301 expected 1 blank line, found 0 E302 expected 2 blank lines, found 1 E303 too many blank lines (n) --- git/test/test_fun.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'git/test/test_fun.py') diff --git a/git/test/test_fun.py b/git/test/test_fun.py index 129df3b9..f435f31b 100644 --- a/git/test/test_fun.py +++ b/git/test/test_fun.py @@ -23,6 +23,7 @@ from stat import ( from git.index import IndexFile from cStringIO import StringIO + class TestFun(TestBase): def _assert_index_entries(self, entries, trees): @@ -78,8 +79,10 @@ class TestFun(TestBase): def test_three_way_merge(self, rwrepo): def mkfile(name, sha, executable=0): return (sha, S_IFREG | 0644 | executable*0111, name) + def mkcommit(name, sha): return (sha, S_IFDIR | S_IFLNK, name) + def assert_entries(entries, num_entries, has_conflict=False): assert len(entries) == num_entries assert has_conflict == (len([e for e in entries if e.stage != 0]) > 0) @@ -156,7 +159,6 @@ class TestFun(TestBase): trees = [tb, th, tm] assert_entries(aggressive_tree_merge(odb, trees), 3, True) - # change mode on same base file, by making one a commit, the other executable # no content change ( this is totally unlikely to happen in the real world ) fa = mkcommit(bfn, shaa) -- cgit v1.2.3 From 614907b7445e2ed8584c1c37df7e466e3b56170f Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Sun, 16 Nov 2014 20:56:53 +0100 Subject: pep8 linting (whitespace before/after) E201 whitespace after '(' E202 whitespace before ')' E203 whitespace before ':' E225 missing whitespace around operator E226 missing whitespace around arithmetic operator E227 missing whitespace around bitwise or shift operator E228 missing whitespace around modulo operator E231 missing whitespace after ',' E241 multiple spaces after ',' E251 unexpected spaces around keyword / parameter equals --- git/test/test_fun.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'git/test/test_fun.py') diff --git a/git/test/test_fun.py b/git/test/test_fun.py index f435f31b..9d6f3ea4 100644 --- a/git/test/test_fun.py +++ b/git/test/test_fun.py @@ -65,7 +65,7 @@ class TestFun(TestBase): self._assert_index_entries(aggressive_tree_merge(odb, trees), trees) # too many trees - self.failUnlessRaises(ValueError, aggressive_tree_merge, odb, trees*2) + self.failUnlessRaises(ValueError, aggressive_tree_merge, odb, trees * 2) def mktree(self, odb, entries): """create a tree from the given tree entries and safe it to the database""" @@ -78,7 +78,7 @@ class TestFun(TestBase): @with_rw_repo('0.1.6') def test_three_way_merge(self, rwrepo): def mkfile(name, sha, executable=0): - return (sha, S_IFREG | 0644 | executable*0111, name) + return (sha, S_IFREG | 0644 | executable * 0111, name) def mkcommit(name, sha): return (sha, S_IFDIR | S_IFLNK, name) @@ -88,9 +88,9 @@ class TestFun(TestBase): assert has_conflict == (len([e for e in entries if e.stage != 0]) > 0) mktree = self.mktree - shaa = "\1"*20 - shab = "\2"*20 - shac = "\3"*20 + shaa = "\1" * 20 + shab = "\2" * 20 + shac = "\3" * 20 odb = rwrepo.odb -- cgit v1.2.3 From c8e70749887370a99adeda972cc3503397b5f9a7 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Sun, 16 Nov 2014 21:09:47 +0100 Subject: pep8 linting (trailing whitespace) W291 trailing whitespace --- git/test/test_fun.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'git/test/test_fun.py') diff --git a/git/test/test_fun.py b/git/test/test_fun.py index 9d6f3ea4..4672901c 100644 --- a/git/test/test_fun.py +++ b/git/test/test_fun.py @@ -1,7 +1,7 @@ from git.test.lib import * from git.objects.fun import ( traverse_tree_recursive, - traverse_trees_recursive, + traverse_trees_recursive, tree_to_stream, tree_entries_from_data ) @@ -15,7 +15,7 @@ from gitdb.base import IStream from gitdb.typ import str_tree_type from stat import ( - S_IFDIR, + S_IFDIR, S_IFREG, S_IFLNK ) @@ -37,7 +37,7 @@ class TestFun(TestBase): def test_aggressive_tree_merge(self): # head tree with additions, removals and modification compared to its predecessor odb = self.rorepo.odb - HC = self.rorepo.commit("6c1faef799095f3990e9970bc2cb10aa0221cf9c") + HC = self.rorepo.commit("6c1faef799095f3990e9970bc2cb10aa0221cf9c") H = HC.tree B = HC.parents[0].tree -- cgit v1.2.3