mercurial/commands.py
changeset 5300 81575b7b505e
parent 5263 d59ed18ec2d0
parent 5298 cba2a689117d
child 5310 ba3dc7883968
equal deleted inserted replaced
5297:ec061aaa25a4 5300:81575b7b505e
  1974     will be printed. If a file argument is given, revision in
  1974     will be printed. If a file argument is given, revision in
  1975     which the file was last changed (before the working directory
  1975     which the file was last changed (before the working directory
  1976     revision or the argument to --rev if given) is printed.
  1976     revision or the argument to --rev if given) is printed.
  1977     """
  1977     """
  1978     rev = opts.get('rev')
  1978     rev = opts.get('rev')
       
  1979     if rev:
       
  1980         ctx = repo.changectx(rev)
       
  1981     else:
       
  1982         ctx = repo.workingctx()
       
  1983 
  1979     if file_:
  1984     if file_:
  1980         files, match, anypats = cmdutil.matchpats(repo, (file_,), opts)
  1985         files, match, anypats = cmdutil.matchpats(repo, (file_,), opts)
  1981         if anypats or len(files) != 1:
  1986         if anypats or len(files) != 1:
  1982             raise util.Abort(_('can only specify an explicit file name'))
  1987             raise util.Abort(_('can only specify an explicit file name'))
  1983         ctx = repo.filectx(files[0], changeid=rev)
  1988         file_ = files[0]
  1984     elif rev:
  1989         filenodes = []
  1985         ctx = repo.changectx(rev)
  1990         for cp in ctx.parents():
       
  1991             if not cp:
       
  1992                 continue
       
  1993             try:
       
  1994                 filenodes.append(cp.filenode(file_))
       
  1995             except revlog.LookupError:
       
  1996                 pass
       
  1997         if not filenodes:
       
  1998             raise util.Abort(_("'%s' not found in manifest!") % file_)
       
  1999         fl = repo.file(file_)
       
  2000         p = [repo.lookup(fl.linkrev(fn)) for fn in filenodes]
  1986     else:
  2001     else:
  1987         ctx = repo.workingctx()
  2002         p = [cp.node() for cp in ctx.parents()]
  1988     p = [cp.node() for cp in ctx.parents()]
       
  1989 
  2003 
  1990     displayer = cmdutil.show_changeset(ui, repo, opts)
  2004     displayer = cmdutil.show_changeset(ui, repo, opts)
  1991     for n in p:
  2005     for n in p:
  1992         if n != nullid:
  2006         if n != nullid:
  1993             displayer.show(changenode=n)
  2007             displayer.show(changenode=n)