# HG changeset patch # User Thomas Arendsen Hein # Date 2005-07-01 07:55:10 # Node ID 2204311609a08017171372e6be13304222dccaa1 # Parent 4fc63e22b1fe707bb542ab1149403daa9a77cdf8 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----- diff --git a/doc/hg.1.txt b/doc/hg.1.txt --- a/doc/hg.1.txt +++ b/doc/hg.1.txt @@ -167,7 +167,7 @@ import [-p -b -q] :: 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 @@ log [file]:: -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]:: diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -515,16 +515,28 @@ def init(ui, source=None): 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 @@ table = { ('b', 'base', "", 'base path')], "hg import [options] "), "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,