[PATCH 08 of 11] [RFC] Add a "--date-from FILE" option to some commands
Markus F.X.J. Oberhumer
markus at oberhumer.com
Mon Jun 25 12:50:45 UTC 2007
# HG changeset patch
# User Markus F.X.J. Oberhumer <markus at oberhumer.com>
# Date 1182775580 -7200
# Node ID 9dec45eed1ed8c6b818563aaa2bb233a611f5768
# Parent da57c9e729038e4e10db387905f39c180210b869
[RFC] Add a "--date-from FILE" option to some commands.
TODO: getxdate() would also be a good place to early check the
validity of a given data, but that does not seem to work ????
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -13,6 +13,15 @@ import difflib, patch, time, help, mdiff
import difflib, patch, time, help, mdiff, tempfile
import errno, version, socket
import archival, changegroup, cmdutil, hgweb.server, sshserver
+
+def getxdate(opts):
+ date = opts['date']
+ if opts.get('date_from'):
+ if date:
+ raise util.Abort(_("cannot use both --date and --date-from!"))
+ date = "%d 0" % int(os.path.getmtime(opts['date_from']))
+## if date: util.parsedate(date) # parse date early to catch errors ## FIXME
+ return date
# Commands start here, listed alphabetically
@@ -443,7 +452,7 @@ def commit(ui, repo, *pats, **opts):
else:
files = []
try:
- repo.commit(files, message, opts['user'], opts['date'], match,
+ repo.commit(files, message, opts['user'], getxdate(opts), match,
force_editor=opts.get('force_editor'))
except ValueError, inst:
raise util.Abort(str(inst))
@@ -2582,7 +2591,7 @@ def tag(ui, repo, name, rev_=None, **opt
if not message:
message = _('Added tag %s for changeset %s') % (name, short(r))
- repo.tag(name, r, message, opts['local'], opts['user'], opts['date'])
+ repo.tag(name, r, message, opts['local'], opts['user'], getxdate(opts))
def tags(ui, repo):
"""list repository tags
@@ -2760,6 +2769,7 @@ table = {
[('', 'merge', None,
_('merge with old dirstate parent after backout')),
('d', 'date', '', _('record datecode as commit date')),
+ ('', 'date-from', '', _('record modification time from <file> as commit date')),
('', 'parent', '', _('parent to choose when backing out merge')),
('u', 'user', '', _('record user as committer')),
('r', 'rev', '', _('revision to backout')),
@@ -2804,6 +2814,7 @@ table = {
[('A', 'addremove', None,
_('mark new/missing files as added/removed before committing')),
('d', 'date', '', _('record datecode as commit date')),
+ ('', 'date-from', '', _('record modification time from <file> as commit date')),
('u', 'user', '', _('record user as commiter')),
] + walkopts + commitopts,
_('hg commit [OPTION]... [FILE]...')),
@@ -3068,6 +3079,7 @@ table = {
('l', 'local', None, _('make the tag local')),
('m', 'message', '', _('message for tag commit log entry')),
('d', 'date', '', _('record datecode as commit date')),
+ ('', 'date-from', '', _('record modification time from <file> as commit date')),
('u', 'user', '', _('record user as commiter')),
('r', 'rev', '', _('revision to tag')),
('', 'remove', None, _('remove a tag'))],
More information about the Mercurial-devel
mailing list