changeset 2267:d812d91c5a84

Force editor to appear for an 'hg backout' if a message or logfile aren't supplied. Pre-fill the commit message with the changeset being backed out. Fixes bug 238.
author john.levon@sun.com
date Thu, 11 May 2006 14:32:09 -0700
parents 2f64cbaa1e92
children 6c9305fbebaf
files mercurial/commands.py mercurial/localrepo.py
diffstat 2 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Thu May 11 09:01:32 2006 -0700
+++ b/mercurial/commands.py	Thu May 11 14:32:09 2006 -0700
@@ -789,6 +789,7 @@
     commit_opts['addremove'] = False
     if not commit_opts['message'] and not commit_opts['logfile']:
         commit_opts['message'] = _("Backed out changeset %s") % (hex(node))
+        commit_opts['force_editor'] = True;
     commit(ui, repo, **commit_opts)
     def nice(node):
         return '%d:%s' % (repo.changelog.rev(node), short(node))
@@ -987,7 +988,12 @@
     else:
         files = []
     try:
-        repo.commit(files, message, opts['user'], opts['date'], match)
+        try:
+            force_editor = opts['force_editor']
+        except KeyError:
+            force_editor = False
+        repo.commit(files, message, opts['user'], opts['date'], match,
+            force_editor=force_editor)
     except ValueError, inst:
         raise util.Abort(str(inst))
 
--- a/mercurial/localrepo.py	Thu May 11 09:01:32 2006 -0700
+++ b/mercurial/localrepo.py	Thu May 11 14:32:09 2006 -0700
@@ -446,7 +446,8 @@
             self.dirstate.setparents(n, nullid)
 
     def commit(self, files=None, text="", user=None, date=None,
-               match=util.always, force=False, lock=None, wlock=None):
+               match=util.always, force=False, lock=None, wlock=None,
+               force_editor=False):
         commit = []
         remove = []
         changed = []
@@ -535,8 +536,11 @@
         new.sort()
 
         user = user or self.ui.username()
-        if not text:
-            edittext = [""]
+        if not text or force_editor:
+            edittext = []
+            if text:
+                edittext.append(text)
+            edittext.append("")
             if p2 != nullid:
                 edittext.append("HG: branch merge")
             edittext.extend(["HG: changed %s" % f for f in changed])