Show More
@@ -923,6 +923,14 class localrepository(object): | |||||
923 | return fetch.keys() |
|
923 | return fetch.keys() | |
924 |
|
924 | |||
925 | def findoutgoing(self, remote, base=None, heads=None, force=False): |
|
925 | def findoutgoing(self, remote, base=None, heads=None, force=False): | |
|
926 | """Return list of nodes that are roots of subsets not in remote | |||
|
927 | ||||
|
928 | If base dict is specified, assume that these nodes and their parents | |||
|
929 | exist on the remote side. | |||
|
930 | If a list of heads is specified, return only nodes which are heads | |||
|
931 | or ancestors of these heads, and return a second element which | |||
|
932 | contains all remote heads which get new children. | |||
|
933 | """ | |||
926 | if base == None: |
|
934 | if base == None: | |
927 | base = {} |
|
935 | base = {} | |
928 | self.findincoming(remote, base, heads, force=force) |
|
936 | self.findincoming(remote, base, heads, force=force) | |
@@ -944,13 +952,23 class localrepository(object): | |||||
944 |
|
952 | |||
945 | # find every node whose parents have been pruned |
|
953 | # find every node whose parents have been pruned | |
946 | subset = [] |
|
954 | subset = [] | |
|
955 | # find every remote head that will get new children | |||
|
956 | updated_heads = {} | |||
947 | for n in remain: |
|
957 | for n in remain: | |
948 | p1, p2 = self.changelog.parents(n) |
|
958 | p1, p2 = self.changelog.parents(n) | |
949 | if p1 not in remain and p2 not in remain: |
|
959 | if p1 not in remain and p2 not in remain: | |
950 | subset.append(n) |
|
960 | subset.append(n) | |
|
961 | if heads: | |||
|
962 | if p1 in heads: | |||
|
963 | updated_heads[p1] = True | |||
|
964 | if p2 in heads: | |||
|
965 | updated_heads[p2] = True | |||
951 |
|
966 | |||
952 | # this is the set of all roots we have to push |
|
967 | # this is the set of all roots we have to push | |
953 | return subset |
|
968 | if heads: | |
|
969 | return subset, updated_heads.keys() | |||
|
970 | else: | |||
|
971 | return subset | |||
954 |
|
972 | |||
955 | def pull(self, remote, heads=None, force=False): |
|
973 | def pull(self, remote, heads=None, force=False): | |
956 | l = self.lock() |
|
974 | l = self.lock() | |
@@ -976,14 +994,15 class localrepository(object): | |||||
976 | lock = remote.lock() |
|
994 | lock = remote.lock() | |
977 |
|
995 | |||
978 | base = {} |
|
996 | base = {} | |
979 | heads = remote.heads() |
|
997 | remote_heads = remote.heads() | |
980 | inc = self.findincoming(remote, base, heads, force=force) |
|
998 | inc = self.findincoming(remote, base, remote_heads, force=force) | |
981 | if not force and inc: |
|
999 | if not force and inc: | |
982 | self.ui.warn(_("abort: unsynced remote changes!\n")) |
|
1000 | self.ui.warn(_("abort: unsynced remote changes!\n")) | |
983 |
self.ui.status(_("(did you forget to sync? |
|
1001 | self.ui.status(_("(did you forget to sync?" | |
|
1002 | " use push -f to force)\n")) | |||
984 | return 1 |
|
1003 | return 1 | |
985 |
|
1004 | |||
986 | update = self.findoutgoing(remote, base) |
|
1005 | update, updated_heads = self.findoutgoing(remote, base, remote_heads) | |
987 | if revs is not None: |
|
1006 | if revs is not None: | |
988 | msng_cl, bases, heads = self.changelog.nodesbetween(update, revs) |
|
1007 | msng_cl, bases, heads = self.changelog.nodesbetween(update, revs) | |
989 | else: |
|
1008 | else: | |
@@ -993,7 +1012,14 class localrepository(object): | |||||
993 | self.ui.status(_("no changes found\n")) |
|
1012 | self.ui.status(_("no changes found\n")) | |
994 | return 1 |
|
1013 | return 1 | |
995 | elif not force: |
|
1014 | elif not force: | |
996 | if len(bases) < len(heads): |
|
1015 | if revs is not None: | |
|
1016 | updated_heads = {} | |||
|
1017 | for base in msng_cl: | |||
|
1018 | for parent in self.changelog.parents(base): | |||
|
1019 | if parent in remote_heads: | |||
|
1020 | updated_heads[parent] = True | |||
|
1021 | updated_heads = updated_heads.keys() | |||
|
1022 | if len(updated_heads) < len(heads): | |||
997 | self.ui.warn(_("abort: push creates new remote branches!\n")) |
|
1023 | self.ui.warn(_("abort: push creates new remote branches!\n")) | |
998 | self.ui.status(_("(did you forget to merge?" |
|
1024 | self.ui.status(_("(did you forget to merge?" | |
999 | " use push -f to force)\n")) |
|
1025 | " use push -f to force)\n")) |
@@ -26,3 +26,30 hg push ../a | |||||
26 | hg up -m |
|
26 | hg up -m | |
27 | hg commit -m "4" -d "1000000 0" |
|
27 | hg commit -m "4" -d "1000000 0" | |
28 | hg push ../a |
|
28 | hg push ../a | |
|
29 | cd .. | |||
|
30 | ||||
|
31 | hg init c | |||
|
32 | cd c | |||
|
33 | for i in 0 1 2; do | |||
|
34 | echo $i >> foo | |||
|
35 | hg ci -Am $i -d "1000000 0" | |||
|
36 | done | |||
|
37 | cd .. | |||
|
38 | ||||
|
39 | hg clone c d | |||
|
40 | cd d | |||
|
41 | for i in 0 1; do | |||
|
42 | hg co -C $i | |||
|
43 | echo d-$i >> foo | |||
|
44 | hg ci -m d-$i -d "1000000 0" | |||
|
45 | done | |||
|
46 | ||||
|
47 | HGMERGE=true hg co -m 3 | |||
|
48 | hg ci -m c-d -d "1000000 0" | |||
|
49 | ||||
|
50 | hg push ../c | |||
|
51 | hg push -r 2 ../c | |||
|
52 | hg push -r 3 -r 4 ../c | |||
|
53 | hg push -r 5 ../c | |||
|
54 | ||||
|
55 | exit 0 |
@@ -19,3 +19,20 adding changesets | |||||
19 | adding manifests |
|
19 | adding manifests | |
20 | adding file changes |
|
20 | adding file changes | |
21 | added 2 changesets with 1 changes to 1 files |
|
21 | added 2 changesets with 1 changes to 1 files | |
|
22 | adding foo | |||
|
23 | merging foo | |||
|
24 | pushing to ../c | |||
|
25 | searching for changes | |||
|
26 | abort: push creates new remote branches! | |||
|
27 | (did you forget to merge? use push -f to force) | |||
|
28 | pushing to ../c | |||
|
29 | searching for changes | |||
|
30 | no changes found | |||
|
31 | pushing to ../c | |||
|
32 | searching for changes | |||
|
33 | abort: push creates new remote branches! | |||
|
34 | (did you forget to merge? use push -f to force) | |||
|
35 | pushing to ../c | |||
|
36 | searching for changes | |||
|
37 | abort: push creates new remote branches! | |||
|
38 | (did you forget to merge? use push -f to force) |
General Comments 0
You need to be logged in to leave comments.
Login now