Created
November 27, 2012 14:26
-
-
Save eiyaya/4154490 to your computer and use it in GitHub Desktop.
count svn diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/bin/env python | |
diff=""" | |
- | |
- | |
- | |
- | |
- | |
- | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
- | |
- | |
- | |
+ | |
+ | |
+ | |
+ | |
+ | |
- | |
""" | |
def main(): | |
count,da,dm,dd,ta,tm,td = 0,0,0,0,0,0,0 | |
for line in diff.split("\n"): | |
count += 1 | |
print ("line %d: %d %d %d" % (count,da,dm,dd)) | |
if line.startswith(" "): | |
dm = da if da < dd else dd | |
da -= dm | |
dd -= dm | |
ta += da | |
tm += dm | |
td += dd | |
da,dm,dd = 0,0,0 | |
pass | |
if line.startswith("+"): | |
da += 1 | |
pass | |
if line.startswith("-"): | |
dd += 1 | |
pass | |
pass | |
print("%d %d %d" % (ta,tm,td)) | |
pass | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment