Ticket #1271: resync_on_ranges--1333.diff
| File resync_on_ranges--1333.diff, 4.5 KB (added by cboos@…, 4 years ago) |
|---|
-
scripts/trac-admin
583 583 print 'Congratulations!' 584 584 print 585 585 586 _help_resync = [('resync ', 'Re-synchronize trac with the repository')]586 _help_resync = [('resync [start-rev][:end-rev]', 'Re-synchronize trac with the repository')] 587 587 588 588 ## Resync 589 589 def do_resync(self, line): 590 arg = self.arg_tokenize(line) 591 if len(arg) > 0 and arg[0] != '': 592 sep = arg[0].find(':') 593 if sep == 0: # only the 'end-rev' given 594 start = 0 # forces a resync from the start 595 end = int(arg[0][1:]) 596 elif sep > 0: # both 'start-rev' and 'end-rev' given 597 start = int(arg[0][:sep]) 598 end = int(arg[0][sep+1:]) 599 else: # only the 'start-rev' given 600 start = int(arg[0]) 601 end = -1 602 else: # no revs given 603 start = 0 604 end = -1 590 605 from svn import util, repos, core 591 606 core.apr_initialize() 592 607 pool = core.svn_pool_create(None) … … 603 618 604 619 cnx = self.__env.get_db_cnx() 605 620 print 'resyncing...' 606 self.db_execsql("DELETE FROM revision") 607 self.db_execsql("DELETE FROM node_change") 608 sync.sync(cnx, rep, fs_ptr, pool) 621 if start > 0 and end > 0: 622 print ' from revision %d to revision %d' % (start, end) 623 self.db_execsql("DELETE FROM revision where rev >= %d and rev <= %d" % (start, end)) 624 self.db_execsql("DELETE FROM node_change where rev >= %d and rev <= %d" % (start, end)) 625 elif start > 0: 626 print ' from revision %d to the youngest revision' % start 627 self.db_execsql("DELETE FROM revision where rev >= %d" % start) 628 self.db_execsql("DELETE FROM node_change where rev >= %d" % start) 629 elif end > 0: 630 print ' from the first revision to revision %d' % end 631 self.db_execsql("DELETE FROM revision where rev <= %d" % end) 632 self.db_execsql("DELETE FROM node_change where rev <= %d" % end) 633 else: 634 print ' all revisions' 635 self.db_execsql("DELETE FROM revision") 636 self.db_execsql("DELETE FROM node_change") 637 sync.sync(cnx, rep, fs_ptr, pool, start, end) 609 638 print 'done.' 610 639 611 640 ## Wiki -
trac/sync.py
21 21 22 22 from svn import fs, util, delta, repos, core 23 23 24 import posixpath 24 25 25 def sync(db, repos, fs_ptr, pool): 26 27 def sync(db, repos, fs_ptr, pool, start=-1, end=-1): 26 28 """ 27 29 Update the revision and node_change tables to be in sync with 28 30 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) 29 33 """ 30 34 31 35 if util.SVN_VER_MAJOR < 1: … … 37 41 cursor.execute("SELECT COALESCE(max(rev),0) FROM revision") 38 42 youngest_stored = int(cursor.fetchone()[0]) 39 43 max_rev = fs.youngest_rev(fs_ptr, pool) 40 num = max_rev - youngest_stored 41 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 42 53 43 54 subpool = core.svn_pool_create(pool) 44 55 for rev in range(num): … … 77 88 || || 'M' || modified path || 78 89 || || 'C' || original rev, original path // copied path || 79 90 || || 'R' || original rev, original path // renamed path || 91 || || 'm' || original rev, original path // modified path || 80 92 || || 'd' || original rev, original path // deleted path || 81 93 82 94 The 'ADM' operations are direct operations. 83 The 'CR' operation can be direct operations.84 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. 85 97 """ 86 98 87 99 class ChangeEditor(delta.Editor):
