diff -u trac/Browser.py trac2/Browser.py
|
old
|
new
|
|
| 40 | 40 | except core.SubversionException: |
| 41 | 41 | raise TracError('Invalid revision number: %d' % revision) |
| 42 | 42 | |
| | 43 | path = svn_path_join( self.repos_path, path) |
| 43 | 44 | node_type = fs.check_path(root, path, self.pool) |
| | 45 | |
| 44 | 46 | if not node_type in [core.svn_node_dir, core.svn_node_file]: |
| 45 | 47 | raise TracError('"%s": no such file or directory in revision %d' \ |
| 46 | 48 | % (path, revision), 'Not such file or directory') |
| … |
… |
|
| 78 | 80 | else: |
| 79 | 81 | date_seconds = 0 |
| 80 | 82 | date = '' |
| | 83 | |
| | 84 | if self.repos_path: |
| | 85 | url_path = fullpath[len(self.repos_path):] |
| | 86 | else: |
| | 87 | url_path = fullpath |
| 81 | 88 | |
| 82 | 89 | item = { |
| 83 | 90 | 'name' : name, |
| 84 | 91 | 'fullpath' : fullpath, |
| | 92 | 'urlpath' : url_path, |
| 85 | 93 | 'created_rev': created_rev, |
| 86 | 94 | 'date' : date, |
| 87 | 95 | 'date_seconds' : date_seconds, |
| … |
… |
|
| 90 | 98 | 'size' : pretty_size(size), |
| 91 | 99 | 'size_bytes' : size } |
| 92 | 100 | if rev_specified: |
| 93 | | item['log_href'] = self.env.href.log(fullpath, revision) |
| | 101 | item['log_href'] = self.env.href.log(url_path, revision) |
| 94 | 102 | if is_dir: |
| 95 | | item['browser_href'] = self.env.href.browser(fullpath, |
| | 103 | item['browser_href'] = self.env.href.browser(url_path, |
| 96 | 104 | revision) |
| 97 | 105 | else: |
| 98 | | item['browser_href'] = self.env.href.file(fullpath, revision) |
| | 106 | item['browser_href'] = self.env.href.file(url_path, revision) |
| 99 | 107 | else: |
| 100 | | item['log_href'] = self.env.href.log(fullpath) |
| | 108 | item['log_href'] = self.env.href.log(url_path) |
| 101 | 109 | if is_dir: |
| 102 | | item['browser_href'] = self.env.href.browser(fullpath) |
| | 110 | item['browser_href'] = self.env.href.browser(url_path) |
| 103 | 111 | else: |
| 104 | | item['browser_href'] = self.env.href.file(fullpath) |
| | 112 | item['browser_href'] = self.env.href.file(url_path) |
| 105 | 113 | |
| 106 | 114 | info.append(item) |
| 107 | 115 | return info |
diff -u trac/File.py trac2/File.py
|
old
|
new
|
|
| 222 | 222 | FileCommon.render(self) |
| 223 | 223 | |
| 224 | 224 | rev = self.args.get('rev', None) |
| 225 | | self.path = self.args.get('path', '/') |
| | 225 | path = self.args.get('path', '/') |
| | 226 | self.path = util.svn_path_join(self.repos_path, path) |
| | 227 | |
| 226 | 228 | if not rev: |
| 227 | 229 | rev_specified = 0 |
| 228 | 230 | rev = svn.fs.youngest_rev(self.fs_ptr, self.pool) |
diff -u trac/core.py trac2/core.py
|
old
|
new
|
|
| 151 | 151 | if need_svn: |
| 152 | 152 | import sync |
| 153 | 153 | repos_dir = env.get_config('trac', 'repository_dir') |
| | 154 | repos_path = env.get_config('trac', 'repository_path') |
| 154 | 155 | pool, rep, fs_ptr = open_svn_repos(repos_dir) |
| 155 | 156 | module.repos = rep |
| | 157 | module.repos_path = repos_path |
| 156 | 158 | module.fs_ptr = fs_ptr |
| 157 | | sync.sync(module.db, rep, fs_ptr, pool) |
| | 159 | sync.sync(module.db, rep, repos_path, fs_ptr, pool) |
| 158 | 160 | module.pool = pool |
| 159 | 161 | return module |
| 160 | 162 | |
Common subdirectories: trac/mimeviewers and trac2/mimeviewers
diff -u trac/sync.py trac2/sync.py
|
old
|
new
|
|
| 20 | 20 | # Author: Jonas Borgstr�jonas@edgewall.com> |
| 21 | 21 | |
| 22 | 22 | from util import * |
| 23 | | from svn import fs, util, delta, repos, core |
| | 23 | from svn import fs, util, delta, core, repos |
| 24 | 24 | |
| 25 | | def sync(db, repos, fs_ptr, pool): |
| | 25 | def sync(db, repo, repos_path, fs_ptr, pool): |
| 26 | 26 | """ |
| 27 | 27 | updates the revision and node_change tables to be in sync with |
| 28 | 28 | the repository. |
| … |
… |
|
| 36 | 36 | cursor = db.cursor() |
| 37 | 37 | cursor.execute('SELECT ifnull(max(rev), 0) FROM revision') |
| 38 | 38 | youngest_stored = int(cursor.fetchone()[0]) |
| | 39 | |
| 39 | 40 | max_rev = fs.youngest_rev(fs_ptr, pool) |
| 40 | | num = max_rev - youngest_stored |
| | 41 | # num = max_rev - youngest_stored |
| 41 | 42 | offset = youngest_stored + 1 |
| | 43 | revision_set = [] |
| 42 | 44 | |
| | 45 | if repos_path: |
| | 46 | revision_set = get_revision_set( |
| | 47 | db, |
| | 48 | repo, |
| | 49 | repos_path, |
| | 50 | fs_ptr, |
| | 51 | pool, |
| | 52 | youngest_stored, |
| | 53 | max_rev |
| | 54 | ) |
| | 55 | |
| | 56 | if not revision_set and not repos_path: |
| | 57 | revision_set = range(youngest_stored+1, max_rev) |
| | 58 | |
| 43 | 59 | subpool = core.svn_pool_create(pool) |
| 44 | | for rev in range(num): |
| | 60 | for rev in revision_set: |
| 45 | 61 | message = fs.revision_prop(fs_ptr, rev + offset, |
| 46 | 62 | util.SVN_PROP_REVISION_LOG, subpool) |
| 47 | 63 | author = fs.revision_prop(fs_ptr, rev + offset, |
| … |
… |
|
| 54 | 70 | cursor.execute ('INSERT INTO revision (rev, time, author, message) ' |
| 55 | 71 | 'VALUES (%s, %s, %s, %s)', rev + offset, date, |
| 56 | 72 | author, message) |
| 57 | | insert_change (subpool, fs_ptr, rev + offset, cursor) |
| | 73 | insert_change (subpool, repos_path, fs_ptr, rev, cursor) |
| 58 | 74 | core.svn_pool_clear(subpool) |
| 59 | 75 | |
| 60 | 76 | core.svn_pool_destroy(subpool) |
| 61 | 77 | db.commit() |
| 62 | 78 | |
| 63 | | def insert_change (pool, fs_ptr, rev, cursor): |
| | 79 | def insert_change (pool, repos_path, fs_ptr, rev, cursor): |
| 64 | 80 | |
| 65 | 81 | class ChangeEditor(delta.Editor): |
| 66 | | def __init__(self, rev, old_root, new_root, cursor): |
| | 82 | def __init__(self, rev, old_root, new_root, repos_path, cursor): |
| 67 | 83 | self.rev = rev |
| 68 | 84 | self.cursor = cursor |
| 69 | 85 | self.old_root = old_root |
| 70 | 86 | self.new_root = new_root |
| | 87 | self.repos_path = repos_path |
| 71 | 88 | |
| 72 | 89 | def delete_entry(self, path, revision, parent_baton, pool): |
| | 90 | if not path.startswith( self.repos_path): |
| | 91 | return |
| 73 | 92 | self.cursor.execute('INSERT INTO node_change (rev, name, change) ' |
| 74 | 93 | 'VALUES (%s, %s, \'D\')', self.rev, path) |
| 75 | 94 | |
| 76 | 95 | def add_directory(self, path, parent_baton, |
| 77 | 96 | copyfrom_path, copyfrom_revision, dir_pool): |
| | 97 | if not path.startswith( self.repos_path): |
| | 98 | return |
| 78 | 99 | self.cursor.execute('INSERT INTO node_change (rev, name, change) ' |
| 79 | 100 | 'VALUES (%s, %s, \'A\')', self.rev, path) |
| 80 | 101 | |
| 81 | 102 | def add_file(self, path, parent_baton, |
| 82 | 103 | copyfrom_path, copyfrom_revision, file_pool): |
| | 104 | if not path.startswith( self.repos_path): |
| | 105 | return |
| 83 | 106 | self.cursor.execute('INSERT INTO node_change (rev, name, change) ' |
| 84 | 107 | 'VALUES (%s, %s, \'A\')',self.rev, path) |
| 85 | 108 | |
| 86 | 109 | def open_file(self, path, parent_baton, base_revision, file_pool): |
| | 110 | if not path.startswith( self.repos_path): |
| | 111 | return |
| 87 | 112 | self.cursor.execute('INSERT INTO node_change (rev, name, change) ' |
| 88 | 113 | 'VALUES (%s, %s, \'M\')',self.rev, path) |
| 89 | 114 | |
| … |
… |
|
| 91 | 116 | old_root = fs.revision_root(fs_ptr, rev - 1, pool) |
| 92 | 117 | new_root = fs.revision_root(fs_ptr, rev, pool) |
| 93 | 118 | |
| 94 | | editor = ChangeEditor(rev, old_root, new_root, cursor) |
| | 119 | editor = ChangeEditor(rev, old_root, new_root, repos_path, cursor) |
| 95 | 120 | e_ptr, e_baton = delta.make_editor(editor, pool) |
| 96 | 121 | |
| 97 | 122 | if util.SVN_VER_MAJOR == 0 and util.SVN_VER_MINOR == 37: |
| … |
… |
|
| 104 | 129 | new_root, '', e_ptr, e_baton, authz_cb, |
| 105 | 130 | 0, 1, 0, 1, pool) |
| 106 | 131 | |
| | 132 | def get_revision_set( db, repo, repos_path, fs_ptr, pool, youngest_stored, max_rev): |
| | 133 | revision_set = [] |
| | 134 | root = fs.revision_root(fs_ptr, max_rev, pool) |
| | 135 | node_type = fs.check_path(root, repos_path, pool) |
| | 136 | |
| | 137 | if not node_type in (core.svn_node_dir, core.svn_node_file): |
| | 138 | raise ValueError("Svn Repository Path Invalid %r"%repos_path) |
| | 139 | |
| | 140 | revs = [] |
| | 141 | |
| | 142 | def addLog( paths, revision, author, date, message, pool): |
| | 143 | revs.append(revision) |
| | 144 | |
| | 145 | repos.svn_repos_get_logs( |
| | 146 | repo, |
| | 147 | [repos_path], |
| | 148 | max_rev, # start rev |
| | 149 | 0, # end rev |
| | 150 | 0, # changed paths |
| | 151 | 0, # strict history |
| | 152 | addLog, |
| | 153 | pool |
| | 154 | ) |
| | 155 | |
| | 156 | revs.sort() |
| | 157 | for rev in revs: |
| | 158 | if rev > youngest_stored: |
| | 159 | revision_set.append( rev ) |
| | 160 | |
| | 161 | return revision_set |
Common subdirectories: trac/tests and trac2/tests
Common subdirectories: trac/upgrades and trac2/upgrades
diff -u trac/util.py trac2/util.py
|
old
|
new
|
|
| 29 | 29 | TRUE = ['yes', '1', 1, 'true', 'on', 'aye'] |
| 30 | 30 | FALSE = ['no', '0', 0, 'false', 'off', 'nay'] |
| 31 | 31 | |
| | 32 | def svn_path_join(*args): |
| | 33 | return "/%s"%'/'.join(filter(None, '/'.join(args).split('/'))) |
| | 34 | |
| 32 | 35 | def svn_date_to_string(date, pool): |
| 33 | 36 | from svn import util |
| 34 | 37 | date_seconds = util.svn_time_from_cstring(date, |