parents: make it match the doc when called on a file
authorPatrick Mezard <pmezard@gmail.com>
Tue, 11 Sep 2007 23:04:42 +0200
changeset 5298 cba2a689117d
parent 5296 c8efd19e248c
child 5299 5a4824f6665c
parents: make it match the doc when called on a file parents used to return the parent revision of the last revision updating selected file, instead of the updating revision itself.
mercurial/commands.py
--- a/mercurial/commands.py	Tue Sep 11 13:23:59 2007 -0700
+++ b/mercurial/commands.py	Tue Sep 11 23:04:42 2007 +0200
@@ -1985,16 +1985,30 @@
     revision or the argument to --rev if given) is printed.
     """
     rev = opts.get('rev')
+    if rev:
+        ctx = repo.changectx(rev)
+    else:
+        ctx = repo.workingctx()
+
     if file_:
         files, match, anypats = cmdutil.matchpats(repo, (file_,), opts)
         if anypats or len(files) != 1:
             raise util.Abort(_('can only specify an explicit file name'))
-        ctx = repo.filectx(files[0], changeid=rev)
-    elif rev:
-        ctx = repo.changectx(rev)
+        file_ = files[0]
+        filenodes = []
+        for cp in ctx.parents():
+            if not cp:
+                continue
+            try:
+                filenodes.append(cp.filenode(file_))
+            except revlog.LookupError:
+                pass
+        if not filenodes:
+            raise util.Abort(_("'%s' not found in manifest!") % file_)
+        fl = repo.file(file_)
+        p = [repo.lookup(fl.linkrev(fn)) for fn in filenodes]
     else:
-        ctx = repo.workingctx()
-    p = [cp.node() for cp in ctx.parents()]
+        p = [cp.node() for cp in ctx.parents()]
 
     displayer = cmdutil.show_changeset(ui, repo, opts)
     for n in p: