[yast-devel] Switch to new locks api
Libzypp uses new locking api now. You can find it in Locks.h. Works everything except unlock, which I hope implement today. few notes about functions - supported is reading and writing locks to file (default is file specified in zypp.conf). - loadLock append to locks available, if someone find useful setting new locks instead appending (something like restore old locks for frontend) it can be added. - addLock locks all result of query and also store this query for later save, also Selectabable can be locked, it uses optimally query to lock - saving locks must frontend explicit call - saving locks rewrite locks file (as unwanted side effect remove all comments) - existEmptyLocks and removeEmptyLocks is functions to maintance locks. First say if exist some locks which doesn't lock anything and second clean it. (ask for each lock by callback) - if locksfile.apply (see zypp.conf) is on (default) then after start of zypp locks is loaded and applied overview of new file format structure is 'attribute: value', locks (queries) separated by empty line attribute can be global_string (see addString for PoolQuery), string_type (values can be exact, substring, regex, glob), repo (repo allias), kind (Resolvable kind), require_all (if all attribute must match), case_sensitive (search case sensitive), install_status( values can be all, installed, not-installed) and all SolvAttributes with replaced colon ( s/:/_/g ). for example look [0]. default locks file path is /etc/zypp/locks Pepa [0] http://svn.opensuse.org/svn/zypp/trunk/libzypp/tests/zypp/data/PoolQuery/sav... -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
great!, so what do I need to do to fix the package selector? I guess for every item I lock on the UI I apply the lock in the pool. What should I call later to save them? Duncan -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
Duncan Mac-Vicar P. napsal(a):
great!, so what do I need to do to fix the package selector? I guess for every item I lock on the UI I apply the lock in the pool. What should I call later to save them?
Duncan
quick: class Locks (no direct locking)- addLock/unlock method and saveLocks for save locks little more verbose: Lock items via Locks class (singleton so can be called where you want). Unlock also via Locks class. There is two method for locking. One use selectable and second is more flexible and use PoolQuery (same class as for searching - locked/unlocked is result of search). When you want save locks to file use method saveLocks (default use settings from ZConfig - but you can specify file...so if frontend want have separated file of locks it is possible). For more detail look at tests locks when they are used. Pepa -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
josef reidiner napsal(a):
Duncan Mac-Vicar P. napsal(a):
great!, so what do I need to do to fix the package selector? I guess for every item I lock on the UI I apply the lock in the pool. What should I call later to save them?
Duncan
quick: class Locks (no direct locking)- addLock/unlock method and saveLocks for save locks
little more verbose: Lock items via Locks class (singleton so can be called where you want). Unlock also via Locks class. There is two method for locking. One use selectable and second is more flexible and use PoolQuery (same class as for searching - locked/unlocked is result of search). When you want save locks to file use method saveLocks (default use settings from ZConfig - but you can specify file...so if frontend want have separated file of locks it is possible). For more detail look at tests locks when they are used. Pepa
I forgot few notes 1) addlock/unlock is added to separate front and is optimalized for few lock/unlock same item, so nothing new is saved if you lock something and unlock it and also if you unlock and lock again. 2) saveLocks use callback for complicated unlocking. So look at ZYpp callbacks, it has been called when locking query doesn't match unlocking but some locked solvable intersects. As argument get locking query which you want unlock (typically user defined or setted by another frontend if that frontend use another strategy to lock) and enum which say if result of queries intersect or is equal (equal results of query, not query itself). Action is delete, don't remove query and abort saving. 3) Locks also have cleaning api, which clean empty locks (and maybe as side efect I add remove duplicated query). This also have callback, which ask you if you really want remove query. Pepa -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
Josef Reidinger wrote:
Libzypp uses new locking api now. You can find it in Locks.h. Works everything except unlock, which I hope implement today.
FYI, i cleaned up the Locks interface recently a bit. - removed the locks namespace - unified method names (removed Locks from doFooLocks(), have addLock, removeLock instead of addLock/unlock - renamed loadLocks -> readAndApply - added read() and apply() - added iterators for Locks' PoolQueries - added some TODO comments Cheers, jano -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
participants (4)
-
Duncan Mac-Vicar P.
-
Jano Kupec
-
josef reidiner
-
Josef Reidinger