Mercurial > hg
comparison hgext/mq.py @ 21420:d009f6555b81
mq: fold the code path to invoke editor into specific logic (qnew)
This factoring simplifies the succeeding patch to switch from
"ui.edit()" to "getcommiteditor()" for qnew.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Sun, 11 May 2014 00:49:36 +0900 |
parents | 8fd982139740 |
children | 4941caa9f0f8 |
comparison
equal
deleted
inserted
replaced
21419:272785489ed3 | 21420:d009f6555b81 |
---|---|
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 edit = opts.get('edit') |
1030 user = opts.get('user') | 1030 user = opts.get('user') |
1031 date = opts.get('date') | 1031 date = opts.get('date') |
1032 if date: | 1032 if date: |
1033 date = util.parsedate(date) | 1033 date = util.parsedate(date) |
1034 diffopts = self.diffopts({'git': opts.get('git')}) | 1034 diffopts = self.diffopts({'git': opts.get('git')}) |
1079 p.write("# User " + user + "\n") | 1079 p.write("# User " + user + "\n") |
1080 if date: | 1080 if date: |
1081 p.write("# Date %s %s\n\n" % date) | 1081 p.write("# Date %s %s\n\n" % date) |
1082 | 1082 |
1083 defaultmsg = "[mq]: %s" % patchfn | 1083 defaultmsg = "[mq]: %s" % patchfn |
1084 if editor: | 1084 editor = False |
1085 origeditor = editor | 1085 if edit: |
1086 def desceditor(repo, ctx, subs): | 1086 def desceditor(repo, ctx, subs): |
1087 desc = origeditor(repo, ctx, subs) | 1087 desc = self.ui.edit(ctx.description() + "\n", |
1088 ctx.user()) | |
1088 if desc.rstrip(): | 1089 if desc.rstrip(): |
1089 return desc | 1090 return desc |
1090 else: | 1091 else: |
1091 return defaultmsg | 1092 return defaultmsg |
1092 commitmsg = msg | 1093 commitmsg = msg |
2440 Returns 0 on successful creation of a new patch. | 2441 Returns 0 on successful creation of a new patch. |
2441 """ | 2442 """ |
2442 msg = cmdutil.logmessage(ui, opts) | 2443 msg = cmdutil.logmessage(ui, opts) |
2443 q = repo.mq | 2444 q = repo.mq |
2444 opts['msg'] = msg | 2445 opts['msg'] = msg |
2445 if opts.get('edit'): | |
2446 def editor(repo, ctx, subs): | |
2447 return ui.edit(ctx.description() + "\n", ctx.user()) | |
2448 opts['editor'] = editor | |
2449 setupheaderopts(ui, opts) | 2446 setupheaderopts(ui, opts) |
2450 q.new(repo, patch, *args, **opts) | 2447 q.new(repo, patch, *args, **opts) |
2451 q.savedirty() | 2448 q.savedirty() |
2452 return 0 | 2449 return 0 |
2453 | 2450 |