diff hgext/graphlog.py @ 17182:cdf1532d89c6

incoming/outgoing: handle --graph in core
author Patrick Mezard <patrick@mezard.eu>
date Wed, 11 Jul 2012 18:22:07 +0200
parents 6f71167292f2
children 434e5bd615fc
line wrap: on
line diff
--- a/hgext/graphlog.py	Sat Jul 14 19:09:22 2012 +0200
+++ b/hgext/graphlog.py	Wed Jul 11 18:22:07 2012 +0200
@@ -12,21 +12,13 @@
 revision graph is also shown.
 '''
 
-from mercurial.cmdutil import show_changeset
 from mercurial.i18n import _
-from mercurial import cmdutil, commands, extensions
-from mercurial import hg, util, graphmod
+from mercurial import cmdutil, commands
 
 cmdtable = {}
 command = cmdutil.command(cmdtable)
 testedwith = 'internal'
 
-def _checkunsupportedflags(pats, opts):
-    for op in ["newest_first"]:
-        if op in opts and opts[op]:
-            raise util.Abort(_("-G/--graph option is incompatible with --%s")
-                             % op.replace("_", "-"))
-
 @command('glog',
     [('f', 'follow', None,
      _('follow changeset history, or file history across copies and renames')),
@@ -60,66 +52,3 @@
     directory.
     """
     return cmdutil.graphlog(ui, repo, *pats, **opts)
-
-def graphrevs(repo, nodes, opts):
-    limit = cmdutil.loglimit(opts)
-    nodes.reverse()
-    if limit is not None:
-        nodes = nodes[:limit]
-    return graphmod.nodes(repo, nodes)
-
-def goutgoing(ui, repo, dest=None, **opts):
-    """show the outgoing changesets alongside an ASCII revision graph
-
-    Print the outgoing changesets alongside a revision graph drawn with
-    ASCII characters.
-
-    Nodes printed as an @ character are parents of the working
-    directory.
-    """
-
-    _checkunsupportedflags([], opts)
-    o = hg._outgoing(ui, repo, dest, opts)
-    if o is None:
-        return
-
-    revdag = graphrevs(repo, o, opts)
-    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)
-
-def gincoming(ui, repo, source="default", **opts):
-    """show the incoming changesets alongside an ASCII revision graph
-
-    Print the incoming changesets alongside a revision graph drawn with
-    ASCII characters.
-
-    Nodes printed as an @ character are parents of the working
-    directory.
-    """
-    def subreporecurse():
-        return 1
-
-    _checkunsupportedflags([], opts)
-    def display(other, chlist, displayer):
-        revdag = graphrevs(other, chlist, opts)
-        showparents = [ctx.node() for ctx in repo[None].parents()]
-        cmdutil.displaygraph(ui, revdag, displayer, showparents,
-                             graphmod.asciiedges)
-
-    hg._incoming(display, subreporecurse, ui, repo, source, opts, buffered=True)
-
-def uisetup(ui):
-    '''Initialize the extension.'''
-    _wrapcmd('incoming', commands.table, gincoming)
-    _wrapcmd('outgoing', commands.table, goutgoing)
-
-def _wrapcmd(cmd, table, wrapfn):
-    '''wrap the command'''
-    def graph(orig, *args, **kwargs):
-        if kwargs['graph']:
-            return wrapfn(*args, **kwargs)
-        return orig(*args, **kwargs)
-    entry = extensions.wrapcommand(table, cmd, graph)
-    entry[1].append(('G', 'graph', None, _("show the revision DAG")))