Patchwork [2,of,5] outgoing: adds some default value for argument

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 11, 2016, 8:06 p.m.
Message ID <9ff7059253fd00094799.1470946012@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/16252/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 11, 2016, 8:06 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1470750944 -7200
#      Tue Aug 09 15:55:44 2016 +0200
# Node ID 9ff7059253fd00094799f592462590cd837fb457
# Parent  69c5716ec081416cfdde62aac72661e9151e0abc
# EXP-Topic outgoing
outgoing: adds some default value for argument

We are about to introduce a third option to create an outgoing object:
'missingroots'. This argument will be mutually exclusive with 'commonheads' so
we implement some default value handling in preparation.

This will also help use to make more use of outgoing creation around the code
base.

Patch

diff -r 69c5716ec081 -r 9ff7059253fd mercurial/discovery.py
--- a/mercurial/discovery.py	Tue Aug 09 15:26:53 2016 +0200
+++ b/mercurial/discovery.py	Tue Aug 09 15:55:44 2016 +0200
@@ -76,10 +76,15 @@  class outgoing(object):
     The sets are computed on demand from the heads, unless provided upfront
     by discovery.'''
 
-    def __init__(self, repo, commonheads, missingheads):
+    def __init__(self, repo, commonheads=None, missingheads=None):
+        cl = repo.changelog
+        if not missingheads:
+            missingheads = cl.heads()
+        if not commonheads:
+            commonheads = [nullid]
         self.commonheads = commonheads
         self.missingheads = missingheads
-        self._revlog = repo.changelog
+        self._revlog = cl
         self._common = None
         self._missing = None
         self.excluded = []