[Pkg-bazaar-commits] ./bzr/unstable r389: - new commit --file option!

Martin Pool mbp at sourcefrog.net
Fri Apr 10 07:52:08 UTC 2009


------------------------------------------------------------
revno: 389
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Fri 2005-05-06 12:49:04 +1000
message:
  - new commit --file option!
modified:
  NEWS
  bzrlib/commands.py
  testbzr
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2005-05-05 09:58:03 +0000
+++ b/NEWS	2005-05-06 02:49:04 +0000
@@ -22,6 +22,9 @@
 
     * Changed format for describing changes in ``bzr log -v``.
 
+    * New option ``bzr commit --file`` to take a message from a file,
+      suggested by LarstiQ.
+
   TESTING:
 
     * Converted black-box test suites from Bourne shell into Python;
@@ -32,8 +35,8 @@
 
     * Included ElementTree library upgraded to 1.2.6 by Fredrik Lundh.
 
-    * Refactor command functions into Command objects based on
-      mango-sorbet by Scott James Remnant.
+    * Refactor command functions into Command objects based on HCT by
+      Scott James Remnant.
 
     * Better help messages for many commands.
 

=== modified file 'bzrlib/commands.py'
--- a/bzrlib/commands.py	2005-05-05 23:28:27 +0000
+++ b/bzrlib/commands.py	2005-05-06 02:49:04 +0000
@@ -578,12 +578,21 @@
 
     TODO: Strict commit that fails if there are unknown or deleted files.
     """
-    takes_options = ['message', 'verbose']
+    takes_options = ['message', 'file', 'verbose']
     aliases = ['ci', 'checkin']
 
-    def run(self, message=None, verbose=False):
-        if not message:
-            raise BzrCommandError("please specify a commit message")
+    def run(self, message=None, file=None, verbose=False):
+        ## Warning: shadows builtin file()
+        if not message and not file:
+            raise BzrCommandError("please specify a commit message",
+                                  ["use either --message or --file"])
+        elif message and file:
+            raise BzrCommandError("please specify either --message or --file")
+        
+        if file:
+            import codecs
+            message = codecs.open(file, 'rt', bzrlib.user_encoding).read()
+
         Branch('.').commit(message, verbose=verbose)
 
 
@@ -690,6 +699,7 @@
 OPTIONS = {
     'all':                    None,
     'help':                   None,
+    'file':                   unicode,
     'message':                unicode,
     'profile':                None,
     'revision':               int,
@@ -702,6 +712,7 @@
 
 SHORT_OPTIONS = {
     'm':                      'message',
+    'F':                      'file', 
     'r':                      'revision',
     'v':                      'verbose',
 }

=== modified file 'testbzr'
--- a/testbzr	2005-05-05 09:51:01 +0000
+++ b/testbzr	2005-05-06 02:49:04 +0000
@@ -230,7 +230,16 @@
 
     runcmd('bzr move sub2/hello.txt .')
     assert exists('hello.txt')
-    
+
+    f = file('hello.txt', 'wt')
+    f.write('some nice new content\n')
+    f.close()
+
+    f = file('msg.tmp', 'wt')
+    f.write('this is my new commit\n')
+    f.close()
+
+    runcmd('bzr commit -F msg.tmp')
     
     cd('..')
 



More information about the Pkg-bazaar-commits mailing list