##// END OF EJS Templates
push: fix subtle bug in prepush logic...
Sune Foldager -
r9479:f3569d95 default
parent child Browse files
Show More
@@ -1493,19 +1493,16 b' class localrepository(repo.repository):'
1493 inc = self.findincoming(remote, common, remote_heads, force=force)
1493 inc = self.findincoming(remote, common, remote_heads, force=force)
1494
1494
1495 update, updated_heads = self.findoutgoing(remote, common, remote_heads)
1495 update, updated_heads = self.findoutgoing(remote, common, remote_heads)
1496 if revs is not None:
1496 msng_cl, bases, heads = self.changelog.nodesbetween(update, revs)
1497 msng_cl, bases, heads = self.changelog.nodesbetween(update, revs)
1498 else:
1499 bases, heads = update, self.changelog.heads()
1500
1497
1501 def checkbranch(lheads, rheads, updatelh):
1498 def checkbranch(lheads, rheads, updatelb):
1502 '''
1499 '''
1503 check whether there are more local heads than remote heads on
1500 check whether there are more local heads than remote heads on
1504 a specific branch.
1501 a specific branch.
1505
1502
1506 lheads: local branch heads
1503 lheads: local branch heads
1507 rheads: remote branch heads
1504 rheads: remote branch heads
1508 updatelh: outgoing local branch heads
1505 updatelb: outgoing local branch bases
1509 '''
1506 '''
1510
1507
1511 warn = 0
1508 warn = 0
@@ -1513,13 +1510,15 b' class localrepository(repo.repository):'
1513 if not revs and len(lheads) > len(rheads):
1510 if not revs and len(lheads) > len(rheads):
1514 warn = 1
1511 warn = 1
1515 else:
1512 else:
1513 # add local heads involved in the push
1516 updatelheads = [self.changelog.heads(x, lheads)
1514 updatelheads = [self.changelog.heads(x, lheads)
1517 for x in updatelh]
1515 for x in updatelb]
1518 newheads = set(sum(updatelheads, [])) & set(lheads)
1516 newheads = set(sum(updatelheads, [])) & set(lheads)
1519
1517
1520 if not newheads:
1518 if not newheads:
1521 return True
1519 return True
1522
1520
1521 # add heads we don't have or that are not involved in the push
1523 for r in rheads:
1522 for r in rheads:
1524 if r in self.changelog.nodemap:
1523 if r in self.changelog.nodemap:
1525 desc = self.changelog.heads(r, heads)
1524 desc = self.changelog.heads(r, heads)
@@ -1535,7 +1534,7 b' class localrepository(repo.repository):'
1535 if not rheads: # new branch requires --force
1534 if not rheads: # new branch requires --force
1536 self.ui.warn(_("abort: push creates new"
1535 self.ui.warn(_("abort: push creates new"
1537 " remote branch '%s'!\n") %
1536 " remote branch '%s'!\n") %
1538 self[updatelh[0]].branch())
1537 self[updatelb[0]].branch())
1539 else:
1538 else:
1540 self.ui.warn(_("abort: push creates new remote heads!\n"))
1539 self.ui.warn(_("abort: push creates new remote heads!\n"))
1541
1540
@@ -1578,11 +1577,11 b' class localrepository(repo.repository):'
1578 else:
1577 else:
1579 rheads = []
1578 rheads = []
1580 lheads = localhds[lh]
1579 lheads = localhds[lh]
1581 updatelh = [upd for upd in update
1580 updatelb = [upd for upd in update
1582 if self[upd].branch() == lh]
1581 if self[upd].branch() == lh]
1583 if not updatelh:
1582 if not updatelb:
1584 continue
1583 continue
1585 if not checkbranch(lheads, rheads, updatelh):
1584 if not checkbranch(lheads, rheads, updatelb):
1586 return None, 0
1585 return None, 0
1587 else:
1586 else:
1588 if not checkbranch(heads, remote_heads, update):
1587 if not checkbranch(heads, remote_heads, update):
@@ -123,4 +123,21 b' echo 11 > foo'
123 hg -q ci -d "1000000 0" -m 11
123 hg -q ci -d "1000000 0" -m 11
124 hg push -r 10 -r 11 ../f; echo $?
124 hg push -r 10 -r 11 ../f; echo $?
125
125
126 echo % checking prepush logic does not allow silently pushing multiple new heads
127 cd ..
128 hg init g
129 echo init > g/init
130 hg -R g ci -Am init
131 echo a > g/a
132 hg -R g ci -Am a
133 hg clone g h
134 hg -R g up 0
135 echo b > g/b
136 hg -R g ci -Am b
137 hg -R h up 0
138 echo c > h/c
139 hg -R h ci -Am c
140 hg -R h push g
141 echo
142
126 exit 0
143 exit 0
@@ -124,3 +124,20 b' adding manifests'
124 adding file changes
124 adding file changes
125 added 2 changesets with 2 changes to 1 files
125 added 2 changesets with 2 changes to 1 files
126 0
126 0
127 % checking prepush logic does not allow silently pushing multiple new heads
128 abort: repository g already exists!
129 adding init
130 adding a
131 updating working directory
132 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
133 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
134 adding b
135 created new head
136 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
137 adding c
138 created new head
139 pushing to g
140 searching for changes
141 abort: push creates new remote heads!
142 (did you forget to merge? use push -f to force)
143
General Comments 0
You need to be logged in to leave comments. Login now