Hi All,

I've not started coding this yet as I'm still getting the environment
setup, but here is the rough outline (pseudo code) of the overall flow
for this.  A few things of note:

Must of the mantis stuff relies on info from the web database thus
'add' operations should be web then mantis while 'delete' operations
should be mantis then web.

I'm envisioning a code pattern that allows for listener plugins.  A
general call to remove_pkgs(pkgset) would be called.  That would then
iterate over the listeners that are plugged in calling their remove
methods.  I'll register a mantis listener and a web db listener.

Listeners will have priorities to facilitate ordering although I'm not
sure the best way (yet) to handle this.

This design should allow swapping out mantis code for $new_bugtracker
later without too much work.

Detecting renames is important in the _stub case.  I'll likely need to
catch it in the general case too.  Things would have been _much_
simpler if the package name instead of the software name was set as
the key for everything...

Anyway, pseudo code.  Any obvious issues?

oldcat = load_old_catalog()
newcat = fetch_new_catalog()
[new, update, remove] = new_compared_to_old(oldcat, newcat)

stubs = find_stubs(new, update)

renames = []
for p in stubs
    # determine based on package name what the old software name was
    # (this does not rely on stub naming convention of $oldname ->
    # $oldname + '_stub') as we'll actually look it up
    stub_oldname = lookup_softname_by_pkgname(p)

    # scan all packages about to be dropped
    for q in remove
        # if a dropped package software name is the stub's old name,
        # handle a renaming case.
        if q.softname = stub_oldname
           # save the rename pair
           renames << [p, q]
           # no longer treat this package as a pure removal
           remove = remove - q
           # no longer treat the stub as a pure add or update
           new = new - p
           update = update -p

for [p,q] in renames
    rename_pkg_in_mantis(p, q)
    rename_pkg_in_webdb(p, q)
    
for p in remove
    remove_pkg_from_mantis(p)
    remove_pkg_from_webdb(p)

for p in new
    add_pkg_to_webdb(p)
    add_pkg_to_mantis(p)

for p in update
    update_pkg_in_mantis(p)
    update_pkg_in_webdb(p)
    
function rename_pkg_in_webdb(p, q)
    # rough sql idea
    update packages set pkgname = p.pkgname, maintainer =
    p.maintainer, ... where q.softname = packages.softname
    
function rename_pkg_in_mantis(p, q)
    # rough sql idea
    update mantis_project_table ...

function delete_pkg_in_webdb(p)
    delete from packages()
    delete from dependencies () ...
    delete from dependlibs () ...
    delete from pathnames () ...
    delete from uniquepaths () ...

function delete_pkg_in_mantis(p)
    delete from mantis_project_user_table () ...
    delete from mantis_project_table () ...

function add_pkg_to_webdb(p)
    insert into packages ()...
    insert into dependencies () ...
    insert into dependlibs () ...
    insert into pathnames () ...
    insert into uniquepaths () ...

function add_pkg_to_mantis(p)
    insert into mantis_project_table ()...
    insert into mantis_project_user_table () ...

function update_pkg_in_webdb(p)
    delete_pkg_in_webdb(p)
    add_pkg_to_webdb(p)

function update_pkg_in_mantis()
    update mantis_project_user_table () ...



Thanks
-Ben

--
Ben Walton
Systems Programmer - CHASS
University of Toronto
C:416.407.5610 | W:416.978.4302

_______________________________________________
devel mailing list
devel@lists.opencsw.org
https://lists.opencsw.org/mailman/listinfo/devel

Reply via email to