forked from edwardbadboy/pydiff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
65 lines (42 loc) · 1.4 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
python pydiff.py [--diffdoc] file1 file2
Compare Python scripts in syntax level, not in text level.
This tool can help you to find changes in code logic, ignoring
code style changes.
It does not compare docstrings by default.
Add --diffdoc option to compare docstrings as well.
Example usage:
test_o.py
def foo(a, b):
pass
if __name__ == '__main__':
A = [1, 2, 3]
print (4, 5, 6), \
"over"
foo(1, 2)
print 'Hello World'
test_n.py
def foo(a, b):
pass
if __name__ == '__main__':
A = [1,
2, 3]
print (4, 5, 6), "over"
fooo(
1, 2)
print ('Hello '
'World')
These two files are different, but some differences are just a matter of style.
The only significant difference is the function call "foo()" is misspelled in test_n.py.
Run pydiff.py, it will report:
$ python pydiff.py test_*.py
1 difference(s)
first file: test_n.py
second file: test_o.py
((8, 'fooo'), (8, 'foo'))
This report tells us the changes that might affect the logic of the code, and print related line numbers.
In fact pydiff parses the files into Abstract Syntax Tree, and compare the trees recursively.
It can also find insertions and deletions.
gitpydiff [commitID|branch or tag ref]
pydiff all .py and .py.in files in a git commit to it's parent commit.
install.sh
make symbol link /usr/bin/pydiff to pydiff.py and /usr/bin/gitpydiff to gitpydiff.