+
+def import_commit(parser, options, args):
+ """Import a commit object as a new patch
+ """
+ if len(args) != 1:
+ parser.error('incorrect number of arguments')
+
+ commit_id = args[0]
+
+ if options.name:
+ patch = options.name
+ else:
+ raise CmdException, 'Unkown patch name'
+
+ commit = git.Commit(commit_id)
+
+ if not options.reverse:
+ bottom = commit.get_parent()
+ top = commit_id
+ else:
+ bottom = commit_id
+ top = commit.get_parent()
+
+ message = commit.get_log()
+ author_name, author_email, author_date = \
+ name_email_date(commit.get_author())
+
+ print 'Importing commit %s...' % commit_id,
+ sys.stdout.flush()
+
+ crt_series.new_patch(patch, message = message, can_edit = False,
+ unapplied = True, bottom = bottom, top = top,
+ author_name = author_name,
+ author_email = author_email,
+ author_date = author_date)
+ crt_series.push_patch(patch)
+
+ print 'done'
+ print_crt_patch()
+
+def func(parser, options, args):
+ """Import a GNU diff file or a commit object as a new patch
+ """
+ check_local_changes()
+ check_conflicts()
+ check_head_top_equal()
+
+ if options.commit:
+ import_commit(parser, options, args)
+ else:
+ import_file(parser, options, args)