2168 if ctx.description(): |
2168 if ctx.description(): |
2169 return ctx.description() |
2169 return ctx.description() |
2170 return commitforceeditor(repo, ctx, subs) |
2170 return commitforceeditor(repo, ctx, subs) |
2171 |
2171 |
2172 def commitforceeditor(repo, ctx, subs, finishdesc=None, extramsg=None): |
2172 def commitforceeditor(repo, ctx, subs, finishdesc=None, extramsg=None): |
|
2173 committext = buildcommittext(repo, ctx, subs, extramsg) |
|
2174 |
|
2175 # run editor in the repository root |
|
2176 olddir = os.getcwd() |
|
2177 os.chdir(repo.root) |
|
2178 text = repo.ui.edit(committext, ctx.user(), ctx.extra()) |
|
2179 text = re.sub("(?m)^HG:.*(\n|$)", "", text) |
|
2180 os.chdir(olddir) |
|
2181 |
|
2182 if finishdesc: |
|
2183 text = finishdesc(text) |
|
2184 if not text.strip(): |
|
2185 raise util.Abort(_("empty commit message")) |
|
2186 |
|
2187 return text |
|
2188 |
|
2189 def buildcommittext(repo, ctx, subs, extramsg): |
2173 edittext = [] |
2190 edittext = [] |
2174 modified, added, removed = ctx.modified(), ctx.added(), ctx.removed() |
2191 modified, added, removed = ctx.modified(), ctx.added(), ctx.removed() |
2175 if ctx.description(): |
2192 if ctx.description(): |
2176 edittext.append(ctx.description()) |
2193 edittext.append(ctx.description()) |
2177 edittext.append("") |
2194 edittext.append("") |
2195 edittext.extend([_("HG: changed %s") % f for f in modified]) |
2212 edittext.extend([_("HG: changed %s") % f for f in modified]) |
2196 edittext.extend([_("HG: removed %s") % f for f in removed]) |
2213 edittext.extend([_("HG: removed %s") % f for f in removed]) |
2197 if not added and not modified and not removed: |
2214 if not added and not modified and not removed: |
2198 edittext.append(_("HG: no files changed")) |
2215 edittext.append(_("HG: no files changed")) |
2199 edittext.append("") |
2216 edittext.append("") |
2200 # run editor in the repository root |
2217 |
2201 olddir = os.getcwd() |
2218 return "\n".join(edittext) |
2202 os.chdir(repo.root) |
|
2203 text = repo.ui.edit("\n".join(edittext), ctx.user(), ctx.extra()) |
|
2204 text = re.sub("(?m)^HG:.*(\n|$)", "", text) |
|
2205 os.chdir(olddir) |
|
2206 |
|
2207 if finishdesc: |
|
2208 text = finishdesc(text) |
|
2209 if not text.strip(): |
|
2210 raise util.Abort(_("empty commit message")) |
|
2211 |
|
2212 return text |
|
2213 |
2219 |
2214 def commitstatus(repo, node, branch, bheads=None, opts={}): |
2220 def commitstatus(repo, node, branch, bheads=None, opts={}): |
2215 ctx = repo[node] |
2221 ctx = repo[node] |
2216 parents = ctx.parents() |
2222 parents = ctx.parents() |
2217 |
2223 |