I'm not happy with the semantics of that first go at
[invirt/scripts/git-migration.git] / git-migrate
index edd916c..909a604 100755 (executable)
@@ -32,7 +32,7 @@ def clonePackage(base, pkg):
                          stdout=subprocess.PIPE)
     p.wait()
     if len(p.stdout.read()) == 0:
-        subprocess.check_call(['git', 'reset', 'HEAD^'],
+        subprocess.check_call(['git', 'reset', '--soft', 'HEAD^'],
                               cwd='%s.git' % pkg)
 
 def cloneAllPackages(base):
@@ -40,16 +40,23 @@ def cloneAllPackages(base):
         clonePackage(base, pkg.strip())
 
 def mergeHistory(old_pkg, new_pkg, n):
-    pass
+    cwd = os.getcwd()
+    subprocess.check_call(['git', 'push',
+                           'file:///%s/%s.git' % (cwd, new_pkg),
+                           'master:refs/heads/%s' % old_pkg],
+                          cwd='%s.git' % old_pkg)
 
 def mergeHistories():
-    for line in open('grafts'):
+    merges = []
+    for line in open('merges'):
         line = line.strip()
-        if line[0] == '#' or line == '':
+        if line == '' or line[0] == '#':
             continue
         
-        old_pkg, new_pkg, n = line.split()
-        mergeHistory(old_pkg, new_pkg, int(n))
+        merges.append(line.split())
+    
+    for merge in merges:
+        mergeHistory(*merge)
 
 if __name__ == '__main__':
     try: