##// END OF EJS Templates
incoming/outgoing: handle --graph in core
Patrick Mezard -
r17182:cdf1532d default
parent child Browse files
Show More
@@ -12,21 +12,13 b' commands. When this options is given, an'
12 revision graph is also shown.
12 revision graph is also shown.
13 '''
13 '''
14
14
15 from mercurial.cmdutil import show_changeset
16 from mercurial.i18n import _
15 from mercurial.i18n import _
17 from mercurial import cmdutil, commands, extensions
16 from mercurial import cmdutil, commands
18 from mercurial import hg, util, graphmod
19
17
20 cmdtable = {}
18 cmdtable = {}
21 command = cmdutil.command(cmdtable)
19 command = cmdutil.command(cmdtable)
22 testedwith = 'internal'
20 testedwith = 'internal'
23
21
24 def _checkunsupportedflags(pats, opts):
25 for op in ["newest_first"]:
26 if op in opts and opts[op]:
27 raise util.Abort(_("-G/--graph option is incompatible with --%s")
28 % op.replace("_", "-"))
29
30 @command('glog',
22 @command('glog',
31 [('f', 'follow', None,
23 [('f', 'follow', None,
32 _('follow changeset history, or file history across copies and renames')),
24 _('follow changeset history, or file history across copies and renames')),
@@ -60,66 +52,3 b' def graphlog(ui, repo, *pats, **opts):'
60 directory.
52 directory.
61 """
53 """
62 return cmdutil.graphlog(ui, repo, *pats, **opts)
54 return cmdutil.graphlog(ui, repo, *pats, **opts)
63
64 def graphrevs(repo, nodes, opts):
65 limit = cmdutil.loglimit(opts)
66 nodes.reverse()
67 if limit is not None:
68 nodes = nodes[:limit]
69 return graphmod.nodes(repo, nodes)
70
71 def goutgoing(ui, repo, dest=None, **opts):
72 """show the outgoing changesets alongside an ASCII revision graph
73
74 Print the outgoing changesets alongside a revision graph drawn with
75 ASCII characters.
76
77 Nodes printed as an @ character are parents of the working
78 directory.
79 """
80
81 _checkunsupportedflags([], opts)
82 o = hg._outgoing(ui, repo, dest, opts)
83 if o is None:
84 return
85
86 revdag = graphrevs(repo, o, opts)
87 displayer = show_changeset(ui, repo, opts, buffered=True)
88 showparents = [ctx.node() for ctx in repo[None].parents()]
89 cmdutil.displaygraph(ui, revdag, displayer, showparents,
90 graphmod.asciiedges)
91
92 def gincoming(ui, repo, source="default", **opts):
93 """show the incoming changesets alongside an ASCII revision graph
94
95 Print the incoming changesets alongside a revision graph drawn with
96 ASCII characters.
97
98 Nodes printed as an @ character are parents of the working
99 directory.
100 """
101 def subreporecurse():
102 return 1
103
104 _checkunsupportedflags([], opts)
105 def display(other, chlist, displayer):
106 revdag = graphrevs(other, chlist, opts)
107 showparents = [ctx.node() for ctx in repo[None].parents()]
108 cmdutil.displaygraph(ui, revdag, displayer, showparents,
109 graphmod.asciiedges)
110
111 hg._incoming(display, subreporecurse, ui, repo, source, opts, buffered=True)
112
113 def uisetup(ui):
114 '''Initialize the extension.'''
115 _wrapcmd('incoming', commands.table, gincoming)
116 _wrapcmd('outgoing', commands.table, goutgoing)
117
118 def _wrapcmd(cmd, table, wrapfn):
119 '''wrap the command'''
120 def graph(orig, *args, **kwargs):
121 if kwargs['graph']:
122 return wrapfn(*args, **kwargs)
123 return orig(*args, **kwargs)
124 entry = extensions.wrapcommand(table, cmd, graph)
125 entry[1].append(('G', 'graph', None, _("show the revision DAG")))
@@ -1450,6 +1450,19 b' def graphlog(ui, repo, *pats, **opts):'
1450 displaygraph(ui, revdag, displayer, showparents,
1450 displaygraph(ui, revdag, displayer, showparents,
1451 graphmod.asciiedges, getrenamed, filematcher)
1451 graphmod.asciiedges, getrenamed, filematcher)
1452
1452
1453 def checkunsupportedgraphflags(pats, opts):
1454 for op in ["newest_first"]:
1455 if op in opts and opts[op]:
1456 raise util.Abort(_("-G/--graph option is incompatible with --%s")
1457 % op.replace("_", "-"))
1458
1459 def graphrevs(repo, nodes, opts):
1460 limit = loglimit(opts)
1461 nodes.reverse()
1462 if limit is not None:
1463 nodes = nodes[:limit]
1464 return graphmod.nodes(repo, nodes)
1465
1453 def add(ui, repo, match, dryrun, listsubrepos, prefix, explicitonly):
1466 def add(ui, repo, match, dryrun, listsubrepos, prefix, explicitonly):
1454 join = lambda f: os.path.join(prefix, f)
1467 join = lambda f: os.path.join(prefix, f)
1455 bad = []
1468 bad = []
@@ -15,7 +15,7 b' import archival, changegroup, cmdutil, h'
15 import sshserver, hgweb, hgweb.server, commandserver
15 import sshserver, hgweb, hgweb.server, commandserver
16 import merge as mergemod
16 import merge as mergemod
17 import minirst, revset, fileset
17 import minirst, revset, fileset
18 import dagparser, context, simplemerge
18 import dagparser, context, simplemerge, graphmod
19 import random, setdiscovery, treediscovery, dagutil, pvec
19 import random, setdiscovery, treediscovery, dagutil, pvec
20 import phases, obsolete
20 import phases, obsolete
21
21
@@ -98,6 +98,7 b' logopts = ['
98 _('limit number of changes displayed'), _('NUM')),
98 _('limit number of changes displayed'), _('NUM')),
99 ('M', 'no-merges', None, _('do not show merges')),
99 ('M', 'no-merges', None, _('do not show merges')),
100 ('', 'stat', None, _('output diffstat-style summary of changes')),
100 ('', 'stat', None, _('output diffstat-style summary of changes')),
101 ('G', 'graph', None, _("show the revision DAG")),
101 ] + templateopts
102 ] + templateopts
102
103
103 diffopts = [
104 diffopts = [
@@ -3828,6 +3829,17 b' def incoming(ui, repo, source="default",'
3828
3829
3829 Returns 0 if there are incoming changes, 1 otherwise.
3830 Returns 0 if there are incoming changes, 1 otherwise.
3830 """
3831 """
3832 if opts.get('graph'):
3833 cmdutil.checkunsupportedgraphflags([], opts)
3834 def display(other, chlist, displayer):
3835 revdag = cmdutil.graphrevs(other, chlist, opts)
3836 showparents = [ctx.node() for ctx in repo[None].parents()]
3837 cmdutil.displaygraph(ui, revdag, displayer, showparents,
3838 graphmod.asciiedges)
3839
3840 hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True)
3841 return 0
3842
3831 if opts.get('bundle') and opts.get('subrepos'):
3843 if opts.get('bundle') and opts.get('subrepos'):
3832 raise util.Abort(_('cannot combine --bundle and --subrepos'))
3844 raise util.Abort(_('cannot combine --bundle and --subrepos'))
3833
3845
@@ -3928,7 +3940,6 b' def locate(ui, repo, *pats, **opts):'
3928 ('P', 'prune', [],
3940 ('P', 'prune', [],
3929 _('do not display revision or any of its ancestors'), _('REV')),
3941 _('do not display revision or any of its ancestors'), _('REV')),
3930 ('', 'hidden', False, _('show hidden changesets (DEPRECATED)')),
3942 ('', 'hidden', False, _('show hidden changesets (DEPRECATED)')),
3931 ('G', 'graph', None, _("show the revision DAG")),
3932 ] + logopts + walkopts,
3943 ] + logopts + walkopts,
3933 _('[OPTION]... [FILE]'))
3944 _('[OPTION]... [FILE]'))
3934 def log(ui, repo, *pats, **opts):
3945 def log(ui, repo, *pats, **opts):
@@ -4283,6 +4294,18 b' def outgoing(ui, repo, dest=None, **opts'
4283
4294
4284 Returns 0 if there are outgoing changes, 1 otherwise.
4295 Returns 0 if there are outgoing changes, 1 otherwise.
4285 """
4296 """
4297 if opts.get('graph'):
4298 cmdutil.checkunsupportedgraphflags([], opts)
4299 o = hg._outgoing(ui, repo, dest, opts)
4300 if o is None:
4301 return
4302
4303 revdag = cmdutil.graphrevs(repo, o, opts)
4304 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
4305 showparents = [ctx.node() for ctx in repo[None].parents()]
4306 cmdutil.displaygraph(ui, revdag, displayer, showparents,
4307 graphmod.asciiedges)
4308 return 0
4286
4309
4287 if opts.get('bookmarks'):
4310 if opts.get('bookmarks'):
4288 dest = ui.expandpath(dest or 'default-push', dest or 'default')
4311 dest = ui.expandpath(dest or 'default-push', dest or 'default')
@@ -199,7 +199,7 b' Show all commands + options'
199 export: output, switch-parent, rev, text, git, nodates
199 export: output, switch-parent, rev, text, git, nodates
200 forget: include, exclude
200 forget: include, exclude
201 init: ssh, remotecmd, insecure
201 init: ssh, remotecmd, insecure
202 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
202 log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, branch, prune, hidden, patch, git, limit, no-merges, stat, graph, style, template, include, exclude
203 merge: force, rev, preview, tool
203 merge: force, rev, preview, tool
204 phase: public, draft, secret, force, rev
204 phase: public, draft, secret, force, rev
205 pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
205 pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
@@ -255,10 +255,10 b' Show all commands + options'
255 help: extension, command, keyword
255 help: extension, command, keyword
256 identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure
256 identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure
257 import: strip, base, edit, force, no-commit, bypass, exact, import-branch, message, logfile, date, user, similarity
257 import: strip, base, edit, force, no-commit, bypass, exact, import-branch, message, logfile, date, user, similarity
258 incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, style, template, ssh, remotecmd, insecure, subrepos
258 incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
259 locate: rev, print0, fullpath, include, exclude
259 locate: rev, print0, fullpath, include, exclude
260 manifest: rev, all
260 manifest: rev, all
261 outgoing: force, rev, newest-first, bookmarks, branch, patch, git, limit, no-merges, stat, style, template, ssh, remotecmd, insecure, subrepos
261 outgoing: force, rev, newest-first, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
262 parents: rev, style, template
262 parents: rev, style, template
263 paths:
263 paths:
264 recover:
264 recover:
General Comments 0
You need to be logged in to leave comments. Login now