changeset 4802:dc403312a012

python3: mark all SQL queries as raw strings
author Raphaël Gomès <rgomes@octobus.net>
date Tue, 06 Aug 2019 11:10:36 +0200
parents 16c1398b0063
children 88472e743c64
files hgext3rd/evolve/obsdiscovery.py hgext3rd/evolve/stablerangecache.py
diffstat 2 files changed, 29 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/obsdiscovery.py	Tue Aug 06 11:07:16 2019 +0200
+++ b/hgext3rd/evolve/obsdiscovery.py	Tue Aug 06 11:10:36 2019 +0200
@@ -262,12 +262,12 @@
 ### sqlite caching
 
 _sqliteschema = [
-    """CREATE TABLE obshashrange(rev     INTEGER NOT NULL,
+    r"""CREATE TABLE obshashrange(rev     INTEGER NOT NULL,
                                  idx     INTEGER NOT NULL,
                                  obshash BLOB    NOT NULL,
                                  PRIMARY KEY(rev, idx));""",
-    "CREATE INDEX range_index ON obshashrange(rev, idx);",
-    """CREATE TABLE meta(schemaversion INTEGER NOT NULL,
+    r"CREATE INDEX range_index ON obshashrange(rev, idx);",
+    r"""CREATE TABLE meta(schemaversion INTEGER NOT NULL,
                          tiprev        INTEGER NOT NULL,
                          tipnode       BLOB    NOT NULL,
                          nbobsmarker   INTEGER NOT NULL,
@@ -275,17 +275,17 @@
                          obskey        BLOB    NOT NULL
                         );""",
 ]
-_queryexist = "SELECT name FROM sqlite_master WHERE type='table' AND name='meta';"
-_clearmeta = """DELETE FROM meta;"""
-_newmeta = """INSERT INTO meta (schemaversion, tiprev, tipnode, nbobsmarker, obssize, obskey)
+_queryexist = r"SELECT name FROM sqlite_master WHERE type='table' AND name='meta';"
+_clearmeta = r"""DELETE FROM meta;"""
+_newmeta = r"""INSERT INTO meta (schemaversion, tiprev, tipnode, nbobsmarker, obssize, obskey)
             VALUES (?,?,?,?,?,?);"""
-_updateobshash = "INSERT INTO obshashrange(rev, idx, obshash) VALUES (?,?,?);"
-_querymeta = "SELECT schemaversion, tiprev, tipnode, nbobsmarker, obssize, obskey FROM meta;"
-_queryobshash = "SELECT obshash FROM obshashrange WHERE (rev = ? AND idx = ?);"
-_query_max_stored = "SELECT MAX(rev) FROM obshashrange"
+_updateobshash = r"INSERT INTO obshashrange(rev, idx, obshash) VALUES (?,?,?);"
+_querymeta = r"SELECT schemaversion, tiprev, tipnode, nbobsmarker, obssize, obskey FROM meta;"
+_queryobshash = r"SELECT obshash FROM obshashrange WHERE (rev = ? AND idx = ?);"
+_query_max_stored = r"SELECT MAX(rev) FROM obshashrange"
 
-_reset = "DELETE FROM obshashrange;"
-_delete = "DELETE FROM obshashrange WHERE (rev = ? AND idx = ?);"
+_reset = r"DELETE FROM obshashrange;"
+_delete = r"DELETE FROM obshashrange WHERE (rev = ? AND idx = ?);"
 
 def _affectedby(repo, markers):
     """return all nodes whose relevant set is affected by this changeset
--- a/hgext3rd/evolve/stablerangecache.py	Tue Aug 06 11:07:16 2019 +0200
+++ b/hgext3rd/evolve/stablerangecache.py	Tue Aug 06 11:10:36 2019 +0200
@@ -120,10 +120,10 @@
 #############################
 
 _sqliteschema = [
-    """CREATE TABLE range(rev INTEGER  NOT NULL,
+    r"""CREATE TABLE range(rev INTEGER  NOT NULL,
                           idx INTEGER NOT NULL,
                           PRIMARY KEY(rev, idx));""",
-    """CREATE TABLE subranges(listidx INTEGER NOT NULL,
+    r"""CREATE TABLE subranges(listidx INTEGER NOT NULL,
                               suprev  INTEGER NOT NULL,
                               supidx  INTEGER NOT NULL,
                               subrev  INTEGER NOT NULL,
@@ -132,37 +132,37 @@
                               FOREIGN KEY (suprev, supidx) REFERENCES range(rev, idx),
                               FOREIGN KEY (subrev, subidx) REFERENCES range(rev, idx)
     );""",
-    "CREATE INDEX subranges_index ON subranges (suprev, supidx);",
-    "CREATE INDEX superranges_index ON subranges (subrev, subidx);",
-    "CREATE INDEX range_index ON range (rev, idx);",
-    """CREATE TABLE meta(schemaversion INTEGER NOT NULL,
+    r"CREATE INDEX subranges_index ON subranges (suprev, supidx);",
+    r"CREATE INDEX superranges_index ON subranges (subrev, subidx);",
+    r"CREATE INDEX range_index ON range (rev, idx);",
+    r"""CREATE TABLE meta(schemaversion INTEGER NOT NULL,
                          tiprev        INTEGER NOT NULL,
                          tipnode       BLOB    NOT NULL
                         );""",
 ]
-_newmeta = "INSERT INTO meta (schemaversion, tiprev, tipnode) VALUES (?,?,?);"
-_updatemeta = "UPDATE meta SET tiprev = ?, tipnode = ?;"
-_updaterange = "INSERT INTO range(rev, idx) VALUES (?,?);"
-_updatesubranges = """INSERT
+_newmeta = r"INSERT INTO meta (schemaversion, tiprev, tipnode) VALUES (?,?,?);"
+_updatemeta = r"UPDATE meta SET tiprev = ?, tipnode = ?;"
+_updaterange = r"INSERT INTO range(rev, idx) VALUES (?,?);"
+_updatesubranges = r"""INSERT
                        INTO subranges(listidx, suprev, supidx, subrev, subidx)
                        VALUES (?,?,?,?,?);"""
-_queryexist = "SELECT name FROM sqlite_master WHERE type='table' AND name='meta';"
-_querymeta = "SELECT schemaversion, tiprev, tipnode FROM meta;"
-_queryrange = "SELECT * FROM range WHERE (rev = ? AND idx = ?);"
-_querysubranges = """SELECT subrev, subidx
+_queryexist = r"SELECT name FROM sqlite_master WHERE type='table' AND name='meta';"
+_querymeta = r"SELECT schemaversion, tiprev, tipnode FROM meta;"
+_queryrange = r"SELECT * FROM range WHERE (rev = ? AND idx = ?);"
+_querysubranges = r"""SELECT subrev, subidx
                      FROM subranges
                      WHERE (suprev = ? AND supidx = ?)
                      ORDER BY listidx;"""
 
-_querysuperrangesmain = """SELECT DISTINCT suprev, supidx
+_querysuperrangesmain = r"""SELECT DISTINCT suprev, supidx
                            FROM subranges
                            WHERE %s;"""
 
-_querysuperrangesbody = '(subrev = %d and subidx = %d)'
+_querysuperrangesbody = r'(subrev = %d and subidx = %d)'
 
 def _make_querysuperranges(ranges):
     # building a tree of OR would allow for more ranges
-    body = ' OR '.join(_querysuperrangesbody % r for r in ranges)
+    body = r' OR '.join(_querysuperrangesbody % r for r in ranges)
     return _querysuperrangesmain % body
 
 class stablerangesqlbase(stablerange.stablerangecached):