Mercurial > hg
changeset 17181:6f71167292f2
log: support --graph without graphlog extension
The glog command is preserved in the extension for backward compatibility.
author | Patrick Mezard <patrick@mezard.eu> |
---|---|
date | Sat, 14 Jul 2012 19:09:22 +0200 |
parents | ae0629161090 |
children | cdf1532d89c6 |
files | hgext/graphlog.py mercurial/cmdutil.py mercurial/commands.py tests/test-debugcomplete.t tests/test-log.t |
diffstat | 5 files changed, 28 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/graphlog.py Sat Jul 14 18:55:21 2012 +0200 +++ b/hgext/graphlog.py Sat Jul 14 19:09:22 2012 +0200 @@ -14,8 +14,8 @@ from mercurial.cmdutil import show_changeset from mercurial.i18n import _ -from mercurial import cmdutil, commands, extensions, scmutil -from mercurial import hg, util, graphmod, templatekw +from mercurial import cmdutil, commands, extensions +from mercurial import hg, util, graphmod cmdtable = {} command = cmdutil.command(cmdtable) @@ -59,24 +59,7 @@ Nodes printed as an @ character are parents of the working directory. """ - - revs, expr, filematcher = cmdutil.getgraphlogrevs(repo, pats, opts) - revs = sorted(revs, reverse=1) - limit = cmdutil.loglimit(opts) - if limit is not None: - revs = revs[:limit] - revdag = graphmod.dagwalker(repo, revs) - - getrenamed = None - if opts.get('copies'): - endrev = None - if opts.get('rev'): - endrev = max(scmutil.revrange(repo, opts.get('rev'))) + 1 - getrenamed = templatekw.getrenamedfn(repo, endrev=endrev) - displayer = show_changeset(ui, repo, opts, buffered=True) - showparents = [ctx.node() for ctx in repo[None].parents()] - cmdutil.displaygraph(ui, revdag, displayer, showparents, - graphmod.asciiedges, getrenamed, filematcher) + return cmdutil.graphlog(ui, repo, *pats, **opts) def graphrevs(repo, nodes, opts): limit = cmdutil.loglimit(opts) @@ -129,7 +112,6 @@ def uisetup(ui): '''Initialize the extension.''' - _wrapcmd('log', commands.table, graphlog) _wrapcmd('incoming', commands.table, gincoming) _wrapcmd('outgoing', commands.table, goutgoing)
--- a/mercurial/cmdutil.py Sat Jul 14 18:55:21 2012 +0200 +++ b/mercurial/cmdutil.py Sat Jul 14 19:09:22 2012 +0200 @@ -1430,6 +1430,26 @@ graphmod.ascii(ui, state, type, char, lines, coldata) displayer.close() +def graphlog(ui, repo, *pats, **opts): + # Parameters are identical to log command ones + revs, expr, filematcher = getgraphlogrevs(repo, pats, opts) + revs = sorted(revs, reverse=1) + limit = loglimit(opts) + if limit is not None: + revs = revs[:limit] + revdag = graphmod.dagwalker(repo, revs) + + getrenamed = None + if opts.get('copies'): + endrev = None + if opts.get('rev'): + endrev = max(scmutil.revrange(repo, opts.get('rev'))) + 1 + getrenamed = templatekw.getrenamedfn(repo, endrev=endrev) + displayer = show_changeset(ui, repo, opts, buffered=True) + showparents = [ctx.node() for ctx in repo[None].parents()] + displaygraph(ui, revdag, displayer, showparents, + graphmod.asciiedges, getrenamed, filematcher) + def add(ui, repo, match, dryrun, listsubrepos, prefix, explicitonly): join = lambda f: os.path.join(prefix, f) bad = []
--- a/mercurial/commands.py Sat Jul 14 18:55:21 2012 +0200 +++ b/mercurial/commands.py Sat Jul 14 19:09:22 2012 +0200 @@ -3928,6 +3928,7 @@ ('P', 'prune', [], _('do not display revision or any of its ancestors'), _('REV')), ('', 'hidden', False, _('show hidden changesets (DEPRECATED)')), + ('G', 'graph', None, _("show the revision DAG")), ] + logopts + walkopts, _('[OPTION]... [FILE]')) def log(ui, repo, *pats, **opts): @@ -4012,6 +4013,8 @@ Returns 0 on success. """ + if opts.get('graph'): + return cmdutil.graphlog(ui, repo, *pats, **opts) matchfn = scmutil.match(repo[None], pats, opts) limit = cmdutil.loglimit(opts)
--- a/tests/test-debugcomplete.t Sat Jul 14 18:55:21 2012 +0200 +++ b/tests/test-debugcomplete.t Sat Jul 14 19:09:22 2012 +0200 @@ -199,7 +199,7 @@ export: output, switch-parent, rev, text, git, nodates forget: include, exclude init: ssh, remotecmd, insecure - log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, branch, prune, hidden, patch, git, limit, no-merges, stat, style, template, include, exclude + log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, branch, prune, hidden, graph, patch, git, limit, no-merges, stat, style, template, include, exclude merge: force, rev, preview, tool phase: public, draft, secret, force, rev pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
--- a/tests/test-log.t Sat Jul 14 18:55:21 2012 +0200 +++ b/tests/test-log.t Sat Jul 14 19:09:22 2012 +0200 @@ -941,7 +941,7 @@ $ hg resolve -m foo $ hg ci -m "Last merge, related" - $ hg --config "extensions.graphlog=" glog + $ hg log --graph @ changeset: 10:4dae8563d2c5 |\ tag: tip | | parent: 9:7b35701b003e