Rev 2773: Merge commit --show-diff feature from Goffredo in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Aug 31 07:25:05 BST 2007
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 2773
revision-id: pqm at pqm.ubuntu.com-20070831062501-zi3hbjphrmz4jv4x
parent: pqm at pqm.ubuntu.com-20070831020510-emrlta5dk6ta95zp
parent: mbp at sourcefrog.net-20070831053200-px49z9ajuv15dxpi
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2007-08-31 07:25:01 +0100
message:
Merge commit --show-diff feature from Goffredo
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/diff.py diff.py-20050309040759-26944fbbf2ebbf36
bzrlib/msgeditor.py msgeditor.py-20050901111708-ef6d8de98f5d8f2f
bzrlib/tests/test_msgeditor.py test_msgeditor.py-20051202041359-920315ec6011ee51
doc/en/user-guide/tutorial.txt tutorial.txt-20050804190939-9dcbba2ef053bc84
------------------------------------------------------------
revno: 2772.1.1
merged: mbp at sourcefrog.net-20070831053200-px49z9ajuv15dxpi
parent: pqm at pqm.ubuntu.com-20070831020510-emrlta5dk6ta95zp
parent: ghigo at venice-20070824165901-x0ifucgrf4oz422a
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: show-diff
timestamp: Fri 2007-08-31 15:32:00 +1000
message:
Merge commit --show-diff feature from Goffredo
------------------------------------------------------------
revno: 2598.6.32
merged: ghigo at venice-20070824165901-x0ifucgrf4oz422a
parent: ghigo at venice-20070824164900-lsll8bfg2389wdj2
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose2
timestamp: Fri 2007-08-24 18:59:01 +0200
message:
Move the info in the NEWS file at the top
------------------------------------------------------------
revno: 2598.6.31
merged: ghigo at venice-20070824164900-lsll8bfg2389wdj2
parent: ghigo at venice-20070824164317-rv1ybnpqv6iorw3e
parent: pqm at pqm.ubuntu.com-20070824133750-r25v5g25g1flggy6
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose2
timestamp: Fri 2007-08-24 18:49:00 +0200
message:
Update to bzr.dev
------------------------------------------------------------
revno: 2598.6.30
merged: ghigo at venice-20070824164317-rv1ybnpqv6iorw3e
parent: ghigo at venice-20070817210416-ah5nh07f2dwky5pp
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose2
timestamp: Fri 2007-08-24 18:43:17 +0200
message:
- Updated the identation on the basis of Aaron suggestions
- Now a default value is passed directly in the function definition
------------------------------------------------------------
revno: 2598.6.29
merged: ghigo at venice-20070817210416-ah5nh07f2dwky5pp
parent: ghigo at venice-20070817194121-axosvcki4xtunyq7
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose2
timestamp: Fri 2007-08-17 23:04:16 +0200
message:
Removed the check on the switch "--show-diff" in order to allow the
use of the switch in an alias.
------------------------------------------------------------
revno: 2598.6.28
merged: ghigo at venice-20070817194121-axosvcki4xtunyq7
parent: ghigo at venice-20070817180457-5rkqnkqzlwls9ld0
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose2
timestamp: Fri 2007-08-17 21:41:21 +0200
message:
remove two uncorrectly commas
------------------------------------------------------------
revno: 2598.6.27
merged: ghigo at venice-20070817180457-5rkqnkqzlwls9ld0
parent: ghigo at venice-20070817180034-v2ypd6dz2nbh515i
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose2
timestamp: Fri 2007-08-17 20:04:57 +0200
message:
small cleanup (line lenght)
------------------------------------------------------------
revno: 2598.6.26
merged: ghigo at venice-20070817180034-v2ypd6dz2nbh515i
parent: ghigo at venice-20070817174636-hiaw4etj4rf2195k
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose2
timestamp: Fri 2007-08-17 20:00:34 +0200
message:
small cleanup
------------------------------------------------------------
revno: 2598.6.25
merged: ghigo at venice-20070817174636-hiaw4etj4rf2195k
parent: ghigo at venice-20070817174415-z9uufl65de5qhvqp
parent: pqm at pqm.ubuntu.com-20070817132000-jr6dro4qkhf7uzwp
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose2
timestamp: Fri 2007-08-17 19:46:36 +0200
message:
update to bzr.dev
------------------------------------------------------------
revno: 2598.6.24
merged: ghigo at venice-20070817174415-z9uufl65de5qhvqp
parent: ghigo at venice-20070813173134-x8n48l7tdx1p3u94
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose2
timestamp: Fri 2007-08-17 19:44:15 +0200
message:
update on the basis of Aaron suggestions
------------------------------------------------------------
revno: 2598.6.23
merged: ghigo at venice-20070813173134-x8n48l7tdx1p3u94
parent: ghigo at venice-20070813171939-kl2ue6y9p38uu1ym
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose2
timestamp: Mon 2007-08-13 19:31:34 +0200
message:
Cosmetic clean up
------------------------------------------------------------
revno: 2598.6.22
merged: ghigo at venice-20070813171939-kl2ue6y9p38uu1ym
parent: ghigo at venice-20070813171344-1qd4y1a70gav4gde
parent: pqm at pqm.ubuntu.com-20070813122444-5pi8f4fwxqpgxs1x
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose2
timestamp: Mon 2007-08-13 19:19:39 +0200
message:
update to bzr.dev, and a small cleanup
------------------------------------------------------------
revno: 2598.6.21
merged: ghigo at venice-20070813171344-1qd4y1a70gav4gde
parent: ghigo at venice-20070726223849-rn3omaw72fexxvmz
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose2
timestamp: Mon 2007-08-13 19:13:44 +0200
message:
updates on the basis of Jhon email
------------------------------------------------------------
revno: 2598.6.20
merged: ghigo at venice-20070726223849-rn3omaw72fexxvmz
parent: ghigo at venice-20070726222759-re7mrag50tghahb7
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose2
timestamp: Fri 2007-07-27 00:38:49 +0200
message:
Small clean up
------------------------------------------------------------
revno: 2598.6.19
merged: ghigo at venice-20070726222759-re7mrag50tghahb7
parent: ghigo at venice-20070726222547-sssldoion0tgxido
parent: pqm at pqm.ubuntu.com-20070726134355-tlidmsn3eux09idz
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose2
timestamp: Fri 2007-07-27 00:27:59 +0200
message:
update to the latest bzr.dev
------------------------------------------------------------
revno: 2598.6.18
merged: ghigo at venice-20070726222547-sssldoion0tgxido
parent: ghigo at venice-20070726221957-za2w39visme8melg
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose2
timestamp: Fri 2007-07-27 00:25:47 +0200
message:
Update the tests to the new *_encoded() functions
------------------------------------------------------------
revno: 2598.6.17
merged: ghigo at venice-20070726221957-za2w39visme8melg
parent: ghigo at venice-20070726054704-ni5ehs28j2cll1ac
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose2
timestamp: Fri 2007-07-27 00:19:57 +0200
message:
Revert the behaviour of the function make_commit_message_template() and make_commit_message_template() to the original one.
Add the function make_commit_message_template_encoded() and make_commit_message_template_encoded() with the new behaviour.
------------------------------------------------------------
revno: 2598.6.16
merged: ghigo at venice-20070726054704-ni5ehs28j2cll1ac
parent: ghigo at venice-20070725214400-s7nbvixlugzb3j8k
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose2
timestamp: Thu 2007-07-26 07:47:04 +0200
message:
Add the "replace" option to the encodeing of the path
------------------------------------------------------------
revno: 2598.6.15
merged: ghigo at venice-20070725214400-s7nbvixlugzb3j8k
parent: ghigo at venice-20070725213832-pe0ssmcily088vb5
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose2
timestamp: Wed 2007-07-25 23:44:00 +0200
message:
Update the param description
------------------------------------------------------------
revno: 2598.6.14
merged: ghigo at venice-20070725213832-pe0ssmcily088vb5
parent: ghigo at venice-20070725212901-1udcxp6s30f1c2yt
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose2
timestamp: Wed 2007-07-25 23:38:32 +0200
message:
Update the test
------------------------------------------------------------
revno: 2598.6.13
merged: ghigo at venice-20070725212901-1udcxp6s30f1c2yt
parent: ghigo at venice-20070725212508-5hsxs33pxdz82pry
parent: pqm at pqm.ubuntu.com-20070725140043-22lenkarm0oc3tvx
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose2
timestamp: Wed 2007-07-25 23:29:01 +0200
message:
Update to the latest bzr.dev
------------------------------------------------------------
revno: 2598.6.12
merged: ghigo at venice-20070725212508-5hsxs33pxdz82pry
parent: ghigo at venice-20070720080314-nq92ucwq0t0kxhiy
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose2
timestamp: Wed 2007-07-25 23:25:08 +0200
message:
Move the encoding of the commit message at the command line level
------------------------------------------------------------
revno: 2598.6.11
merged: ghigo at venice-20070720080314-nq92ucwq0t0kxhiy
parent: ghigo at venice-20070720075831-agxwyertov4td8dn
parent: pqm at pqm.ubuntu.com-20070720065314-hhb0qw5h3cfe8mga
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose
timestamp: Fri 2007-07-20 10:03:14 +0200
message:
update to the latest bzr.dev
------------------------------------------------------------
revno: 2598.6.10
merged: ghigo at venice-20070720075831-agxwyertov4td8dn
parent: ghigo at venice-20070717164221-52lc5ucruuvjvova
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose
timestamp: Fri 2007-07-20 09:58:31 +0200
message:
In the commit dialog, the diff is stored as 8-bit raw data
------------------------------------------------------------
revno: 2598.6.9
merged: ghigo at venice-20070717164221-52lc5ucruuvjvova
parent: ghigo at venice-20070717162736-3t9jgxmxcasg2yvr
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose
timestamp: Tue 2007-07-17 18:42:21 +0200
message:
Simplify the diff encoding logic in the commit message
------------------------------------------------------------
revno: 2598.6.8
merged: ghigo at venice-20070717162736-3t9jgxmxcasg2yvr
parent: ghigo at venice-20070716191531-4fs3y55tw5o4o6uk
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose
timestamp: Tue 2007-07-17 18:27:36 +0200
message:
As suggested by Martin Pool replace user_encoding with output_encoding
------------------------------------------------------------
revno: 2598.6.7
merged: ghigo at venice-20070716191531-4fs3y55tw5o4o6uk
parent: ghigo at venice-20070716181359-5mcipugnmxmazdi4
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose
timestamp: Mon 2007-07-16 21:15:31 +0200
message:
Thank to Aaron Bentley for the bug signalation...
------------------------------------------------------------
revno: 2598.6.6
merged: ghigo at venice-20070716181359-5mcipugnmxmazdi4
parent: ghigo at venice-20070716175207-d1d8mmetgg8krcbd
parent: pqm at pqm.ubuntu.com-20070716084122-jfjzwtbimsjv0iqv
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose
timestamp: Mon 2007-07-16 20:13:59 +0200
message:
update to the latest bzr.dev
------------------------------------------------------------
revno: 2598.6.5
merged: ghigo at venice-20070716175207-d1d8mmetgg8krcbd
parent: ghigo at venice-20070711190503-s776n86krp6oeijy
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose
timestamp: Mon 2007-07-16 19:52:07 +0200
message:
On the basis of the email from Martin, Aaron I changed the encoding logic
in the function make_commit_message_template()
- in the diff, if the line is an header is decoded as UTF8
- otherwise the line is decoded as bzrlib.user_encoding
the rationale is that the message is already encoded as bzrlib.user_encoding
during the writing.
So the header which is know the encoding are correctly decoded. For the
other data, the decoding is the same of one which is used during the
file writing in order do minimize the encoding/decoding effect.
In order to move the user encoding at the UI level, the parameter user_encoding
is added to the functions
- make_commit_message_template
- _create_temp_file_with_commit_template
- edit_commit_message
Finally, I also added a paragraph to the tutorial about the option, and added
another while I was there (thank to James Westby)
------------------------------------------------------------
revno: 2598.6.4
merged: ghigo at venice-20070711190503-s776n86krp6oeijy
parent: ghigo at venice-20070711183728-4r5bws042aw361cd
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose
timestamp: Wed 2007-07-11 21:05:03 +0200
message:
- Update NEWS
- Revert the change '%r' to '%s' for the path in the diff generator
------------------------------------------------------------
revno: 2598.6.3
merged: ghigo at venice-20070711183728-4r5bws042aw361cd
parent: ghigo at venice-20070710211157-0jx3e7fmigifj0c2
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose
timestamp: Wed 2007-07-11 20:37:28 +0200
message:
Add test case
------------------------------------------------------------
revno: 2598.6.2
merged: ghigo at venice-20070710211157-0jx3e7fmigifj0c2
parent: ghigo at venice-20070710191709-9p9yvqspufxc9eon
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose
timestamp: Tue 2007-07-10 23:11:57 +0200
message:
Add testcase
Add support for unicode and StringIO in the make_commit_message_template function
------------------------------------------------------------
revno: 2598.6.1
merged: ghigo at venice-20070710191709-9p9yvqspufxc9eon
parent: pqm at pqm.ubuntu.com-20070710021221-8o98e4q8vcpaarnk
committer: ghigo <ghigo at venice>
branch nick: bzr-ci-verbose
timestamp: Tue 2007-07-10 21:17:09 +0200
message:
add support for the diff at the end of the commit messages
=== modified file 'NEWS'
--- a/NEWS 2007-08-31 02:05:10 +0000
+++ b/NEWS 2007-08-31 05:32:00 +0000
@@ -16,86 +16,89 @@
FEATURES:
- * New option ``--author`` in ``bzr commit`` to specify the author of the
- change, if it's different from the committer. ``bzr log`` and
- ``bzr annotate`` display the author instead of the committer.
- (Lukáš Lalinský)
+ * New option ``--author`` in ``bzr commit`` to specify the author of the
+ change, if it's different from the committer. ``bzr log`` and
+ ``bzr annotate`` display the author instead of the committer.
+ (Lukáš Lalinský)
BUG FIXES:
* ``bzr plugins`` now lists the version number for each plugin in square
brackets after the path. (Robert Collins, #125421)
- * Suppress warning "integer argument expected, got float" from Paramiko,
- which sometimes caused false test failures. (Martin Pool)
-
- * Fix bug in bundle 4 that could cause attempts to write data to wrong
- versionedfile. (Aaron Bentley)
-
- * Diffs generated using "diff -p" no longer break the patch parser.
- (Aaron Bentley)
-
- * get_transport treats an empty possible_transports list the same as a non-
- empty one. (Aaron Bentley)
-
- * patch verification for merge directives is reactivated, and works with
- CRLF and CR files. (Aaron Bentley)
-
- * Accept ..\ as a path in revision specifiers. This fixes for example
- "-r branch:..\other-branch" on Windows. (Lukáš Lalinský)
-
- * ``BZR_PLUGIN_PATH`` may now contain trailing slashes.
- (Blake Winton, #129299)
-
- * man page no longer lists hidden options (#131667, Aaron Bentley)
-
- * ``uncommit --help`` now explains the -r option adequately. (Daniel
- Watkins, #106726)
-
- * Error messages are now better formatted with parameters (such as
- filenames) quoted when necessary. This avoids confusion when directory
- names ending in a '.' at the end of messages were confused with a
- full stop that may or not have been there. (Daniel Watkins, #129791)
-
- * Fix ``status FILE -r X..Y``. (Lukáš Lalinský)
-
- * If a particular command is an alias, ``help`` will show the alias
- instead of claiming there is no help for said alias. (Daniel Watkins,
- #133548)
-
- * TreeTransform-based operations, like pull, merge, revert, and branch,
- now roll back if they encounter an error. (Aaron Bentley, #67699)
-
- * ``bzr commit`` now exits cleanly if a character unsupported by the
- current encoding is used in the commit message. (Daniel Watkins,
- #116143)
-
- * bzr send uses default values for ranges when only half of an elipsis
- is specified ("-r..5" or "-r5.."). (#61685, Aaron Bentley)
+ * Suppress warning "integer argument expected, got float" from Paramiko,
+ which sometimes caused false test failures. (Martin Pool)
+
+ * Fix bug in bundle 4 that could cause attempts to write data to wrong
+ versionedfile. (Aaron Bentley)
+
+ * Diffs generated using "diff -p" no longer break the patch parser.
+ (Aaron Bentley)
+
+ * get_transport treats an empty possible_transports list the same as a non-
+ empty one. (Aaron Bentley)
+
+ * patch verification for merge directives is reactivated, and works with
+ CRLF and CR files. (Aaron Bentley)
+
+ * Accept ..\ as a path in revision specifiers. This fixes for example
+ "-r branch:..\other-branch" on Windows. (Lukáš Lalinský)
+
+ * ``BZR_PLUGIN_PATH`` may now contain trailing slashes.
+ (Blake Winton, #129299)
+
+ * man page no longer lists hidden options (#131667, Aaron Bentley)
+
+ * ``uncommit --help`` now explains the -r option adequately. (Daniel
+ Watkins, #106726)
+
+ * Error messages are now better formatted with parameters (such as
+ filenames) quoted when necessary. This avoids confusion when directory
+ names ending in a '.' at the end of messages were confused with a
+ full stop that may or not have been there. (Daniel Watkins, #129791)
+
+ * Fix ``status FILE -r X..Y``. (Lukáš Lalinský)
+
+ * If a particular command is an alias, ``help`` will show the alias
+ instead of claiming there is no help for said alias. (Daniel Watkins,
+ #133548)
+
+ * TreeTransform-based operations, like pull, merge, revert, and branch,
+ now roll back if they encounter an error. (Aaron Bentley, #67699)
+
+ * ``bzr commit`` now exits cleanly if a character unsupported by the
+ current encoding is used in the commit message. (Daniel Watkins,
+ #116143)
+
+ * bzr send uses default values for ranges when only half of an elipsis
+ is specified ("-r..5" or "-r5.."). (#61685, Aaron Bentley)
IMPROVEMENTS:
- * ``pull`` and ``merge`` are much faster at installing bundle format 4.
- (Aaron Bentley)
-
- * ``pull -v`` no longer includes deltas, making it much faster.
- (Aaron Bentley)
-
- * ``send`` now sends the directive as an attachment by default.
- (Aaron Bentley, Lukáš Lalinský, Alexander Belchenko)
-
- * Documentation updates (Martin Albisetti)
-
- * Help on debug flags is now included in ``help global-options``.
- (Daniel Watkins, #124853)
-
- * Parameters passed on the command line are checked to ensure they are
- supported by the encoding in use. (Daniel Watkins)
-
- * The compression used within the bzr repository has changed from zlib
- level 9 to the zlib default level. This improves commit performance with
- only a small increase in space used (and in some cases a reduction in
- space). (Robert Collins)
+ * Add the option "--show-diff" to the commit command in order to display
+ the diff during the commit log creation. (Goffredo Baroncelli)
+
+ * ``pull`` and ``merge`` are much faster at installing bundle format 4.
+ (Aaron Bentley)
+
+ * ``pull -v`` no longer includes deltas, making it much faster.
+ (Aaron Bentley)
+
+ * ``send`` now sends the directive as an attachment by default.
+ (Aaron Bentley, Lukáš Lalinský, Alexander Belchenko)
+
+ * Documentation updates (Martin Albisetti)
+
+ * Help on debug flags is now included in ``help global-options``.
+ (Daniel Watkins, #124853)
+
+ * Parameters passed on the command line are checked to ensure they are
+ supported by the encoding in use. (Daniel Watkins)
+
+ * The compression used within the bzr repository has changed from zlib
+ level 9 to the zlib default level. This improves commit performance with
+ only a small increase in space used (and in some cases a reduction in
+ space). (Robert Collins)
API BREAKS:
@@ -126,6 +129,14 @@
useful functionality for determining the path of a plugin, its tests, and
its version information. (Robert Collins)
+ * Add the option user_encoding to the function 'show_diff_trees()'
+ in order to move the user encoding at the UI level. (Goffredo Baroncelli)
+
+ * Add the function make_commit_message_template_encoded() and the function
+ edit_commit_message_encoded() which handle encoded strings.
+ This is done in order to mix the commit messages (which is a unicode
+ string), and the diff which is a raw string. (Goffredo Baroncelli)
+
* New trace function ``mutter_callsite`` will print out a subset of the
stack to the log, which can be useful for gathering debug details.
(Robert Collins)
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2007-08-29 15:07:11 +0000
+++ b/bzrlib/builtins.py 2007-08-31 05:32:00 +0000
@@ -2194,6 +2194,9 @@
"the master branch until a normal commit "
"is performed."
),
+ Option('show-diff',
+ help='When no message is supplied, show the diff along'
+ ' with the status summary in the message editor.'),
]
aliases = ['ci', 'checkin']
@@ -2221,12 +2224,20 @@
def run(self, message=None, file=None, verbose=True, selected_list=None,
unchanged=False, strict=False, local=False, fixes=None,
- author=None):
- from bzrlib.commit import (NullCommitReporter, ReportCommitToLog)
- from bzrlib.errors import (PointlessCommit, ConflictsInTree,
- StrictCommitFailed)
- from bzrlib.msgeditor import edit_commit_message, \
- make_commit_message_template
+ author=None, show_diff=False):
+ from bzrlib.commit import (
+ NullCommitReporter,
+ ReportCommitToLog
+ )
+ from bzrlib.errors import (
+ PointlessCommit,
+ ConflictsInTree,
+ StrictCommitFailed
+ )
+ from bzrlib.msgeditor import (
+ edit_commit_message_encoded,
+ make_commit_message_template_encoded
+ )
# TODO: Need a blackbox test for invoking the external editor; may be
# slightly problematic to run this cross-platform.
@@ -2254,8 +2265,10 @@
"""Callback to get commit message"""
my_message = message
if my_message is None and not file:
- template = make_commit_message_template(tree, selected_list)
- my_message = edit_commit_message(template)
+ t = make_commit_message_template_encoded(tree,
+ selected_list, diff=show_diff,
+ output_encoding=bzrlib.user_encoding)
+ my_message = edit_commit_message_encoded(t)
if my_message is None:
raise errors.BzrCommandError("please specify a commit"
" message with either --message or --file")
=== modified file 'bzrlib/diff.py'
--- a/bzrlib/diff.py 2007-08-19 09:49:02 +0000
+++ b/bzrlib/diff.py 2007-08-24 16:49:00 +0000
@@ -347,7 +347,8 @@
def show_diff_trees(old_tree, new_tree, to_file, specific_files=None,
external_diff_options=None,
old_label='a/', new_label='b/',
- extra_trees=None):
+ extra_trees=None,
+ path_encoding='utf8'):
"""Show in text form the changes from one tree to another.
to_files
@@ -358,6 +359,10 @@
extra_trees
If set, more Trees to use for looking up file ids
+
+ path_encoding
+ If set, the path will be encoded as specified, otherwise is supposed
+ to be utf8
"""
old_tree.lock_read()
try:
@@ -369,7 +374,8 @@
return _show_diff_trees(old_tree, new_tree, to_file,
specific_files, external_diff_options,
old_label=old_label, new_label=new_label,
- extra_trees=extra_trees)
+ extra_trees=extra_trees,
+ path_encoding=path_encoding)
finally:
new_tree.unlock()
if extra_trees is not None:
@@ -380,7 +386,7 @@
def _show_diff_trees(old_tree, new_tree, to_file,
- specific_files, external_diff_options,
+ specific_files, external_diff_options, path_encoding,
old_label='a/', new_label='b/', extra_trees=None):
# GNU Patch uses the epoch date to detect files that are being added
@@ -405,7 +411,8 @@
has_changes = 0
for path, file_id, kind in delta.removed:
has_changes = 1
- print >>to_file, "=== removed %s '%s'" % (kind, path.encode('utf8'))
+ path_encoded = path.encode(path_encoding, "replace")
+ print >>to_file, "=== removed %s '%s'" % (kind, path_encoded)
old_name = '%s%s\t%s' % (old_label, path,
_patch_header_date(old_tree, file_id, path))
new_name = '%s%s\t%s' % (new_label, path, EPOCH_DATE)
@@ -413,7 +420,8 @@
new_name, None, None, to_file)
for path, file_id, kind in delta.added:
has_changes = 1
- print >>to_file, "=== added %s '%s'" % (kind, path.encode('utf8'))
+ path_encoded = path.encode(path_encoding, "replace")
+ print >>to_file, "=== added %s '%s'" % (kind, path_encoded)
old_name = '%s%s\t%s' % (old_label, path, EPOCH_DATE)
new_name = '%s%s\t%s' % (new_label, path,
_patch_header_date(new_tree, file_id, path))
@@ -424,9 +432,10 @@
text_modified, meta_modified) in delta.renamed:
has_changes = 1
prop_str = get_prop_change(meta_modified)
- print >>to_file, "=== renamed %s '%s' => '%s'%s" % (
- kind, old_path.encode('utf8'),
- new_path.encode('utf8'), prop_str)
+ oldpath_encoded = old_path.encode(path_encoding, "replace")
+ newpath_encoded = new_path.encode(path_encoding, "replace")
+ print >>to_file, "=== renamed %s '%s' => '%s'%s" % (kind,
+ oldpath_encoded, newpath_encoded, prop_str)
old_name = '%s%s\t%s' % (old_label, old_path,
_patch_header_date(old_tree, file_id,
old_path))
@@ -439,8 +448,9 @@
for path, file_id, kind, text_modified, meta_modified in delta.modified:
has_changes = 1
prop_str = get_prop_change(meta_modified)
- print >>to_file, "=== modified %s '%s'%s" % (kind, path.encode('utf8'),
- prop_str)
+ path_encoded = path.encode(path_encoding, "replace")
+ print >>to_file, "=== modified %s '%s'%s" % (kind,
+ path_encoded, prop_str)
# The file may be in a different location in the old tree (because
# the containing dir was renamed, but the file itself was not)
old_path = old_tree.id2path(file_id)
=== modified file 'bzrlib/msgeditor.py'
--- a/bzrlib/msgeditor.py 2007-08-29 08:55:21 +0000
+++ b/bzrlib/msgeditor.py 2007-08-31 05:32:00 +0000
@@ -99,6 +99,34 @@
:return: commit message or None.
"""
+
+ if not start_message is None:
+ start_message = start_message.encode(bzrlib.user_encoding)
+ return edit_commit_message_encoded(infotext.encode(bzrlib.user_encoding),
+ ignoreline, start_message)
+
+
+def edit_commit_message_encoded(infotext, ignoreline=DEFAULT_IGNORE_LINE,
+ start_message=None):
+ """Let the user edit a commit message in a temp file.
+
+ This is run if they don't give a message or
+ message-containing file on the command line.
+
+ :param infotext: Text to be displayed at bottom of message
+ for the user's reference;
+ currently similar to 'bzr status'.
+ The string is already encoded
+
+ :param ignoreline: The separator to use above the infotext.
+
+ :param start_message: The text to place above the separator, if any.
+ This will not be removed from the message
+ after the user has edited it.
+ The string is already encoded
+
+ :return: commit message or None.
+ """
msgfilename = None
try:
msgfilename, hasinfo = _create_temp_file_with_commit_template(
@@ -163,12 +191,14 @@
:param infotext: Text to be displayed at bottom of message
for the user's reference;
currently similar to 'bzr status'.
+ The text is already encoded.
:param ignoreline: The separator to use above the infotext.
:param start_message: The text to place above the separator, if any.
This will not be removed from the message
after the user has edited it.
+ The string is already encoded
:return: 2-tuple (temp file name, hasinfo)
"""
@@ -179,14 +209,11 @@
msgfile = os.fdopen(tmp_fileno, 'w')
try:
if start_message is not None:
- msgfile.write("%s\n" % start_message.encode(
- bzrlib.user_encoding, 'replace'))
+ msgfile.write("%s\n" % start_message)
if infotext is not None and infotext != "":
hasinfo = True
- msgfile.write("\n\n%s\n\n%s" % (ignoreline,
- infotext.encode(bzrlib.user_encoding,
- 'replace')))
+ msgfile.write("\n\n%s\n\n%s" %(ignoreline, infotext))
else:
hasinfo = False
finally:
@@ -200,8 +227,6 @@
Returns a unicode string containing the template.
"""
- # TODO: Should probably be given the WorkingTree not the branch
- #
# TODO: make provision for this to be overridden or modified by a hook
#
# TODO: Rather than running the status command, should prepare a draft of
@@ -213,3 +238,30 @@
show_tree_status(working_tree, specific_files=specific_files,
to_file=status_tmp)
return status_tmp.getvalue()
+
+
+def make_commit_message_template_encoded(working_tree, specific_files,
+ diff=None, output_encoding='utf-8'):
+ """Prepare a template file for a commit into a branch.
+
+ Returns an encoded string.
+ """
+ # TODO: make provision for this to be overridden or modified by a hook
+ #
+ # TODO: Rather than running the status command, should prepare a draft of
+ # the revision to be committed, then pause and ask the user to
+ # confirm/write a message.
+ from StringIO import StringIO # must be unicode-safe
+ from bzrlib.diff import show_diff_trees
+
+ template = make_commit_message_template(working_tree, specific_files)
+ template = template.encode(output_encoding, "replace")
+
+ if diff:
+ stream = StringIO()
+ show_diff_trees(working_tree.basis_tree(),
+ working_tree, stream, specific_files,
+ path_encoding=output_encoding)
+ template = template + '\n' + stream.getvalue()
+
+ return template
=== modified file 'bzrlib/tests/test_msgeditor.py'
--- a/bzrlib/tests/test_msgeditor.py 2007-08-21 12:28:01 +0000
+++ b/bzrlib/tests/test_msgeditor.py 2007-08-31 05:32:00 +0000
@@ -20,18 +20,20 @@
import os
import sys
+from bzrlib import (
+ errors,
+ msgeditor,
+ osutils,
+ )
from bzrlib.branch import Branch
from bzrlib.config import ensure_config_dir_exists, config_filename
-import bzrlib.msgeditor
+from bzrlib.msgeditor import (
+ make_commit_message_template_encoded,
+ edit_commit_message_encoded
+)
from bzrlib.tests import TestCaseWithTransport, TestSkipped
from bzrlib.trace import mutter
-from bzrlib import (
- osutils,
- errors
- )
-
-
class MsgEditorTest(TestCaseWithTransport):
def make_uncommitted_tree(self):
@@ -50,13 +52,44 @@
def test_commit_template(self):
"""Test building a commit message template"""
working_tree = self.make_uncommitted_tree()
- template = bzrlib.msgeditor.make_commit_message_template(working_tree, None)
+ template = msgeditor.make_commit_message_template(working_tree,
+ None)
self.assertEqualDiff(template,
u"""\
added:
hell\u00d8
""")
+ def test_commit_template_encoded(self):
+ """Test building a commit message template"""
+ working_tree = self.make_uncommitted_tree()
+ template = make_commit_message_template_encoded(working_tree,
+ None,
+ output_encoding='utf8')
+ self.assertEqualDiff(template,
+u"""\
+added:
+ hell\u00d8
+""".encode("utf8"))
+
+
+ def test_commit_template_and_diff(self):
+ """Test building a commit message template"""
+ working_tree = self.make_uncommitted_tree()
+ template = make_commit_message_template_encoded(working_tree,
+ None,
+ diff=True,
+ output_encoding='utf8')
+
+ self.assertTrue("""\
+@@ -0,0 +1,1 @@
++contents of hello
+""" in template)
+ self.assertTrue(u"""\
+added:
+ hell\u00d8
+""".encode('utf8') in template)
+
def setUp(self):
super(MsgEditorTest, self).setUp()
self._bzr_editor = os.environ.get('BZR_EDITOR', None)
@@ -82,7 +115,7 @@
os.chmod('fed.sh', 0755)
os.environ['BZR_EDITOR'] = './fed.sh'
- self.assertEqual(True, bzrlib.msgeditor._run_editor(''),
+ self.assertEqual(True, msgeditor._run_editor(''),
'Unable to run dummy fake editor')
def make_fake_editor(self, message='test message from fed\\n'):
@@ -127,20 +160,23 @@
mutter('edit_commit_message without infotext')
self.assertEqual('test message from fed\n',
- bzrlib.msgeditor.edit_commit_message(''))
+ msgeditor.edit_commit_message(''))
mutter('edit_commit_message with unicode infotext')
self.assertEqual('test message from fed\n',
- bzrlib.msgeditor.edit_commit_message(u'\u1234'))
+ msgeditor.edit_commit_message(u'\u1234'))
+
+ tmpl = edit_commit_message_encoded(u'\u1234'.encode("utf8"))
+ self.assertEqual('test message from fed\n', tmpl)
def test_start_message(self):
self.make_uncommitted_tree()
self.make_fake_editor()
self.assertEqual('test message from fed\nstart message\n',
- bzrlib.msgeditor.edit_commit_message('',
+ msgeditor.edit_commit_message('',
start_message='start message\n'))
self.assertEqual('test message from fed\n',
- bzrlib.msgeditor.edit_commit_message('',
+ msgeditor.edit_commit_message('',
start_message=''))
def test_deleted_commit_message(self):
@@ -151,7 +187,7 @@
else:
os.environ['BZR_EDITOR'] = 'rm'
- self.assertRaises((IOError, OSError), bzrlib.msgeditor.edit_commit_message, '')
+ self.assertRaises((IOError, OSError), msgeditor.edit_commit_message, '')
def test__get_editor(self):
# Test that _get_editor can return a decent list of items
@@ -168,7 +204,7 @@
f.write('editor = config_editor\n')
f.close()
- editors = list(bzrlib.msgeditor._get_editor())
+ editors = list(msgeditor._get_editor())
self.assertEqual(['bzr_editor', 'config_editor', 'visual',
'editor'], editors[:4])
@@ -197,7 +233,7 @@
def test__create_temp_file_with_commit_template(self):
# check that commit template written properly
# and has platform native line-endings (CRLF on win32)
- create_file = bzrlib.msgeditor._create_temp_file_with_commit_template
+ create_file = msgeditor._create_temp_file_with_commit_template
msgfilename, hasinfo = create_file('infotext','----','start message')
self.assertNotEqual(None, msgfilename)
self.assertTrue(hasinfo)
@@ -211,7 +247,7 @@
def test__create_temp_file_with_empty_commit_template(self):
# empty file
- create_file = bzrlib.msgeditor._create_temp_file_with_commit_template
+ create_file = msgeditor._create_temp_file_with_commit_template
msgfilename, hasinfo = create_file('')
self.assertNotEqual(None, msgfilename)
self.assertFalse(hasinfo)
@@ -224,6 +260,6 @@
working_tree = self.make_uncommitted_tree()
self.assertRaises(errors.BadCommitMessageEncoding,
- bzrlib.msgeditor.edit_commit_message, '')
+ msgeditor.edit_commit_message, '')
finally:
osutils.set_or_unset_env('LANG', old_env)
=== modified file 'doc/en/user-guide/tutorial.txt'
--- a/doc/en/user-guide/tutorial.txt 2007-08-20 23:43:41 +0000
+++ b/doc/en/user-guide/tutorial.txt 2007-08-24 16:49:00 +0000
@@ -317,6 +317,20 @@
override either of the above mentioned editor options. If you quit the
editor without making any changes, the commit will be cancelled.
+The file that is opened in the editor contains a horizontal line. The part
+of the file below this line is included for information only, and will not
+form part of the commit message. Below the separator is shown the list of
+files that are changed in the commit. You should write your message above
+the line, and then save the file and exit.
+
+If you would like to see the diff that will be committed as you edit the
+message you can use the ``--show-diff`` option to ``commit``. This will include
+the diff in the editor when it is opened, below the separator and the
+information about the files that will be committed. This means that you can
+read it as you write the message, but the diff itself wont be seen in the
+commit message when you have finished. If you would like parts to be
+included in the message you can copy and paste them above the separator.
+
Selective commit
----------------
More information about the bazaar-commits
mailing list