Merge lp:~jelmer/bzr-svn/sqlite-lock into lp:bzr-svn/1.1

Proposed by Jelmer Vernooij
Status: Merged
Merged at revision: 3807
Proposed branch: lp:~jelmer/bzr-svn/sqlite-lock
Merge into: lp:bzr-svn/1.1
Diff against target: 473 lines (+127/-52)
5 files modified
NEWS (+3/-0)
cache/__init__.py (+5/-0)
cache/sqlitecache.py (+58/-33)
logwalker.py (+34/-7)
revmeta.py (+27/-12)
To merge this branch: bzr merge lp:~jelmer/bzr-svn/sqlite-lock
Reviewer Review Type Date Requested Status
bzr-svn developers Pending
Review via email: mp+71591@code.launchpad.net

Description of the change

When hitting a SQLite lock, simply continue without the cache.

To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

This looks ok to me. (dunno if you wanted my opinion :p). I bet you didn't mean to leave that "raise ImportError" in though :)

The change in get_revision_paths looks a little strange -- does what happens in the else: clause of the try: not access the db?

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Thanks for the review, and catching that ImportError. Removed now :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'NEWS'
--- NEWS 2011-08-09 15:07:13 +0000
+++ NEWS 2011-08-15 17:39:32 +0000
@@ -96,6 +96,9 @@
96 * Fix importing of non-ascii characters in bzr:revprop: values.96 * Fix importing of non-ascii characters in bzr:revprop: values.
97 (Jelmer Vernooij, #821168)97 (Jelmer Vernooij, #821168)
9898
99 * Allow concurrent access of SQLite cache, rather than aborting.
100 (Jelmer Vernooij, #685251)
101
99 FEATURES102 FEATURES
100103
101 * When roundtripping revisions a revision property with the Bazaar testament is104 * When roundtripping revisions a revision property with the Bazaar testament is
102105
=== modified file 'cache/__init__.py'
--- cache/__init__.py 2011-08-13 14:22:02 +0000
+++ cache/__init__.py 2011-08-15 17:39:32 +0000
@@ -38,6 +38,10 @@
38from bzrlib.plugins.svn import version_info38from bzrlib.plugins.svn import version_info
3939
4040
41class CacheConcurrencyError(Exception):
42 """Unable to access cache while write is in progress."""
43
44
41def write_cache_readme(path):45def write_cache_readme(path):
42 f = open(path, 'w')46 f = open(path, 'w')
43 try:47 try:
@@ -146,6 +150,7 @@
146try:150try:
147 from bzrlib.plugins.svn.cache.tdbcache import TdbRepositoryCache151 from bzrlib.plugins.svn.cache.tdbcache import TdbRepositoryCache
148 cache_cls = TdbRepositoryCache152 cache_cls = TdbRepositoryCache
153 raise ImportError
149except ImportError:154except ImportError:
150 from bzrlib.plugins.svn.cache.sqlitecache import SqliteRepositoryCache155 from bzrlib.plugins.svn.cache.sqlitecache import SqliteRepositoryCache
151 cache_cls = SqliteRepositoryCache156 cache_cls = SqliteRepositoryCache
152157
=== modified file 'cache/sqlitecache.py'
--- cache/sqlitecache.py 2011-07-30 16:44:57 +0000
+++ cache/sqlitecache.py 2011-08-15 17:39:32 +0000
@@ -27,6 +27,7 @@
27 )27 )
2828
29from bzrlib.plugins.svn.cache import (29from bzrlib.plugins.svn.cache import (
30 CacheConcurrencyError,
30 RepositoryCache,31 RepositoryCache,
31 )32 )
32from bzrlib.plugins.svn.mapping import (33from bzrlib.plugins.svn.mapping import (
@@ -71,7 +72,7 @@
7172
7273
73def _connect_sqlite3_file(path):74def _connect_sqlite3_file(path):
74 return sqlite3.connect(path, timeout=20.0)75 return sqlite3.connect(path, timeout=20.0, isolation_level=None)
7576
7677
77connect_cachefile = _connect_sqlite3_file78connect_cachefile = _connect_sqlite3_file
@@ -87,8 +88,32 @@
87 self.cachedb = cache_db88 self.cachedb = cache_db
88 self._commit_interval = 50089 self._commit_interval = 500
89 self._create_table()90 self._create_table()
90 self.cachedb.commit()91 self.commit()
91 self._commit_countdown = self._commit_interval92
93 @classmethod
94 def _convert_operational_errors(cls, e):
95 if "database is locked" in e:
96 return CacheConcurrencyError()
97 else:
98 return e
99
100 def execute(self, *args, **kwargs):
101 try:
102 return self.cachedb.execute(*args, **kwargs)
103 except sqlite3.OperationalError, e:
104 raise self._convert_operational_errors(e)
105
106 def executemany(self, *args, **kwargs):
107 try:
108 return self.cachedb.executemany(*args, **kwargs)
109 except sqlite3.OperationalError, e:
110 raise self._convert_operational_errors(e)
111
112 def executescript(self, *args, **kwargs):
113 try:
114 return self.cachedb.executescript(*args, **kwargs)
115 except sqlite3.OperationalError, e:
116 raise self._convert_operational_errors(e)
92117
93 def commit(self):118 def commit(self):
94 """Commit the changes to the database."""119 """Commit the changes to the database."""
@@ -140,13 +165,13 @@
140 """See RevisionIdMapCache.set_last_revnum_checked."""165 """See RevisionIdMapCache.set_last_revnum_checked."""
141166
142 self.mutter("set last revnum checked for %r to %r", layout, revnum)167 self.mutter("set last revnum checked for %r to %r", layout, revnum)
143 self.cachedb.execute("replace into revids_seen (layout, max_revnum) VALUES (?, ?)", (layout, revnum))168 self.execute("replace into revids_seen (layout, max_revnum) VALUES (?, ?)", (layout, revnum))
144 self.commit()169 self.commit()
145170
146 def last_revnum_checked(self, layout):171 def last_revnum_checked(self, layout):
147 """See RevisionIdMapCache.last_revnum_checked."""172 """See RevisionIdMapCache.last_revnum_checked."""
148173
149 ret = self.cachedb.execute(174 ret = self.execute(
150 "select max_revnum from revids_seen where layout = ?", (layout,)).fetchone()175 "select max_revnum from revids_seen where layout = ?", (layout,)).fetchone()
151 if ret is None:176 if ret is None:
152 revnum = 0177 revnum = 0
@@ -160,7 +185,7 @@
160185
161 assert isinstance(revid, str)186 assert isinstance(revid, str)
162 self.mutter("lookup revid %r", revid)187 self.mutter("lookup revid %r", revid)
163 ret = self.cachedb.execute(188 ret = self.execute(
164 "select path, min_revnum, max_revnum, mapping from revmap where revid=? order by abs(min_revnum-max_revnum) asc", (revid,)).fetchone()189 "select path, min_revnum, max_revnum, mapping from revmap where revid=? order by abs(min_revnum-max_revnum) asc", (revid,)).fetchone()
165 if ret is None:190 if ret is None:
166 raise errors.NoSuchRevision(self, revid)191 raise errors.NoSuchRevision(self, revid)
@@ -176,7 +201,7 @@
176 assert isinstance(revnum, int)201 assert isinstance(revnum, int)
177 assert isinstance(path, str)202 assert isinstance(path, str)
178 assert isinstance(mapping, str)203 assert isinstance(mapping, str)
179 row = self.cachedb.execute(204 row = self.execute(
180 "select revid from revmap where max_revnum=? and min_revnum=? and path=? and mapping=?", (revnum, revnum, path, mapping)).fetchone()205 "select revid from revmap where max_revnum=? and min_revnum=? and path=? and mapping=?", (revnum, revnum, path, mapping)).fetchone()
181 if row is not None:206 if row is not None:
182 ret = str(row[0])207 ret = str(row[0])
@@ -195,16 +220,16 @@
195 assert min_revnum <= max_revnum220 assert min_revnum <= max_revnum
196 self.mutter("insert revid %r:%r-%r -> %r", branch, min_revnum, max_revnum, revid)221 self.mutter("insert revid %r:%r-%r -> %r", branch, min_revnum, max_revnum, revid)
197 if min_revnum == max_revnum:222 if min_revnum == max_revnum:
198 cursor = self.cachedb.execute(223 cursor = self.execute(
199 "update revmap set min_revnum = ?, max_revnum = ? WHERE revid=? AND path=? AND mapping=?",224 "update revmap set min_revnum = ?, max_revnum = ? WHERE revid=? AND path=? AND mapping=?",
200 (min_revnum, max_revnum, revid, branch, mapping))225 (min_revnum, max_revnum, revid, branch, mapping))
201 else:226 else:
202 cursor = self.cachedb.execute(227 cursor = self.execute(
203 "update revmap set min_revnum = MAX(min_revnum,?), max_revnum = MIN(max_revnum, ?) WHERE revid=? AND path=? AND mapping=?",228 "update revmap set min_revnum = MAX(min_revnum,?), max_revnum = MIN(max_revnum, ?) WHERE revid=? AND path=? AND mapping=?",
204 (min_revnum, max_revnum, revid, branch, mapping))229 (min_revnum, max_revnum, revid, branch, mapping))
205 if cursor.rowcount == 0:230 if cursor.rowcount == 0:
206 self.cachedb.execute(231 self.execute(
207 "insert into revmap (revid,path,min_revnum,max_revnum,mapping) VALUES (?,?,?,?,?)",232 "replace into revmap (revid,path,min_revnum,max_revnum,mapping) VALUES (?,?,?,?,?)",
208 (revid, branch, min_revnum, max_revnum, mapping))233 (revid, branch, min_revnum, max_revnum, mapping))
209 self._commit_conditionally()234 self._commit_conditionally()
210235
@@ -212,7 +237,7 @@
212class SqliteRevisionInfoCache(RevisionInfoCache, CacheTable):237class SqliteRevisionInfoCache(RevisionInfoCache, CacheTable):
213238
214 def _create_table(self):239 def _create_table(self):
215 self.cachedb.executescript("""240 self.executescript("""
216 create table if not exists revmetainfo (241 create table if not exists revmetainfo (
217 path text not null,242 path text not null,
218 revnum integer,243 revnum integer,
@@ -240,20 +265,20 @@
240 orig_mapping_name = original_mapping.name265 orig_mapping_name = original_mapping.name
241 else:266 else:
242 orig_mapping_name = None267 orig_mapping_name = None
243 self.cachedb.execute("insert into original_mapping (path, revnum, original_mapping) values (?, ?, ?)", (foreign_revid[1].decode("utf-8"), foreign_revid[2], orig_mapping_name))268 self.execute("replace into original_mapping (path, revnum, original_mapping) values (?, ?, ?)", (foreign_revid[1].decode("utf-8"), foreign_revid[2], orig_mapping_name))
244269
245 def insert_revision(self, foreign_revid, mapping, (revno, revid, hidden),270 def insert_revision(self, foreign_revid, mapping, (revno, revid, hidden),
246 stored_lhs_parent_revid):271 stored_lhs_parent_revid):
247 """See RevisionInfoCache.insert_revision."""272 """See RevisionInfoCache.insert_revision."""
248273
249 self.cachedb.execute("insert into revmetainfo (path, revnum, mapping, revid, revno, hidden, stored_lhs_parent_revid) values (?, ?, ?, ?, ?, ?, ?)", (foreign_revid[1], foreign_revid[2], mapping.name, revid, revno, hidden, stored_lhs_parent_revid))274 self.execute("replace into revmetainfo (path, revnum, mapping, revid, revno, hidden, stored_lhs_parent_revid) values (?, ?, ?, ?, ?, ?, ?)", (foreign_revid[1], foreign_revid[2], mapping.name, revid, revno, hidden, stored_lhs_parent_revid))
250 self._commit_conditionally()275 self._commit_conditionally()
251276
252 def get_revision(self, foreign_revid, mapping):277 def get_revision(self, foreign_revid, mapping):
253 """See RevisionInfoCache.get_revision."""278 """See RevisionInfoCache.get_revision."""
254279
255 # Will raise KeyError if not present280 # Will raise KeyError if not present
256 row = self.cachedb.execute("select revno, revid, hidden, stored_lhs_parent_revid from revmetainfo where path = ? and revnum = ? and mapping = ?", (foreign_revid[1], foreign_revid[2], mapping.name)).fetchone()281 row = self.execute("select revno, revid, hidden, stored_lhs_parent_revid from revmetainfo where path = ? and revnum = ? and mapping = ?", (foreign_revid[1], foreign_revid[2], mapping.name)).fetchone()
257 if row is None:282 if row is None:
258 raise KeyError((foreign_revid, mapping))283 raise KeyError((foreign_revid, mapping))
259 else:284 else:
@@ -270,7 +295,7 @@
270 def get_original_mapping(self, foreign_revid):295 def get_original_mapping(self, foreign_revid):
271 """See RevisionInfoCache.get_original_mapping."""296 """See RevisionInfoCache.get_original_mapping."""
272297
273 row = self.cachedb.execute("select original_mapping from original_mapping where path = ? and revnum = ?", (foreign_revid[1].decode("utf-8"), foreign_revid[2])).fetchone()298 row = self.execute("select original_mapping from original_mapping where path = ? and revnum = ?", (foreign_revid[1].decode("utf-8"), foreign_revid[2])).fetchone()
274 if row is None:299 if row is None:
275 raise KeyError(foreign_revid)300 raise KeyError(foreign_revid)
276 if row[0] is None:301 if row[0] is None:
@@ -282,7 +307,7 @@
282class SqliteLogCache(LogCache, CacheTable):307class SqliteLogCache(LogCache, CacheTable):
283308
284 def _create_table(self):309 def _create_table(self):
285 self.cachedb.executescript("""310 self.executescript("""
286 create table if not exists changed_path(311 create table if not exists changed_path(
287 rev integer,312 rev integer,
288 action text not null check(action in ('A', 'D', 'M', 'R')),313 action text not null check(action in ('A', 'D', 'M', 'R')),
@@ -305,7 +330,7 @@
305 create unique index if not exists revinfo_rev on revinfo(rev);330 create unique index if not exists revinfo_rev on revinfo(rev);
306 """ % NODE_UNKNOWN)331 """ % NODE_UNKNOWN)
307 try:332 try:
308 self.cachedb.executescript(333 self.executescript(
309 "alter table changed_path ADD kind INT DEFAULT %d;" % NODE_UNKNOWN)334 "alter table changed_path ADD kind INT DEFAULT %d;" % NODE_UNKNOWN)
310 except sqlite3.OperationalError:335 except sqlite3.OperationalError:
311 pass # Column already exists.336 pass # Column already exists.
@@ -314,8 +339,8 @@
314 """See LogCache.find_latest_change."""339 """See LogCache.find_latest_change."""
315340
316 if path == "":341 if path == "":
317 return self.cachedb.execute("select max(rev) from changed_path where rev <= ?", (revnum,)).fetchone()[0]342 return self.execute("select max(rev) from changed_path where rev <= ?", (revnum,)).fetchone()[0]
318 return self.cachedb.execute("""343 return self.execute("""
319 select max(rev) from changed_path344 select max(rev) from changed_path
320 where rev <= ?345 where rev <= ?
321 and (path=?346 and (path=?
@@ -327,7 +352,7 @@
327 def get_revision_paths(self, revnum):352 def get_revision_paths(self, revnum):
328 """See LogCache.get_revision_paths."""353 """See LogCache.get_revision_paths."""
329354
330 result = self.cachedb.execute("select path, action, copyfrom_path, copyfrom_rev, kind from changed_path where rev=?", (revnum,))355 result = self.execute("select path, action, copyfrom_path, copyfrom_rev, kind from changed_path where rev=?", (revnum,))
331 paths = {}356 paths = {}
332 for p, act, cf, cr, kind in result:357 for p, act, cf, cr, kind in result:
333 if cf is not None:358 if cf is not None:
@@ -353,19 +378,19 @@
353 kind = NODE_UNKNOWN378 kind = NODE_UNKNOWN
354 new_paths.append((rev, p.strip("/").decode("utf-8"), v[0], copyfrom_path, v[2], kind))379 new_paths.append((rev, p.strip("/").decode("utf-8"), v[0], copyfrom_path, v[2], kind))
355380
356 self.cachedb.executemany("replace into changed_path (rev, path, action, copyfrom_path, copyfrom_rev, kind) values (?, ?, ?, ?, ?, ?)", new_paths)381 self.executemany("replace into changed_path (rev, path, action, copyfrom_path, copyfrom_rev, kind) values (?, ?, ?, ?, ?, ?)", new_paths)
357382
358 def drop_revprops(self, revnum):383 def drop_revprops(self, revnum):
359 """See LogCache.drop_revprops."""384 """See LogCache.drop_revprops."""
360385
361 self.cachedb.execute("update revinfo set all_revprops = 0 where rev = ?", (revnum,))386 self.execute("update revinfo set all_revprops = 0 where rev = ?", (revnum,))
362387
363 def get_revprops(self, revnum):388 def get_revprops(self, revnum):
364 """See LogCache.get_revprops."""389 """See LogCache.get_revprops."""
365390
366 result = self.cachedb.execute("select name, value from revprop where rev = ?", (revnum,))391 result = self.execute("select name, value from revprop where rev = ?", (revnum,))
367 revprops = dict((k.encode("utf-8"), v.encode("utf-8")) for (k, v) in result)392 revprops = dict((k.encode("utf-8"), v.encode("utf-8")) for (k, v) in result)
368 result = self.cachedb.execute("select all_revprops from revinfo where rev = ?", (revnum,)).fetchone()393 result = self.execute("select all_revprops from revinfo where rev = ?", (revnum,)).fetchone()
369 if result is None:394 if result is None:
370 all_revprops = False395 all_revprops = False
371 else:396 else:
@@ -377,15 +402,15 @@
377402
378 if revprops is None:403 if revprops is None:
379 return404 return
380 self.cachedb.executemany("replace into revprop (rev, name, value) values (?, ?, ?)", [(revision, name.decode("utf-8", "replace"), value.decode("utf-8", "replace")) for (name, value) in revprops.iteritems()])405 self.executemany("replace into revprop (rev, name, value) values (?, ?, ?)", [(revision, name.decode("utf-8", "replace"), value.decode("utf-8", "replace")) for (name, value) in revprops.iteritems()])
381 self.cachedb.execute("""406 self.execute("""
382 replace into revinfo (rev, all_revprops) values (?, ?)407 replace into revinfo (rev, all_revprops) values (?, ?)
383 """, (revision, all_revprops))408 """, (revision, all_revprops))
384409
385 def max_revnum(self):410 def max_revnum(self):
386 """See LogCache.last_revnum."""411 """See LogCache.last_revnum."""
387412
388 saved_revnum = self.cachedb.execute("SELECT MAX(rev) FROM changed_path").fetchone()[0]413 saved_revnum = self.execute("SELECT MAX(rev) FROM changed_path").fetchone()[0]
389 if saved_revnum is None:414 if saved_revnum is None:
390 return 0415 return 0
391 return saved_revnum416 return saved_revnum
@@ -393,13 +418,13 @@
393 def min_revnum(self):418 def min_revnum(self):
394 """See LogCache.min_revnum."""419 """See LogCache.min_revnum."""
395420
396 return self.cachedb.execute("SELECT MIN(rev) FROM changed_path").fetchone()[0]421 return self.execute("SELECT MIN(rev) FROM changed_path").fetchone()[0]
397422
398423
399class SqliteParentsCache(ParentsCache, CacheTable):424class SqliteParentsCache(ParentsCache, CacheTable):
400425
401 def _create_table(self):426 def _create_table(self):
402 self.cachedb.executescript("""427 self.executescript("""
403 create table if not exists parent (428 create table if not exists parent (
404 rev text not null,429 rev text not null,
405 parent text,430 parent text,
@@ -415,17 +440,17 @@
415440
416 self.mutter('insert parents: %r -> %r', revid, parents)441 self.mutter('insert parents: %r -> %r', revid, parents)
417 if len(parents) == 0:442 if len(parents) == 0:
418 self.cachedb.execute("replace into parent (rev, parent, idx) values (?, NULL, -1)", (revid,))443 self.execute("replace into parent (rev, parent, idx) values (?, NULL, -1)", (revid,))
419 else:444 else:
420 for i, p in enumerate(parents):445 for i, p in enumerate(parents):
421 self.cachedb.execute("replace into parent (rev, parent, idx) values (?, ?, ?)", (revid, p, i))446 self.execute("replace into parent (rev, parent, idx) values (?, ?, ?)", (revid, p, i))
422 self._commit_conditionally()447 self._commit_conditionally()
423448
424 def lookup_parents(self, revid):449 def lookup_parents(self, revid):
425 """See ParentsCache.lookup_parents."""450 """See ParentsCache.lookup_parents."""
426451
427 self.mutter('lookup parents: %r', revid)452 self.mutter('lookup parents: %r', revid)
428 rows = self.cachedb.execute("select parent from parent where rev = ? order by idx", (revid, )).fetchall()453 rows = self.execute("select parent from parent where rev = ? order by idx", (revid, )).fetchall()
429 if len(rows) == 0:454 if len(rows) == 0:
430 return None455 return None
431 return tuple([row[0].encode("utf-8") for row in rows if row[0] is not None])456 return tuple([row[0].encode("utf-8") for row in rows if row[0] is not None])
432457
=== modified file 'logwalker.py'
--- logwalker.py 2011-08-15 01:13:33 +0000
+++ logwalker.py 2011-08-15 17:39:32 +0000
@@ -33,6 +33,9 @@
33from bzrlib.plugins.svn import (33from bzrlib.plugins.svn import (
34 changes,34 changes,
35 )35 )
36from bzrlib.plugins.svn.cache import (
37 CacheConcurrencyError,
38 )
36from bzrlib.plugins.svn.transport import (39from bzrlib.plugins.svn.transport import (
37 SvnRaTransport,40 SvnRaTransport,
38 )41 )
@@ -231,6 +234,9 @@
231 if "logwalker" in debug.debug_flags:234 if "logwalker" in debug.debug_flags:
232 trace.mutter(text, *args, **kwargs)235 trace.mutter(text, *args, **kwargs)
233236
237 def _warn_busy_cache(self):
238 trace.warning("Cache for repository %s busy, ignoring")
239
234 def find_latest_change(self, path, revnum):240 def find_latest_change(self, path, revnum):
235 """Find latest revision that touched path.241 """Find latest revision that touched path.
236242
@@ -239,7 +245,11 @@
239 """245 """
240 assert isinstance(path, str)246 assert isinstance(path, str)
241 assert isinstance(revnum, int) and revnum >= 0247 assert isinstance(revnum, int) and revnum >= 0
242 self._fetch_revisions(revnum)248 try:
249 self._fetch_revisions(revnum)
250 except CacheConcurrencyError:
251 self._warn_busy_cache()
252 return self.actual.find_latest_change(path, revnum)
243253
244 self.mutter("latest change: %r:%r", path, revnum)254 self.mutter("latest change: %r:%r", path, revnum)
245 try:255 try:
@@ -263,19 +273,33 @@
263 """273 """
264 assert from_revnum >= 0 and to_revnum >= 0, "%r -> %r" % (from_revnum, to_revnum)274 assert from_revnum >= 0 and to_revnum >= 0, "%r -> %r" % (from_revnum, to_revnum)
265 self.mutter("iter changes %r->%r (%r)", from_revnum, to_revnum, prefixes)275 self.mutter("iter changes %r->%r (%r)", from_revnum, to_revnum, prefixes)
266 self._fetch_revisions(max(from_revnum, to_revnum), pb=pb)276 try:
277 self._fetch_revisions(max(from_revnum, to_revnum), pb=pb)
278 except CacheConcurrencyError:
279 self._warn_busy_cache()
280 return self.actual.iter_changes(prefixes, from_revnum, to_revnum,
281 limit, pb)
267 return iter(iter_changes(prefixes, from_revnum, to_revnum,282 return iter(iter_changes(prefixes, from_revnum, to_revnum,
268 self.get_revision_paths, self.revprop_list, limit))283 self.get_revision_paths, self.revprop_list, limit))
269284
270 def get_revision_paths(self, revnum):285 def get_revision_paths(self, revnum):
271 if revnum == 0:286 if revnum == 0:
272 return changes.REV0_CHANGES287 return changes.REV0_CHANGES
273 self._fetch_revisions(revnum)288 try:
274 return self.cache.get_revision_paths(revnum)289 self._fetch_revisions(revnum)
290 except CacheConcurrencyError:
291 self._warn_busy_cache()
292 return self.actual.get_revision_paths(revnum)
293 else:
294 return self.cache.get_revision_paths(revnum)
275295
276 def revprop_list(self, revnum):296 def revprop_list(self, revnum):
277 self.mutter('revprop list: %d' % revnum)297 self.mutter('revprop list: %d' % revnum)
278 self._fetch_revisions(revnum)298 try:
299 self._fetch_revisions(revnum)
300 except CacheConcurrencyError:
301 self._warn_busy_cache()
302 return self.actual.revprop_list(revnum)
279303
280 if revnum > 0:304 if revnum > 0:
281 (known_revprops, has_all_revprops) = self.cache.get_revprops(revnum)305 (known_revprops, has_all_revprops) = self.cache.get_revprops(revnum)
@@ -290,8 +314,11 @@
290314
291 def _caching_revprop_list(self, revnum):315 def _caching_revprop_list(self, revnum):
292 revprops = self._transport.revprop_list(revnum)316 revprops = self._transport.revprop_list(revnum)
293 self.cache.insert_revprops(revnum, revprops, True)317 try:
294 self.cache.commit()318 self.cache.insert_revprops(revnum, revprops, True)
319 self.cache.commit()
320 except CacheConcurrencyError:
321 pass
295 return revprops322 return revprops
296323
297 def _fetch_revisions(self, to_revnum, pb=None):324 def _fetch_revisions(self, to_revnum, pb=None):
298325
=== modified file 'revmeta.py'
--- revmeta.py 2011-08-13 11:27:34 +0000
+++ revmeta.py 2011-08-15 17:39:32 +0000
@@ -35,6 +35,9 @@
35 errors as svn_errors,35 errors as svn_errors,
36 util,36 util,
37 )37 )
38from bzrlib.plugins.svn.cache import (
39 CacheConcurrencyError,
40 )
38from bzrlib.plugins.svn.mapping import (41from bzrlib.plugins.svn.mapping import (
39 SVN_PROP_BZR_HIDDEN,42 SVN_PROP_BZR_HIDDEN,
40 SVN_PROP_BZR_REVPROP_REDIRECT,43 SVN_PROP_BZR_REVPROP_REDIRECT,
@@ -735,14 +738,19 @@
735 self._stored_lhs_parent_revid = {}738 self._stored_lhs_parent_revid = {}
736739
737 def _update_cache(self, mapping):740 def _update_cache(self, mapping):
738 if (self.get_original_mapping() is not None and741 try:
739 self._revision_info[mapping][1] is not None):742 if (self.get_original_mapping() is not None and
740 self._revid_cache.insert_revid(self._revision_info[mapping][1],743 self._revision_info[mapping][1] is not None):
741 self.metarev.branch_path, self.metarev.revnum,744 self._revid_cache.insert_revid(self._revision_info[mapping][1],
742 self.metarev.revnum, mapping.name)745 self.metarev.branch_path, self.metarev.revnum,
743 self._revinfo_cache.insert_revision(self.metarev.get_foreign_revid(), mapping,746 self.metarev.revnum, mapping.name)
744 self._revision_info[mapping],747 self._revinfo_cache.insert_revision(
745 self._stored_lhs_parent_revid[mapping])748 self.metarev.get_foreign_revid(),
749 mapping,
750 self._revision_info[mapping],
751 self._stored_lhs_parent_revid[mapping])
752 except CacheConcurrencyError:
753 pass
746754
747 def _determine(self, mapping):755 def _determine(self, mapping):
748 self._revision_info[mapping] = self.base.get_revision_info(mapping)756 self._revision_info[mapping] = self.base.get_revision_info(mapping)
@@ -752,8 +760,8 @@
752 assert mapping is not None760 assert mapping is not None
753 (self._revision_info[mapping],761 (self._revision_info[mapping],
754 self._stored_lhs_parent_revid[mapping]) = \762 self._stored_lhs_parent_revid[mapping]) = \
755 self._revinfo_cache.get_revision(self.metarev.get_foreign_revid(),763 self._revinfo_cache.get_revision(
756 mapping)764 self.metarev.get_foreign_revid(), mapping)
757765
758 def get_original_mapping(self):766 def get_original_mapping(self):
759 if self._original_mapping_set:767 if self._original_mapping_set:
@@ -763,8 +771,12 @@
763 self.metarev.get_foreign_revid())771 self.metarev.get_foreign_revid())
764 except KeyError:772 except KeyError:
765 self._original_mapping = self.base.get_original_mapping()773 self._original_mapping = self.base.get_original_mapping()
766 self._revinfo_cache.set_original_mapping(self.metarev.get_foreign_revid(),774 try:
775 self._revinfo_cache.set_original_mapping(
776 self.metarev.get_foreign_revid(),
767 self._original_mapping)777 self._original_mapping)
778 except CacheConcurrencyError:
779 pass
768 self._original_mapping_set = True780 self._original_mapping_set = True
769 return self._original_mapping781 return self._original_mapping
770782
@@ -815,7 +827,10 @@
815 if parent_ids is not None:827 if parent_ids is not None:
816 return parent_ids828 return parent_ids
817 parent_ids = self.base.get_parent_ids(mapping, parentrevmeta)829 parent_ids = self.base.get_parent_ids(mapping, parentrevmeta)
818 self._parents_cache.insert_parents(myrevid, parent_ids)830 try:
831 self._parents_cache.insert_parents(myrevid, parent_ids)
832 except CacheConcurrencyError:
833 pass
819 return parent_ids834 return parent_ids
820835
821836

Subscribers

People subscribed via source and target branches