Show More
@@ -2061,7 +2061,12 b' def debugobsolete(ui, repo, precursor=No' | |||||
2061 | succs = tuple(bin(succ) for succ in successors) |
|
2061 | succs = tuple(bin(succ) for succ in successors) | |
2062 | l = repo.lock() |
|
2062 | l = repo.lock() | |
2063 | try: |
|
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 | finally: |
|
2070 | finally: | |
2066 | l.release() |
|
2071 | l.release() | |
2067 | else: |
|
2072 | else: |
@@ -987,8 +987,6 b' class localrepository(repo.repository):' | |||||
987 | self.store.write() |
|
987 | self.store.write() | |
988 | if '_phasecache' in vars(self): |
|
988 | if '_phasecache' in vars(self): | |
989 | self._phasecache.write() |
|
989 | self._phasecache.write() | |
990 | if 'obsstore' in vars(self): |
|
|||
991 | self.obsstore.flushmarkers() |
|
|||
992 | for k, ce in self._filecache.items(): |
|
990 | for k, ce in self._filecache.items(): | |
993 | if k == 'dirstate': |
|
991 | if k == 'dirstate': | |
994 | continue |
|
992 | continue | |
@@ -1607,6 +1605,10 b' class localrepository(repo.repository):' | |||||
1607 | return r |
|
1605 | return r | |
1608 |
|
1606 | |||
1609 | def pull(self, remote, heads=None, force=False): |
|
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 | lock = self.lock() |
|
1612 | lock = self.lock() | |
1611 | try: |
|
1613 | try: | |
1612 | tmp = discovery.findcommonincoming(self, remote, heads=heads, |
|
1614 | tmp = discovery.findcommonincoming(self, remote, heads=heads, | |
@@ -1617,6 +1619,7 b' class localrepository(repo.repository):' | |||||
1617 | added = [] |
|
1619 | added = [] | |
1618 | result = 0 |
|
1620 | result = 0 | |
1619 | else: |
|
1621 | else: | |
|
1622 | tr = self.transaction(trname) | |||
1620 | if heads is None and list(common) == [nullid]: |
|
1623 | if heads is None and list(common) == [nullid]: | |
1621 | self.ui.status(_("requesting all changes\n")) |
|
1624 | self.ui.status(_("requesting all changes\n")) | |
1622 | elif heads is None and remote.capable('changegroupsubset'): |
|
1625 | elif heads is None and remote.capable('changegroupsubset'): | |
@@ -1665,9 +1668,15 b' class localrepository(repo.repository):' | |||||
1665 |
|
1668 | |||
1666 | remoteobs = remote.listkeys('obsolete') |
|
1669 | remoteobs = remote.listkeys('obsolete') | |
1667 | if 'dump' in remoteobs: |
|
1670 | if 'dump' in remoteobs: | |
|
1671 | if tr is None: | |||
|
1672 | tr = self.transaction(trname) | |||
1668 | data = base85.b85decode(remoteobs['dump']) |
|
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 | finally: |
|
1677 | finally: | |
|
1678 | if tr is not None: | |||
|
1679 | tr.release() | |||
1671 | lock.release() |
|
1680 | lock.release() | |
1672 |
|
1681 | |||
1673 | return result |
|
1682 | return result |
@@ -159,7 +159,6 b' class obsstore(object):' | |||||
159 | def __init__(self, sopener): |
|
159 | def __init__(self, sopener): | |
160 | self._all = [] |
|
160 | self._all = [] | |
161 | # new markers to serialize |
|
161 | # new markers to serialize | |
162 | self._new = [] |
|
|||
163 | self.precursors = {} |
|
162 | self.precursors = {} | |
164 | self.successors = {} |
|
163 | self.successors = {} | |
165 | self.sopener = sopener |
|
164 | self.sopener = sopener | |
@@ -174,7 +173,7 b' class obsstore(object):' | |||||
174 | def __nonzero__(self): |
|
173 | def __nonzero__(self): | |
175 | return bool(self._all) |
|
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 | """obsolete: add a new obsolete marker |
|
177 | """obsolete: add a new obsolete marker | |
179 |
|
178 | |||
180 | * ensuring it is hashable |
|
179 | * ensuring it is hashable | |
@@ -189,39 +188,33 b' class obsstore(object):' | |||||
189 | if len(succ) != 20: |
|
188 | if len(succ) != 20: | |
190 | raise ValueError(succ) |
|
189 | raise ValueError(succ) | |
191 | marker = (str(prec), tuple(succs), int(flag), encodemeta(metadata)) |
|
190 | marker = (str(prec), tuple(succs), int(flag), encodemeta(metadata)) | |
192 | self.add(marker) |
|
191 | self.add(transaction, 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) |
|
|||
200 |
|
192 | |||
201 | def mergemarkers(self, data): |
|
193 | def add(self, transaction, marker): | |
202 | other = set(_readmarkers(data)) |
|
194 | """Add a new marker to the store""" | |
203 |
|
|
195 | if marker not in self._all: | |
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: |
|
|||
214 | f = self.sopener('obsstore', 'ab') |
|
196 | f = self.sopener('obsstore', 'ab') | |
215 | try: |
|
197 | try: | |
216 |
|
|
198 | offset = f.tell() | |
217 | # plain new obsstore |
|
199 | transaction.add('obsstore', offset) | |
|
200 | if offset == 0: | |||
|
201 | # new file add version header | |||
218 | f.write(_pack('>B', _fmversion)) |
|
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 | f.close() |
|
207 | f.close() | |
221 |
|
|
208 | self._load(marker) | |
222 | except: # re-raises |
|
209 | ||
223 | f.discard() |
|
210 | def mergemarkers(self, transation, data): | |
224 | raise |
|
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 | def _load(self, marker): |
|
219 | def _load(self, marker): | |
227 | self._all.append(marker) |
|
220 | self._all.append(marker) | |
@@ -261,8 +254,13 b' def pushmarker(repo, key, old, new):' | |||||
261 | data = base85.b85decode(new) |
|
254 | data = base85.b85decode(new) | |
262 | lock = repo.lock() |
|
255 | lock = repo.lock() | |
263 | try: |
|
256 | try: | |
264 | repo.obsstore.mergemarkers(data) |
|
257 | tr = repo.transaction('pushkey: obsolete markers') | |
265 |
|
|
258 | try: | |
|
259 | repo.obsstore.mergemarkers(tr, data) | |||
|
260 | tr.close() | |||
|
261 | return 1 | |||
|
262 | finally: | |||
|
263 | tr.release() | |||
266 | finally: |
|
264 | finally: | |
267 | lock.release() |
|
265 | lock.release() | |
268 |
|
266 |
@@ -158,9 +158,28 b' Try to pull markers' | |||||
158 | added 6 changesets with 6 changes to 6 files (+3 heads) |
|
158 | added 6 changesets with 6 changes to 6 files (+3 heads) | |
159 | (run 'hg heads' to see heads, 'hg merge' to merge) |
|
159 | (run 'hg heads' to see heads, 'hg merge' to merge) | |
160 | $ hg debugobsolete |
|
160 | $ hg debugobsolete | |
|
161 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f 0 {'date': '56 12', 'user': 'test'} | |||
|
162 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'} | |||
161 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'} |
|
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 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'} |
|
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 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f 0 {'date': '56 12', 'user': 'test'} |
|
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 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'} |
|
183 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'} | |
165 |
|
184 | |||
166 | $ cd .. |
|
185 | $ cd .. | |
@@ -176,9 +195,9 b' Try to pull markers' | |||||
176 | adding file changes |
|
195 | adding file changes | |
177 | added 6 changesets with 6 changes to 6 files (+3 heads) |
|
196 | added 6 changesets with 6 changes to 6 files (+3 heads) | |
178 | $ hg -R tmpd debugobsolete |
|
197 | $ hg -R tmpd debugobsolete | |
179 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'} |
|
198 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f 0 {'date': '56 12', 'user': 'test'} | |
180 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'} |
|
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 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'} |
|
201 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'} | |
183 |
|
202 | |||
184 |
|
203 | |||
@@ -200,9 +219,9 b' On pull' | |||||
200 | (run 'hg heads' to see heads, 'hg merge' to merge) |
|
219 | (run 'hg heads' to see heads, 'hg merge' to merge) | |
201 | $ hg debugobsolete |
|
220 | $ hg debugobsolete | |
202 | 2448244824482448244824482448244824482448 1339133913391339133913391339133913391339 0 {'date': '1339 0', 'user': 'test'} |
|
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 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'} |
|
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 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'} |
|
225 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'} | |
207 |
|
226 | |||
208 | On push |
|
227 | On push | |
@@ -213,8 +232,8 b' On push' | |||||
213 | no changes found |
|
232 | no changes found | |
214 | [1] |
|
233 | [1] | |
215 | $ hg -R ../tmpc debugobsolete |
|
234 | $ hg -R ../tmpc debugobsolete | |
216 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'} |
|
235 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f 0 {'date': '56 12', 'user': 'test'} | |
217 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'} |
|
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 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'} |
|
238 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'} | |
220 | 2448244824482448244824482448244824482448 1339133913391339133913391339133913391339 0 {'date': '1339 0', 'user': 'test'} |
|
239 | 2448244824482448244824482448244824482448 1339133913391339133913391339133913391339 0 {'date': '1339 0', 'user': 'test'} |
General Comments 0
You need to be logged in to leave comments.
Login now