Patchwork [08,of,12,V2] hg: make "_outgoing()" return empty list instead of "None"

login
register
mail settings
Submitter Katsunori FUJIWARA
Date April 15, 2014, 3:52 p.m.
Message ID <90e8731c7a427cc21b21.1397577149@juju>
Download mbox | patch
Permalink /patch/4365/
State Accepted
Commit f117a0ba5289c17e8a04bf7cbc7bf3d19e76b593
Headers show

Comments

Katsunori FUJIWARA - April 15, 2014, 3:52 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1397576244 -32400
#      Wed Apr 16 00:37:24 2014 +0900
# Node ID 90e8731c7a427cc21b21cf4e588741ce02e9f726
# Parent  4728096bc1fa68b93ed8a1779c1ecef737de9154
hg: make "_outgoing()" return empty list instead of "None"

This patch makes "_outgoing()" return empty list instead of "None", if
there are no outgoing changesets, because:

  - returning "None" requires callers to examine whether returned
    value is "None" or not explicitly, if callers want to execute loop
    on returned value, but

  - there are no explicit needs to return "None"

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4388,7 +4388,7 @@ 
     if opts.get('graph'):
         cmdutil.checkunsupportedgraphflags([], opts)
         o = hg._outgoing(ui, repo, dest, opts)
-        if o is None:
+        if not o:
             return
 
         revdag = cmdutil.graphrevs(repo, o, opts)
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -585,7 +585,6 @@ 
     o = outgoing.missing
     if not o:
         scmutil.nochangesfound(repo.ui, repo, outgoing.excluded)
-        return None
     return o
 
 def outgoing(ui, repo, dest, opts):
@@ -600,7 +599,7 @@ 
 
     limit = cmdutil.loglimit(opts)
     o = _outgoing(ui, repo, dest, opts)
-    if o is None:
+    if not o:
         return recurse()
 
     if opts.get('newest_first'):