1024 def new(self, repo, patchfn, *pats, **opts): |
1024 def new(self, repo, patchfn, *pats, **opts): |
1025 """options: |
1025 """options: |
1026 msg: a string or a no-argument function returning a string |
1026 msg: a string or a no-argument function returning a string |
1027 """ |
1027 """ |
1028 msg = opts.get('msg') |
1028 msg = opts.get('msg') |
|
1029 editor = opts.get('editor') |
1029 user = opts.get('user') |
1030 user = opts.get('user') |
1030 date = opts.get('date') |
1031 date = opts.get('date') |
1031 if date: |
1032 if date: |
1032 date = util.parsedate(date) |
1033 date = util.parsedate(date) |
1033 diffopts = self.diffopts({'git': opts.get('git')}) |
1034 diffopts = self.diffopts({'git': opts.get('git')}) |
1076 + hex(repo[None].p1().node()) + "\n") |
1077 + hex(repo[None].p1().node()) + "\n") |
1077 if user: |
1078 if user: |
1078 p.write("# User " + user + "\n") |
1079 p.write("# User " + user + "\n") |
1079 if date: |
1080 if date: |
1080 p.write("# Date %s %s\n\n" % date) |
1081 p.write("# Date %s %s\n\n" % date) |
1081 if util.safehasattr(msg, '__call__'): |
1082 |
1082 msg = msg() |
1083 defaultmsg = "[mq]: %s" % patchfn |
1083 repo.savecommitmessage(msg) |
1084 if editor: |
1084 commitmsg = msg and msg or ("[mq]: %s" % patchfn) |
1085 origeditor = editor |
|
1086 def desceditor(repo, ctx, subs): |
|
1087 desc = origeditor(repo, ctx, subs) |
|
1088 if desc.rstrip(): |
|
1089 return desc |
|
1090 else: |
|
1091 return defaultmsg |
|
1092 commitmsg = msg |
|
1093 editor = desceditor |
|
1094 else: |
|
1095 commitmsg = msg or defaultmsg |
|
1096 |
1085 n = newcommit(repo, None, commitmsg, user, date, match=match, |
1097 n = newcommit(repo, None, commitmsg, user, date, match=match, |
1086 force=True) |
1098 force=True, editor=editor) |
1087 if n is None: |
1099 if n is None: |
1088 raise util.Abort(_("repo commit failed")) |
1100 raise util.Abort(_("repo commit failed")) |
1089 try: |
1101 try: |
1090 self.fullseries[insert:insert] = [patchfn] |
1102 self.fullseries[insert:insert] = [patchfn] |
1091 self.applied.append(statusentry(n, patchfn)) |
1103 self.applied.append(statusentry(n, patchfn)) |
1092 self.parseseries() |
1104 self.parseseries() |
1093 self.seriesdirty = True |
1105 self.seriesdirty = True |
1094 self.applieddirty = True |
1106 self.applieddirty = True |
1095 if msg: |
1107 nctx = repo[n] |
1096 msg = msg + "\n\n" |
1108 if nctx.description() != defaultmsg.rstrip(): |
|
1109 msg = nctx.description() + "\n\n" |
1097 p.write(msg) |
1110 p.write(msg) |
1098 if commitfiles: |
1111 if commitfiles: |
1099 parent = self.qparents(repo, n) |
1112 parent = self.qparents(repo, n) |
1100 if inclsubs: |
1113 if inclsubs: |
1101 self.putsubstate2changes(substatestate, changes) |
1114 self.putsubstate2changes(substatestate, changes) |
2415 information. |
2428 information. |
2416 |
2429 |
2417 Returns 0 on successful creation of a new patch. |
2430 Returns 0 on successful creation of a new patch. |
2418 """ |
2431 """ |
2419 msg = cmdutil.logmessage(ui, opts) |
2432 msg = cmdutil.logmessage(ui, opts) |
2420 def getmsg(): |
|
2421 return ui.edit(msg, opts.get('user') or ui.username()) |
|
2422 q = repo.mq |
2433 q = repo.mq |
2423 opts['msg'] = msg |
2434 opts['msg'] = msg |
2424 if opts.get('edit'): |
2435 if opts.get('edit'): |
2425 opts['msg'] = getmsg |
2436 def editor(repo, ctx, subs): |
2426 else: |
2437 return ui.edit(ctx.description() + "\n", ctx.user()) |
2427 opts['msg'] = msg |
2438 opts['editor'] = editor |
2428 setupheaderopts(ui, opts) |
2439 setupheaderopts(ui, opts) |
2429 q.new(repo, patch, *args, **opts) |
2440 q.new(repo, patch, *args, **opts) |
2430 q.savedirty() |
2441 q.savedirty() |
2431 return 0 |
2442 return 0 |
2432 |
2443 |