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