# HG changeset patch # User Benoit Boissinot # Date 1153094449 -7200 # Node ID b24efed24e8f82f914575f9d252c207ac49636b6 # Parent f23973ea3107786112d19d1274e8dad896c73019 allow specifying a file to hg parents, change the syntax to use -r/--rev diff -r f23973ea3107 -r b24efed24e8f mercurial/commands.py --- a/mercurial/commands.py Mon Jul 17 01:59:06 2006 +0200 +++ b/mercurial/commands.py Mon Jul 17 02:00:49 2006 +0200 @@ -2076,13 +2076,28 @@ dodiff(ui, ui, repo, prev, n) ui.write("\n") -def parents(ui, repo, rev=None, branches=None, **opts): +def parents(ui, repo, file_=None, rev=None, branches=None, **opts): """show the parents of the working dir or revision Print the working directory's parent revisions. """ + # legacy + if file_ and not rev: + try: + rev = repo.lookup(file_) + file_ = None + except hg.RepoError: + pass + else: + ui.warn(_("'hg parent REV' is deprecated, " + "please use 'hg parents -r REV instead\n")) + if rev: - p = repo.changelog.parents(repo.lookup(rev)) + if file_: + ctx = repo.filectx(file_, changeid=rev) + else: + ctx = repo.changectx(rev) + p = [cp.node() for cp in ctx.parents()] else: p = repo.dirstate.parents() @@ -3025,9 +3040,10 @@ "^parents": (parents, [('b', 'branches', None, _('show branches')), + ('r', 'rev', '', _('show parents from the specified rev')), ('', 'style', '', _('display using template map file')), ('', 'template', '', _('display with template'))], - _('hg parents [-b] [REV]')), + _('hg parents [-b] [-r REV] [FILE]')), "paths": (paths, [], _('hg paths [NAME]')), "^pull": (pull,