Add a "--notags" option for git-p4import.

P4import currently creates a git tag for every commit it imports.
When importing from a large repository too many tags can be created
for git to manage, so this provides an option to shut that feature
off if necessary.

Signed-off-by: Sean Estabrooks <seanlkml@sympatico.ca>
This commit is contained in:
Sean 2006-06-15 17:26:21 -04:00 committed by Junio C Hamano
parent 5b139a66fc
commit ada7781dc3
2 changed files with 12 additions and 5 deletions

View File

@ -8,7 +8,7 @@ git-p4import - Import a Perforce repository into git
SYNOPSIS SYNOPSIS
-------- --------
`git-p4import` [-q|-v] [--authors <file>] [-t <timezone>] <//p4repo/path> <branch> `git-p4import` [-q|-v] [--notags] [--authors <file>] [-t <timezone>] <//p4repo/path> <branch>
`git-p4import` --stitch <//p4repo/path> `git-p4import` --stitch <//p4repo/path>
@ -43,6 +43,9 @@ OPTIONS
Specify an authors file containing a mapping of Perforce user Specify an authors file containing a mapping of Perforce user
ids to full names and email addresses (see Notes below). ids to full names and email addresses (see Notes below).
\--notags::
Do not create a tag for each imported commit.
\--stitch:: \--stitch::
Import the contents of the given perforce branch into the Import the contents of the given perforce branch into the
currently checked out git branch. currently checked out git branch.

View File

@ -23,7 +23,6 @@ s = signal(SIGINT, SIG_DFL)
if s != default_int_handler: if s != default_int_handler:
signal(SIGINT, s) signal(SIGINT, s)
def die(msg, *args): def die(msg, *args):
for a in args: for a in args:
msg = "%s %s" % (msg, a) msg = "%s %s" % (msg, a)
@ -38,6 +37,7 @@ verbosity = 1
logfile = "/dev/null" logfile = "/dev/null"
ignore_warnings = False ignore_warnings = False
stitch = 0 stitch = 0
tagall = True
def report(level, msg, *args): def report(level, msg, *args):
global verbosity global verbosity
@ -261,10 +261,9 @@ class git_command:
self.make_tag("p4/%s"%id, commit) self.make_tag("p4/%s"%id, commit)
self.git("update-ref HEAD %s %s" % (commit, current) ) self.git("update-ref HEAD %s %s" % (commit, current) )
try: try:
opts, args = getopt.getopt(sys.argv[1:], "qhvt:", opts, args = getopt.getopt(sys.argv[1:], "qhvt:",
["authors=","help","stitch=","timezone=","log=","ignore"]) ["authors=","help","stitch=","timezone=","log=","ignore","notags"])
except getopt.GetoptError: except getopt.GetoptError:
usage() usage()
@ -275,6 +274,8 @@ for o, a in opts:
verbosity += 1 verbosity += 1
if o in ("--log"): if o in ("--log"):
logfile = a logfile = a
if o in ("--notags"):
tagall = False
if o in ("-h", "--help"): if o in ("-h", "--help"):
usage() usage()
if o in ("--ignore"): if o in ("--ignore"):
@ -350,7 +351,10 @@ for id in changes:
report(1, "Importing changeset", id) report(1, "Importing changeset", id)
change = p4.describe(id) change = p4.describe(id)
p4.sync(id) p4.sync(id)
if tagall :
git.commit(change.author, change.email, change.date, change.msg, id) git.commit(change.author, change.email, change.date, change.msg, id)
else:
git.commit(change.author, change.email, change.date, change.msg, "import")
if stitch == 1: if stitch == 1:
git.clean_directories() git.clean_directories()
stitch = 0 stitch = 0