Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 21240:1a833fcf5a14
amend: use "editor" argument for "memctx.__init__" to save commit message
This patch uses "editor" argument of "memctx.__init__" to save commit
message, instead of explicit editor invocation and saving commit
message by "localrepository.savecommitmessage()".
By passing one of "commiteditor" or "commitforceeditor" as "editor",
"memctx.__init__" saves commit message, even when editor invocation is
not needed.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Mon, 05 May 2014 21:26:40 +0900 |
parents | 69402eb72115 |
children | 244b177a152e |
comparison
equal
deleted
inserted
replaced
21239:19d98da5c018 | 21240:1a833fcf5a14 |
---|---|
2043 except KeyError: | 2043 except KeyError: |
2044 raise IOError | 2044 raise IOError |
2045 | 2045 |
2046 user = opts.get('user') or old.user() | 2046 user = opts.get('user') or old.user() |
2047 date = opts.get('date') or old.date() | 2047 date = opts.get('date') or old.date() |
2048 editmsg = False | 2048 editor = commiteditor |
2049 if not message: | 2049 if not message: |
2050 editmsg = True | 2050 editor = commitforceeditor |
2051 message = old.description() | 2051 message = old.description() |
2052 elif opts.get('edit'): | 2052 elif opts.get('edit'): |
2053 editmsg = True | 2053 editor = commitforceeditor |
2054 | 2054 |
2055 pureextra = extra.copy() | 2055 pureextra = extra.copy() |
2056 extra['amend_source'] = old.hex() | 2056 extra['amend_source'] = old.hex() |
2057 | 2057 |
2058 new = context.memctx(repo, | 2058 new = context.memctx(repo, |
2060 text=message, | 2060 text=message, |
2061 files=files, | 2061 files=files, |
2062 filectxfn=filectxfn, | 2062 filectxfn=filectxfn, |
2063 user=user, | 2063 user=user, |
2064 date=date, | 2064 date=date, |
2065 extra=extra) | 2065 extra=extra, |
2066 if editmsg: | 2066 editor=editor) |
2067 new._text = commitforceeditor(repo, new, []) | |
2068 repo.savecommitmessage(new.description()) | |
2069 | 2067 |
2070 newdesc = changelog.stripdesc(new.description()) | 2068 newdesc = changelog.stripdesc(new.description()) |
2071 if ((not node) | 2069 if ((not node) |
2072 and newdesc == old.description() | 2070 and newdesc == old.description() |
2073 and user == old.user() | 2071 and user == old.user() |