Merge branch 'org.openembedded.dev' of git://git.openembedded.net/openembedded into...
[vuplus_openembedded] / contrib / mtnpatch.py
old mode 100644 (file)
new mode 100755 (executable)
index 520ebfa..4de9ecc
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
-import sys, os, string, getopt
+import sys, os, string, getopt, re
 
-mtncmd = "monotone"
+mtncmd = "mtn"
 
 def main(argv = None):
     if argv is None:
@@ -18,32 +18,24 @@ def main(argv = None):
         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] == '#':
-                    parts = line.split()
-                    if len(parts) > 2:
-                        cmd = parts[1]
-                        # deal with whilespace in filenames (badly)
-                        fileName = parts[2]
-                        i = 3
-                        while i < len(parts) and fileName.count('"') % 2:
-                            fileName += " %s" % parts[i]
-                        if cmd == "delete_file":
+                    matches = re.search("#\s+(\w+)\s+\"(.*)\"", line)
+                    if matches is not None:
+                        cmd = matches.group(1)
+                        fileName = matches.group(2)
+                        if cmd == "delete":
                             if reverse:
                                 print "%s add %s" % (mtncmd, fileName)
                             else:
                                 print "%s drop -e %s" % (mtncmd, fileName)
-                        elif cmd == "add_file":
+                        elif cmd == "add" or cmd == "add_file" or cmd == "add_dir":
                             if reverse:
                                 print "%s drop -e %s" % (mtncmd, fileName)
                             else:
                                 print "%s add %s" % (mtncmd, fileName)
-                        elif cmd == "rename_file":
+                        elif cmd == "rename":
                             renameFrom = fileName
                         elif cmd == "to" and renameFrom != "":
                             if reverse:
@@ -53,6 +45,10 @@ def main(argv = None):
                             renameFrom = ""
                         else:
                             cmd = ""
+        if reverse:
+            print "patch -R -p0 < %s" % list[0]
+        else:
+            print "patch -p0 < %s" % list[0]
 
 if __name__ == "__main__":
     sys.exit(main())