Mercurial > public > mercurial-scm > hg
comparison mercurial/hg.py @ 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 | d45d1c90032e |
children | e9fe5d5e67f7 |
comparison
equal
deleted
inserted
replaced
620:7369ec5d93f2 | 621:004e811f7706 |
---|---|
852 nl.append(n) | 852 nl.append(n) |
853 break | 853 break |
854 | 854 |
855 return nl | 855 return nl |
856 | 856 |
857 def findincoming(self, remote): | 857 def findincoming(self, remote, base={}): |
858 m = self.changelog.nodemap | 858 m = self.changelog.nodemap |
859 search = [] | 859 search = [] |
860 fetch = [] | 860 fetch = [] |
861 base = {} | |
862 seen = {} | 861 seen = {} |
863 seenbranch = {} | 862 seenbranch = {} |
864 | 863 |
865 # if we have an empty repo, fetch everything | 864 # if we have an empty repo, fetch everything |
866 if self.changelog.tip() == nullid: | 865 if self.changelog.tip() == nullid: |
873 heads = remote.heads() | 872 heads = remote.heads() |
874 unknown = [] | 873 unknown = [] |
875 for h in heads: | 874 for h in heads: |
876 if h not in m: | 875 if h not in m: |
877 unknown.append(h) | 876 unknown.append(h) |
877 else: | |
878 base[h] = 1 | |
878 | 879 |
879 if not unknown: | 880 if not unknown: |
880 return None | 881 return None |
881 | 882 |
882 rep = {} | 883 rep = {} |
967 " ".join([short(f) for f in fetch]) + "\n") | 968 " ".join([short(f) for f in fetch]) + "\n") |
968 | 969 |
969 self.ui.debug("%d total queries\n" % reqcnt) | 970 self.ui.debug("%d total queries\n" % reqcnt) |
970 | 971 |
971 return fetch | 972 return fetch |
973 | |
974 def findoutgoing(self, remote): | |
975 base = {} | |
976 findincoming(self, remote, base) | |
977 remain = dict.fromkeys(self.changelog.nodemap) | |
978 | |
979 # prune everything remote has from the tree | |
980 remove = base.keys() | |
981 while remove: | |
982 n = remove.pop(0) | |
983 if n in remain: | |
984 del remain[n] | |
985 for p in self.changelog.parents(n): | |
986 remain.append(p) | |
987 | |
988 # find every node whose parents have been pruned | |
989 subset = [] | |
990 for n in remain: | |
991 p1, p2 = self.changelog.parents(n) | |
992 if p1 not in remain and p2 not in remain: | |
993 subset.append(n) | |
994 | |
995 # this is the set of all roots we have to push | |
996 return subset | |
972 | 997 |
973 def changegroup(self, basenodes): | 998 def changegroup(self, basenodes): |
974 nodes = self.newer(basenodes) | 999 nodes = self.newer(basenodes) |
975 | 1000 |
976 # construct the link map | 1001 # construct the link map |