Edgewall Software

Ticket #1271: resync_on_ranges--1387.diff

File resync_on_ranges--1387.diff, 3.9 KB (added by Juanma Barranquero, 4 years ago)

Patch adapted to changes in [1379].

  • scripts/admin.py

     
    587587         
    588     _help_resync = [('resync', 'Re-synchronize trac with the repository')] 
     588    _help_resync = [('resync [start-rev][:end-rev]', 'Re-synchronize trac with the repository')] 
    589589     
     
    591591    def do_resync(self, line): 
     592        arg = self.arg_tokenize(line) 
     593        if len(arg) > 0 and arg[0] != '': 
     594            sep = arg[0].find(':') 
     595            if sep == 0:                # only the 'end-rev' given 
     596                start = 0               # forces a resync from the start 
     597                end = int(arg[0][1:]) 
     598            elif sep > 0:               # both 'start-rev' and 'end-rev' given 
     599                start = int(arg[0][:sep]) 
     600                end = int(arg[0][sep+1:]) 
     601            else:                       # only the 'start-rev' given 
     602                start = int(arg[0]) 
     603                end = -1 
     604        else:                           # no revs given 
     605            start = 0 
     606            end = -1 
    592607        from svn import repos, core 
     
    607622        print 'resyncing...' 
    608         self.db_execsql("DELETE FROM revision") 
    609         self.db_execsql("DELETE FROM node_change") 
    610         sync.sync(cnx, rep, fs_ptr, pool) 
     623        if start > 0 and end > 0: 
     624            print '  from revision %d to revision %d' % (start, end) 
     625            self.db_execsql("DELETE FROM revision where rev >= %d and rev <= %d" % (start, end)) 
     626            self.db_execsql("DELETE FROM node_change where rev >= %d and rev <= %d" % (start, end)) 
     627        elif start > 0: 
     628            print '  from revision %d to the youngest revision' % start 
     629            self.db_execsql("DELETE FROM revision where rev >= %d" % start) 
     630            self.db_execsql("DELETE FROM node_change where rev >= %d" % start) 
     631        elif end > 0: 
     632            print '  from the first revision to revision %d' % end 
     633            self.db_execsql("DELETE FROM revision where rev <= %d" % end) 
     634            self.db_execsql("DELETE FROM node_change where rev <= %d" % end) 
     635        else: 
     636            print '  all revisions' 
     637            self.db_execsql("DELETE FROM revision") 
     638            self.db_execsql("DELETE FROM node_change") 
     639        sync.sync(cnx, rep, fs_ptr, pool, start, end) 
    611640        print 'done.' 
  • sync.py

     
    2626 
    27 def sync(db, repos, fs_ptr, pool): 
     27def sync(db, repos, fs_ptr, pool, start=-1, end=-1): 
    2828    """ 
     
    3030    the repository. 
     31    start -- start from this changeset (-1 means the youngest stored) 
     32    end   -- end at this changeset (-1 means the youngest rev in the repository) 
    3133    """ 
     
    4143    max_rev = fs.youngest_rev(fs_ptr, pool) 
    42     num = max_rev - youngest_stored 
    43     offset = youngest_stored + 1 
     44    if end < 0 or end > max_rev: 
     45        end = max_rev 
     46    # Note: after that point, start is readjusted to be one changeset _before_ the real start 
     47    if start < 0 or start > youngest_stored: 
     48        start = youngest_stored 
     49    else: 
     50        start -= 1 
     51    num = end - start 
     52    offset = start + 1 
    4453     
     
    8190    ||     ||  'R'   || original rev, original path // renamed path   || 
     91    ||     ||  'm'   || original rev, original path // modified path  || 
    8292    ||     ||  'd'   || original rev, original path // deleted path   || 
     
    8494    The 'ADM' operations are direct operations. 
    85     The 'CR' operation can be direct operations. 
    86     The 'CRdm' may happen after a 'CR' operation on a parent path. 
     95    The 'CR' operations can be direct operations. 
     96    The 'CRdm' operations may happen after a 'CR' operation on a parent path. 
    8797    """