我怎样才能“svn删除”一个文件夹,然后添加一个同名的文件夹?

发布于 2024-10-16 13:57:02 字数 668 浏览 9 评论 0原文

我基于SQL和Subversion为自己的程序编写了一个部署工具。

我能够创建不同版本的应用程序并使用 Subversion 存储它们,而这些信息则存储在 SQL 中。

直到我的“部署工具”工作得很好,但现在我发现了一个问题。

创建应用程序的版本时,我会检查头部修订版并在程序中将其可视化。 然后可以通过删除、重命名、添加或覆盖文件和文件夹来编辑最新版本。

假设我的工作副本中有以下树结构:

- ProgramFiles
  - Assemblies
  - Data
     - Type 1
         - ...
     - Type 2 
         - ...
     - Type 3
         - ...

我想替换一个目录(数据)。这会调用 svn delete 以及 Directory.Delete,因为“svn delete”仅在您执行提交时标记要删除的文件夹。 现在我想再次添加一个名为“Data”的文件夹,其中包含新的子文件夹和文件,但随后出现异常“工作副本管理区域丢失”。 据我所知,问题是 ProgramFiles 下的目录 .svn 存储了文件夹 Data 应被删除的信息,如果我读取此文件夹,它就会崩溃。
我还知道我可以在添加文件夹之前提交,但这会通过“不稳定版本”增加我的修订号。

我该如何解决这个问题?

I wrote a deployment tool for my own programs based on SQL and Subversion.

I'm able to create different versions of applications and store them with Subversion while the information for those is stored in SQL.

Until my "deployment tool" worked quite fine but now I found a problem.

When creating a version of an application I checkout the head revision and visualize this in my program.
The latest version can then be edited by deleting, renaming, adding or overwriting files and folders.

Say, if I have the following tree structure in my working copy:

- ProgramFiles
  - Assemblies
  - Data
     - Type 1
         - ...
     - Type 2 
         - ...
     - Type 3
         - ...

I want to replace one directory (Data). This calls svn delete and after that Directory.Delete, because "svn delete" just marks the folders for delete when you do a commit.
Now I want to add a folder named "Data" again with new subfolders and files but then I get an exception "working copy admin area is missing".
As far as I can tell the problem is that the directory .svn under ProgramFiles stores information that the folder Data shall be deleted an if I read this folder it crashes.
I also know that I can commit before adding the folder but that would increase my revision number with a "non stable version".

How can I solve this problem?

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

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

发布评论

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

评论(4

淡莣 2024-10-23 13:57:02

您无法通过一次提交来完成此操作,您需要分别提交删除和添加

You can't do this with one commit, you need to commit the delete and the add separately

可是我不能没有你 2024-10-23 13:57:02

难道你不能只删除文件夹内容而不是删除文件夹(但不要删除“.svn”文件夹!),然后将新文件放在那里?

Can't you just delete the folder contents instead of deleting the folder (but don't delete the ".svn" folder!), and then just put the new files there?

橘亓 2024-10-23 13:57:02

好吧,在我思考这个问题一段时间后,假设不可能完成我在这里尝试做的事情,我有了一个想法。

我实际上想做的是制作一个工作副本,这意味着交换、删除、移动添加等等。所有这些变化都将在我的程序中可视化。 (基于文件系统上的文件夹结构)

在用户想要将其保存为新的“数据包”之前,不应提交所有这些更改。这表明他可以取消进度并且不提交也不改变任何内容。

我知道首先尝试了一种解决方法进行导出。编辑这些文件夹和文件。
当我现在准备好提交时,我会签出相同的路径,删除工作副本中不存在的所有内容,并将导出的所有新文件添加到工作副本中。

这只是一种解决方法,但也是我脑海中唯一想到的事情。

颠覆中有没有一种方法可以做类似的事情?我的解决方法的运行速度只有以前的一半,因为导出和签出而不是仅签出程序。

而且两个文件夹的比较也非常复杂。有谁知道简化这个问题的解决方案?

Well, after I've thought about the problem for a while assuming that it's impossible to do what I'm trying to do here I had an idea.

What I'm actually trying to do, is working an that working copy that means exchanging, deleting, moving adding and so on. All those changes shall be visualized in my program. (based on the folder structure on the filesystem)

All those changes should not be commited until the user wants to save it as a new "packet". This indicates that he may cancel the progress and nothing is commited neither changed.

I know tried a workaround doing an export first. Editing those folders and files.
When I am now ready to commit, I checkout the same path, delete all those things that don't exist in working copy and add all new files from export into the working copy.

It's only a workaround but the only thing that comes through my mind.

Is there a method in subversion doing something like that? My workaround is running only half as fast as before, because of that export and checkout instead of only checking out the program.

Also the comparison of both folders is really complicated. Does anyone know a solution to simplify this?

不寐倦长更 2024-10-23 13:57:02

如果您需要在一次提交中执行此操作,那么这是可能的,但很棘手!

您应该编写一个函数来递归检查现有文件和文件夹与所需文件和文件夹,而不是简单的 svn delete 然后 Directory.Delete(...)

伪代码:

function OverwriteFolder(old, new){
    foreach (file system) object in old or new{
        if object is in old and new{
            if object is file{
                overwrite file //no svn command needed
            }
            if object is folder{
                OverwriteFolder(old/object,new/object)
            }
        }
        if file is in old and not new{
            svn delete object
        }
        if file is in new and not old{
            svn add object
        }
    }
}

现在它应该在一次提交中工作。仅当您尝试用同名文件替换文件夹时,它才会失败,反之亦然。

If you need this to be performed in a single commit then it is possible, but tricky!

Instead of the simple svn delete and then Directory.Delete(...) you should write a function that recursively checks files and folders of incumbent vs desired.

Pseudo code:

function OverwriteFolder(old, new){
    foreach (file system) object in old or new{
        if object is in old and new{
            if object is file{
                overwrite file //no svn command needed
            }
            if object is folder{
                OverwriteFolder(old/object,new/object)
            }
        }
        if file is in old and not new{
            svn delete object
        }
        if file is in new and not old{
            svn add object
        }
    }
}

Now it should work in a single commit. it only fails if you're trying to replace a folder with a file of the same name or vice-versa.

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