Merge lp:~asac/bzr/lp459276 into lp:bzr

Proposed by Alexander Sack
Status: Merged
Approved by: Andrew Bennetts
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~asac/bzr/lp459276
Merge into: lp:bzr
Diff against target: 63 lines
1 file modified
bzrlib/builtins.py (+13/-5)
To merge this branch: bzr merge lp:~asac/bzr/lp459276
Reviewer Review Type Date Requested Status
Andrew Bennetts Approve
Ian Clatworthy Approve
Review via email: mp+13861@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Alexander Sack (asac) wrote :

add --commit-time option to the commit built-in command ... requested in lp:459276

Revision history for this message
Ian Clatworthy (ian-clatworthy) wrote :

Alexander,

Thanks for the patch. I'm ok with the concept though I wonder if some other core members might have concerns? It might be worth a short email to the list explaining the problem and outlining your suggested improvement. Others can then provide input as to whether we ought to solve it another way or in the way you've proposed.

The code itself looks fine. Assuming there's agreement on doing this, it really needs some tests though before we can land it. Some other minor things:

* Please add a '.' to the end of the commit-time help to pass our pre-commit checks.
* Please add an entry to NEWS.

review: Needs Fixing
Revision history for this message
Robert Collins (lifeless) wrote :

No concerns here, we don't trust timestamps anyway.

-Rob

Revision history for this message
Ian Clatworthy (ian-clatworthy) wrote :

OK, this is now agreed to conceptually. The next step under our new process is for Andrew to "pilot" this until it lands.

review: Approve
Revision history for this message
Andrew Bennetts (spiv) wrote :
Download full text (3.7 KiB)

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'
--- 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;

=== modified file 'bzrlib/tests/blackbox/test_commit.py'
--- bzrlib/tests/blackbox/test_commit.py 2009-08-28 05:00:33 +0000
+++ bzrlib/tests/blackbox/test_commit.py 2009-11-19 06:27:16 +0000
@@ -590,6 +590,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))
+ ...

Read more...

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-10-12 22:09:19 +0000
+++ bzrlib/builtins.py 2009-10-23 18:05:24 +0000
@@ -44,6 +44,7 @@
44 rename_map,44 rename_map,
45 revision as _mod_revision,45 revision as _mod_revision,
46 symbol_versioning,46 symbol_versioning,
47 timestamp,
47 transport,48 transport,
48 ui,49 ui,
49 urlutils,50 urlutils,
@@ -2941,6 +2942,9 @@
2941 Option('strict',2942 Option('strict',
2942 help="Refuse to commit if there are unknown "2943 help="Refuse to commit if there are unknown "
2943 "files in the working tree."),2944 "files in the working tree."),
2945 Option('commit-time', type=str,
2946 help="Manually set a commit time using commit date format, e.g."
2947 "'2009-10-10 08:00:00 +0100'"),
2944 ListOption('fixes', type=str,2948 ListOption('fixes', type=str,
2945 help="Mark a bug as being fixed by this revision "2949 help="Mark a bug as being fixed by this revision "
2946 "(see \"bzr help bugs\")."),2950 "(see \"bzr help bugs\")."),
@@ -2953,9 +2957,9 @@
2953 "the master branch until a normal commit "2957 "the master branch until a normal commit "
2954 "is performed."2958 "is performed."
2955 ),2959 ),
2956 Option('show-diff',2960 Option('show-diff',
2957 help='When no message is supplied, show the diff along'2961 help='When no message is supplied, show the diff along'
2958 ' with the status summary in the message editor.'),2962 ' with the status summary in the message editor.'),
2959 ]2963 ]
2960 aliases = ['ci', 'checkin']2964 aliases = ['ci', 'checkin']
29612965
@@ -2980,7 +2984,7 @@
29802984
2981 def run(self, message=None, file=None, verbose=False, selected_list=None,2985 def run(self, message=None, file=None, verbose=False, selected_list=None,
2982 unchanged=False, strict=False, local=False, fixes=None,2986 unchanged=False, strict=False, local=False, fixes=None,
2983 author=None, show_diff=False, exclude=None):2987 author=None, show_diff=False, exclude=None, commit_time=None):
2984 from bzrlib.errors import (2988 from bzrlib.errors import (
2985 PointlessCommit,2989 PointlessCommit,
2986 ConflictsInTree,2990 ConflictsInTree,
@@ -2992,6 +2996,10 @@
2992 make_commit_message_template_encoded2996 make_commit_message_template_encoded
2993 )2997 )
29942998
2999 commit_stamp = None
3000 if commit_time is not None:
3001 commit_stamp, offset = timestamp.parse_patch_date(commit_time)
3002
2995 # TODO: Need a blackbox test for invoking the external editor; may be3003 # TODO: Need a blackbox test for invoking the external editor; may be
2996 # slightly problematic to run this cross-platform.3004 # slightly problematic to run this cross-platform.
29973005
@@ -3049,7 +3057,7 @@
3049 specific_files=selected_list,3057 specific_files=selected_list,
3050 allow_pointless=unchanged, strict=strict, local=local,3058 allow_pointless=unchanged, strict=strict, local=local,
3051 reporter=None, verbose=verbose, revprops=properties,3059 reporter=None, verbose=verbose, revprops=properties,
3052 authors=author,3060 authors=author, timestamp=commit_stamp,
3053 exclude=safe_relpath_files(tree, exclude))3061 exclude=safe_relpath_files(tree, exclude))
3054 except PointlessCommit:3062 except PointlessCommit:
3055 # FIXME: This should really happen before the file is read in;3063 # FIXME: This should really happen before the file is read in;