Mercurial > hg-stable
changeset 46915:efc6f6a794bd
outgoing: merge the code handling --graph with the main one
The --graph code had its own copy of the logic. With the previous reorganisation
of the code, we can now merge it with the main code, reducing fragile
complication.
As a side effect, `hg out --graph` now use the right return code when they are
nothing outgoing. This explain the change to output in
`tests/test-largefiles-misc.t`.
Differential Revision: https://phab.mercurial-scm.org/D10383
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sun, 11 Apr 2021 20:00:46 +0200 |
parents | 50b79f8b802d |
children | 7061eee84151 |
files | mercurial/commands.py mercurial/hg.py tests/test-largefiles-misc.t |
diffstat | 3 files changed, 19 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Tue Apr 13 15:13:20 2021 +0200 +++ b/mercurial/commands.py Sun Apr 11 20:00:46 2021 +0200 @@ -4972,22 +4972,6 @@ ) opts = pycompat.byteskwargs(opts) - if opts.get(b'graph'): - logcmdutil.checkunsupportedgraphflags([], opts) - o, other = hg._outgoing(ui, repo, dest, opts) - if not o: - cmdutil.outgoinghooks(ui, repo, other, opts, o) - return - - revdag = logcmdutil.graphrevs(repo, o, opts) - ui.pager(b'outgoing') - displayer = logcmdutil.changesetdisplayer(ui, repo, opts, buffered=True) - logcmdutil.displaygraph( - ui, repo, revdag, displayer, graphmod.asciiedges - ) - cmdutil.outgoinghooks(ui, repo, other, opts, o) - return 0 - if opts.get(b'bookmarks'): dest = path.pushloc or path.loc other = hg.peer(repo, opts, dest)
--- a/mercurial/hg.py Tue Apr 13 15:13:20 2021 +0200 +++ b/mercurial/hg.py Sun Apr 11 20:00:46 2021 +0200 @@ -32,6 +32,7 @@ error, exchange, extensions, + graphmod, httppeer, localrepo, lock, @@ -1382,18 +1383,29 @@ def outgoing(ui, repo, dest, opts): - + if opts.get(b'graph'): + logcmdutil.checkunsupportedgraphflags([], opts) o, other = _outgoing(ui, repo, dest, opts) ret = 1 try: if o: ret = 0 - ui.pager(b'outgoing') - displayer = logcmdutil.changesetdisplayer(ui, repo, opts) - for n in _outgoing_filter(repo, o, opts): - displayer.show(repo[n]) - displayer.close() + if opts.get(b'graph'): + revdag = logcmdutil.graphrevs(repo, o, opts) + ui.pager(b'outgoing') + displayer = logcmdutil.changesetdisplayer( + ui, repo, opts, buffered=True + ) + logcmdutil.displaygraph( + ui, repo, revdag, displayer, graphmod.asciiedges + ) + else: + ui.pager(b'outgoing') + displayer = logcmdutil.changesetdisplayer(ui, repo, opts) + for n in _outgoing_filter(repo, o, opts): + displayer.show(repo[n]) + displayer.close() cmdutil.outgoinghooks(ui, repo, other, opts, o) ret = min(ret, _outgoing_recurse(ui, repo, dest, opts)) return ret # exit code is zero since we found outgoing changes