Use filter-branch to correct the trunk/packages/$package/$package
authorEvan Broder <broder@mit.edu>
Thu, 25 Dec 2008 07:33:38 +0000 (02:33 -0500)
committerEvan Broder <broder@mit.edu>
Thu, 25 Dec 2008 07:33:38 +0000 (02:33 -0500)
setup from earlier in the repo history.

svn path=/trunk/scripts/git-migration/; revision=1898

filter-subdirs [new file with mode: 0755]
git-migrate

diff --git a/filter-subdirs b/filter-subdirs
new file mode 100755 (executable)
index 0000000..3e44a8d
--- /dev/null
@@ -0,0 +1,23 @@
+#!/usr/bin/python
+
+import sys
+import os
+import subprocess
+
+tree = sys.argv[1]
+package = os.environ['PACKAGE']
+
+p = subprocess.Popen(['git', 'ls-tree',
+                      tree,
+                      package],
+                     stdout=subprocess.PIPE,
+                     stdin=subprocess.PIPE)
+p.wait()
+t = p.stdout.read().strip().split()
+
+if t != [] and t[1] == 'tree':
+    tree = t[2]
+
+subprocess.check_call(['git', 'commit-tree',
+                       tree] + sys.argv[2:],
+                      stdin=sys.stdin)
index c116db5..c5886a9 100755 (executable)
@@ -62,6 +62,18 @@ def clonePackage(base, pkg):
         subprocess.check_call(['git', 'reset', '--soft', 'HEAD^'],
                               cwd='%s.git' % pkg)
     
         subprocess.check_call(['git', 'reset', '--soft', 'HEAD^'],
                               cwd='%s.git' % pkg)
     
+    # Early in the project's history, there were a bunch of double
+    # directory trees - i.e. the source was actually in
+    # trunk/packages/$package/$package. Correct for that
+    cwd = os.getcwd()
+    os.environ['PACKAGE'] = pkg
+    p = subprocess.check_call(['git', 'filter-branch',
+                               '--commit-filter', '%s "$@"' % os.path.join(cwd, 'filter-subdirs'),
+                               '--tag-name-filter', 'cat',
+                               '--',
+                               '--all'],
+                              cwd='%s.git' % pkg)
+    
     tagBase(pkg)
 
 def cloneAllPackages(base):
     tagBase(pkg)
 
 def cloneAllPackages(base):