开发者

Is there a guarantee that svn automatically merges concurrent "add line" and "delete line" to the same file?

I have a distributed system which uses XML files in an SVN repository as a means of communication (as you may guess from that, communication normally is slow). Some processing nodes add or delete some data to a repository, another processing node takes this as an input event and reacts accordingly.

At the moment, everything's fine, but I'm wondering if I may run into problems with SVN auto-merge.

Let's say one node adds a specific job to another node by adding a line in an xml file pointing to another xml file with the job details. This looks like the following code:

----File: nodename.xml----
<assignments>
  <file>537f7acb382326.xml</file>
  <file>572919a90c0234.xml</file>
  <file>58a7c3e2015922.xml</file>
</assignments>

Every file listed in that file is a job assignment to the host nodename. On execution of the job the corresponding line will be deleted by the assignee.

From the perspective of the SVN repository, I have one "adder" and one "read-and-deleter". One node only adds lines to that file, one node only deletes lines from that file. I can guarantee that only one node may add and only one node may delete. But: Although the file names have unique IDs, they may be re-added, so a line may be added and deleted at the same time, which may theoretically cau开发者_高级运维se problems.

My question is: Is there a guarantee that SVN automatically merges a concurrent "add line" and "delete line" without user interaction? If not, is there a guarantee if I add a timestamp to every added line, rendering each line unique?


With SVN there is no concurrency happening. Either the delete or the add will happen first. If the repository has changed since you have updated then the commit will fail. For instance if your read-and-deleter reads the file, the adder adds a new line and the read-and-deleter tries to commit a delete, it will fail because its copy is out of date.

But really SVN is not a great way to do this type of thing. That said, you might fare better by having a work-to-do folder where the adder adds individual files representing work to do. The read-and-deleter can then update that directory and delete files as work is done. The names of the files can be made unique with a timestamp or something like that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