Mercurial > public > mercurial-scm > hg-stable
diff mercurial/commands.py @ 2694:0fb28dbf0dc7
MQ: uniformise message and logfile option.
Possibility to change message in qrefresh option
author | "Mathieu Clabaut <mathieu.clabaut@gmail.com>" |
---|---|
date | Wed, 26 Jul 2006 20:11:54 +0200 |
parents | 109a22f5434a |
children | 14ebe97542a7 |
line wrap: on
line diff
--- a/mercurial/commands.py Thu Jul 27 09:14:53 2006 -0700 +++ b/mercurial/commands.py Wed Jul 26 20:11:54 2006 +0200 @@ -40,6 +40,25 @@ return [util.normpath(os.path.join(cwd, x)) for x in args] return args +def logmessage(**opts): + """ get the log message according to -m and -l option """ + message = opts['message'] + logfile = opts['logfile'] + + if message and logfile: + raise util.Abort(_('options --message and --logfile are mutually ' + 'exclusive')) + if not message and logfile: + try: + if logfile == '-': + message = sys.stdin.read() + else: + message = open(logfile).read() + except IOError, inst: + raise util.Abort(_("can't read commit message '%s': %s") % + (logfile, inst.strerror)) + return message + def matchpats(repo, pats=[], opts={}, head=''): cwd = repo.getcwd() if not pats and cwd: @@ -989,21 +1008,7 @@ If no commit message is specified, the editor configured in your hgrc or in the EDITOR environment variable is started to enter a message. """ - message = opts['message'] - logfile = opts['logfile'] - - if message and logfile: - raise util.Abort(_('options --message and --logfile are mutually ' - 'exclusive')) - if not message and logfile: - try: - if logfile == '-': - message = sys.stdin.read() - else: - message = open(logfile).read() - except IOError, inst: - raise util.Abort(_("can't read commit message '%s': %s") % - (logfile, inst.strerror)) + message = logmessage(**opts) if opts['addremove']: addremove_lock(ui, repo, pats, opts)