##// END OF EJS Templates
correct remote heads test in prepush
Matt Mackall -
r3684:975c2469 default
parent child Browse files
Show More
@@ -1309,20 +1309,40 b' class localrepository(repo.repository):'
1309 self.ui.status(_("no changes found\n"))
1309 self.ui.status(_("no changes found\n"))
1310 return None, 1
1310 return None, 1
1311 elif not force:
1311 elif not force:
1312 # FIXME we don't properly detect creation of new heads
1312 # check if we're creating new remote heads
1313 # in the push -r case, assume the user knows what he's doing
1313 # to be a remote head after push, node must be either
1314 if not revs and len(remote_heads) < len(heads) \
1314 # - unknown locally
1315 and remote_heads != [nullid]:
1315 # - a local outgoing head descended from update
1316 # - a remote head that's known locally and not
1317 # ancestral to an outgoing head
1318
1319 warn = 0
1320
1321 if remote_heads == [nullid]:
1322 warn = 0
1323 elif not revs and len(heads) > len(remote_heads):
1324 warn = 1
1325 else:
1326 newheads = list(heads)
1327 for r in remote_heads:
1328 if r in self.changelog.nodemap:
1329 desc = self.changelog.heads(r)
1330 l = [h for h in heads if h in desc]
1331 if not l:
1332 newheads.append(r)
1333 else:
1334 newheads.append(r)
1335 if len(newheads) > len(remote_heads):
1336 warn = 1
1337
1338 if warn:
1316 self.ui.warn(_("abort: push creates new remote branches!\n"))
1339 self.ui.warn(_("abort: push creates new remote branches!\n"))
1317 self.ui.status(_("(did you forget to merge?"
1340 self.ui.status(_("(did you forget to merge?"
1318 " use push -f to force)\n"))
1341 " use push -f to force)\n"))
1319 return None, 1
1342 return None, 1
1343 elif inc:
1344 self.ui.warn(_("note: unsynced remote changes!\n"))
1320
1345
1321 if not force and inc:
1322 self.ui.warn(_("abort: unsynced remote changes!\n"))
1323 self.ui.status(_("(did you forget to sync?"
1324 " use push -f to force)\n"))
1325 return None, 1
1326
1346
1327 if revs is None:
1347 if revs is None:
1328 cg = self.changegroup(update, 'push')
1348 cg = self.changegroup(update, 'push')
@@ -50,6 +50,7 b' hg ci -m c-d -d "1000000 0"'
50 hg push ../c
50 hg push ../c
51 hg push -r 2 ../c
51 hg push -r 2 ../c
52 hg push -r 3 -r 4 ../c
52 hg push -r 3 -r 4 ../c
53 hg push -f -r 3 -r 4 ../c
53 hg push -r 5 ../c
54 hg push -r 5 ../c
54
55
55 exit 0
56 exit 0
@@ -1,8 +1,8 b''
1 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
2 pushing to ../a
2 pushing to ../a
3 searching for changes
3 searching for changes
4 abort: unsynced remote changes!
4 abort: push creates new remote branches!
5 (did you forget to sync? use push -f to force)
5 (did you forget to merge? use push -f to force)
6 pulling from ../a
6 pulling from ../a
7 searching for changes
7 searching for changes
8 adding changesets
8 adding changesets
@@ -38,6 +38,10 b' searching for changes'
38 no changes found
38 no changes found
39 pushing to ../c
39 pushing to ../c
40 searching for changes
40 searching for changes
41 abort: push creates new remote branches!
42 (did you forget to merge? use push -f to force)
43 pushing to ../c
44 searching for changes
41 adding changesets
45 adding changesets
42 adding manifests
46 adding manifests
43 adding file changes
47 adding file changes
@@ -92,11 +92,8 b' cd ../local'
92 echo r > r
92 echo r > r
93 hg ci -A -m z -d '1000002 0' r
93 hg ci -A -m z -d '1000002 0' r
94
94
95 echo "# push should fail"
95 echo "# push should succeed"
96 hg push
96 hg push
97
97
98 echo "# push should succeed"
99 hg push -f
100
101 cd ..
98 cd ..
102 cat dummylog
99 cat dummylog
@@ -68,14 +68,10 b' crosschecking files in changesets and ma'
68 checking files
68 checking files
69 1 files, 2 changesets, 2 total revisions
69 1 files, 2 changesets, 2 total revisions
70 bleah
70 bleah
71 # push should fail
72 pushing to ssh://user@dummy/remote
73 searching for changes
74 abort: unsynced remote changes!
75 (did you forget to sync? use push -f to force)
76 # push should succeed
71 # push should succeed
77 pushing to ssh://user@dummy/remote
72 pushing to ssh://user@dummy/remote
78 searching for changes
73 searching for changes
74 note: unsynced remote changes!
79 remote: adding changesets
75 remote: adding changesets
80 remote: adding manifests
76 remote: adding manifests
81 remote: adding file changes
77 remote: adding file changes
@@ -89,5 +85,4 b' Got arguments 1:user@dummy 2:hg -R local'
89 Got arguments 1:user@dummy 2:hg -R remote serve --stdio 3: 4: 5:
85 Got arguments 1:user@dummy 2:hg -R remote serve --stdio 3: 4: 5:
90 changegroup in remote: u=remote:ssh:127.0.0.1
86 changegroup in remote: u=remote:ssh:127.0.0.1
91 Got arguments 1:user@dummy 2:hg -R remote serve --stdio 3: 4: 5:
87 Got arguments 1:user@dummy 2:hg -R remote serve --stdio 3: 4: 5:
92 Got arguments 1:user@dummy 2:hg -R remote serve --stdio 3: 4: 5:
93 changegroup in remote: u=remote:ssh:127.0.0.1
88 changegroup in remote: u=remote:ssh:127.0.0.1
General Comments 0
You need to be logged in to leave comments. Login now