Show More
@@ -4,12 +4,11 b'' | |||
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms of the |
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | ||
|
8 | 7 | from node import bin, hex, nullid, nullrev, short |
|
9 | 8 | from i18n import _ |
|
10 | 9 | import repo, changegroup, subrepo, discovery, pushkey, obsolete |
|
11 | 10 | import changelog, dirstate, filelog, manifest, context, bookmarks, phases |
|
12 | import lock, transaction, store, encoding | |
|
11 | import lock, transaction, store, encoding, base85 | |
|
13 | 12 | import scmutil, util, extensions, hook, error, revset |
|
14 | 13 | import match as matchmod |
|
15 | 14 | import merge as mergemod |
@@ -1674,6 +1673,11 b' class localrepository(repo.repository):' | |||
|
1674 | 1673 | # Remote is old or publishing all common changesets |
|
1675 | 1674 | # should be seen as public |
|
1676 | 1675 | phases.advanceboundary(self, phases.public, subset) |
|
1676 | ||
|
1677 | remoteobs = remote.listkeys('obsolete') | |
|
1678 | if 'dump' in remoteobs: | |
|
1679 | data = base85.b85decode(remoteobs['dump']) | |
|
1680 | self.obsstore.mergemarkers(data) | |
|
1677 | 1681 | finally: |
|
1678 | 1682 | lock.release() |
|
1679 | 1683 | |
@@ -1814,6 +1818,12 b' class localrepository(repo.repository):' | |||
|
1814 | 1818 | if not r: |
|
1815 | 1819 | self.ui.warn(_('updating %s to public failed!\n') |
|
1816 | 1820 | % newremotehead) |
|
1821 | if 'obsolete' in self.listkeys('namespaces') and self.obsstore: | |
|
1822 | data = self.obsstore._writemarkers() | |
|
1823 | r = remote.pushkey('obsolete', 'dump', '', | |
|
1824 | base85.b85encode(data)) | |
|
1825 | if not r: | |
|
1826 | self.ui.warn(_('failed to push obsolete markers!\n')) | |
|
1817 | 1827 | finally: |
|
1818 | 1828 | if lock is not None: |
|
1819 | 1829 | lock.release() |
@@ -52,7 +52,7 b' The header is followed by the markers. E' | |||
|
52 | 52 | cannot contain '\0'. |
|
53 | 53 | """ |
|
54 | 54 | import struct |
|
55 | from mercurial import util | |
|
55 | from mercurial import util, base85 | |
|
56 | 56 | from i18n import _ |
|
57 | 57 | |
|
58 | 58 | _pack = struct.pack |
@@ -166,6 +166,9 b' class obsstore(object):' | |||
|
166 | 166 | def __iter__(self): |
|
167 | 167 | return iter(self._all) |
|
168 | 168 | |
|
169 | def __nonzero__(self): | |
|
170 | return bool(self._all) | |
|
171 | ||
|
169 | 172 | def create(self, prec, succs=(), flag=0, metadata=None): |
|
170 | 173 | """obsolete: add a new obsolete marker |
|
171 | 174 | |
@@ -195,6 +198,13 b' class obsstore(object):' | |||
|
195 | 198 | for marker in _readmarkers(data): |
|
196 | 199 | self._load(marker) |
|
197 | 200 | |
|
201 | def mergemarkers(self, data): | |
|
202 | other = set(_readmarkers(data)) | |
|
203 | local = set(self._all) | |
|
204 | new = other - local | |
|
205 | for marker in new: | |
|
206 | self.add(marker) | |
|
207 | ||
|
198 | 208 | def flushmarkers(self, stream): |
|
199 | 209 | """Write all markers to a stream |
|
200 | 210 | |
@@ -209,20 +219,48 b' class obsstore(object):' | |||
|
209 | 219 | for suc in sucs: |
|
210 | 220 | self.successors.setdefault(suc, set()).add(marker) |
|
211 | 221 | |
|
212 | def _writemarkers(self, stream): | |
|
222 | def _writemarkers(self, stream=None): | |
|
213 | 223 | # Kept separate from flushmarkers(), it will be reused for |
|
214 | 224 | # markers exchange. |
|
215 | stream.write(_pack('>B', _fmversion)) | |
|
225 | if stream is None: | |
|
226 | final = [] | |
|
227 | w = final.append | |
|
228 | else: | |
|
229 | w = stream.write | |
|
230 | w(_pack('>B', _fmversion)) | |
|
216 | 231 | for marker in self._all: |
|
217 | 232 | pre, sucs, flags, metadata = marker |
|
218 | 233 | nbsuc = len(sucs) |
|
219 | 234 | format = _fmfixed + (_fmnode * nbsuc) |
|
220 | 235 | data = [nbsuc, len(metadata), flags, pre] |
|
221 | 236 | data.extend(sucs) |
|
222 |
|
|
|
223 |
|
|
|
237 | w(_pack(format, *data)) | |
|
238 | w(metadata) | |
|
239 | if stream is None: | |
|
240 | return ''.join(final) | |
|
241 | ||
|
242 | def listmarkers(repo): | |
|
243 | """List markers over pushkey""" | |
|
244 | if not repo.obsstore: | |
|
245 | return {} | |
|
246 | data = repo.obsstore._writemarkers() | |
|
247 | return {'dump': base85.b85encode(data)} | |
|
224 | 248 | |
|
225 | ||
|
249 | def pushmarker(repo, key, old, new): | |
|
250 | """Push markers over pushkey""" | |
|
251 | if key != 'dump': | |
|
252 | repo.ui.warn(_('unknown key: %r') % key) | |
|
253 | return 0 | |
|
254 | if old: | |
|
255 | repo.ui.warn(_('unexpected old value') % key) | |
|
256 | return 0 | |
|
257 | data = base85.b85decode(new) | |
|
258 | lock = repo.lock() | |
|
259 | try: | |
|
260 | repo.obsstore.mergemarkers(data) | |
|
261 | return 1 | |
|
262 | finally: | |
|
263 | lock.release() | |
|
226 | 264 | |
|
227 | 265 | def allmarkers(repo): |
|
228 | 266 | """all obsolete markers known in a repository""" |
@@ -5,7 +5,7 b'' | |||
|
5 | 5 | # This software may be used and distributed according to the terms of the |
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | |
|
8 | import bookmarks, phases | |
|
8 | import bookmarks, phases, obsolete | |
|
9 | 9 | |
|
10 | 10 | def _nslist(repo): |
|
11 | 11 | n = {} |
@@ -16,6 +16,7 b' def _nslist(repo):' | |||
|
16 | 16 | _namespaces = {"namespaces": (lambda *x: False, _nslist), |
|
17 | 17 | "bookmarks": (bookmarks.pushbookmark, bookmarks.listbookmarks), |
|
18 | 18 | "phases": (phases.pushphase, phases.listphases), |
|
19 | "obsolete": (obsolete.pushmarker, obsolete.listmarkers), | |
|
19 | 20 | } |
|
20 | 21 | |
|
21 | 22 | def register(namespace, pushkey, listkeys): |
@@ -40,6 +40,7 b' import bookmark by name' | |||
|
40 | 40 | bookmarks |
|
41 | 41 | phases |
|
42 | 42 | namespaces |
|
43 | obsolete | |
|
43 | 44 | $ hg debugpushkey ../a bookmarks |
|
44 | 45 | Y 4e3505fd95835d721066b76e75dbb8cc554d7f77 |
|
45 | 46 | X 4e3505fd95835d721066b76e75dbb8cc554d7f77 |
@@ -214,6 +215,7 b' hgweb' | |||
|
214 | 215 | bookmarks |
|
215 | 216 | phases |
|
216 | 217 | namespaces |
|
218 | obsolete | |
|
217 | 219 | $ hg debugpushkey http://localhost:$HGPORT/ bookmarks |
|
218 | 220 | Y 4efff6d98829d9c824c621afd6e3f01865f5439f |
|
219 | 221 | foobar 9b140be1080824d768c5a4691a564088eede71f9 |
@@ -198,6 +198,7 b' listkeys hook' | |||
|
198 | 198 | listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'} |
|
199 | 199 | no changes found |
|
200 | 200 | listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'} |
|
201 | listkeys hook: HG_NAMESPACE=obsolete HG_VALUES={} | |
|
201 | 202 | listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'} |
|
202 | 203 | adding remote bookmark bar |
|
203 | 204 | importing bookmark bar |
@@ -105,20 +105,24 b' do not use the proxy if it is in the no ' | |||
|
105 | 105 | * - - [*] "GET http://localhost:$HGPORT/?cmd=batch HTTP/1.1" - - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D (glob) |
|
106 | 106 | * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 (glob) |
|
107 | 107 | * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=phases (glob) |
|
108 | * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=obsolete (glob) | |
|
108 | 109 | * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=bookmarks (glob) |
|
109 | 110 | * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob) |
|
110 | 111 | * - - [*] "GET http://localhost:$HGPORT/?cmd=batch HTTP/1.1" - - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D (glob) |
|
111 | 112 | * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 (glob) |
|
112 | 113 | * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=phases (glob) |
|
114 | * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=obsolete (glob) | |
|
113 | 115 | * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=bookmarks (glob) |
|
114 | 116 | * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob) |
|
115 | 117 | * - - [*] "GET http://localhost:$HGPORT/?cmd=batch HTTP/1.1" - - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D (glob) |
|
116 | 118 | * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 (glob) |
|
117 | 119 | * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=phases (glob) |
|
120 | * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=obsolete (glob) | |
|
118 | 121 | * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=bookmarks (glob) |
|
119 | 122 | * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob) |
|
120 | 123 | * - - [*] "GET http://localhost:$HGPORT/?cmd=batch HTTP/1.1" - - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D (glob) |
|
121 | 124 | * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 (glob) |
|
122 | 125 | * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=phases (glob) |
|
126 | * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=obsolete (glob) | |
|
123 | 127 | * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=bookmarks (glob) |
|
124 | 128 |
@@ -125,6 +125,7 b' clone via pull' | |||
|
125 | 125 | adding file changes |
|
126 | 126 | added 1 changesets with 4 changes to 4 files |
|
127 | 127 | warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting) |
|
128 | warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting) | |
|
128 | 129 | updating to branch default |
|
129 | 130 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
130 | 131 | $ hg verify -R copy-pull |
@@ -154,6 +155,7 b' pull without cacert' | |||
|
154 | 155 | added 1 changesets with 1 changes to 1 files |
|
155 | 156 | warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting) |
|
156 | 157 | changegroup hook: HG_NODE=5fed3813f7f5e1824344fdc9cf8f63bb662c292d HG_SOURCE=pull HG_URL=https://localhost:$HGPORT/ |
|
158 | warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting) | |
|
157 | 159 | (run 'hg update' to get a working copy) |
|
158 | 160 | $ cd .. |
|
159 | 161 | |
@@ -182,6 +184,7 b' variables in the filename' | |||
|
182 | 184 | pulling from https://localhost:$HGPORT/ |
|
183 | 185 | searching for changes |
|
184 | 186 | no changes found |
|
187 | warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting) | |
|
185 | 188 | |
|
186 | 189 | cacert mismatch |
|
187 | 190 | |
@@ -194,6 +197,7 b' cacert mismatch' | |||
|
194 | 197 | pulling from https://127.0.0.1:$HGPORT/ |
|
195 | 198 | searching for changes |
|
196 | 199 | no changes found |
|
200 | warning: 127.0.0.1 certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting) | |
|
197 | 201 | $ hg -R copy-pull pull --config web.cacerts=pub-other.pem |
|
198 | 202 | abort: error: *:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed (glob) |
|
199 | 203 | [255] |
@@ -202,6 +206,7 b' cacert mismatch' | |||
|
202 | 206 | pulling from https://localhost:$HGPORT/ |
|
203 | 207 | searching for changes |
|
204 | 208 | no changes found |
|
209 | warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting) | |
|
205 | 210 | |
|
206 | 211 | Test server cert which isn't valid yet |
|
207 | 212 | |
@@ -259,6 +264,7 b' Test unvalidated https through proxy' | |||
|
259 | 264 | pulling from https://localhost:$HGPORT/ |
|
260 | 265 | searching for changes |
|
261 | 266 | no changes found |
|
267 | warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting) | |
|
262 | 268 | |
|
263 | 269 | Test https with cacert and fingerprint through proxy |
|
264 | 270 |
@@ -59,3 +59,85 b' Register two markers with a missing node' | |||
|
59 | 59 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'} |
|
60 | 60 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'} |
|
61 | 61 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'} |
|
62 | ||
|
63 | $ cd .. | |
|
64 | ||
|
65 | Exchange Test | |
|
66 | ============================ | |
|
67 | ||
|
68 | Destination repo does not have any data | |
|
69 | --------------------------------------- | |
|
70 | ||
|
71 | Try to pull markers | |
|
72 | ||
|
73 | $ hg init tmpc | |
|
74 | $ cd tmpc | |
|
75 | $ hg pull ../tmpb | |
|
76 | pulling from ../tmpb | |
|
77 | requesting all changes | |
|
78 | adding changesets | |
|
79 | adding manifests | |
|
80 | adding file changes | |
|
81 | added 6 changesets with 6 changes to 6 files (+3 heads) | |
|
82 | (run 'hg heads' to see heads, 'hg merge' to merge) | |
|
83 | $ hg debugobsolete | |
|
84 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'} | |
|
85 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'} | |
|
86 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f 0 {'date': '56 12', 'user': 'test'} | |
|
87 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'} | |
|
88 | ||
|
89 | $ cd .. | |
|
90 | ||
|
91 | Try to pull markers | |
|
92 | ||
|
93 | $ hg init tmpd | |
|
94 | $ hg -R tmpb push tmpd | |
|
95 | pushing to tmpd | |
|
96 | searching for changes | |
|
97 | adding changesets | |
|
98 | adding manifests | |
|
99 | adding file changes | |
|
100 | added 6 changesets with 6 changes to 6 files (+3 heads) | |
|
101 | $ hg -R tmpd debugobsolete | |
|
102 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'} | |
|
103 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'} | |
|
104 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f 0 {'date': '56 12', 'user': 'test'} | |
|
105 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'} | |
|
106 | ||
|
107 | ||
|
108 | Destination repo have existing data | |
|
109 | --------------------------------------- | |
|
110 | ||
|
111 | On pull | |
|
112 | ||
|
113 | $ hg init tmpe | |
|
114 | $ cd tmpe | |
|
115 | $ hg debugobsolete -d '1339 0' 2448244824482448244824482448244824482448 1339133913391339133913391339133913391339 | |
|
116 | $ hg pull ../tmpb | |
|
117 | pulling from ../tmpb | |
|
118 | requesting all changes | |
|
119 | adding changesets | |
|
120 | adding manifests | |
|
121 | adding file changes | |
|
122 | added 6 changesets with 6 changes to 6 files (+3 heads) | |
|
123 | (run 'hg heads' to see heads, 'hg merge' to merge) | |
|
124 | $ hg debugobsolete | |
|
125 | 2448244824482448244824482448244824482448 1339133913391339133913391339133913391339 0 {'date': '1339 0', 'user': 'test'} | |
|
126 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'} | |
|
127 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'} | |
|
128 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f 0 {'date': '56 12', 'user': 'test'} | |
|
129 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'} | |
|
130 | ||
|
131 | On push | |
|
132 | ||
|
133 | $ hg push ../tmpc | |
|
134 | pushing to ../tmpc | |
|
135 | searching for changes | |
|
136 | no changes found | |
|
137 | [1] | |
|
138 | $ hg -R ../tmpc debugobsolete | |
|
139 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'} | |
|
140 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'} | |
|
141 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f 0 {'date': '56 12', 'user': 'test'} | |
|
142 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'} | |
|
143 | 2448244824482448244824482448244824482448 1339133913391339133913391339133913391339 0 {'date': '1339 0', 'user': 'test'} |
General Comments 0
You need to be logged in to leave comments.
Login now