Commits

Christian Boos committed f8549a5

0.10.4dev: ported r5122 (''upgrade 20 works without vc enabled, #5015'')

  • Participants
  • Parent commits 19aba68
  • Branches 0.10-stable

Comments (0)

Files changed (1)

File trac/upgrades/db20.py

 from trac.db import Table, Column, Index, DatabaseManager
+from trac.core import TracError
 from trac.versioncontrol.cache import CACHE_YOUNGEST_REV
 
 def do_upgrade(env, ver, cursor):
-    """Modify the repository cache scheme.
+    """Modify the repository cache scheme (if needed)
 
     Now we use the 'youngest_rev' entry in the system table
     to explicitly store the youngest rev in the cache.
     """
     db = env.get_db_cnx()
-    repos = env.get_repository(None, sync=False)
-    youngest = repos.get_youngest_rev_in_cache(db) or ''
-    # deleting first, for the 0.11dev and 0.10.4dev users
-    cursor.execute("DELETE FROM system WHERE name=%s", (CACHE_YOUNGEST_REV,))
-    cursor.execute("INSERT INTO system (name, value) VALUES (%s, %s)",
-                   (CACHE_YOUNGEST_REV, youngest))
+    try:
+        repos = env.get_repository(None, sync=False)
+        youngest = repos.get_youngest_rev_in_cache(db) or ''
+        # deleting first, for the 0.11dev and 0.10.4dev users
+        cursor.execute("DELETE FROM system WHERE name=%s",
+                       (CACHE_YOUNGEST_REV,))
+        cursor.execute("INSERT INTO system (name, value) VALUES (%s, %s)",
+                       (CACHE_YOUNGEST_REV, youngest))
+    except TracError: # no repository available
+        pass
+