This looks good to me. I've implemented Ian's review suggestions (added tests, added NEWS entry, and added '.' to the end of the option help). I also fixed it to preserve the timezone specified in the --commit-time.
+* ``bzr commit`` now has a ``--commit-time`` option.
+ (Alexander Sack, #459276)
+
Bug Fixes
*********
=== modified file 'bzrlib/builtins.py'
--- bzrlib/builtins.py 2009-10-23 18:00:44 +0000
+++ bzrlib/builtins.py 2009-11-19 06:27:16 +0000
@@ -2943,8 +2943,8 @@ help="Refuse to commit if there are unknown " "files in the working tree."), Option('commit-time', type=str,
- help="Manually set a commit time using commit date format, e.g."
- "'2009-10-10 08:00:00 +0100'"),
+ help="Manually set a commit time using commit date "
+ "format, e.g. '2009-10-10 08:00:00 +0100'."), ListOption('fixes', type=str, help="Mark a bug as being fixed by this revision " "(see \"bzr help bugs\")."),
@@ -2996,9 +2996,13 @@ make_commit_message_template_encoded
)
- commit_stamp = None
+ commit_stamp = offset = None
if commit_time is not None:
+ try: commit_stamp, offset = timestamp.parse_patch_date(commit_time)
+ except ValueError, e:
+ raise errors.BzrCommandError(
+ "Could not parse --commit-time: " + str(e))
# TODO: Need a blackbox test for invoking the external editor; may be
# slightly problematic to run this cross-platform.
@@ -3058,6 +3062,7 @@ allow_pointless=unchanged, strict=strict, local=local, reporter=None, verbose=verbose, revprops=properties, authors=author, timestamp=commit_stamp,
+ timezone=offset, exclude=safe_relpath_files(tree, exclude))
except PointlessCommit:
# FIXME: This should really happen before the file is read in;
This looks good to me. I've implemented Ian's review suggestions (added tests, added NEWS entry, and added '.' to the end of the option help). I also fixed it to preserve the timezone specified in the --commit-time.
I'm submitting it to PQM now.
Here's the relevant diff of my changes:
=== modified file 'NEWS'
--- NEWS 2009-11-18 22:03:00 +0000
+++ NEWS 2009-11-19 06:30:25 +0000
@@ -23,6 +23,9 @@
New Features
************
+* ``bzr commit`` now has a ``--commit-time`` option.
+ (Alexander Sack, #459276)
+
Bug Fixes
*********
=== modified file 'bzrlib/ builtins. py'
help="Refuse to commit if there are unknown "
"files in the working tree."),
Option( 'commit- time', type=str,
ListOption( 'fixes' , type=str,
help="Mark a bug as being fixed by this revision "
"( see \"bzr help bugs\")."),
make_ commit_ message_ template_ encoded
--- bzrlib/builtins.py 2009-10-23 18:00:44 +0000
+++ bzrlib/builtins.py 2009-11-19 06:27:16 +0000
@@ -2943,8 +2943,8 @@
- help="Manually set a commit time using commit date format, e.g."
- "'2009-10-10 08:00:00 +0100'"),
+ help="Manually set a commit time using commit date "
+ "format, e.g. '2009-10-10 08:00:00 +0100'."),
@@ -2996,9 +2996,13 @@
)
- commit_stamp = None
commit_ stamp, offset = timestamp. parse_patch_ date(commit_ time) BzrCommandError (
+ commit_stamp = offset = None
if commit_time is not None:
+ try:
+ except ValueError, e:
+ raise errors.
+ "Could not parse --commit-time: " + str(e))
# TODO: Need a blackbox test for invoking the external editor; may be
allow_ pointless= unchanged, strict=strict, local=local,
reporter= None, verbose=verbose, revprops= properties,
authors= author, timestamp= commit_ stamp,
exclude= safe_relpath_ files(tree, exclude))
# slightly problematic to run this cross-platform.
@@ -3058,6 +3062,7 @@
+ timezone=offset,
except PointlessCommit:
# FIXME: This should really happen before the file is read in;
=== modified file 'bzrlib/ tests/blackbox/ test_commit. py' tests/blackbox/ test_commit. py 2009-08-28 05:00:33 +0000 tests/blackbox/ test_commit. py 2009-11-19 06:27:16 +0000
self. assertEqual( 'John Doe\nJane Rey', properties[ 'authors' ])
--- bzrlib/
+++ bzrlib/
@@ -590,6 +590,26 @@
properties = last_rev.properties
+ def test_commit_ time(self) : branch_ and_tree( 'tree') tree([' tree/hello. txt']) 'hello. txt') bzr("commit -m hello " time='2009- 10-10 08:00:00 +0100' tree/hello.txt") repository. get_revision( tree.last_ revision( )) format_ date(last_ rev.timestamp, last_rev.timezone)) time_bad_ time(self) : branch_ and_tree( 'tree') tree([' tree/hello. txt']) 'hello. txt') bzr("commit -m hello " tsWith( commit_ with_renames_ in_tree( self): branch_ and_tree( '.')
+ tree = self.make_
+ self.build_
+ tree.add(
+ out, err = self.run_
+ "--commit-
+ last_rev = tree.branch.
+ self.assertEqual(
+ 'Sat 2009-10-10 08:00:00 +0100',
+ osutils.
+
+ def test_commit_
+ tree = self.make_
+ self.build_
+ tree.add(
+ out, err = self.run_
+ "--commit-time='NOT A TIME' tree/hello.txt", retcode=3)
+ self.assertStar
+ err, "bzr: ERROR: Could not parse --commit-time:")
+
def test_partial_
# this test illustrates bug #140419
t = self.make_
Thanks very much for the code!