Build number python script
authorBrandon King <kingb@caltech.edu>
Fri, 13 Oct 2006 22:52:24 +0000 (22:52 +0000)
committerBrandon King <kingb@caltech.edu>
Fri, 13 Oct 2006 22:52:24 +0000 (22:52 +0000)
 * Reports the build number of a given darcs repository of mussa.
 * In support for ticket:124.

makelib/buildnum.py [new file with mode: 0644]

diff --git a/makelib/buildnum.py b/makelib/buildnum.py
new file mode 100644 (file)
index 0000000..863ce85
--- /dev/null
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+
+import re
+import subprocess
+import sys
+
+#_build_search = re.compile('^(Mon)|(Tue)|(Wed)|(Thu)|(Fri)|(Sat)|(Sun)', re.MULTILINE)
+_build_search = re.compile('</patch>', re.MULTILINE)
+
+def getBuildNumber():
+  """Counts the number of patches that have been made and
+  returns that as the build number."""
+  
+  p = subprocess.Popen(['darcs', 'changes', '--xml-output'], stdout=subprocess.PIPE)
+  data = p.stdout.read()
+  build_num = len(_build_search.findall(data))
+  return build_num
+  
+if __name__ == '__main__':
+  print "%s" % (getBuildNumber())