[MERGE][Bug #52479] Message at the end of commit for bound branches

Daniel Watkins D.M.Watkins at warwick.ac.uk
Wed Sep 5 00:26:24 BST 2007


On Tue, 2007-09-04 at 13:18 +1000, Martin Pool wrote:
> > I wouldn't veto it, but it seems like a half-measure to me.  Why show
> > the location for bound commits, but not regular commits, or commits in
> > lightweight checkouts?
> >
> > And why not show it earlier, so the user can abort the commit if it's
> > going to the wrong place?
> 
> That makes sense to me.  Daniel, what do you think?
It makes sense to me.

In the attached I've added a started hook to be called when the initial
message should be sent.  I'm not 100% sure that this is the right way to
do it but need some input regardless.

-- 
Daniel Watkins (Odd_Bloke) <D.M.Watkins at warwick.ac.uk>
University of Warwick Christian Focus President
University of Warwick Computing Society WUGLUG Liaison Officer
-------------- next part --------------
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: d.m.watkins at warwick.ac.uk-20070904232551-\
#   atbaa0o3wlb8utrp
# target_branch: file:///home/daniel/devel/bzr/bzr.dev/
# testament_sha1: 5d9291125efbda9919818357144292d24f8a2df1
# timestamp: 2007-09-05 00:26:04 +0100
# base_revision_id: pqm at pqm.ubuntu.com-20070904035759-iv4xl6d7ez69txba
# 
# Begin patch
=== modified file 'NEWS'
--- NEWS	2007-09-04 01:20:26 +0000
+++ NEWS	2007-09-04 23:25:51 +0000
@@ -117,6 +117,9 @@
    * When two plugins conflict, the source of both the losing and now the
      winning definition is shown.  (Konstantin Mikhaylov, #5454)
 
+   * When committing to a branch, the location being committed to is
+     displayed.  (Daniel Watkins, #52479)
+
   IMPROVEMENTS:
 
    * Add the option "--show-diff" to the commit command in order to display

=== modified file 'bzrlib/commit.py'
--- bzrlib/commit.py	2007-09-02 05:37:08 +0000
+++ bzrlib/commit.py	2007-09-04 23:23:25 +0000
@@ -86,6 +86,9 @@
 class NullCommitReporter(object):
     """I report on progress of a commit."""
 
+    def started(self, revno, revid, location=None):
+        pass
+
     def snapshot_change(self, change, path):
         pass
 
@@ -121,6 +124,13 @@
             return
         self._note("%s %s", change, path)
 
+    def started(self, revno, rev_id, location=None):
+        if location is not None:
+            location = ' to "' + location + '"'
+        else:
+            location = ''
+        self._note('Committing revision %d%s.', revno, location)
+
     def completed(self, revno, rev_id):
         self._note('Committed revision %d.', revno)
     
@@ -290,7 +300,7 @@
             self._gather_parents()
             if len(self.parents) > 1 and self.specific_files:
                 raise errors.CannotCommitSelectedFileMerge(self.specific_files)
-            
+
             # Collect the changes
             self._set_progress_stage("Collecting changes",
                     entries_title="Directory")
@@ -298,6 +308,15 @@
                 self.config, timestamp, timezone, committer, revprops, rev_id)
             
             try:
+                # find the location being committed to
+                if self.bound_branch:
+                    master_location = self.master_branch.base
+                else:
+                    master_location = self.branch.base
+
+                # report the start of the commit
+                self.reporter.started(new_revno, self.rev_id, master_location)
+
                 self._update_builder_with_changes()
                 self._check_pointless()
 

=== modified file 'bzrlib/tests/blackbox/test_commit.py'
--- bzrlib/tests/blackbox/test_commit.py	2007-09-04 03:57:59 +0000
+++ bzrlib/tests/blackbox/test_commit.py	2007-09-04 23:23:25 +0000
@@ -35,7 +35,7 @@
         self.build_tree(['hello.txt'])
         out,err = self.run_bzr('commit -m empty', retcode=3)
         self.assertEqual('', out)
-        self.assertStartsWith(err, 'bzr: ERROR: no changes to commit.'
+        self.assertContainsRe(err, 'bzr: ERROR: no changes to commit\.'
                                   ' use --unchanged to commit anyhow\n')
 
     def test_commit_success(self):
@@ -75,9 +75,9 @@
         tree.add("hello.txt")
         out,err = self.run_bzr('commit -m added')
         self.assertEqual('', out)
-        self.assertEqual('added hello.txt\n'
-                         'Committed revision 1.\n',
-                         err)
+        self.assertContainsRe(err, '^Committing revision 1 to ".*"\.\n'
+                              'added hello.txt\n'
+                              'Committed revision 1.\n$',)
 
     def prepare_simple_history(self):
         """Prepare and return a working tree with one commit of one file"""
@@ -94,9 +94,9 @@
         self.build_tree_contents([('hello.txt', 'new contents')])
         out, err = self.run_bzr('commit -m modified')
         self.assertEqual('', out)
-        self.assertEqual('modified hello.txt\n'
-                         'Committed revision 2.\n',
-                         err)
+        self.assertContainsRe(err, '^Committing revision 2 to ".*"\.\n'
+                              'modified hello\.txt\n'
+                              'Committed revision 2\.\n$')
 
     def test_verbose_commit_renamed(self):
         # Verbose commit of renamed file should say so
@@ -104,9 +104,9 @@
         wt.rename_one('hello.txt', 'gutentag.txt')
         out, err = self.run_bzr('commit -m renamed')
         self.assertEqual('', out)
-        self.assertEqual('renamed hello.txt => gutentag.txt\n'
-                         'Committed revision 2.\n',
-                         err)
+        self.assertContainsRe(err, '^Committing revision 2 to ".*"\.\n'
+                              'renamed hello\.txt => gutentag\.txt\n'
+                              'Committed revision 2\.$\n')
 
     def test_verbose_commit_moved(self):
         # Verbose commit of file moved to new directory should say so
@@ -116,10 +116,10 @@
         wt.rename_one('hello.txt', 'subdir/hello.txt')
         out, err = self.run_bzr('commit -m renamed')
         self.assertEqual('', out)
-        self.assertEqualDiff('added subdir\n'
-                             'renamed hello.txt => subdir/hello.txt\n'
-                             'Committed revision 2.\n',
-                             err)
+        self.assertContainsRe(err, '^Committing revision 2 to ".*"\.\n'
+                              'added subdir\n'
+                              'renamed hello\.txt => subdir/hello\.txt\n'
+                              'Committed revision 2\.\n$')
 
     def test_verbose_commit_with_unknown(self):
         """Unknown files should not be listed by default in verbose output"""
@@ -129,9 +129,9 @@
         wt.add(['hello.txt'])
         out,err = self.run_bzr('commit -m added')
         self.assertEqual('', out)
-        self.assertEqual('added hello.txt\n'
-                         'Committed revision 1.\n',
-                         err)
+        self.assertContainsRe(err, '^Committing revision 1 to ".*"\.\n'
+                              'added hello\.txt\n'
+                              'Committed revision 1\.\n$')
 
     def test_verbose_commit_with_unchanged(self):
         """Unchanged files should not be listed by default in verbose output"""
@@ -142,9 +142,22 @@
         tree.add("hello.txt")
         out,err = self.run_bzr('commit -m added')
         self.assertEqual('', out)
-        self.assertEqual('added hello.txt\n'
-                         'Committed revision 2.\n',
-                         err)
+        self.assertContainsRe(err, '^Committing revision 2 to ".*"\.\n'
+                              'added hello\.txt\n'
+                              'Committed revision 2\.$\n')
+
+    def test_verbose_bound_commit_includes_master_location(self):
+        """Location of master is displayed when committing to bound branch"""
+        a_tree = self.make_branch_and_tree('a')
+        self.build_tree(['a/b'])
+        a_tree.add('b')
+        a_tree.commit(message='Initial message')
+
+        b_tree = a_tree.branch.create_checkout('b')
+        expected = self.get_url('a') + '/'
+        out, err = self.run_bzr('commit -m blah --unchanged', working_dir='b')
+        self.assertEqual(err, 'Committing revision 2 to "%s".\n'
+                         'Committed revision 2.\n' % expected)
 
     def test_commit_merge_reports_all_modified_files(self):
         # the commit command should show all the files that are shown by
@@ -198,9 +211,9 @@
         this_tree.merge_from_branch(other_tree.branch)
         os.chdir('this')
         out,err = self.run_bzr('commit -m added')
-        os.chdir('..')
         self.assertEqual('', out)
         self.assertEqualDiff(
+            'Committing revision 2 to "%s".\n'
             'modified filetomodify\n'
             'added newdir\n'
             'added newfile\n'
@@ -210,7 +223,7 @@
             'renamed filetorename => renamedfile\n'
             'deleted dirtoremove\n'
             'deleted filetoremove\n'
-            'Committed revision 2.\n',
+            'Committed revision 2.\n' % (this_tree.branch.base, ),
             err)
 
     def test_empty_commit_message(self):
@@ -367,7 +380,9 @@
         output, err = self.run_bzr(
             'commit -m hello --fixes=lp:23452 tree/hello.txt')
         self.assertEqual('', output)
-        self.assertEqual('added hello.txt\nCommitted revision 1.\n', err)
+        self.assertContainsRe(err, 'Committing revision 1 to ".*"\.\n'
+                              'added hello\.txt\n'
+                              'Committed revision 1\.\n')
 
     def test_no_bugs_no_properties(self):
         """If no bugs are fixed, the bugs property is not set.

# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWa3U1QMAE0f/gHRUQhBf////
fieej7////BgFq7vYoab7PX3e4j1Y4KKPrQqig29xoUUAZa0m1MijCMhGrMqqFEhSq1tVqKhkRKa
P1PUnqep4k00bU8KeoBoAeoAAAAAKp+pGgNP1J+qbJAyAA0AAAAAAABpqGSeqJo00zUNG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ImJrNBmIgq29RUJ1uW
Uto0m6PvRdai5QZIPdCV+aPjjD9SnTxMiKyuCEghU5xPvEkDpEhVmxSGE0U25uMViP+EXbeu12Pc
RclL4l1yokkkkgSIBMZnEoKjQV0CdNOoTTJX0Wv1J3IUychKCLAhiLCQk5jKBaLuL3kvWjcwQHqe
sk4XxIFNApfEwCIyE32BY23hKIorSSMunspVZcTOBX9dspyNFf75x5+928zvMB3VZtvSjSFa3IRz
COIjIRci+ayZ5k5wttEtW2woF6WbTSXorzJ2zjoEpRtNjsbtbhVXEQClN56Q7wYVROCPNFYed/Hl
+CLCLiNZJxhOFERcRREiIxoBkkK94sviJrQpMapIlsAayQpBlieULbkfsRRG0nPK1RfJ+e0O2kFB
UdXEX7BMgmA5yfsAvL12zzkPXt8J/MfgJwEqMQm+4TjpD5tALZmwVx02QKLUJmBghPHSJ41OYVHW
CDvseHAMwqO4jJLK1SanHf2ouPfb4ns4xdCiDRFZHRsUb9BNbsErBPt875WJjL24Tm4ahNq7hMjG
ydIn4Wo8ockcNkbo//F3JFOFCQrdTVAw
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20070905/0f088aab/attachment-0001.pgp 


More information about the bazaar mailing list