Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/cmdutil.py @ 8407:223000a687b0
commit: move commit editor to cmdutil, pass as function
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 14 May 2009 13:20:40 -0500 |
parents | beae42f3d93b |
children | e84a8482c6f2 |
comparison
equal
deleted
inserted
replaced
8406:6ad1f72bdf34 | 8407:223000a687b0 |
---|---|
1219 m = matchfiles(repo, files) | 1219 m = matchfiles(repo, files) |
1220 try: | 1220 try: |
1221 return commitfunc(ui, repo, message, m, opts) | 1221 return commitfunc(ui, repo, message, m, opts) |
1222 except ValueError, inst: | 1222 except ValueError, inst: |
1223 raise util.Abort(str(inst)) | 1223 raise util.Abort(str(inst)) |
1224 | |
1225 def commiteditor(repo, ctx, added, updated, removed): | |
1226 if ctx.description(): | |
1227 return ctx.description() | |
1228 return commitforceeditor(repo, ctx, added, updated, removed) | |
1229 | |
1230 def commitforceeditor(repo, ctx, added, updated, removed): | |
1231 edittext = [] | |
1232 if ctx.description(): | |
1233 edittext.append(ctx.description()) | |
1234 edittext.append("") | |
1235 edittext.append("") # Empty line between message and comments. | |
1236 edittext.append(_("HG: Enter commit message." | |
1237 " Lines beginning with 'HG:' are removed.")) | |
1238 edittext.append("HG: --") | |
1239 edittext.append(_("HG: user: %s") % ctx.user()) | |
1240 if ctx.p2(): | |
1241 edittext.append(_("HG: branch merge")) | |
1242 if ctx.branch(): | |
1243 edittext.append(_("HG: branch '%s'") | |
1244 % encoding.tolocal(ctx.branch())) | |
1245 edittext.extend([_("HG: added %s") % f for f in added]) | |
1246 edittext.extend([_("HG: changed %s") % f for f in updated]) | |
1247 edittext.extend([_("HG: removed %s") % f for f in removed]) | |
1248 if not added and not updated and not removed: | |
1249 edittext.append(_("HG: no files changed")) | |
1250 edittext.append("") | |
1251 # run editor in the repository root | |
1252 olddir = os.getcwd() | |
1253 os.chdir(repo.root) | |
1254 text = repo.ui.edit("\n".join(edittext), ctx.user()) | |
1255 os.chdir(olddir) | |
1256 | |
1257 if not text.strip(): | |
1258 raise util.Abort(_("empty commit message")) | |
1259 | |
1260 return text |