Mercurial > hg
changeset 3820:4f056896c093
Merge with crew
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 06 Dec 2006 17:59:19 -0600 |
parents | e3ba19ec8c48 (diff) 6099cfa7c4aa (current diff) |
children | 158fce02dc40 2631b506e93d |
files | |
diffstat | 2 files changed, 34 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Wed Dec 06 13:51:54 2006 -0800 +++ b/mercurial/cmdutil.py Wed Dec 06 17:59:19 2006 -0600 @@ -554,6 +554,25 @@ return t return changeset_printer(ui, repo, patch, br, buffered) +def finddate(ui, repo, date): + """Find the tipmost changeset that matches the given date spec""" + df = util.matchdate(date + " to " + date) + get = util.cachefunc(lambda r: repo.changectx(r).changeset()) + changeiter, matchfn = walkchangerevs(ui, repo, [], get, {'rev':None}) + results = {} + for st, rev, fns in changeiter: + if st == 'add': + d = get(rev)[2] + if df(d[0]): + results[rev] = d + elif st == 'iter': + if rev in results: + ui.status("Found revision %s from %s\n" % + (rev, util.datestr(results[rev]))) + return str(rev) + + raise util.Abort(_("revision matching date not found")) + def walkchangerevs(ui, repo, pats, change, opts): '''Iterate over files and the revs they changed in.
--- a/mercurial/commands.py Wed Dec 06 13:51:54 2006 -0800 +++ b/mercurial/commands.py Wed Dec 06 17:59:19 2006 -0600 @@ -222,6 +222,7 @@ parent = p1 hg.clean(repo, node, show_stats=False) revert_opts = opts.copy() + revert_opts['date'] = None revert_opts['all'] = True revert_opts['rev'] = hex(parent) revert(ui, repo, **revert_opts) @@ -1943,6 +1944,11 @@ If no arguments are given, no files are reverted. """ + if opts["date"]: + if opts["rev"]: + raise util.Abort(_("you can't specify a revision and a date")) + opts["rev"] = cmdutil.finddate(ui, repo, opts["date"]) + if not pats and not opts['all']: raise util.Abort(_('no files or directories specified; ' 'use --all to revert the whole repo')) @@ -2297,7 +2303,7 @@ modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname) return postincoming(ui, repo, modheads, opts['update']) -def update(ui, repo, node=None, clean=False, branch=None): +def update(ui, repo, node=None, clean=False, branch=None, date=None): """update or merge working directory Update the working directory to the specified revision. @@ -2312,6 +2318,11 @@ By default, update will refuse to run if doing so would require merging or discarding local changes. """ + if date: + if node: + raise util.Abort(_("you can't specify a revision and a date")) + node = cmdutil.finddate(ui, repo, date) + node = _lookup(repo, node, branch) if clean: return hg.clean(repo, node) @@ -2676,6 +2687,7 @@ "^revert": (revert, [('a', 'all', None, _('revert all changes when no arguments given')), + ('d', 'date', '', _('tipmost revision matching date')), ('r', 'rev', '', _('revision to revert to')), ('', 'no-backup', None, _('do not save backup copies of files')), ] + walkopts + dryrunopts, @@ -2746,7 +2758,8 @@ (update, [('b', 'branch', '', _('checkout the head of a specific branch (DEPRECATED)')), - ('C', 'clean', None, _('overwrite locally modified files'))], + ('C', 'clean', None, _('overwrite locally modified files')), + ('d', 'date', '', _('tipmost revision matching date'))], _('hg update [-C] [REV]')), "verify": (verify, [], _('hg verify')), "version": (version_, [], _('hg version')),