Patchwork [1,of,3] commit: refactor logmessage(..) so the repo is passed in

login
register
mail settings
Submitter Tony Tung
Date May 15, 2015, 10:54 p.m.
Message ID <18cadf9d058931ef00e5.1431730475@andromeda.dhcp.thefacebook.com>
Download mbox | patch
Permalink /patch/9107/
State Changes Requested
Headers show

Comments

Tony Tung - May 15, 2015, 10:54 p.m.
# HG changeset patch
# User Tony Tung <tonytung@fb.com>
# Date 1429043234 14400
#      Tue Apr 14 16:27:14 2015 -0400
# Node ID 18cadf9d058931ef00e5272d15cb5cf2ebc3a248
# Parent  2f34746c27dfd9d4ff51c1f0081526438ded0c04
commit: refactor logmessage(..) so the repo is passed in

This allows us to extract a commit message from another rev in the repo.

Patch

diff --git a/hgext/fetch.py b/hgext/fetch.py
--- a/hgext/fetch.py
+++ b/hgext/fetch.py
@@ -134,7 +134,7 @@ 
 
         if not err:
             # we don't translate commit messages
-            message = (cmdutil.logmessage(ui, opts) or
+            message = (cmdutil.logmessage(ui, repo, opts) or
                        ('Automated merge with %s' %
                         util.removeauth(other.url())))
             editopt = opts.get('edit') or opts.get('force_editor')
diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -2562,7 +2562,7 @@ 
 
     Returns 0 on successful creation of a new patch.
     """
-    msg = cmdutil.logmessage(ui, opts)
+    msg = cmdutil.logmessage(ui, repo, opts)
     q = repo.mq
     opts['msg'] = msg
     setupheaderopts(ui, opts)
@@ -2608,7 +2608,7 @@ 
     Returns 0 on success.
     """
     q = repo.mq
-    message = cmdutil.logmessage(ui, opts)
+    message = cmdutil.logmessage(ui, repo, opts)
     setupheaderopts(ui, opts)
     wlock = repo.wlock()
     try:
@@ -2666,7 +2666,7 @@ 
         raise util.Abort(_('no patches applied'))
     q.checklocalchanges(repo)
 
-    message = cmdutil.logmessage(ui, opts)
+    message = cmdutil.logmessage(ui, repo, opts)
 
     parent = q.lookup('qtip')
     patches = []
@@ -3018,7 +3018,7 @@ 
 
     This command is deprecated, use :hg:`rebase` instead."""
     q = repo.mq
-    message = cmdutil.logmessage(ui, opts)
+    message = cmdutil.logmessage(ui, repo, opts)
     ret = q.save(repo, msg=message)
     if ret:
         return ret
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -185,7 +185,7 @@ 
         contf = opts.get('continue')
         abortf = opts.get('abort')
         collapsef = opts.get('collapse', False)
-        collapsemsg = cmdutil.logmessage(ui, opts)
+        collapsemsg = cmdutil.logmessage(ui, repo, opts)
         e = opts.get('extrafn') # internal, used by e.g. hgsubversion
         extrafns = [_savegraft]
         if e:
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -281,7 +281,7 @@ 
     for s in sorted(ctx.substate):
         ctx.sub(s).bailifchanged()
 
-def logmessage(ui, opts):
+def logmessage(ui, repo, opts):
     """ get the log message according to -m and -l option """
     message = opts.get('message')
     logfile = opts.get('logfile')
@@ -821,7 +821,7 @@ 
     dsguard = None
 
     try:
-        cmdline_message = logmessage(ui, opts)
+        cmdline_message = logmessage(ui, repo, opts)
         if cmdline_message:
             # pickup the cmdline msg
             message = cmdline_message
@@ -2451,7 +2451,7 @@ 
     date = opts.get('date')
     if date:
         opts['date'] = util.parsedate(date)
-    message = logmessage(ui, opts)
+    message = logmessage(ui, repo, opts)
     matcher = scmutil.match(repo[None], pats, opts)
 
     # extract addremove carefully -- this function can be called from a command
@@ -2481,7 +2481,7 @@ 
         try:
             # See if we got a message from -m or -l, if not, open the editor
             # with the message of the changeset to amend
-            message = logmessage(ui, opts)
+            message = logmessage(ui, repo, opts)
             # ensure logfile does not conflict with later enforcement of the
             # message. potential logfile content has been processed by
             # `logmessage` anyway.