Show More
@@ -2061,7 +2061,12 b' def debugobsolete(ui, repo, precursor=No' | |||
|
2061 | 2061 | succs = tuple(bin(succ) for succ in successors) |
|
2062 | 2062 | l = repo.lock() |
|
2063 | 2063 | try: |
|
2064 | repo.obsstore.create(bin(precursor), succs, 0, metadata) | |
|
2064 | tr = repo.transaction('debugobsolete') | |
|
2065 | try: | |
|
2066 | repo.obsstore.create(tr, bin(precursor), succs, 0, metadata) | |
|
2067 | tr.close() | |
|
2068 | finally: | |
|
2069 | tr.release() | |
|
2065 | 2070 | finally: |
|
2066 | 2071 | l.release() |
|
2067 | 2072 | else: |
@@ -987,8 +987,6 b' class localrepository(repo.repository):' | |||
|
987 | 987 | self.store.write() |
|
988 | 988 | if '_phasecache' in vars(self): |
|
989 | 989 | self._phasecache.write() |
|
990 | if 'obsstore' in vars(self): | |
|
991 | self.obsstore.flushmarkers() | |
|
992 | 990 | for k, ce in self._filecache.items(): |
|
993 | 991 | if k == 'dirstate': |
|
994 | 992 | continue |
@@ -1607,6 +1605,10 b' class localrepository(repo.repository):' | |||
|
1607 | 1605 | return r |
|
1608 | 1606 | |
|
1609 | 1607 | def pull(self, remote, heads=None, force=False): |
|
1608 | # don't open transaction for nothing or you break future useful | |
|
1609 | # rollback call | |
|
1610 | tr = None | |
|
1611 | trname = 'pull\n' + util.hidepassword(remote.url()) | |
|
1610 | 1612 | lock = self.lock() |
|
1611 | 1613 | try: |
|
1612 | 1614 | tmp = discovery.findcommonincoming(self, remote, heads=heads, |
@@ -1617,6 +1619,7 b' class localrepository(repo.repository):' | |||
|
1617 | 1619 | added = [] |
|
1618 | 1620 | result = 0 |
|
1619 | 1621 | else: |
|
1622 | tr = self.transaction(trname) | |
|
1620 | 1623 | if heads is None and list(common) == [nullid]: |
|
1621 | 1624 | self.ui.status(_("requesting all changes\n")) |
|
1622 | 1625 | elif heads is None and remote.capable('changegroupsubset'): |
@@ -1665,9 +1668,15 b' class localrepository(repo.repository):' | |||
|
1665 | 1668 | |
|
1666 | 1669 | remoteobs = remote.listkeys('obsolete') |
|
1667 | 1670 | if 'dump' in remoteobs: |
|
1671 | if tr is None: | |
|
1672 | tr = self.transaction(trname) | |
|
1668 | 1673 | data = base85.b85decode(remoteobs['dump']) |
|
1669 | self.obsstore.mergemarkers(data) | |
|
1674 | self.obsstore.mergemarkers(tr, data) | |
|
1675 | if tr is not None: | |
|
1676 | tr.close() | |
|
1670 | 1677 | finally: |
|
1678 | if tr is not None: | |
|
1679 | tr.release() | |
|
1671 | 1680 | lock.release() |
|
1672 | 1681 | |
|
1673 | 1682 | return result |
@@ -159,7 +159,6 b' class obsstore(object):' | |||
|
159 | 159 | def __init__(self, sopener): |
|
160 | 160 | self._all = [] |
|
161 | 161 | # new markers to serialize |
|
162 | self._new = [] | |
|
163 | 162 | self.precursors = {} |
|
164 | 163 | self.successors = {} |
|
165 | 164 | self.sopener = sopener |
@@ -174,7 +173,7 b' class obsstore(object):' | |||
|
174 | 173 | def __nonzero__(self): |
|
175 | 174 | return bool(self._all) |
|
176 | 175 | |
|
177 | def create(self, prec, succs=(), flag=0, metadata=None): | |
|
176 | def create(self, transaction, prec, succs=(), flag=0, metadata=None): | |
|
178 | 177 | """obsolete: add a new obsolete marker |
|
179 | 178 | |
|
180 | 179 | * ensuring it is hashable |
@@ -189,39 +188,33 b' class obsstore(object):' | |||
|
189 | 188 | if len(succ) != 20: |
|
190 | 189 | raise ValueError(succ) |
|
191 | 190 | marker = (str(prec), tuple(succs), int(flag), encodemeta(metadata)) |
|
192 | self.add(marker) | |
|
193 | ||
|
194 | def add(self, marker): | |
|
195 | """Add a new marker to the store | |
|
196 | ||
|
197 | This marker still needs to be written to disk""" | |
|
198 | self._new.append(marker) | |
|
199 | self._load(marker) | |
|
191 | self.add(transaction, marker) | |
|
200 | 192 | |
|
201 | def mergemarkers(self, data): | |
|
202 | other = set(_readmarkers(data)) | |
|
203 |
|
|
|
204 | new = other - local | |
|
205 | for marker in new: | |
|
206 | self.add(marker) | |
|
207 | ||
|
208 | def flushmarkers(self): | |
|
209 | """Write all markers on disk | |
|
210 | ||
|
211 | After this operation, "new" markers are considered "known".""" | |
|
212 | # XXX: transaction logic should be used | |
|
213 | if self._new: | |
|
193 | def add(self, transaction, marker): | |
|
194 | """Add a new marker to the store""" | |
|
195 | if marker not in self._all: | |
|
214 | 196 | f = self.sopener('obsstore', 'ab') |
|
215 | 197 | try: |
|
216 |
|
|
|
217 | # plain new obsstore | |
|
198 | offset = f.tell() | |
|
199 | transaction.add('obsstore', offset) | |
|
200 | if offset == 0: | |
|
201 | # new file add version header | |
|
218 | 202 | f.write(_pack('>B', _fmversion)) |
|
219 |
_writemarkers(f.write, |
|
|
203 | _writemarkers(f.write, [marker]) | |
|
204 | finally: | |
|
205 | # XXX: f.close() == filecache invalidation == obsstore rebuilt. | |
|
206 | # call 'filecacheentry.refresh()' here | |
|
220 | 207 | f.close() |
|
221 |
|
|
|
222 | except: # re-raises | |
|
223 | f.discard() | |
|
224 | raise | |
|
208 | self._load(marker) | |
|
209 | ||
|
210 | def mergemarkers(self, transation, data): | |
|
211 | other = _readmarkers(data) | |
|
212 | local = set(self._all) | |
|
213 | new = [m for m in other if m not in local] | |
|
214 | for marker in new: | |
|
215 | # XXX: N marker == N x (open, write, close) | |
|
216 | # we should write them all at once | |
|
217 | self.add(transation, marker) | |
|
225 | 218 | |
|
226 | 219 | def _load(self, marker): |
|
227 | 220 | self._all.append(marker) |
@@ -261,8 +254,13 b' def pushmarker(repo, key, old, new):' | |||
|
261 | 254 | data = base85.b85decode(new) |
|
262 | 255 | lock = repo.lock() |
|
263 | 256 | try: |
|
264 | repo.obsstore.mergemarkers(data) | |
|
265 |
|
|
|
257 | tr = repo.transaction('pushkey: obsolete markers') | |
|
258 | try: | |
|
259 | repo.obsstore.mergemarkers(tr, data) | |
|
260 | tr.close() | |
|
261 | return 1 | |
|
262 | finally: | |
|
263 | tr.release() | |
|
266 | 264 | finally: |
|
267 | 265 | lock.release() |
|
268 | 266 |
@@ -158,9 +158,28 b' Try to pull markers' | |||
|
158 | 158 | added 6 changesets with 6 changes to 6 files (+3 heads) |
|
159 | 159 | (run 'hg heads' to see heads, 'hg merge' to merge) |
|
160 | 160 | $ hg debugobsolete |
|
161 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f 0 {'date': '56 12', 'user': 'test'} | |
|
162 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'} | |
|
161 | 163 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'} |
|
164 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'} | |
|
165 | ||
|
166 | Rollback//Transaction support | |
|
167 | ||
|
168 | $ hg debugobsolete -d '1340 0' aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | |
|
169 | $ hg debugobsolete | |
|
170 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f 0 {'date': '56 12', 'user': 'test'} | |
|
162 | 171 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'} |
|
172 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'} | |
|
173 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'} | |
|
174 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 0 {'date': '1340 0', 'user': 'test'} | |
|
175 | $ hg rollback -n | |
|
176 | repository tip rolled back to revision 5 (undo debugobsolete) | |
|
177 | $ hg rollback | |
|
178 | repository tip rolled back to revision 5 (undo debugobsolete) | |
|
179 | $ hg debugobsolete | |
|
163 | 180 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f 0 {'date': '56 12', 'user': 'test'} |
|
181 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'} | |
|
182 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'} | |
|
164 | 183 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'} |
|
165 | 184 | |
|
166 | 185 | $ cd .. |
@@ -176,9 +195,9 b' Try to pull markers' | |||
|
176 | 195 | adding file changes |
|
177 | 196 | added 6 changesets with 6 changes to 6 files (+3 heads) |
|
178 | 197 | $ hg -R tmpd debugobsolete |
|
179 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'} | |
|
198 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f 0 {'date': '56 12', 'user': 'test'} | |
|
180 | 199 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'} |
|
181 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f 0 {'date': '56 12', 'user': 'test'} | |
|
200 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'} | |
|
182 | 201 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'} |
|
183 | 202 | |
|
184 | 203 | |
@@ -200,9 +219,9 b' On pull' | |||
|
200 | 219 | (run 'hg heads' to see heads, 'hg merge' to merge) |
|
201 | 220 | $ hg debugobsolete |
|
202 | 221 | 2448244824482448244824482448244824482448 1339133913391339133913391339133913391339 0 {'date': '1339 0', 'user': 'test'} |
|
203 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'} | |
|
222 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f 0 {'date': '56 12', 'user': 'test'} | |
|
204 | 223 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'} |
|
205 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f 0 {'date': '56 12', 'user': 'test'} | |
|
224 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'} | |
|
206 | 225 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'} |
|
207 | 226 | |
|
208 | 227 | On push |
@@ -213,8 +232,8 b' On push' | |||
|
213 | 232 | no changes found |
|
214 | 233 | [1] |
|
215 | 234 | $ hg -R ../tmpc debugobsolete |
|
216 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'} | |
|
235 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f 0 {'date': '56 12', 'user': 'test'} | |
|
217 | 236 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'} |
|
218 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f 0 {'date': '56 12', 'user': 'test'} | |
|
237 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'} | |
|
219 | 238 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'} |
|
220 | 239 | 2448244824482448244824482448244824482448 1339133913391339133913391339133913391339 0 {'date': '1339 0', 'user': 'test'} |
General Comments 0
You need to be logged in to leave comments.
Login now