comparison mercurial/localrepo.py @ 3684:975c2469c316

correct remote heads test in prepush
author Matt Mackall <mpm@selenic.com>
date Sun, 19 Nov 2006 16:32:36 -0600
parents 20912eb2667d
children d5dd0a2a44bc
comparison
equal deleted inserted replaced
3683:b0fd43effdb3 3684:975c2469c316
1307 1307
1308 if not bases: 1308 if not bases:
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
1320 1343 elif inc:
1321 if not force and inc: 1344 self.ui.warn(_("note: unsynced remote changes!\n"))
1322 self.ui.warn(_("abort: unsynced remote changes!\n")) 1345
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')
1329 else: 1349 else:
1330 cg = self.changegroupsubset(update, revs, 'push') 1350 cg = self.changegroupsubset(update, revs, 'push')