44 from mercurial import cmdutil |
44 from mercurial import cmdutil |
45 from mercurial import commands |
45 from mercurial import commands |
46 from mercurial import context |
46 from mercurial import context |
47 from mercurial import copies |
47 from mercurial import copies |
48 from mercurial import error |
48 from mercurial import error |
|
49 from mercurial import exchange |
49 from mercurial import extensions |
50 from mercurial import extensions |
50 from mercurial import hg |
51 from mercurial import hg |
51 from mercurial import lock as lockmod |
52 from mercurial import lock as lockmod |
52 from mercurial import merge |
53 from mercurial import merge |
53 from mercurial import node |
54 from mercurial import node |
2072 pendingnodes -= seennodes |
2073 pendingnodes -= seennodes |
2073 seennodes |= pendingnodes |
2074 seennodes |= pendingnodes |
2074 return seenmarkers |
2075 return seenmarkers |
2075 |
2076 |
2076 |
2077 |
|
2078 _pushkeyescape = getattr(obsolete, '_pushkeyescape', None) |
|
2079 if _pushkeyescape is None: |
|
2080 def _pushkeyescape(markers): |
|
2081 """encode markers into a dict suitable for pushkey exchange |
|
2082 |
|
2083 - binary data are base86 encoded |
|
2084 - splited in chunk less than 5300 bytes""" |
|
2085 parts = [] |
|
2086 currentlen = _maxpayload * 2 # ensure we create a new part |
|
2087 for marker in markers: |
|
2088 nextdata = _encodeonemarker(marker) |
|
2089 if (len(nextdata) + currentlen > _maxpayload): |
|
2090 currentpart = [] |
|
2091 currentlen = 0 |
|
2092 parts.append(currentpart) |
|
2093 currentpart.append(nextdata) |
|
2094 currentlen += len(nextdata) |
|
2095 keys = {} |
|
2096 for idx, part in enumerate(reversed(parts)): |
|
2097 data = ''.join([_pack('>B', _fmversion)] + part) |
|
2098 keys['dump%i' % idx] = base85.b85encode(data) |
|
2099 return keys |
|
2100 |
|
2101 |
|
2102 |
|
2103 @eh.wrapfunction(exchange, '_pushobsolete') |
|
2104 def _pushobsolete(orig, pushop): |
|
2105 """utility function to push obsolete markers to a remote""" |
|
2106 pushop.ui.debug('try to push obsolete markers to remote\n') |
|
2107 repo = pushop.repo |
|
2108 remote = pushop.remote |
|
2109 unfi = repo.unfiltered() |
|
2110 if (obsolete._enabled and repo.obsstore and |
|
2111 'obsolete' in remote.listkeys('namespaces')): |
|
2112 repo.ui.status("OBSEXC: computing relevant nodes\n") |
|
2113 nodes = [ctx.node() for ctx in unfi.set('::%ln', pushop.commonheads)] |
|
2114 repo.ui.status("OBSEXC: computing markers relevant to %i nodes\n" |
|
2115 % len(nodes)) |
|
2116 markers = repo.obsstore.relevantmarkers(nodes) |
|
2117 rslts = [] |
|
2118 repo.ui.status("OBSEXC: encoding %i markers\n" % len(markers)) |
|
2119 remotedata = obsolete._pushkeyescape(markers).items() |
|
2120 totalbytes = sum(len(d) for k,d in remotedata) |
|
2121 sentbytes = 0 |
|
2122 repo.ui.status("OBSEXC: sending %i pushkey payload (%i bytes)\n" |
|
2123 % (len(remotedata), totalbytes)) |
|
2124 for key, data in remotedata: |
|
2125 repo.ui.progress('OBSEXC', sentbytes, item=key, unit="bytes", |
|
2126 total=totalbytes) |
|
2127 rslts.append(remote.pushkey('obsolete', key, '', data)) |
|
2128 sentbytes += len(data) |
|
2129 repo.ui.progress('OBSEXC', sentbytes, item=key, unit="bytes", |
|
2130 total=totalbytes) |
|
2131 repo.ui.progress('OBSEXC', None) |
|
2132 if [r for r in rslts if not r]: |
|
2133 msg = _('failed to push some obsolete markers!\n') |
|
2134 repo.ui.warn(msg) |
|
2135 repo.ui.status("OBSEXC: DONE\n") |