diff --git a/doc/hg.1.txt b/doc/hg.1.txt --- a/doc/hg.1.txt +++ b/doc/hg.1.txt @@ -183,7 +183,7 @@ import [-p -b -q] :: init:: Initialize a new repository in the current directory. -log [-r revision ...] [file]:: +log [-r revision ...] [-p] [file]:: Print the revision history of the specified file or the entire project. By default this command outputs: changeset id and hash, tags, @@ -191,10 +191,13 @@ log [-r revision ...] [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. + options: + -r, --rev , ... 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. + -p, --patch show patch aliases: history diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -635,10 +635,12 @@ def init(ui, source=None): def log(ui, repo, f=None, **opts): """show the revision history of the repository or a single file""" if f: - filelog = repo.file(relpath(repo, [f])[0]) + files = relpath(repo, [f]) + filelog = repo.file(files[0]) log = filelog lookup = filelog.lookup else: + files = None filelog = None log = repo.changelog lookup = repo.lookup @@ -655,6 +657,15 @@ def log(ui, repo, f=None, **opts): for i in revlist or range(log.count() - 1, -1, -1): show_changeset(ui, repo, filelog=filelog, rev=i) + if opts['patch']: + if filelog: + filenode = filelog.node(i) + i = filelog.linkrev(filenode) + changenode = repo.changelog.node(i) + prev, other = repo.changelog.parents(changenode) + dodiff(sys.stdout, ui, repo, files, prev, changenode) + ui.write("\n") + ui.write("\n") def manifest(ui, repo, rev = []): """output the latest or given revision of the project manifest""" @@ -977,8 +988,9 @@ table = { "hg import [options] "), "^init": (init, [], 'hg init'), "^log|history": (log, - [('r', 'rev', [], 'revision')], - 'hg log [-r A] [-r B] [file]'), + [('r', 'rev', [], 'revision'), + ('p', 'patch', None, 'show patch')], + 'hg log [-r A] [-r B] [-p] [file]'), "manifest": (manifest, [], 'hg manifest [rev]'), "parents": (parents, [], 'hg parents [node]'), "^pull": (pull,