comparison mercurial/commands.py @ 4584:0d26e3d0eeeb

Make parents with a file but not a revision use working directory revision.
author Brendan Cully <brendan@kublai.com>
date Thu, 14 Jun 2007 10:58:49 -0700
parents b36d8cd1d8ff
children d8a08b92ad34
comparison
equal deleted inserted replaced
4582:7de7a80e7422 4584:0d26e3d0eeeb
1875 displayer.show(changenode=n) 1875 displayer.show(changenode=n)
1876 1876
1877 def parents(ui, repo, file_=None, **opts): 1877 def parents(ui, repo, file_=None, **opts):
1878 """show the parents of the working dir or revision 1878 """show the parents of the working dir or revision
1879 1879
1880 Print the working directory's parent revisions. 1880 Print the working directory's parent revisions. If a
1881 revision is given via --rev, the parent of that revision
1882 will be printed. If a file argument is given, revision in
1883 which the file was last changed (before the working directory
1884 revision or the argument to --rev if given) is printed.
1881 """ 1885 """
1882 rev = opts.get('rev') 1886 rev = opts.get('rev')
1883 if rev: 1887 if file_:
1884 if file_: 1888 ctx = repo.filectx(file_, changeid=rev)
1885 ctx = repo.filectx(file_, changeid=rev) 1889 elif rev:
1886 else: 1890 ctx = repo.changectx(rev)
1887 ctx = repo.changectx(rev)
1888 p = [cp.node() for cp in ctx.parents()]
1889 else: 1891 else:
1890 p = repo.dirstate.parents() 1892 ctx = repo.workingctx()
1893 p = [cp.node() for cp in ctx.parents()]
1891 1894
1892 displayer = cmdutil.show_changeset(ui, repo, opts) 1895 displayer = cmdutil.show_changeset(ui, repo, opts)
1893 for n in p: 1896 for n in p:
1894 if n != nullid: 1897 if n != nullid:
1895 displayer.show(changenode=n) 1898 displayer.show(changenode=n)