diff -ur trac_russian.orig/trac/scripts/admin.py trac_russian/trac/scripts/admin.py
old
|
new
|
|
649 | 649 | project_dir=os.path.basename(self.envname), |
650 | 650 | config_path=os.path.join(self.envname, 'conf', 'trac.ini')) |
651 | 651 | |
652 | | _help_resync = [('resync', 'Re-synchronize trac with the repository')] |
| 652 | _help_resync = [('resync [start-rev][:end-rev]', 'Re-synchronize trac with the repository')] |
653 | 653 | |
654 | 654 | ## Resync |
655 | 655 | def do_resync(self, line): |
| 656 | arg = self.arg_tokenize(line) |
| 657 | if len(arg) > 0 and arg[0] != '': |
| 658 | sep = arg[0].find(':') |
| 659 | if sep == 0: # only the 'end-rev' given |
| 660 | start = 0 # forces a resync from the start |
| 661 | end = int(arg[0][1:]) |
| 662 | elif sep > 0: # both 'start-rev' and 'end-rev' given |
| 663 | start = int(arg[0][:sep]) |
| 664 | end = int(arg[0][sep+1:]) |
| 665 | else: # only the 'start-rev' given |
| 666 | start = int(arg[0]) |
| 667 | end = -1 |
| 668 | else: # no revs given |
| 669 | start = 0 |
| 670 | end = -1 |
656 | 671 | print 'Resyncing repository history...' |
657 | 672 | cnx = self.db_open() |
658 | 673 | cursor = cnx.cursor() |
659 | | cursor.execute("DELETE FROM revision") |
660 | | cursor.execute("DELETE FROM node_change") |
| 674 | if start > 0 and end > 0: |
| 675 | print ' from revision %d to revision %d' % (start, end) |
| 676 | cursor.execute("DELETE FROM revision where rev >= %d and rev <= %d" % (start, end)) |
| 677 | cursor.execute("DELETE FROM node_change where rev >= %d and rev <= %d" % (start, end)) |
| 678 | elif start > 0: |
| 679 | print ' from revision %d to the youngest revision' % start |
| 680 | cursor.execute("DELETE FROM revision where rev >= %d" % start) |
| 681 | cursor.execute("DELETE FROM node_change where rev >= %d" % start) |
| 682 | elif end > 0: |
| 683 | print ' from the first revision to revision %d' % end |
| 684 | cursor.execute("DELETE FROM revision where rev <= %d" % end) |
| 685 | cursor.execute("DELETE FROM node_change where rev <= %d" % end) |
| 686 | else: |
| 687 | print ' all revisions' |
| 688 | cursor.execute("DELETE FROM revision") |
| 689 | cursor.execute("DELETE FROM node_change") |
661 | 690 | repos = self.__env.get_repository() |
662 | 691 | cursor.execute("DELETE FROM system WHERE name='repository_dir'") |
663 | 692 | cursor.execute("INSERT INTO system (name,value) " |
664 | 693 | "VALUES ('repository_dir',%s)", (repos.name,)) |
665 | | repos.sync() |
| 694 | if start <= 0: |
| 695 | start = None |
| 696 | if end <= 0: |
| 697 | end = None |
| 698 | repos.sync(start, end) |
666 | 699 | print 'Done.' |
667 | 700 | |
668 | 701 | ## Wiki |
diff -ur trac_russian.orig/trac/versioncontrol/cache.py trac_russian/trac/versioncontrol/cache.py
old
|
new
|
|
44 | 44 | return CachedChangeset(self.repos.normalize_rev(rev), self.db, |
45 | 45 | self.authz) |
46 | 46 | |
47 | | def sync(self): |
| 47 | def sync(self, first = None, last = None): |
48 | 48 | self.log.debug("Checking whether sync with repository is needed") |
49 | 49 | cursor = self.db.cursor() |
50 | 50 | |
… |
… |
|
61 | 61 | "a 'trac-admin resync' operation is needed.") |
62 | 62 | |
63 | 63 | youngest_stored = self.repos.get_youngest_rev_in_cache(self.db) |
64 | | |
65 | | if youngest_stored != str(self.repos.youngest_rev): |
| 64 | if youngest_stored != str(self.repos.youngest_rev) or first or last: |
66 | 65 | authz = self.repos.authz |
67 | 66 | self.repos.authz = Authorizer() # remove permission checking |
68 | 67 | |
69 | 68 | kindmap = dict(zip(_kindmap.values(), _kindmap.keys())) |
70 | 69 | actionmap = dict(zip(_actionmap.values(), _actionmap.keys())) |
71 | | self.log.info("Syncing with repository (%s to %s)" |
72 | | % (youngest_stored, self.repos.youngest_rev)) |
73 | | if youngest_stored: |
74 | | current_rev = self.repos.next_rev(youngest_stored) |
| 70 | |
| 71 | if first == None and not youngest_stored: |
| 72 | first = self.repos.oldest_rev |
| 73 | elif first == None or self.rev_older_than(youngest_stored, first): |
| 74 | first = self.repos.next_rev(youngest_stored) |
| 75 | else: |
| 76 | first = self.normalize_rev(first) |
| 77 | |
| 78 | if last == None: |
| 79 | last = self.repos.youngest_rev |
75 | 80 | else: |
76 | | current_rev = self.repos.oldest_rev |
77 | | while current_rev is not None: |
| 81 | last = self.normalize_rev(last) |
| 82 | |
| 83 | self.log.info("Syncing with repository (%s to %s)" % (first, last)) |
| 84 | |
| 85 | current_rev = first |
| 86 | while current_rev is not None and not self.repos.rev_older_than(last, current_rev): |
78 | 87 | changeset = self.repos.get_changeset(current_rev) |
79 | | cursor.execute("INSERT INTO revision (rev,time,author,message) " |
80 | | "VALUES (%s,%s,%s,%s)", (str(current_rev), |
81 | | changeset.date, changeset.author, |
82 | | changeset.message)) |
| 88 | cursor.execute("INSERT INTO revision (rev, time, " |
| 89 | "author, message) VALUES (%s,%s,%s,%s)", |
| 90 | (str(current_rev), changeset.date, |
| 91 | changeset.author, changeset.message)) |
83 | 92 | for path,kind,action,base_path,base_rev in changeset.get_changes(): |
84 | 93 | self.log.debug("Caching node change in [%s]: %s" |
85 | 94 | % (current_rev, (path, kind, action, |