Merge lp:~ian-clatworthy/bzr/commit-help into lp:~bzr/bzr/trunk-old

Proposed by Ian Clatworthy on 2009-05-12
Status: Merged
Merged at revision: not available
Proposed branch: lp:~ian-clatworthy/bzr/commit-help
Merge into: lp:~bzr/bzr/trunk-old
Diff against target: 158 lines
To merge this branch: bzr merge lp:~ian-clatworthy/bzr/commit-help
Reviewer Review Type Date Requested Status
Robert Collins (community) 2009-05-12 Approve on 2009-05-12
Review via email: mp+6454@code.launchpad.net
To post a comment you must log in.
Ian Clatworthy (ian-clatworthy) wrote :

Some drive-by improvements to the commit help and a commit error message.

Robert Collins (lifeless) wrote :

 review approve

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bzrlib/builtins.py'
--- bzrlib/builtins.py 2009-05-11 18:35:20 +0000
+++ bzrlib/builtins.py 2009-05-12 13:35:10 +0000
@@ -2727,42 +2727,75 @@
2727class cmd_commit(Command):2727class cmd_commit(Command):
2728 """Commit changes into a new revision.2728 """Commit changes into a new revision.
27292729
2730 If no arguments are given, the entire tree is committed.2730 An explanatory message needs to be given for each commit. This is
27312731 often done by using the --message option (getting the message from the
2732 If selected files are specified, only changes to those files are2732 command line) or by using the --file option (getting the message from
2733 committed. If a directory is specified then the directory and everything2733 a file). If neither of these options is given, an editor is opened for
2734 within it is committed.2734 the user to enter the message. To see the changed files in the
27352735 boilerplate text loaded into the editor, use the --show-diff option.
2736 When excludes are given, they take precedence over selected files.2736
2737 For example, too commit only changes within foo, but not changes within2737 By default, the entire tree is committed and the person doing the
2738 foo/bar::2738 commit is assumed to be the author. These defaults can be overridden
27392739 as explained below.
2740 bzr commit foo -x foo/bar2740
27412741 :Selective commits:
2742 If author of the change is not the same person as the committer, you can2742
2743 specify the author's name using the --author option. The name should be2743 If selected files are specified, only changes to those files are
2744 in the same format as a committer-id, e.g. "John Doe <jdoe@example.com>".2744 committed. If a directory is specified then the directory and
2745 If there is more than one author of the change you can specify the option2745 everything within it is committed.
2746 multiple times, once for each author.2746
27472747 When excludes are given, they take precedence over selected files.
2748 A selected-file commit may fail in some cases where the committed2748 For example, to commit only changes within foo, but not changes
2749 tree would be invalid. Consider::2749 within foo/bar::
27502750
2751 bzr init foo2751 bzr commit foo -x foo/bar
2752 mkdir foo/bar2752
2753 bzr add foo/bar2753 A selective commit after a merge is not yet supported.
2754 bzr commit foo -m "committing foo"2754
2755 bzr mv foo/bar foo/baz2755 :Custom authors:
2756 mkdir foo/bar2756
2757 bzr add foo/bar2757 If the author of the change is not the same person as the committer,
2758 bzr commit foo/bar -m "committing bar but not baz"2758 you can specify the author's name using the --author option. The
27592759 name should be in the same format as a committer-id, e.g.
2760 In the example above, the last commit will fail by design. This gives2760 "John Doe <jdoe@example.com>". If there is more than one author of
2761 the user the opportunity to decide whether they want to commit the2761 the change you can specify the option multiple times, once for each
2762 rename at the same time, separately first, or not at all. (As a general2762 author.
2763 rule, when in doubt, Bazaar has a policy of Doing the Safe Thing.)2763
27642764 :Checks:
2765 Note: A selected-file commit after a merge is not yet supported.2765
2766 A common mistake is to forget to add a new file or directory before
2767 running the commit command. The --strict option checks for unknown
2768 files and aborts the commit if any are found. More advanced pre-commit
2769 checks can be implemented by defining hooks. See ``bzr help hooks``
2770 for details.
2771
2772 :Things to note:
2773
2774 If you accidentially commit the wrong changes or make a spelling
2775 mistake in the commit message say, you can use the uncommit command
2776 to undo it. See ``bzr help uncommit`` for details.
2777
2778 Hooks can also be configured to run after a commit. This allows you
2779 to trigger updates to external systems like bug trackers. The --fixes
2780 option can be used to record the association between a revision and
2781 one or more bugs. See ``bzr help bugs`` for details.
2782
2783 A selective commit may fail in some cases where the committed
2784 tree would be invalid. Consider::
2785
2786 bzr init foo
2787 mkdir foo/bar
2788 bzr add foo/bar
2789 bzr commit foo -m "committing foo"
2790 bzr mv foo/bar foo/baz
2791 mkdir foo/bar
2792 bzr add foo/bar
2793 bzr commit foo/bar -m "committing bar but not baz"
2794
2795 In the example above, the last commit will fail by design. This gives
2796 the user the opportunity to decide whether they want to commit the
2797 rename at the same time, separately first, or not at all. (As a general
2798 rule, when in doubt, Bazaar has a policy of Doing the Safe Thing.)
2766 """2799 """
2767 # TODO: Run hooks on tree to-be-committed, and after commit.2800 # TODO: Run hooks on tree to-be-committed, and after commit.
27682801
@@ -2773,7 +2806,7 @@
27732806
2774 # XXX: verbose currently does nothing2807 # XXX: verbose currently does nothing
27752808
2776 _see_also = ['bugs', 'uncommit']2809 _see_also = ['add', 'bugs', 'hooks', 'uncommit']
2777 takes_args = ['selected*']2810 takes_args = ['selected*']
2778 takes_options = [2811 takes_options = [
2779 ListOption('exclude', type=str, short_name='x',2812 ListOption('exclude', type=str, short_name='x',
@@ -2900,8 +2933,8 @@
2900 except PointlessCommit:2933 except PointlessCommit:
2901 # FIXME: This should really happen before the file is read in;2934 # FIXME: This should really happen before the file is read in;
2902 # perhaps prepare the commit; get the message; then actually commit2935 # perhaps prepare the commit; get the message; then actually commit
2903 raise errors.BzrCommandError("no changes to commit."2936 raise errors.BzrCommandError("No changes to commit."
2904 " use --unchanged to commit anyhow")2937 " Use --unchanged to commit anyhow.")
2905 except ConflictsInTree:2938 except ConflictsInTree:
2906 raise errors.BzrCommandError('Conflicts detected in working '2939 raise errors.BzrCommandError('Conflicts detected in working '
2907 'tree. Use "bzr conflicts" to list, "bzr resolve FILE" to'2940 'tree. Use "bzr conflicts" to list, "bzr resolve FILE" to'
29082941
=== modified file 'bzrlib/tests/blackbox/test_commit.py'
--- bzrlib/tests/blackbox/test_commit.py 2009-03-27 04:10:25 +0000
+++ bzrlib/tests/blackbox/test_commit.py 2009-05-12 13:35:11 +0000
@@ -43,8 +43,8 @@
43 self.build_tree(['hello.txt'])43 self.build_tree(['hello.txt'])
44 out,err = self.run_bzr('commit -m empty', retcode=3)44 out,err = self.run_bzr('commit -m empty', retcode=3)
45 self.assertEqual('', out)45 self.assertEqual('', out)
46 self.assertContainsRe(err, 'bzr: ERROR: no changes to commit\.'46 self.assertContainsRe(err, 'bzr: ERROR: No changes to commit\.'
47 ' use --unchanged to commit anyhow\n')47 ' Use --unchanged to commit anyhow.\n')
4848
49 def test_commit_success(self):49 def test_commit_success(self):
50 """Successful commit should not leave behind a bzr-commit-* file"""50 """Successful commit should not leave behind a bzr-commit-* file"""
@@ -395,7 +395,7 @@
395395
396 # With no changes, it should just be 'no changes'396 # With no changes, it should just be 'no changes'
397 # Make sure that commit is failing because there is nothing to do397 # Make sure that commit is failing because there is nothing to do
398 self.run_bzr_error(['no changes to commit'],398 self.run_bzr_error(['No changes to commit'],
399 'commit --strict -m no-changes',399 'commit --strict -m no-changes',
400 working_dir='tree')400 working_dir='tree')
401401