changeset 621:004e811f7706

Add a function to calculate the outgoing changegroup
author Matt Mackall <mpm@selenic.com>
date Tue, 05 Jul 2005 17:49:01 -0800
parents 7369ec5d93f2
children e9fe5d5e67f7
files mercurial/hg.py
diffstat 1 files changed, 27 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hg.py	Mon Jul 04 15:42:26 2005 -0800
+++ b/mercurial/hg.py	Tue Jul 05 17:49:01 2005 -0800
@@ -854,11 +854,10 @@
 
         return nl
 
-    def findincoming(self, remote):
+    def findincoming(self, remote, base={}):
         m = self.changelog.nodemap
         search = []
         fetch = []
-        base = {}
         seen = {}
         seenbranch = {}
 
@@ -875,6 +874,8 @@
         for h in heads:
             if h not in m:
                 unknown.append(h)
+            else:
+                base[h] = 1
 
         if not unknown:
             return None
@@ -970,6 +971,30 @@
 
         return fetch
 
+    def findoutgoing(self, remote):
+        base = {}
+        findincoming(self, remote, base)
+        remain = dict.fromkeys(self.changelog.nodemap)
+
+        # prune everything remote has from the tree
+        remove = base.keys()
+        while remove:
+            n = remove.pop(0)
+            if n in remain:
+                del remain[n]
+                for p in self.changelog.parents(n):
+                    remain.append(p)
+
+        # find every node whose parents have been pruned
+        subset = []
+        for n in remain:
+            p1, p2 = self.changelog.parents(n)
+            if p1 not in remain and p2 not in remain:
+                subset.append(n)
+
+        # this is the set of all roots we have to push
+        return subset
+
     def changegroup(self, basenodes):
         nodes = self.newer(basenodes)