Code

Added a little helper script to remove unused tags from the perforce import.
[git.git] / contrib / fast-import / p4-clean-tags.py
1 #!/usr/bin/python
2 #
3 # p4-debug.py
4 #
5 # Author: Simon Hausmann <hausmann@kde.org>
6 # License: MIT <http://www.opensource.org/licenses/mit-license.php>
7 #
8 # removes unused p4 import tags
9 #
10 import os, string, sys
11 import popen2, getopt
13 branch = "refs/heads/master"
15 try:
16     opts, args = getopt.getopt(sys.argv[1:], "", [ "branch=" ])
17 except getopt.GetoptError:
18     print "fixme, syntax error"
19     sys.exit(1)
21 for o, a in opts:
22     if o == "--branch":
23         branch = "refs/heads/" + a
25 sout, sin, serr = popen2.popen3("git-name-rev --tags `git-rev-parse %s`" % branch)
26 output = sout.read()
27 tagIdx = output.index(" tags/p4/")
28 caretIdx = output.index("^")
29 rev = int(output[tagIdx + 9 : caretIdx])
31 allTags = os.popen("git tag -l p4/").readlines()
32 for i in range(len(allTags)):
33     allTags[i] = int(allTags[i][3:-1])
35 allTags.sort()
37 allTags.remove(rev)
39 for rev in allTags:
40     print os.popen("git tag -d p4/%s" % rev).read()