changeset 552:2204311609a0

Allow specifying revisions in 'hg log' like with 'hg diff'. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Allow specifying revisions in 'hg log' like with 'hg diff'. manifest hash: 62d48dbaa0213b36f08dc15bc3b1a1f35ecd89f0 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFCxPbeW7P1GVgWeRoRApOgAJsFYCQ8EEpYDQz8t53bRXfrP/MXwwCfWDV5 dLv6zwG6/I++SyChFkTPfAY= =cg0V -----END PGP SIGNATURE-----
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 01 Jul 2005 08:55:10 +0100
parents 4fc63e22b1fe
children f2442a6a5893
files doc/hg.1.txt mercurial/commands.py
diffstat 2 files changed, 28 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/doc/hg.1.txt	Thu Jun 30 23:28:16 2005 -0800
+++ b/doc/hg.1.txt	Fri Jul 01 08:55:10 2005 +0100
@@ -167,7 +167,7 @@
 init::
     Initialize a new repository in the current directory.
 
-log [file]::
+log [-r revision ...] [file]::
     Print the revision history of the specified file or the entire project.
 
     By default this command outputs: changeset id and hash, tags,
@@ -175,6 +175,11 @@
     -v switch adds some more detail, such as changed files, manifest
     hashes or message signatures.
 
+    When a revision argument is given, only this file or changelog revision
+    is displayed. With two revision arguments all revisions in this range
+    are listed. Additional revision arguments may be given repeating the above
+    cycle.
+
     aliases: history
 
 manifest [revision]::
--- a/mercurial/commands.py	Thu Jun 30 23:28:16 2005 -0800
+++ b/mercurial/commands.py	Fri Jul 01 08:55:10 2005 +0100
@@ -515,16 +515,28 @@
         sys.exit(1)
     repo = hg.repository(ui, ".", create=1)
 
-def log(ui, repo, f = None):
+def log(ui, repo, f=None, **opts):
     """show the revision history of the repository or a single file"""
     if f:
-        f = relpath(repo, [f])[0]
-        r = repo.file(f)
-        for i in range(r.count() - 1, -1, -1):
-            show_changeset(ui, repo, filelog=r, rev=i)
+        filelog = repo.file(relpath(repo, [f])[0])
+        log = filelog
+        lookup = filelog.lookup
     else:
-        for i in range(repo.changelog.count() - 1, -1, -1):
-            show_changeset(ui, repo, rev=i)
+        filelog = None
+        log = repo.changelog
+        lookup = repo.lookup
+    revlist = []
+    revs = [log.rev(lookup(rev)) for rev in opts['rev']]
+    while revs:
+        if len(revs) == 1:
+            revlist.append(revs.pop(0))
+        else:
+            a = revs.pop(0)
+            b = revs.pop(0)
+            off = a > b and -1 or 1
+            revlist.extend(range(a, b + off, off))
+    for i in revlist or range(log.count() - 1, -1, -1):
+        show_changeset(ui, repo, filelog=filelog, rev=i)
 
 def manifest(ui, repo, rev = []):
     """output the latest or given revision of the project manifest"""
@@ -765,7 +777,9 @@
                       ('b', 'base', "", 'base path')],
                      "hg import [options] <patches>"),
     "init": (init, [], 'hg init'),
-    "log|history": (log, [], 'hg log [file]'),
+    "log|history": (log,
+                    [('r', 'rev', [], 'revision')],
+                    'hg log [-r A] [-r B] [file]'),
     "manifest": (manifest, [], 'hg manifest [rev]'),
     "parents": (parents, [], 'hg parents [node]'),
     "pull": (pull,