Mercurial > hg
annotate tests/test-linerange.py @ 37485:0b7475ea38cf
wireproto: port heads command to wire protocol v2
After much thought and consideration, wire protocol version 2's
commands will be defined in different functions from the existing
commands. This will make it easier to implement these commands
because it won't require shoehorning things like response formatting
and argument declaration into the same APIs.
For example, wire protocol version 1 requires that commands declare
a fixed and ordered list of argument names. It isn't really possible
to insert new arguments or have optional arguments without
breaking backwards compatibility. Wire protocol version 2, however,
uses CBOR maps for passing arguments. So arguments a) can be
optional b) can be added without BC c) can be strongly typed.
This commit starts our trek towards reimplementing the wire protocol
for version 2 with the heads command. It is pretty similar to the
existing heads command. One added feature is it can be told to
operate on only public phase changesets. This is useful for
making discovery faster when a repo has tens of thousands of
draft phase heads (such as Mozilla's "try" repository).
The HTTPv2 server-side protocol has had its `getargs()` implementation
updated to reflect that arguments are a map and not a list.
Differential Revision: https://phab.mercurial-scm.org/D3179
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 28 Mar 2018 14:55:13 -0700 |
parents | 3eeb8e138e5c |
children | 6939b6ac960a |
rev | line source |
---|---|
30717
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
1 from __future__ import absolute_import |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
2 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
3 import unittest |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
4 from mercurial import error, mdiff |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
5 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
6 # for readability, line numbers are 0-origin |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
7 text1 = ''' |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
8 00 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
9 01 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
10 02 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
11 02 at NEW, 03 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
12 03 at NEW, 04 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
13 04 at NEW, 05 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
14 05 at NEW, 06 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
15 07 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
16 08 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
17 09 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
18 10 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
19 11 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
20 '''[1:] # strip initial LF |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
21 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
22 text2 = ''' |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
23 00 at NEW |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
24 01 at NEW |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
25 02 at NEW, 03 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
26 03 at NEW, 04 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
27 04 at NEW, 05 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
28 05 at NEW, 06 at OLD |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
29 06 at NEW |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
30 07 at NEW |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
31 08 at NEW |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
32 09 at NEW |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
33 10 at NEW |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
34 11 at NEW |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
35 '''[1:] # strip initial LF |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
36 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
37 def filteredblocks(blocks, rangeb): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
38 """return `rangea` extracted from `blocks` coming from |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
39 `mdiff.blocksinrange` along with the mask of blocks within rangeb. |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
40 """ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
41 filtered, rangea = mdiff.blocksinrange(blocks, rangeb) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
42 skipped = [b not in filtered for b in blocks] |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
43 return rangea, skipped |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
44 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
45 class blocksinrangetests(unittest.TestCase): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
46 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
47 def setUp(self): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
48 self.blocks = list(mdiff.allblocks(text1, text2)) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
49 assert self.blocks == [ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
50 ([0, 3, 0, 2], '!'), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
51 ((3, 7, 2, 6), '='), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
52 ([7, 12, 6, 12], '!'), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
53 ((12, 12, 12, 12), '='), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
54 ], self.blocks |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
55 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
56 def testWithinEqual(self): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
57 """linerange within an "=" block""" |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
58 # IDX 0 1 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
59 # 012345678901 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
60 # SRC NNOOOONNNNNN (New/Old) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
61 # ^^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
62 linerange2 = (3, 5) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
63 linerange1, skipped = filteredblocks(self.blocks, linerange2) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
64 self.assertEqual(linerange1, (4, 6)) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
65 self.assertEqual(skipped, [True, False, True, True]) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
66 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
67 def testWithinEqualStrictly(self): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
68 """linerange matching exactly an "=" block""" |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
69 # IDX 0 1 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
70 # 012345678901 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
71 # SRC NNOOOONNNNNN (New/Old) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
72 # ^^^^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
73 linerange2 = (2, 6) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
74 linerange1, skipped = filteredblocks(self.blocks, linerange2) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
75 self.assertEqual(linerange1, (3, 7)) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
76 self.assertEqual(skipped, [True, False, True, True]) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
77 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
78 def testWithinEqualLowerbound(self): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
79 """linerange at beginning of an "=" block""" |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
80 # IDX 0 1 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
81 # 012345678901 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
82 # SRC NNOOOONNNNNN (New/Old) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
83 # ^^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
84 linerange2 = (2, 4) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
85 linerange1, skipped = filteredblocks(self.blocks, linerange2) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
86 self.assertEqual(linerange1, (3, 5)) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
87 self.assertEqual(skipped, [True, False, True, True]) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
88 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
89 def testWithinEqualLowerboundOneline(self): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
90 """oneline-linerange at beginning of an "=" block""" |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
91 # IDX 0 1 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
92 # 012345678901 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
93 # SRC NNOOOONNNNNN (New/Old) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
94 # ^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
95 linerange2 = (2, 3) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
96 linerange1, skipped = filteredblocks(self.blocks, linerange2) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
97 self.assertEqual(linerange1, (3, 4)) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
98 self.assertEqual(skipped, [True, False, True, True]) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
99 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
100 def testWithinEqualUpperbound(self): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
101 """linerange at end of an "=" block""" |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
102 # IDX 0 1 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
103 # 012345678901 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
104 # SRC NNOOOONNNNNN (New/Old) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
105 # ^^^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
106 linerange2 = (3, 6) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
107 linerange1, skipped = filteredblocks(self.blocks, linerange2) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
108 self.assertEqual(linerange1, (4, 7)) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
109 self.assertEqual(skipped, [True, False, True, True]) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
110 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
111 def testWithinEqualUpperboundOneLine(self): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
112 """oneline-linerange at end of an "=" block""" |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
113 # IDX 0 1 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
114 # 012345678901 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
115 # SRC NNOOOONNNNNN (New/Old) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
116 # ^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
117 linerange2 = (5, 6) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
118 linerange1, skipped = filteredblocks(self.blocks, linerange2) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
119 self.assertEqual(linerange1, (6, 7)) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
120 self.assertEqual(skipped, [True, False, True, True]) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
121 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
122 def testWithinFirstBlockNeq(self): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
123 """linerange within the first "!" block""" |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
124 # IDX 0 1 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
125 # 012345678901 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
126 # SRC NNOOOONNNNNN (New/Old) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
127 # ^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
128 # | (empty) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
129 # ^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
130 # ^^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
131 for linerange2 in [ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
132 (0, 1), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
133 (1, 1), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
134 (1, 2), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
135 (0, 2), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
136 ]: |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
137 linerange1, skipped = filteredblocks(self.blocks, linerange2) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
138 self.assertEqual(linerange1, (0, 3)) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
139 self.assertEqual(skipped, [False, True, True, True]) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
140 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
141 def testWithinLastBlockNeq(self): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
142 """linerange within the last "!" block""" |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
143 # IDX 0 1 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
144 # 012345678901 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
145 # SRC NNOOOONNNNNN (New/Old) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
146 # ^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
147 # ^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
148 # | (empty) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
149 # ^^^^^^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
150 # ^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
151 for linerange2 in [ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
152 (6, 7), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
153 (7, 8), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
154 (7, 7), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
155 (6, 12), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
156 (11, 12), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
157 ]: |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
158 linerange1, skipped = filteredblocks(self.blocks, linerange2) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
159 self.assertEqual(linerange1, (7, 12)) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
160 self.assertEqual(skipped, [True, True, False, True]) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
161 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
162 def testAccrossTwoBlocks(self): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
163 """linerange accross two blocks""" |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
164 # IDX 0 1 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
165 # 012345678901 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
166 # SRC NNOOOONNNNNN (New/Old) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
167 # ^^^^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
168 linerange2 = (1, 5) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
169 linerange1, skipped = filteredblocks(self.blocks, linerange2) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
170 self.assertEqual(linerange1, (0, 6)) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
171 self.assertEqual(skipped, [False, False, True, True]) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
172 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
173 def testCrossingSeveralBlocks(self): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
174 """linerange accross three blocks""" |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
175 # IDX 0 1 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
176 # 012345678901 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
177 # SRC NNOOOONNNNNN (New/Old) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
178 # ^^^^^^^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
179 linerange2 = (1, 8) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
180 linerange1, skipped = filteredblocks(self.blocks, linerange2) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
181 self.assertEqual(linerange1, (0, 12)) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
182 self.assertEqual(skipped, [False, False, False, True]) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
183 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
184 def testStartInEqBlock(self): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
185 """linerange starting in an "=" block""" |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
186 # IDX 0 1 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
187 # 012345678901 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
188 # SRC NNOOOONNNNNN (New/Old) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
189 # ^^^^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
190 # ^^^^^^^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
191 for linerange2, expectedlinerange1 in [ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
192 ((5, 9), (6, 12)), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
193 ((4, 11), (5, 12)), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
194 ]: |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
195 linerange1, skipped = filteredblocks(self.blocks, linerange2) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
196 self.assertEqual(linerange1, expectedlinerange1) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
197 self.assertEqual(skipped, [True, False, False, True]) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
198 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
199 def testEndInEqBlock(self): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
200 """linerange ending in an "=" block""" |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
201 # IDX 0 1 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
202 # 012345678901 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
203 # SRC NNOOOONNNNNN (New/Old) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
204 # ^^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
205 # ^^^^^ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
206 for linerange2, expectedlinerange1 in [ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
207 ((1, 3), (0, 4)), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
208 ((0, 4), (0, 5)), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
209 ]: |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
210 linerange1, skipped = filteredblocks(self.blocks, linerange2) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
211 self.assertEqual(linerange1, expectedlinerange1) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
212 self.assertEqual(skipped, [False, False, True, True]) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
213 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
214 def testOutOfRange(self): |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
215 """linerange exceeding file size""" |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
216 exctype = error.Abort |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
217 for linerange2 in [ |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
218 (0, 34), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
219 (15, 12), |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
220 ]: |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
221 # Could be `with self.assertRaises(error.Abort)` but python2.6 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
222 # does not have assertRaises context manager. |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
223 try: |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
224 mdiff.blocksinrange(self.blocks, linerange2) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
225 except exctype as exc: |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
226 self.assertTrue('line range exceeds file size' in str(exc)) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
227 else: |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
228 self.fail('%s not raised' % exctype.__name__) |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
229 |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
230 if __name__ == '__main__': |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
231 import silenttestrunner |
3eeb8e138e5c
mdiff: add a "blocksinrange" function to filter diff blocks by line range
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff
changeset
|
232 silenttestrunner.main(__name__) |