[oe-commits] org.oe.dev mtnpatch: resurrect mtnpatch

justinp commit openembedded-commits at lists.openembedded.org
Tue Sep 5 16:29:09 UTC 2006


mtnpatch: resurrect mtnpatch

Author: justinp at openembedded.org
Branch: org.openembedded.dev
Revision: 4e7386151d1273724db821c550dbd7106a83f5ab
ViewMTN: http://monotone.openembedded.org/revision.psp?id=4e7386151d1273724db821c550dbd7106a83f5ab
Files:
1
contrib/mtnpatch.py
mtn:execute
true
Diffs:

#
# mt diff -rc6ec5439acd914995223480fe072be1b263ab120 -r4e7386151d1273724db821c550dbd7106a83f5ab
#
# 
# 
# add_file "contrib/mtnpatch.py"
#  content [ac24174963d8b986599a91a0e9c36648d8b0c120]
# 
#   set "contrib/mtnpatch.py"
#  attr "mtn:execute"
# value "true"
# 
============================================================
--- contrib/mtnpatch.py	ac24174963d8b986599a91a0e9c36648d8b0c120
+++ contrib/mtnpatch.py	ac24174963d8b986599a91a0e9c36648d8b0c120
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+import sys, os, string, getopt, re
+
+mtncmd = "monotone"
+
+def main(argv = None):
+    if argv is None:
+        argv = sys.argv
+    opts, list = getopt.getopt(sys.argv[1:], ':R')
+    if len(list) < 1:
+        print "You must specify a file"
+        return 2
+    reverse = False
+    for o, a in opts:
+        if o == "-R":
+            reverse = True
+    if os.path.exists(list[0]):
+        input = open(list[0], 'r')
+        renameFrom = ""
+        cmd = ""
+        if reverse:
+            print "patch -R -p0 < %s" % list[0]
+        else:
+            print "patch -p0 < %s" % list[0]
+        for line in input:
+            if len(line) > 0:
+                if line[0] == '#':
+                    matches = re.search("#\s+(\w+)\s+\"(.*)\"", line)
+                    if matches is not None:
+                        cmd = matches.group(1)
+                        fileName = matches.group(2)
+                        if cmd == "delete_file":
+                            if reverse:
+                                print "%s add %s" % (mtncmd, fileName)
+                            else:
+                                print "%s drop -e %s" % (mtncmd, fileName)
+                        elif cmd == "add_file":
+                            if reverse:
+                                print "%s drop -e %s" % (mtncmd, fileName)
+                            else:
+                                print "%s add %s" % (mtncmd, fileName)
+                        elif cmd == "rename_file":
+                            renameFrom = fileName
+                        elif cmd == "to" and renameFrom != "":
+                            if reverse:
+                                print "%s rename -e %s %s" % (mtncmd, fileName, renameFrom)
+                            else:
+                                print "%s rename -e %s %s" % (mtncmd, renameFrom, fileName)
+                            renameFrom = ""
+                        else:
+                            cmd = ""
+
+if __name__ == "__main__":
+    sys.exit(main())






More information about the Openembedded-commits mailing list