# HG changeset patch # User Raphaël Gomès # Date 1565082636 -7200 # Node ID dc403312a012ac6f22798ce2c71ec27949b20c26 # Parent 16c1398b006312b555b580ee9d9cc0c8edaad1d7 python3: mark all SQL queries as raw strings diff -r 16c1398b0063 -r dc403312a012 hgext3rd/evolve/obsdiscovery.py --- 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 diff -r 16c1398b0063 -r dc403312a012 hgext3rd/evolve/stablerangecache.py --- 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):