From c96eea184cfd5d03af68db9a48860b354c607f6a Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Thu, 25 Dec 2008 02:33:38 -0500 Subject: [PATCH] Use filter-branch to correct the trunk/packages/$package/$package setup from earlier in the repo history. svn path=/trunk/scripts/git-migration/; revision=1898 --- filter-subdirs | 23 +++++++++++++++++++++++ git-migrate | 12 ++++++++++++ 2 files changed, 35 insertions(+) create mode 100755 filter-subdirs diff --git a/filter-subdirs b/filter-subdirs new file mode 100755 index 0000000..3e44a8d --- /dev/null +++ b/filter-subdirs @@ -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) diff --git a/git-migrate b/git-migrate index c116db5..c5886a9 100755 --- a/git-migrate +++ b/git-migrate @@ -62,6 +62,18 @@ def clonePackage(base, 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): -- 1.7.9.5