Skip to content

Instantly share code, notes, and snippets.

@eiyaya
Created November 27, 2012 14:26
Show Gist options
  • Save eiyaya/4154490 to your computer and use it in GitHub Desktop.
Save eiyaya/4154490 to your computer and use it in GitHub Desktop.
count svn diff
#/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