comparison mercurial/cmdutil.py @ 3818:120be84f33de

Add --date support to update and revert Add finddate to find the tipmost revision that matches a date spec Add --date option to update Add --date option to revert Don't pass backout's -d option to revert
author Matt Mackall <mpm@selenic.com>
date Wed, 06 Dec 2006 17:58:09 -0600
parents cb48cd27d3f4
children 000d122071b5
comparison
equal deleted inserted replaced
3816:fc5ba0ab7f45 3818:120be84f33de
551 except SyntaxError, inst: 551 except SyntaxError, inst:
552 raise util.Abort(inst.args[0]) 552 raise util.Abort(inst.args[0])
553 if tmpl: t.use_template(tmpl) 553 if tmpl: t.use_template(tmpl)
554 return t 554 return t
555 return changeset_printer(ui, repo, patch, br, buffered) 555 return changeset_printer(ui, repo, patch, br, buffered)
556
557 def finddate(ui, repo, date):
558 """Find the tipmost changeset that matches the given date spec"""
559 df = util.matchdate(date + " to " + date)
560 get = util.cachefunc(lambda r: repo.changectx(r).changeset())
561 changeiter, matchfn = walkchangerevs(ui, repo, [], get, {'rev':None})
562 results = {}
563 for st, rev, fns in changeiter:
564 if st == 'add':
565 d = get(rev)[2]
566 if df(d[0]):
567 results[rev] = d
568 elif st == 'iter':
569 if rev in results:
570 ui.status("Found revision %s from %s\n" %
571 (rev, util.datestr(results[rev])))
572 return str(rev)
573
574 raise util.Abort(_("revision matching date not found"))
556 575
557 def walkchangerevs(ui, repo, pats, change, opts): 576 def walkchangerevs(ui, repo, pats, change, opts):
558 '''Iterate over files and the revs they changed in. 577 '''Iterate over files and the revs they changed in.
559 578
560 Callers most commonly need to iterate backwards over the history 579 Callers most commonly need to iterate backwards over the history