Rev 5650: (vila) msgeditor use cmdline.split (Martin Pool) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Mon Feb 7 09:43:17 UTC 2011
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5650 [merge]
revision-id: pqm at pqm.ubuntu.com-20110207094313-kms5t2agjk410hqt
parent: pqm at pqm.ubuntu.com-20110207063138-sq3gnzlz57p7thbr
parent: mbp at canonical.com-20110207013942-roj88kez6jir13tr
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2011-02-07 09:43:13 +0000
message:
(vila) msgeditor use cmdline.split (Martin Pool)
modified:
bzrlib/cmdline.py bzrlibcmdline.py-20100202043522-83yorxx3tcigi7ap-1
bzrlib/msgeditor.py msgeditor.py-20050901111708-ef6d8de98f5d8f2f
bzrlib/tests/test_msgeditor.py test_msgeditor.py-20051202041359-920315ec6011ee51
doc/en/user-guide/configuring_bazaar.txt configuring_bazaar.t-20071128000722-ncxiua259xwbdbg7-1
=== modified file 'bzrlib/cmdline.py'
--- a/bzrlib/cmdline.py 2010-12-06 10:33:58 +0000
+++ b/bzrlib/cmdline.py 2011-02-07 01:39:42 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2010 Canonical Ltd
+# Copyright (C) 2010-2011 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -14,7 +14,11 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-"""Unicode-compatible command-line splitter for all platforms."""
+"""Unicode-compatible command-line splitter for all platforms.
+
+The user-visible behaviour of this module is described in
+configuring_bazaar.txt.
+"""
import re
=== modified file 'bzrlib/msgeditor.py'
--- a/bzrlib/msgeditor.py 2010-11-11 13:45:02 +0000
+++ b/bzrlib/msgeditor.py 2011-02-07 01:30:38 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005-2010 Canonical Ltd
+# Copyright (C) 2005-2011 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -23,6 +23,7 @@
import sys
from bzrlib import (
+ cmdline,
config,
osutils,
trace,
@@ -59,7 +60,7 @@
def _run_editor(filename):
"""Try to execute an editor to edit the commit message."""
for candidate, candidate_source in _get_editor():
- edargs = candidate.split(' ')
+ edargs = cmdline.split(candidate)
try:
## mutter("trying editor: %r", (edargs +[filename]))
x = call(edargs + [filename])
=== modified file 'bzrlib/tests/test_msgeditor.py'
--- a/bzrlib/tests/test_msgeditor.py 2011-01-12 01:01:53 +0000
+++ b/bzrlib/tests/test_msgeditor.py 2011-02-07 01:30:38 +0000
@@ -141,24 +141,35 @@
hell\u00d8
""".encode('utf8') in template)
- def make_do_nothing_editor(self):
+ def make_do_nothing_editor(self, basename='fed'):
if sys.platform == "win32":
- f = file('fed.bat', 'w')
+ name = basename + '.bat'
+ f = file(name, 'w')
f.write('@rem dummy fed')
f.close()
- return 'fed.bat'
+ return name
else:
- f = file('fed.sh', 'wb')
+ name = basename + '.sh'
+ f = file(name, 'wb')
f.write('#!/bin/sh\n')
f.close()
- os.chmod('fed.sh', 0755)
- return './fed.sh'
+ os.chmod(name, 0755)
+ return './' + name
def test_run_editor(self):
self.overrideEnv('BZR_EDITOR', self.make_do_nothing_editor())
self.assertEqual(True, msgeditor._run_editor(''),
'Unable to run dummy fake editor')
+ def test_parse_editor_name(self):
+ """Correctly interpret names with spaces.
+
+ See <https://bugs.launchpad.net/bzr/+bug/220331>
+ """
+ self.overrideEnv('BZR_EDITOR',
+ '"%s"' % self.make_do_nothing_editor('name with spaces'))
+ self.assertEqual(True, msgeditor._run_editor('a_filename'))
+
def make_fake_editor(self, message='test message from fed\\n'):
"""Set up environment so that an editor will be a known script.
=== modified file 'doc/en/user-guide/configuring_bazaar.txt'
--- a/doc/en/user-guide/configuring_bazaar.txt 2010-11-12 22:08:18 +0000
+++ b/doc/en/user-guide/configuring_bazaar.txt 2011-02-07 01:39:42 +0000
@@ -133,3 +133,17 @@
For further information on how rules are searched and the detailed syntax of
the relevant files, see `Rules <../user-reference/index.html#rules>`_
in the Bazaar User Reference.
+
+
+Escaping command lines
+----------------------
+
+When you give a program name or command line in configuration, you can quote
+to include special characters or whitespace. The same rules are used across
+all platforms.
+
+The rules are: strings surrounded by double-quotes are interpreted as single
+"words" even if they contain whitespace, and backslash may be used to quote
+quotation marks. For example::
+
+ BZR_EDITOR="C:\Program Files\My Editor\myeditor.exe"
More information about the bazaar-commits
mailing list