Changeset 199 in tracdarcs for tracdarcs/repository.py


Ignore:
Timestamp:
07/30/10 14:08:49 (22 months ago)
Author:
lele@…
Hash name:
20100730120849-7a6fb-6b7c92483ad8f00bbd506a3b70615b4d20432992
Message:

Added a way to group together different repositories, for the "MissingIn?" attribute on changesets

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tracdarcs/repository.py

    r198 r199  
    617617        props = dict(Hashname=self.__hash) 
    618618 
     619        # See if there are any "related repository", with a common "identity" 
     620        # property. 
     621 
     622        c = self.repos.db.cursor() 
     623        c.execute("SELECT rep2.id " 
     624                  "FROM repository rep, repository rep2 " 
     625                  "WHERE rep.id=%s" 
     626                  "  AND rep.name='identity'" 
     627                  "  AND rep2.id<>rep.id" 
     628                  "  AND rep2.name='identity'" 
     629                  "  AND rep2.value=rep.value", (self.repos.id,)) 
     630        other_rids = [r[0] for r in c.fetchall()] 
     631 
     632        if not other_rids: 
     633            return props 
     634 
    619635        # Compute a list of "equivalent changesets", when the same 
    620         # changeset is present in other repositories. 
    621  
    622         c = self.repos.db.cursor() 
    623         c.execute('SELECT rep.value, dcs.rev ' 
    624                   'FROM darcs_changesets dcs, darcs_changesets dcs2, repository rep ' 
    625                   'WHERE dcs2.repo_id = %s AND dcs2.rev = %s ' 
    626                   '  AND dcs.hash = dcs2.hash ' 
    627                   '  AND dcs.repo_id <> dcs2.repo_id' 
    628                   '  AND rep.id = dcs.repo_id AND rep.name = \'name\'' 
    629                   'ORDER BY rep.value', (self.repos.id, self.rev)) 
     636        # changeset is present in other related repositories. 
     637 
     638        other_rids = ','.join(str(rid) for rid in other_rids), 
     639 
     640        c.execute("SELECT rep.value, dcs.rev " 
     641                  "FROM darcs_changesets dcs, repository rep " 
     642                  "WHERE dcs.hash = %%s" 
     643                  "  AND dcs.repo_id IN (%s)" 
     644                  "  AND rep.id = dcs.repo_id AND rep.name = 'name'" 
     645                  "ORDER BY rep.value" % other_rids, 
     646                  (self.__hash,)) 
    630647        eqcsets = [(repo, rev) for repo,rev in c.fetchall()] 
    631         if eqcsets: 
    632             props['EqChangesets'] = eqcsets 
     648        props['PresentIn'] = eqcsets 
     649 
     650        # Compute the opposite list, that is the repositories where 
     651        # the changeset is missing. 
     652 
     653        c.execute("SELECT rep.value " 
     654                  "FROM repository rep " 
     655                  "WHERE rep.name='name'" 
     656                  "  AND rep.id IN (%s)" 
     657                  "  AND NOT EXISTS (" 
     658                  "SELECT dcs.rev " 
     659                  "FROM darcs_changesets dcs " 
     660                  "WHERE dcs.repo_id=rep.id" 
     661                  "  AND dcs.hash=%%s) " 
     662                  "ORDER BY rep.value" % other_rids, 
     663                  (self.__hash,)) 
     664        mir = [r[0] for r in c.fetchall()] 
     665        props['MissingIn'] = mir 
    633666 
    634667        return props 
Note: See TracChangeset for help on using the changeset viewer.