Rev 4812: (Alexander Sack) Add --commit-time option to 'bzr commit'. (#459276) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Nov 19 07:19:37 GMT 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4812 [merge]
revision-id: pqm at pqm.ubuntu.com-20091119071935-afqk3kz52tlwssze
parent: pqm at pqm.ubuntu.com-20091119024838-oatmgpzxox7lwx4y
parent: andrew.bennetts at canonical.com-20091119063025-ofke4pt2rz6jlnj3
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2009-11-19 07:19:35 +0000
message:
(Alexander Sack) Add --commit-time option to 'bzr commit'. (#459276)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/tests/blackbox/test_commit.py test_commit.py-20060212094538-ae88fc861d969db0
=== modified file 'NEWS'
--- a/NEWS 2009-11-18 22:03:00 +0000
+++ b/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'
--- a/bzrlib/builtins.py 2009-11-17 03:54:52 +0000
+++ b/bzrlib/builtins.py 2009-11-19 06:28:13 +0000
@@ -44,6 +44,7 @@
rename_map,
revision as _mod_revision,
symbol_versioning,
+ timestamp,
transport,
ui,
urlutils,
@@ -2949,6 +2950,9 @@
Option('strict',
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'."),
ListOption('fixes', type=str,
help="Mark a bug as being fixed by this revision "
"(see \"bzr help bugs\")."),
@@ -2961,9 +2965,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.'),
+ Option('show-diff',
+ help='When no message is supplied, show the diff along'
+ ' with the status summary in the message editor.'),
]
aliases = ['ci', 'checkin']
@@ -2988,7 +2992,7 @@
def run(self, message=None, file=None, verbose=False, selected_list=None,
unchanged=False, strict=False, local=False, fixes=None,
- author=None, show_diff=False, exclude=None):
+ author=None, show_diff=False, exclude=None, commit_time=None):
from bzrlib.errors import (
PointlessCommit,
ConflictsInTree,
@@ -3000,6 +3004,14 @@
make_commit_message_template_encoded
)
+ 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.
@@ -3060,7 +3072,8 @@
specific_files=selected_list,
allow_pointless=unchanged, strict=strict, local=local,
reporter=None, verbose=verbose, revprops=properties,
- authors=author,
+ 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;
=== modified file 'bzrlib/tests/blackbox/test_commit.py'
--- a/bzrlib/tests/blackbox/test_commit.py 2009-11-08 01:09:14 +0000
+++ b/bzrlib/tests/blackbox/test_commit.py 2009-11-19 06:28:13 +0000
@@ -608,6 +608,26 @@
properties = last_rev.properties
self.assertEqual('John Doe\nJane Rey', properties['authors'])
+ def test_commit_time(self):
+ tree = self.make_branch_and_tree('tree')
+ self.build_tree(['tree/hello.txt'])
+ tree.add('hello.txt')
+ out, err = self.run_bzr("commit -m hello "
+ "--commit-time='2009-10-10 08:00:00 +0100' tree/hello.txt")
+ last_rev = tree.branch.repository.get_revision(tree.last_revision())
+ self.assertEqual(
+ 'Sat 2009-10-10 08:00:00 +0100',
+ osutils.format_date(last_rev.timestamp, last_rev.timezone))
+
+ def test_commit_time_bad_time(self):
+ tree = self.make_branch_and_tree('tree')
+ self.build_tree(['tree/hello.txt'])
+ tree.add('hello.txt')
+ out, err = self.run_bzr("commit -m hello "
+ "--commit-time='NOT A TIME' tree/hello.txt", retcode=3)
+ self.assertStartsWith(
+ err, "bzr: ERROR: Could not parse --commit-time:")
+
def test_partial_commit_with_renames_in_tree(self):
# this test illustrates bug #140419
t = self.make_branch_and_tree('.')
More information about the bazaar-commits
mailing list