自动SVN同步Eclipse

发布于 2024-11-23 15:51:56 字数 62 浏览 1 评论 0原文

我从 SVN 开始。有没有什么方法可以配置 subclipse 自动与存储库同步,以便尽快知道文件何时被修改?

I'm starting with SVN. Is there any way of configuring subclipse to automatically sync with the repo in order to know when a file was modified as soon as possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

原来是傀儡 2024-11-30 15:51:56

在 Subversive 的情况下(我相信,在 Subclipse 的情况下也应该提供相同的选项),同步视图允许自动同步。

使用某些项目的上下文菜单中的“团队/同步”来初始化同步,或者打开“团队同步”透视图,然后使用“同步”视图的“同步”按钮(该按钮是视图工具栏的第一个按钮)选择同步项目集。

然后执行同步,并显示更改。此时,您可以从视图菜单中选择“计划...”选项(“同步”视图右上角附近的向下三角形图标),然后您可以在其中设置同步。

据我所知,这种同步不会自动更新您的工作区(这是一个好主意,例如冲突解决必须手动进行),但至少您可以在需要时查看更改。

In case of Subversive (and I believe, the same option should be available in case of Subclipse as well) the Synchronize view allows automatic synchronization.

Initialize a synchronization using either Team/Synchronize from the context menu of some projects, or open the Team Synchronizing perspective, and select the set of synchronized projects using the Synchronize button of the Synchronize view (the button is the first button of the view toolbar).

Then the synchronization is performed, and the changes are displayed there. At this point, you could select the Schedule... option from the view menu (down-pointing triangle icon near the top right corner of the Synchronize view), and there you could set the synchronization.

AFAIK this synchronization does not update your workspace automatically (that is a sound idea, e.g. conflict resolution must happen manually), but at least you can look at the changes when needed.

独夜无伴 2024-11-30 15:51:56

真的不想这样做。与存储库同步是一项繁重的操作,会产生很多副作用。例如,您现在可以更改存储库中正在更改的文件。您不希望在工作时发现自己和他人的更改不匹配。您希望工作然后一起更新所有文件并解决冲突(如果有)

You really do not want to do this. Synchronization with repository is a heavy operation with a lot of side effects. For example you can change file that is being changed in repository now. You do not want to get mismatch of your and other's changes while you are working. You wish to work and then update all files together and resolve conflicts (if any)

相权↑美人 2024-11-30 15:51:56

在上下文菜单中(右键单击项目)应该有一个选项“团队>与存储库同步”。

我确实发现本教程很有用。

In the context menu (right-click on project) there should be an option "Team>Synchronize with repository".

I did find this tutorial useful.

黎歌 2024-11-30 15:51:56

据我所知,subclipse 没有提供这样的选项。您可以编写一个 cron 作业,使用 SVN 命令行工具定期执行更新,但我不建议这样做。您无法自动与SVN同步,因为更新可能会导致无法自动合并的冲突。

As far as I know, subclipse provides no such option. You could write a cron job that uses the SVN command-line tools to perform an update at regular intervals, but I wouldn't recommend this. You can't automate synchronizing with SVN because updating may cause conflicts which cannot be automatically merged.

最美不过初阳 2024-11-30 15:51:56

尽管我同意在某些情况下拥有自动提交功能可能不是一个好主意,但出于某些原因您可能仍然希望拥有此选项。

我创建了一个小的 EASE 脚本来替换我的常规保存键绑定 (ctrl+s)。它首先保存文件,尝试更新文件(如果可能的话,还会自动合并版本,否则会产生冲突,在这种情况下脚本会终止),最后提交文件。

// ********************************************************************************
// name                 : SaveUpdateCommit
// keyboard             : CTRL+S
// toolbar              : PHP Explorer
// script-type          : JavaScript
// description          : Save a file, update from the repository and commit automatically
// ********************************************************************************

var UI = loadModule("/System/UI");


