From: Evan Broder Date: Wed, 24 Dec 2008 22:46:16 +0000 (-0500) Subject: Create the info/grafts files. X-Git-Url: http://xvm.mit.edu/gitweb/invirt/scripts/git-migration.git/commitdiff_plain/8a400ded68b16317a3e3c96f7bd5cf3d632ebe86 Create the info/grafts files. svn path=/trunk/scripts/git-migration/; revision=1882 --- diff --git a/git-migrate b/git-migrate index b79053a..7440717 100755 --- a/git-migrate +++ b/git-migrate @@ -44,7 +44,41 @@ def mergeHistory(old_pkg, new_pkg, n): subprocess.check_call(['git', 'push', 'file:///%s/%s.git' % (cwd, new_pkg), 'master:refs/heads/%s' % old_pkg], - cwd=new_pkg) + cwd='%s.git' % new_pkg) + + graft = [] + p = subprocess.Popen(['git', 'rev-list', + '--reverse', + '--skip=%s' % n, + 'master'], + cwd='%s.git' % new_pkg, + stdout=subprocess.PIPE) + p.wait() + new_rev = p.stdout.read().split()[0] + graft.append(new_rev) + + # If n isn't 0, then n has a parent commit already that we + # shouldn't forget about. + if n != 0: + p = subprocess.Popen(['git', 'rev-parse', + '%s^' % new_rev], + cwd='%s.git' % new_pkg, + stdout=subprocess.PIPE) + p.wait() + graft.append(p.stdout.read().strip()) + + # And regardless, the HEAD of old_pkg should be a parent of + # new_pkg + p = subprocess.Popen(['git', 'rev-parse', + 'master'], + cwd='%s.git' % old_pkg, + stdout=subprocess.PIPE) + p.wait() + graft.append(p.stdout.read().strip()) + + f = open('%s.git/info/grafts' % new_pkg, 'a') + + print >>f, ' '.join(graft) def mergeHistories(): for line in open('grafts'):