Comment 3 for bug 488108

Revision history for this message
Jamu Kakar (jkakar) wrote :

[1]

+ @param relation, version: The condition the package version must
+ satisfy in order to be locked.

The Epytext syntax used here is incorrect, I believe.

[2]

+ def set_package_lock(self, name, relation="", version=""):

and then:

+ # Smart wants None here
+ if relation == "":
+ relation = None
+ if version == "":
+ version = None

I think you should use None as the default values. It will allow
you to remove the conversion code you have and shouldn't have any
impact on the behaviour of _validate_lock_condition.

[3]

+ def remove_package_lock(self, name, relation="", version=""):

and then:

+ # Smart wants () here
+ if not relation:
+ relation = ()
+ if not version:
+ version = ()

I recommend you use () as the default values for relation and
version here. It will allow you to remove the conversion code
without impacting the other surrounding code.

[4]

+ if set_package_locks:
+ message["set"] = sorted(set_package_locks)
+ if unset_package_locks:
+ message["unset"] = sorted(unset_package_locks)

Would you mind calling these keys 'lock' and 'unlock'. I realize
that's pretty nit-picky, but it feels a bit more clear to me.

[5]

+ If Smart indicates us locked packages we didn't know about, report

s/us// please.

[6]

+ Locked packages whose hashes are unkwnown don't get reported.

s/unkwnown/unknown/ please.

[7]

+ cursor.execute("CREATE TABLE package_locks"
+ " (name TEXT NOT NULL, relation TEXT, version TEXT,"
+ " UNIQUE(name, relation, version))")
+ cursor.execute("CREATE TABLE locked"
+ " (id INTEGER PRIMARY KEY)")

You need to add a patch to correctly upgrade existing package store
databases.