##// END OF EJS Templates
phases: mark content pushed as public in local repo on push
Pierre-Yves David -
r15485:fa47291b default
parent child Browse files
Show More
@@ -67,14 +67,18 b' def prepush(repo, remote, force, revs, n'
67 on circumstances:
67 on circumstances:
68
68
69 If we are not going to push anything, return a tuple (None,
69 If we are not going to push anything, return a tuple (None,
70 outgoing) where outgoing is 0 if there are no outgoing
70 outgoing, common) where outgoing is 0 if there are no outgoing
71 changesets and 1 if there are, but we refuse to push them
71 changesets and 1 if there are, but we refuse to push them
72 (e.g. would create new remote heads).
72 (e.g. would create new remote heads). The third element "common"
73 is the list of heads of the common set between local and remote.
73
74
74 Otherwise, return a tuple (changegroup, remoteheads), where
75 Otherwise, return a tuple (changegroup, remoteheads, futureheads),
75 changegroup is a readable file-like object whose read() returns
76 where changegroup is a readable file-like object whose read()
76 successive changegroup chunks ready to be sent over the wire and
77 returns successive changegroup chunks ready to be sent over the
77 remoteheads is the list of remote heads.'''
78 wire, remoteheads is the list of remote heads and futureheads is
79 the list of heads of the common set between local and remote to
80 be after push completion.
81 '''
78 commoninc = findcommonincoming(repo, remote, force=force)
82 commoninc = findcommonincoming(repo, remote, force=force)
79 common, revs = findcommonoutgoing(repo, remote, onlyheads=revs,
83 common, revs = findcommonoutgoing(repo, remote, onlyheads=revs,
80 commoninc=commoninc, force=force)
84 commoninc=commoninc, force=force)
@@ -85,7 +89,7 b' def prepush(repo, remote, force, revs, n'
85
89
86 if not outg:
90 if not outg:
87 repo.ui.status(_("no changes found\n"))
91 repo.ui.status(_("no changes found\n"))
88 return None, 1
92 return None, 1, common
89
93
90 if not force and remoteheads != [nullid]:
94 if not force and remoteheads != [nullid]:
91 if remote.capable('branchmap'):
95 if remote.capable('branchmap'):
@@ -189,4 +193,10 b' def prepush(repo, remote, force, revs, n'
189 cg = repo._changegroup(outg, 'push')
193 cg = repo._changegroup(outg, 'push')
190 else:
194 else:
191 cg = repo.getbundle('push', heads=revs, common=common)
195 cg = repo.getbundle('push', heads=revs, common=common)
192 return cg, remoteheads
196 # no need to compute outg ancestor. All node in outg have either:
197 # - parents in outg
198 # - parents in common
199 # - nullid parent
200 rset = repo.set('heads(%ln + %ln)', common, outg)
201 futureheads = [ctx.node() for ctx in rset]
202 return cg, remoteheads, futureheads
@@ -1554,24 +1554,32 b' class localrepository(repo.repository):'
1554 if not unbundle:
1554 if not unbundle:
1555 lock = remote.lock()
1555 lock = remote.lock()
1556 try:
1556 try:
1557 cg, remote_heads = discovery.prepush(self, remote, force, revs,
1557 # get local lock as we might write phase data
1558 newbranch)
1558 locallock = self.lock()
1559 ret = remote_heads
1559 try:
1560 if cg is not None:
1560 cg, remote_heads, fut = discovery.prepush(self, remote, force,
1561 if unbundle:
1561 revs, newbranch)
1562 # local repo finds heads on server, finds out what
1562 ret = remote_heads
1563 # revs it must push. once revs transferred, if server
1563 if cg is not None:
1564 # finds it has different heads (someone else won
1564 if unbundle:
1565 # commit/push race), server aborts.
1565 # local repo finds heads on server, finds out what
1566 if force:
1566 # revs it must push. once revs transferred, if server
1567 remote_heads = ['force']
1567 # finds it has different heads (someone else won
1568 # ssh: return remote's addchangegroup()
1568 # commit/push race), server aborts.
1569 # http: return remote's addchangegroup() or 0 for error
1569 if force:
1570 ret = remote.unbundle(cg, remote_heads, 'push')
1570 remote_heads = ['force']
1571 else:
1571 # ssh: return remote's addchangegroup()
1572 # we return an integer indicating remote head count change
1572 # http: return remote's addchangegroup() or 0 for error
1573 ret = remote.addchangegroup(cg, 'push', self.url(),
1573 ret = remote.unbundle(cg, remote_heads, 'push')
1574 lock=lock)
1574 else:
1575 # we return an integer indicating remote head count change
1576 ret = remote.addchangegroup(cg, 'push', self.url(),
1577 lock=lock)
1578 # if we don't push, the common data is already useful
1579 # everything exchange is public for now
1580 phases.advanceboundary(self, 0, fut)
1581 finally:
1582 locallock.release()
1575 finally:
1583 finally:
1576 if lock is not None:
1584 if lock is not None:
1577 lock.release()
1585 lock.release()
@@ -30,6 +30,12 b''
30 adding manifests
30 adding manifests
31 adding file changes
31 adding file changes
32 added 2 changesets with 2 changes to 2 files
32 added 2 changesets with 2 changes to 2 files
33 $ hgph
34 3 1 a-D
35 2 1 a-C
36 1 0 a-B
37 0 0 a-A
38
33 $ cd ../beta
39 $ cd ../beta
34 $ hgph
40 $ hgph
35 1 0 a-B
41 1 0 a-B
@@ -55,4 +61,22 b''
55 1 0 a-B
61 1 0 a-B
56 0 0 a-A
62 0 0 a-A
57
63
64 pull did not updated ../alpha state.
65 push from alpha to beta should update phase even if nothing is transfered
58
66
67 $ cd ../alpha
68 $ hgph # not updated by remote pull
69 3 1 a-D
70 2 1 a-C
71 1 0 a-B
72 0 0 a-A
73 $ hg push ../beta
74 pushing to ../beta
75 searching for changes
76 no changes found
77 $ hgph
78 3 0 a-D
79 2 0 a-C
80 1 0 a-B
81 0 0 a-A
82
General Comments 0
You need to be logged in to leave comments. Login now