##// END OF EJS Templates
Add --date support to update and revert...
Matt Mackall -
r3814:120be84f default
parent child Browse files
Show More
@@ -554,6 +554,25 b' def show_changeset(ui, repo, opts, buffe'
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
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"))
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
@@ -222,6 +222,7 b' def backout(ui, repo, rev, **opts):'
222 parent = p1
222 parent = p1
223 hg.clean(repo, node, show_stats=False)
223 hg.clean(repo, node, show_stats=False)
224 revert_opts = opts.copy()
224 revert_opts = opts.copy()
225 revert_opts['date'] = None
225 revert_opts['all'] = True
226 revert_opts['all'] = True
226 revert_opts['rev'] = hex(parent)
227 revert_opts['rev'] = hex(parent)
227 revert(ui, repo, **revert_opts)
228 revert(ui, repo, **revert_opts)
@@ -1596,7 +1597,7 b' def manifest(ui, repo, rev=None):'
1596 ui.write("%3s " % (m.execf(f) and "755" or "644"))
1597 ui.write("%3s " % (m.execf(f) and "755" or "644"))
1597 ui.write("%s\n" % f)
1598 ui.write("%s\n" % f)
1598
1599
1599 def merge(ui, repo, node=None, force=None, branch=None):
1600 def merge(ui, repo, node=None, force=None, branch=None, date=None):
1600 """Merge working directory with another revision
1601 """Merge working directory with another revision
1601
1602
1602 Merge the contents of the current working directory and the
1603 Merge the contents of the current working directory and the
@@ -1943,6 +1944,11 b' def revert(ui, repo, *pats, **opts):'
1943 If no arguments are given, no files are reverted.
1944 If no arguments are given, no files are reverted.
1944 """
1945 """
1945
1946
1947 if opts["date"]:
1948 if opts["rev"]:
1949 raise util.Abort(_("you can't specify a revision and a date"))
1950 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
1951
1946 if not pats and not opts['all']:
1952 if not pats and not opts['all']:
1947 raise util.Abort(_('no files or directories specified; '
1953 raise util.Abort(_('no files or directories specified; '
1948 'use --all to revert the whole repo'))
1954 'use --all to revert the whole repo'))
@@ -2297,7 +2303,7 b' def unbundle(ui, repo, fname, **opts):'
2297 modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
2303 modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
2298 return postincoming(ui, repo, modheads, opts['update'])
2304 return postincoming(ui, repo, modheads, opts['update'])
2299
2305
2300 def update(ui, repo, node=None, clean=False, branch=None):
2306 def update(ui, repo, node=None, clean=False, branch=None, date=None):
2301 """update or merge working directory
2307 """update or merge working directory
2302
2308
2303 Update the working directory to the specified revision.
2309 Update the working directory to the specified revision.
@@ -2312,6 +2318,11 b' def update(ui, repo, node=None, clean=Fa'
2312 By default, update will refuse to run if doing so would require
2318 By default, update will refuse to run if doing so would require
2313 merging or discarding local changes.
2319 merging or discarding local changes.
2314 """
2320 """
2321 if date:
2322 if node:
2323 raise util.Abort(_("you can't specify a revision and a date"))
2324 node = cmdutil.finddate(ui, repo, date)
2325
2315 node = _lookup(repo, node, branch)
2326 node = _lookup(repo, node, branch)
2316 if clean:
2327 if clean:
2317 return hg.clean(repo, node)
2328 return hg.clean(repo, node)
@@ -2676,6 +2687,7 b' table = {'
2676 "^revert":
2687 "^revert":
2677 (revert,
2688 (revert,
2678 [('a', 'all', None, _('revert all changes when no arguments given')),
2689 [('a', 'all', None, _('revert all changes when no arguments given')),
2690 ('d', 'date', '', _('tipmost revision matching date')),
2679 ('r', 'rev', '', _('revision to revert to')),
2691 ('r', 'rev', '', _('revision to revert to')),
2680 ('', 'no-backup', None, _('do not save backup copies of files')),
2692 ('', 'no-backup', None, _('do not save backup copies of files')),
2681 ] + walkopts + dryrunopts,
2693 ] + walkopts + dryrunopts,
@@ -2746,7 +2758,8 b' table = {'
2746 (update,
2758 (update,
2747 [('b', 'branch', '',
2759 [('b', 'branch', '',
2748 _('checkout the head of a specific branch (DEPRECATED)')),
2760 _('checkout the head of a specific branch (DEPRECATED)')),
2749 ('C', 'clean', None, _('overwrite locally modified files'))],
2761 ('C', 'clean', None, _('overwrite locally modified files')),
2762 ('d', 'date', '', _('tipmost revision matching date'))],
2750 _('hg update [-C] [REV]')),
2763 _('hg update [-C] [REV]')),
2751 "verify": (verify, [], _('hg verify')),
2764 "verify": (verify, [], _('hg verify')),
2752 "version": (version_, [], _('hg version')),
2765 "version": (version_, [], _('hg version')),
General Comments 0
You need to be logged in to leave comments. Login now