mercurial/discovery.py
changeset 16746 9acb5cd19162
parent 16683 525fdb738975
parent 16736 025b3b763ba9
child 16835 4267c840c481
equal deleted inserted replaced
16745:27b2e1823e83 16746:9acb5cd19162
    85         if self._missing is None:
    85         if self._missing is None:
    86             self._computecommonmissing()
    86             self._computecommonmissing()
    87         return self._missing
    87         return self._missing
    88 
    88 
    89 def findcommonoutgoing(repo, other, onlyheads=None, force=False,
    89 def findcommonoutgoing(repo, other, onlyheads=None, force=False,
    90                        commoninc=None):
    90                        commoninc=None, portable=False):
    91     '''Return an outgoing instance to identify the nodes present in repo but
    91     '''Return an outgoing instance to identify the nodes present in repo but
    92     not in other.
    92     not in other.
    93 
    93 
    94     If onlyheads is given, only nodes ancestral to nodes in onlyheads
    94     If onlyheads is given, only nodes ancestral to nodes in onlyheads
    95     (inclusive) are included. If you already know the local repo's heads,
    95     (inclusive) are included. If you already know the local repo's heads,
    96     passing them in onlyheads is faster than letting them be recomputed here.
    96     passing them in onlyheads is faster than letting them be recomputed here.
    97 
    97 
    98     If commoninc is given, it must the the result of a prior call to
    98     If commoninc is given, it must the the result of a prior call to
    99     findcommonincoming(repo, other, force) to avoid recomputing it here.'''
    99     findcommonincoming(repo, other, force) to avoid recomputing it here.
       
   100 
       
   101     If portable is given, compute more conservative common and missingheads,
       
   102     to make bundles created from the instance more portable.'''
   100     # declare an empty outgoing object to be filled later
   103     # declare an empty outgoing object to be filled later
   101     og = outgoing(repo.changelog, None, None)
   104     og = outgoing(repo.changelog, None, None)
   102 
   105 
   103     # get common set if not provided
   106     # get common set if not provided
   104     if commoninc is None:
   107     if commoninc is None:
   127             # update missing heads
   130             # update missing heads
   128             missingheads = phases.newheads(repo, onlyheads, excluded)
   131             missingheads = phases.newheads(repo, onlyheads, excluded)
   129         else:
   132         else:
   130             missingheads = onlyheads
   133             missingheads = onlyheads
   131         og.missingheads = missingheads
   134         og.missingheads = missingheads
       
   135 
       
   136     if portable:
       
   137         # recompute common and missingheads as if -r<rev> had been given for
       
   138         # each head of missing, and --base <rev> for each head of the proper
       
   139         # ancestors of missing
       
   140         og._computecommonmissing()
       
   141         cl = repo.changelog
       
   142         missingrevs = set(cl.rev(n) for n in og._missing)
       
   143         og._common = set(cl.ancestors(*missingrevs)) - missingrevs
       
   144         commonheads = set(og.commonheads)
       
   145         og.missingheads = [h for h in og.missingheads if h not in commonheads]
   132 
   146 
   133     return og
   147     return og
   134 
   148 
   135 def checkheads(repo, remote, outgoing, remoteheads, newbranch=False, inc=False):
   149 def checkheads(repo, remote, outgoing, remoteheads, newbranch=False, inc=False):
   136     """Check that a push won't add any outgoing head
   150     """Check that a push won't add any outgoing head