Patchwork D10383: outgoing: merge the code handling --graph with the main one

login
register
mail settings
Submitter phabricator
Date April 13, 2021, 2:53 p.m.
Message ID <differential-rev-PHID-DREV-l54oesu7pnxttmu7i2oe-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48701/
State Superseded
Headers show

Comments

phabricator - April 13, 2021, 2:53 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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`.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10383

AFFECTED FILES
  mercurial/commands.py
  mercurial/hg.py
  tests/test-largefiles-misc.t

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-largefiles-misc.t b/tests/test-largefiles-misc.t
--- a/tests/test-largefiles-misc.t
+++ b/tests/test-largefiles-misc.t
@@ -675,6 +675,7 @@ 
   searching for changes
   no changes found
   largefiles: no files to upload
+  [1]
 
 check messages when there are files to upload:
 
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -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
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4971,22 +4971,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)