Show More
@@ -0,0 +1,28 b'' | |||||
|
1 | #!/bin/sh | |||
|
2 | ||||
|
3 | mkdir a | |||
|
4 | cd a | |||
|
5 | hg init | |||
|
6 | echo foo > t1 | |||
|
7 | hg add t1 | |||
|
8 | hg commit -m "1" -d "0 0" | |||
|
9 | ||||
|
10 | cd .. | |||
|
11 | hg clone a b | |||
|
12 | ||||
|
13 | cd a | |||
|
14 | echo foo > t2 | |||
|
15 | hg add t2 | |||
|
16 | hg commit -m "2" -d "0 0" | |||
|
17 | ||||
|
18 | cd ../b | |||
|
19 | echo foo > t3 | |||
|
20 | hg add t3 | |||
|
21 | hg commit -m "3" -d "0 0" | |||
|
22 | ||||
|
23 | hg push ../a | |||
|
24 | hg pull ../a | |||
|
25 | hg push ../a | |||
|
26 | hg up -m | |||
|
27 | hg commit -m "4" -d "0 0" | |||
|
28 | hg push ../a |
@@ -0,0 +1,35 b'' | |||||
|
1 | + hg init | |||
|
2 | + hg add t1 | |||
|
3 | + hg commit -m 1 -d 0 0 | |||
|
4 | + hg clone a b | |||
|
5 | + hg add t2 | |||
|
6 | + hg commit -m 2 -d 0 0 | |||
|
7 | + hg add t3 | |||
|
8 | + hg commit -m 3 -d 0 0 | |||
|
9 | + hg push ../a | |||
|
10 | pushing to ../a | |||
|
11 | searching for changes | |||
|
12 | abort: unsynced remote changes! | |||
|
13 | (did you forget to sync? use push -f to force) | |||
|
14 | + hg pull ../a | |||
|
15 | pulling from ../a | |||
|
16 | searching for changes | |||
|
17 | adding changesets | |||
|
18 | adding manifests | |||
|
19 | adding file changes | |||
|
20 | added 1 changesets with 1 changes to 1 files | |||
|
21 | (run 'hg update' to get a working copy) | |||
|
22 | + hg push ../a | |||
|
23 | pushing to ../a | |||
|
24 | searching for changes | |||
|
25 | abort: push creates new remote branches! | |||
|
26 | (did you forget to merge? use push -f to force) | |||
|
27 | + hg up -m | |||
|
28 | + hg commit -m 4 -d 0 0 | |||
|
29 | + hg push ../a | |||
|
30 | pushing to ../a | |||
|
31 | searching for changes | |||
|
32 | adding changesets | |||
|
33 | adding manifests | |||
|
34 | adding file changes | |||
|
35 | added 2 changesets with 2 changes to 2 files |
@@ -1048,17 +1048,22 b' class localrepository:' | |||||
1048 |
|
1048 | |||
1049 | return nl |
|
1049 | return nl | |
1050 |
|
1050 | |||
1051 |
def findincoming(self, remote, base= |
|
1051 | def findincoming(self, remote, base=None, heads=None): | |
1052 | m = self.changelog.nodemap |
|
1052 | m = self.changelog.nodemap | |
1053 | search = [] |
|
1053 | search = [] | |
1054 | fetch = [] |
|
1054 | fetch = [] | |
1055 | seen = {} |
|
1055 | seen = {} | |
1056 | seenbranch = {} |
|
1056 | seenbranch = {} | |
|
1057 | if base == None: | |||
|
1058 | base = {} | |||
1057 |
|
1059 | |||
1058 | # assume we're closer to the tip than the root |
|
1060 | # assume we're closer to the tip than the root | |
1059 | # and start by examining the heads |
|
1061 | # and start by examining the heads | |
1060 | self.ui.status("searching for changes\n") |
|
1062 | self.ui.status("searching for changes\n") | |
|
1063 | ||||
|
1064 | if not heads: | |||
1061 | heads = remote.heads() |
|
1065 | heads = remote.heads() | |
|
1066 | ||||
1062 | unknown = [] |
|
1067 | unknown = [] | |
1063 | for h in heads: |
|
1068 | for h in heads: | |
1064 | if h not in m: |
|
1069 | if h not in m: | |
@@ -1160,9 +1165,11 b' class localrepository:' | |||||
1160 |
|
1165 | |||
1161 | return fetch |
|
1166 | return fetch | |
1162 |
|
1167 | |||
1163 | def findoutgoing(self, remote): |
|
1168 | def findoutgoing(self, remote, base=None, heads=None): | |
|
1169 | if base == None: | |||
1164 | base = {} |
|
1170 | base = {} | |
1165 | self.findincoming(remote, base) |
|
1171 | self.findincoming(remote, base, heads) | |
|
1172 | ||||
1166 | remain = dict.fromkeys(self.changelog.nodemap) |
|
1173 | remain = dict.fromkeys(self.changelog.nodemap) | |
1167 |
|
1174 | |||
1168 | # prune everything remote has from the tree |
|
1175 | # prune everything remote has from the tree | |
@@ -1202,12 +1209,27 b' class localrepository:' | |||||
1202 | cg = remote.changegroup(fetch) |
|
1209 | cg = remote.changegroup(fetch) | |
1203 | return self.addchangegroup(cg) |
|
1210 | return self.addchangegroup(cg) | |
1204 |
|
1211 | |||
1205 | def push(self, remote): |
|
1212 | def push(self, remote, force=False): | |
1206 | lock = remote.lock() |
|
1213 | lock = remote.lock() | |
1207 | update = self.findoutgoing(remote) |
|
1214 | ||
|
1215 | base = {} | |||
|
1216 | heads = remote.heads() | |||
|
1217 | inc = self.findincoming(remote, base, heads) | |||
|
1218 | if not force and inc: | |||
|
1219 | self.ui.warn("abort: unsynced remote changes!\n") | |||
|
1220 | self.ui.status("(did you forget to sync? use push -f to force)\n") | |||
|
1221 | return 1 | |||
|
1222 | ||||
|
1223 | update = self.findoutgoing(remote, base) | |||
1208 | if not update: |
|
1224 | if not update: | |
1209 | self.ui.status("no changes found\n") |
|
1225 | self.ui.status("no changes found\n") | |
1210 | return 1 |
|
1226 | return 1 | |
|
1227 | elif not force: | |||
|
1228 | if len(heads) < len(self.changelog.heads()): | |||
|
1229 | self.ui.warn("abort: push creates new remote branches!\n") | |||
|
1230 | self.ui.status("(did you forget to merge?" + | |||
|
1231 | " use push -f to force)\n") | |||
|
1232 | return 1 | |||
1211 |
|
1233 | |||
1212 | cg = self.changegroup(update) |
|
1234 | cg = self.changegroup(update) | |
1213 | return remote.addchangegroup(cg) |
|
1235 | return remote.addchangegroup(cg) |
General Comments 0
You need to be logged in to leave comments.
Login now