Show More
@@ -208,6 +208,12 b' class httprepository(repo.repository):' | |||||
208 | return util.chunkbuffer(zgenerator(f)) |
|
208 | return util.chunkbuffer(zgenerator(f)) | |
209 |
|
209 | |||
210 | def unbundle(self, cg, heads, source): |
|
210 | def unbundle(self, cg, heads, source): | |
|
211 | '''Send cg (a readable file-like object representing the | |||
|
212 | changegroup to push, typically a chunkbuffer object) to the | |||
|
213 | remote server as a bundle. Return an integer response code: | |||
|
214 | non-zero indicates a successful push (see | |||
|
215 | localrepository.addchangegroup()), and zero indicates either | |||
|
216 | error or nothing to push.''' | |||
211 | # have to stream bundle to a temp file because we do not have |
|
217 | # have to stream bundle to a temp file because we do not have | |
212 | # http 1.1 chunked transfer. |
|
218 | # http 1.1 chunked transfer. | |
213 |
|
219 |
@@ -1507,6 +1507,13 b' class localrepository(repo.repository):' | |||||
1507 | lock.release() |
|
1507 | lock.release() | |
1508 |
|
1508 | |||
1509 | def push(self, remote, force=False, revs=None): |
|
1509 | def push(self, remote, force=False, revs=None): | |
|
1510 | '''Push outgoing changesets (limited by revs) from the current | |||
|
1511 | repository to remote. Return an integer: | |||
|
1512 | - 0 means HTTP error *or* nothing to push | |||
|
1513 | - 1 means we pushed and remote head count is unchanged *or* | |||
|
1514 | we have outgoing changesets but refused to push | |||
|
1515 | - other values as described by addchangegroup() | |||
|
1516 | ''' | |||
1510 | # there are two ways to push to remote repo: |
|
1517 | # there are two ways to push to remote repo: | |
1511 | # |
|
1518 | # | |
1512 | # addchangegroup assumes local user can lock remote |
|
1519 | # addchangegroup assumes local user can lock remote | |
@@ -1521,11 +1528,18 b' class localrepository(repo.repository):' | |||||
1521 |
|
1528 | |||
1522 | def prepush(self, remote, force, revs): |
|
1529 | def prepush(self, remote, force, revs): | |
1523 | '''Analyze the local and remote repositories and determine which |
|
1530 | '''Analyze the local and remote repositories and determine which | |
1524 |
changesets need to be pushed to the remote. |
|
1531 | changesets need to be pushed to the remote. Return value depends | |
1525 | (changegroup, remoteheads). changegroup is a readable file-like |
|
1532 | on circumstances: | |
1526 | object whose read() returns successive changegroup chunks ready to |
|
1533 | ||
1527 | be sent over the wire. remoteheads is the list of remote heads. |
|
1534 | If we are not going to push anything, return a tuple (None, | |
1528 | ''' |
|
1535 | outgoing) where outgoing is 0 if there are no outgoing | |
|
1536 | changesets and 1 if there are, but we refuse to push them | |||
|
1537 | (e.g. would create new remote heads). | |||
|
1538 | ||||
|
1539 | Otherwise, return a tuple (changegroup, remoteheads), where | |||
|
1540 | changegroup is a readable file-like object whose read() returns | |||
|
1541 | successive changegroup chunks ready to be sent over the wire and | |||
|
1542 | remoteheads is the list of remote heads.''' | |||
1529 | common = {} |
|
1543 | common = {} | |
1530 | remote_heads = remote.heads() |
|
1544 | remote_heads = remote.heads() | |
1531 | inc = self.findincoming(remote, common, remote_heads, force=force) |
|
1545 | inc = self.findincoming(remote, common, remote_heads, force=force) | |
@@ -1640,17 +1654,26 b' class localrepository(repo.repository):' | |||||
1640 | return cg, remote_heads |
|
1654 | return cg, remote_heads | |
1641 |
|
1655 | |||
1642 | def push_addchangegroup(self, remote, force, revs): |
|
1656 | def push_addchangegroup(self, remote, force, revs): | |
|
1657 | '''Push a changegroup by locking the remote and sending the | |||
|
1658 | addchangegroup command to it. Used for local and old SSH repos. | |||
|
1659 | Return an integer: see push(). | |||
|
1660 | ''' | |||
1643 | lock = remote.lock() |
|
1661 | lock = remote.lock() | |
1644 | try: |
|
1662 | try: | |
1645 | ret = self.prepush(remote, force, revs) |
|
1663 | ret = self.prepush(remote, force, revs) | |
1646 | if ret[0] is not None: |
|
1664 | if ret[0] is not None: | |
1647 | cg, remote_heads = ret |
|
1665 | cg, remote_heads = ret | |
|
1666 | # here, we return an integer indicating remote head count change | |||
1648 | return remote.addchangegroup(cg, 'push', self.url()) |
|
1667 | return remote.addchangegroup(cg, 'push', self.url()) | |
|
1668 | # and here we return 0 for "nothing to push" or 1 for | |||
|
1669 | # "something to push but I refuse" | |||
1649 | return ret[1] |
|
1670 | return ret[1] | |
1650 | finally: |
|
1671 | finally: | |
1651 | lock.release() |
|
1672 | lock.release() | |
1652 |
|
1673 | |||
1653 | def push_unbundle(self, remote, force, revs): |
|
1674 | def push_unbundle(self, remote, force, revs): | |
|
1675 | '''Push a changegroup by unbundling it on the remote. Used for new | |||
|
1676 | SSH and HTTP repos. Return an integer: see push().''' | |||
1654 | # local repo finds heads on server, finds out what revs it |
|
1677 | # local repo finds heads on server, finds out what revs it | |
1655 | # must push. once revs transferred, if server finds it has |
|
1678 | # must push. once revs transferred, if server finds it has | |
1656 | # different heads (someone else won commit/push race), server |
|
1679 | # different heads (someone else won commit/push race), server | |
@@ -1661,7 +1684,10 b' class localrepository(repo.repository):' | |||||
1661 | cg, remote_heads = ret |
|
1684 | cg, remote_heads = ret | |
1662 | if force: |
|
1685 | if force: | |
1663 | remote_heads = ['force'] |
|
1686 | remote_heads = ['force'] | |
|
1687 | # ssh: return remote's addchangegroup() | |||
|
1688 | # http: return remote's addchangegroup() or 0 for error | |||
1664 | return remote.unbundle(cg, remote_heads, 'push') |
|
1689 | return remote.unbundle(cg, remote_heads, 'push') | |
|
1690 | # as in push_addchangegroup() | |||
1665 | return ret[1] |
|
1691 | return ret[1] | |
1666 |
|
1692 | |||
1667 | def changegroupinfo(self, nodes, source): |
|
1693 | def changegroupinfo(self, nodes, source): | |
@@ -2025,12 +2051,14 b' class localrepository(repo.repository):' | |||||
2025 | return util.chunkbuffer(gengroup()) |
|
2051 | return util.chunkbuffer(gengroup()) | |
2026 |
|
2052 | |||
2027 | def addchangegroup(self, source, srctype, url, emptyok=False): |
|
2053 | def addchangegroup(self, source, srctype, url, emptyok=False): | |
2028 |
""" |
|
2054 | """Add the changegroup returned by source.read() to this repo. | |
|
2055 | srctype is a string like 'push', 'pull', or 'unbundle'. url is | |||
|
2056 | the URL of the repo where this changegroup is coming from. | |||
2029 |
|
2057 | |||
2030 | return values: |
|
2058 | Return an integer summarizing the change to this repo: | |
2031 | - nothing changed or no source: 0 |
|
2059 | - nothing changed or no source: 0 | |
2032 | - more heads than before: 1+added heads (2..n) |
|
2060 | - more heads than before: 1+added heads (2..n) | |
2033 |
- |
|
2061 | - fewer heads than before: -1-removed heads (-2..-n) | |
2034 | - number of heads stays the same: 1 |
|
2062 | - number of heads stays the same: 1 | |
2035 | """ |
|
2063 | """ | |
2036 | def csmap(x): |
|
2064 | def csmap(x): |
@@ -217,6 +217,10 b' class sshrepository(repo.repository):' | |||||
217 | return self.do_cmd("changegroupsubset", bases=bases, heads=heads) |
|
217 | return self.do_cmd("changegroupsubset", bases=bases, heads=heads) | |
218 |
|
218 | |||
219 | def unbundle(self, cg, heads, source): |
|
219 | def unbundle(self, cg, heads, source): | |
|
220 | '''Send cg (a readable file-like object representing the | |||
|
221 | changegroup to push, typically a chunkbuffer object) to the | |||
|
222 | remote server as a bundle. Return an integer indicating the | |||
|
223 | result of the push (see localrepository.addchangegroup()).''' | |||
220 | d = self.call("unbundle", heads=' '.join(map(hex, heads))) |
|
224 | d = self.call("unbundle", heads=' '.join(map(hex, heads))) | |
221 | if d: |
|
225 | if d: | |
222 | # remote may send "unsynced changes" |
|
226 | # remote may send "unsynced changes" | |
@@ -242,6 +246,9 b' class sshrepository(repo.repository):' | |||||
242 | self.abort(error.ResponseError(_("unexpected response:"), r)) |
|
246 | self.abort(error.ResponseError(_("unexpected response:"), r)) | |
243 |
|
247 | |||
244 | def addchangegroup(self, cg, source, url): |
|
248 | def addchangegroup(self, cg, source, url): | |
|
249 | '''Send a changegroup to the remote server. Return an integer | |||
|
250 | similar to unbundle(). DEPRECATED, since it requires locking the | |||
|
251 | remote.''' | |||
245 | d = self.call("addchangegroup") |
|
252 | d = self.call("addchangegroup") | |
246 | if d: |
|
253 | if d: | |
247 | self.abort(error.RepoError(_("push refused: %s") % d)) |
|
254 | self.abort(error.RepoError(_("push refused: %s") % d)) |
General Comments 0
You need to be logged in to leave comments.
Login now