UI.executeUI(function(){
var editor = UI.getActiveEditor();
editor.doSave(null);

var site = editor.getSite();
var commandService = site.getService(org.eclipse.ui.commands.ICommandService);
var handlerService = site.getService(org.eclipse.ui.handlers.IHandlerService);

var subclipse = org.tigris.subversion.subclipse.core.SVNProviderPlugin.getPlugin();

try
{
var file = editor.getEditorInput().getFile();
}
catch(e)
{
    return;
}
var filePath = file.getFullPath();
var project = file.getProject();
var projectPath = project.getWorkingLocation(subclipse.toString());
var workspace = project.getWorkspace();

var localFile = org.tigris.subversion.subclipse.core.resources.SVNWorkspaceRoot.getSVNFileFor(file);
localFile.refreshStatus();
if(localFile.isDirty()){
    var remoteFile = localFile.getBaseResource();

    var empty = java.lang.reflect.Array.newInstance(org.eclipse.core.resources.IResource, 0);
    var commitFiles = java.lang.reflect.Array.newInstance(org.eclipse.core.resources.IResource, 1); 
    commitFiles[0] = remoteFile.getResource();

    var update = new org.tigris.subversion.subclipse.ui.operations.UpdateOperation(editor, remoteFile.getResource(), org.tigris.subversion.svnclientadapter.SVNRevision.HEAD);
    update.run(null);

    var commit = new org.tigris.subversion.subclipse.ui.operations.CommitOperation(editor, empty, empty, empty, commitFiles, "AutoCommit", false);
    commit.run(null);
}

为此,您需要安装 Eclipse EASE (http://download.eclipse.org/ease/更新/发布)并通过设置使该脚本可用。此外,脚本需要 UI 访问权限,同样需要在设置中进行配置。

因此,根据您的需要,您可能希望将该行为更改为频繁更新。我从来没有在日食中使用过计时器,但我想这是可能的。

Although I agree that in some situations it might be a bad idea to have an automated commit feature, there might be some reasons why you could want to have this option anyway.

I created a small EASE-script that replaced my regular save key binding (ctrl+s). It first saves the file, tries to update the file (which also automatically merges the versions if possible or creates conflicts in which case the script terminates) and commits the file at last.

// ********************************************************************************
// name                 : SaveUpdateCommit
// keyboard             : CTRL+S
// toolbar              : PHP Explorer
// script-type          : JavaScript
// description          : Save a file, update from the repository and commit automatically
// ********************************************************************************

var UI = loadModule("/System/UI");


UI.executeUI(function(){
var editor = UI.getActiveEditor();
editor.doSave(null);

var site = editor.getSite();
var commandService = site.getService(org.eclipse.ui.commands.ICommandService);
var handlerService = site.getService(org.eclipse.ui.handlers.IHandlerService);

var subclipse = org.tigris.subversion.subclipse.core.SVNProviderPlugin.getPlugin();

try
{
var file = editor.getEditorInput().getFile();
}
catch(e)
{
    return;
}
var filePath = file.getFullPath();
var project = file.getProject();
var projectPath = project.getWorkingLocation(subclipse.toString());
var workspace = project.getWorkspace();

var localFile = org.tigris.subversion.subclipse.core.resources.SVNWorkspaceRoot.getSVNFileFor(file);
localFile.refreshStatus();
if(localFile.isDirty()){
    var remoteFile = localFile.getBaseResource();

    var empty = java.lang.reflect.Array.newInstance(org.eclipse.core.resources.IResource, 0);
    var commitFiles = java.lang.reflect.Array.newInstance(org.eclipse.core.resources.IResource, 1); 
    commitFiles[0] = remoteFile.getResource();

    var update = new org.tigris.subversion.subclipse.ui.operations.UpdateOperation(editor, remoteFile.getResource(), org.tigris.subversion.svnclientadapter.SVNRevision.HEAD);
    update.run(null);

    var commit = new org.tigris.subversion.subclipse.ui.operations.CommitOperation(editor, empty, empty, empty, commitFiles, "AutoCommit", false);
    commit.run(null);
}

For this, you need to install Eclipse EASE (http://download.eclipse.org/ease/update/release) and to make this script available through the settings. Also, the script needs UI-access, again this needs to be configured in the settings.

So for your needs you may want to change that behavior to frequent updates. I never played around with timers in eclipse, but i guess it is possible though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文