这是完全可行的,只需要几个小技巧......哇哦!
我遇到的问题是 get_repository 从 trac.ini 文件中读取 svn 存储库的值。这是指向 E:/ 而不是 Y:/。简单的修复包括检查存储库是否位于repository_dir,如果不是,则检查新变量remote_repository_dir。修复的第二部分涉及从 cache.py 中删除错误消息,该消息检查当前存储库地址是否与传入的存储库地址匹配。
与往常一样,使用它需要您自担风险,并事先备份所有内容!!!
首先打开 trac.ini 文件并在“repository_dir”变量下添加一个新变量“remote_repository_dir”。远程存储库目录将指向本地计算机上的映射驱动器。它现在应该看起来像这样:
repository_dir = E:/Projects/svn/InfoProj
remote_repository_dir = Y:/Projects/svn/InfoProj
接下来我们将修改 api.py 文件以检查新变量是否在repository_dir位置找不到存储库。大约 :71 你应该有这样的东西:
repository_dir = Option('trac', 'repository_dir', '',
"""Path to local repository. This can also be a relative path
(''since 0.11'').""")
在此行下方添加:
remote_repository_dir = Option('trac', 'remote_repository_dir', '',
"""Path to remote repository.""")
接下来在 :156 附近,您将拥有:
rtype, rdir = self.repository_type, self.repository_dir
if not os.path.isabs(rdir):
rdir = os.path.join(self.env.path, rdir)
将其更改为:
rtype, rdir = self.repository_type, self.repository_dir
if not os.path.isdir(rdir):
rdir = self.remote_repository_dir
if not os.path.isabs(rdir):
rdir = os.path.join(self.env.path, rdir)
最后,您需要删除 cache.py 文件中的警报(请注意,这不是最好的方法,您应该能够将远程变量包含在检查中,但现在它可以工作)。
在 :97 附近的 cache.py 中,它应该如下所示:
if repository_dir:
# directory part of the repo name can vary on case insensitive fs
if os.path.normcase(repository_dir) != os.path.normcase(self.name):
self.log.info("'repository_dir' has changed from %r to %r"
% (repository_dir, self.name))
raise TracError(_("The 'repository_dir' has changed, a "
"'trac-admin resync' operation is needed."))
elif repository_dir is None: #
self.log.info('Storing initial "repository_dir": %s' % self.name)
cursor.execute("INSERT INTO system (name,value) VALUES (%s,%s)",
(CACHE_REPOSITORY_DIR, self.name,))
else: # 'repository_dir' cleared by a resync
self.log.info('Resetting "repository_dir": %s' % self.name)
cursor.execute("UPDATE system SET value=%s WHERE name=%s",
(self.name, CACHE_REPOSITORY_DIR))
我们将删除 if 语句的第一部分,所以它现在应该如下所示:
if repository_dir is None: #
self.log.info('Storing initial "repository_dir": %s' % self.name)
cursor.execute("INSERT INTO system (name,value) VALUES (%s,%s)",
(CACHE_REPOSITORY_DIR, self.name,))
else: # 'repository_dir' cleared by a resync
self.log.info('Resetting "repository_dir": %s' % self.name)
cursor.execute("UPDATE system SET value=%s WHERE name=%s",
(self.name, CACHE_REPOSITORY_DIR))
警告!这样做意味着如果您的目录已更改并且您需要重新同步,它将不再给您错误。
希望这可以帮助某人。