Show More
@@ -208,6 +208,12 b' class httprepository(repo.repository):' | |||
|
208 | 208 | return util.chunkbuffer(zgenerator(f)) |
|
209 | 209 | |
|
210 | 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 | 217 | # have to stream bundle to a temp file because we do not have |
|
212 | 218 | # http 1.1 chunked transfer. |
|
213 | 219 |
@@ -1507,6 +1507,13 b' class localrepository(repo.repository):' | |||
|
1507 | 1507 | lock.release() |
|
1508 | 1508 | |
|
1509 | 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 | 1517 | # there are two ways to push to remote repo: |
|
1511 | 1518 | # |
|
1512 | 1519 | # addchangegroup assumes local user can lock remote |
@@ -1521,11 +1528,18 b' class localrepository(repo.repository):' | |||
|
1521 | 1528 | |
|
1522 | 1529 | def prepush(self, remote, force, revs): |
|
1523 | 1530 | '''Analyze the local and remote repositories and determine which |
|
1524 |
changesets need to be pushed to the remote. |
|
|
1525 | (changegroup, remoteheads). changegroup is a readable file-like | |
|
1526 | object whose read() returns successive changegroup chunks ready to | |
|
1527 | be sent over the wire. remoteheads is the list of remote heads. | |
|
1528 | ''' | |
|
1531 | changesets need to be pushed to the remote. Return value depends | |
|
1532 | on circumstances: | |
|
1533 | ||
|
1534 | If we are not going to push anything, return a tuple (None, | |
|
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 | 1543 | common = {} |
|
1530 | 1544 | remote_heads = remote.heads() |
|
1531 | 1545 | inc = self.findincoming(remote, common, remote_heads, force=force) |
@@ -1640,17 +1654,26 b' class localrepository(repo.repository):' | |||
|
1640 | 1654 | return cg, remote_heads |
|
1641 | 1655 | |
|
1642 | 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 | 1661 | lock = remote.lock() |
|
1644 | 1662 | try: |
|
1645 | 1663 | ret = self.prepush(remote, force, revs) |
|
1646 | 1664 | if ret[0] is not None: |
|
1647 | 1665 | cg, remote_heads = ret |
|
1666 | # here, we return an integer indicating remote head count change | |
|
1648 | 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 | 1670 | return ret[1] |
|
1650 | 1671 | finally: |
|
1651 | 1672 | lock.release() |
|
1652 | 1673 | |
|
1653 | 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 | 1677 | # local repo finds heads on server, finds out what revs it |
|
1655 | 1678 | # must push. once revs transferred, if server finds it has |
|
1656 | 1679 | # different heads (someone else won commit/push race), server |
@@ -1661,7 +1684,10 b' class localrepository(repo.repository):' | |||
|
1661 | 1684 | cg, remote_heads = ret |
|
1662 | 1685 | if force: |
|
1663 | 1686 | remote_heads = ['force'] |
|
1687 | # ssh: return remote's addchangegroup() | |
|
1688 | # http: return remote's addchangegroup() or 0 for error | |
|
1664 | 1689 | return remote.unbundle(cg, remote_heads, 'push') |
|
1690 | # as in push_addchangegroup() | |
|
1665 | 1691 | return ret[1] |
|
1666 | 1692 | |
|
1667 | 1693 | def changegroupinfo(self, nodes, source): |
@@ -2025,12 +2051,14 b' class localrepository(repo.repository):' | |||
|
2025 | 2051 | return util.chunkbuffer(gengroup()) |
|
2026 | 2052 | |
|
2027 | 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 | 2059 | - nothing changed or no source: 0 |
|
2032 | 2060 | - more heads than before: 1+added heads (2..n) |
|
2033 |
- |
|
|
2061 | - fewer heads than before: -1-removed heads (-2..-n) | |
|
2034 | 2062 | - number of heads stays the same: 1 |
|
2035 | 2063 | """ |
|
2036 | 2064 | def csmap(x): |
@@ -217,6 +217,10 b' class sshrepository(repo.repository):' | |||
|
217 | 217 | return self.do_cmd("changegroupsubset", bases=bases, heads=heads) |
|
218 | 218 | |
|
219 | 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 | 224 | d = self.call("unbundle", heads=' '.join(map(hex, heads))) |
|
221 | 225 | if d: |
|
222 | 226 | # remote may send "unsynced changes" |
@@ -242,6 +246,9 b' class sshrepository(repo.repository):' | |||
|
242 | 246 | self.abort(error.ResponseError(_("unexpected response:"), r)) |
|
243 | 247 | |
|
244 | 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 | 252 | d = self.call("addchangegroup") |
|
246 | 253 | if d: |
|
247 | 254 | self.abort(error.RepoError(_("push refused: %s") % d)) |
General Comments 0
You need to be logged in to leave comments.
Login now