为什么Subversion无法标记修改后的Microsoft Excel电子表格文件?

时间:2021-12-07 07:12:30

I have encountered some behaviour I didn't expect from Subversion, and discovered this almost accidentally: A modified file is not being flagged as modified.

我遇到了一些我没想到的Subversion行为,并且几乎意外地发现了这一点:修改后的文件没有被标记为已修改。

I have a unit test involving a Microsoft Excel spreadsheet as an input file. The unit test calculates a CRC checksum; my test started failing due to the checksum changing.

我有一个涉及Microsoft Excel电子表格作为输入文件的单元测试。单元测试计算CRC校验和;由于校验和的变化,我的测试开始失败。

The test file is stored in SVN, and has MIME type "application/octet-stream", and is therefore considered as binary by SVN.

测试文件存储在SVN中,并且具有MIME类型“application / octet-stream”,因此被SVN视为二进制。

I get the same behaviour from TortoiseSVN and the SVN command line client, in this case both based on SVN 1.6: When the file is opened in Excel, the fact that it is open must be encoded in the file itself; SVN shows that the file is modified. However, when the file is closed again (without saving), it seems to return to its unmodified state: that is, svn status does not list the Excel file; svn diff produces no output anyway due to the data being binary.

我从TortoiseSVN和SVN命令行客户端获得相同的行为,在这种情况下都基于SVN 1.6:当在Excel中打开文件时,它打开的事实必须在文件本身中编码; SVN显示该文件已被修改。但是,当文件再次关闭(不保存)时,它似乎返回到未修改状态:即,svn status不会列出Excel文件;由于数据是二进制的,svn diff无论如何都不产生输出。

The catch is that the file does not now binary compare with the file stored in the repository. (If a fresh copy is exported, it does not binary compare with the opened-and-closed copy.) The file is apparently unchanged from the user's point of view, so in a semantic sense, the SVN response is reasonable. But not syntactically; and SVN is essentially syntactic.

问题是该文件现在不与存储库中存储的文件进行二进制比较。 (如果导出新副本,则不会与打开和关闭的副本进行二进制比较。)从用户的角度来看,文件显然没有变化,因此从语义上讲,SVN响应是合理的。但不是语法上的;而SVN本质上是语法的。

The part for which I can't find a reason is why SVN does not flag the file as modified. I can't imagine SVN has any special handling for Excel files (and in any case the MIME type is not specifically one associated with MS Excel); there is no SNV keyword property defined. Likewise, I can imagine Excel knows anything about the contents of the hidden .svn subdirectory in which the SVN working copy information is stored.

我无法找到原因的部分是为什么SVN不会将文件标记为已修改。我无法想象SVN对Excel文件有任何特殊处理(在任何情况下,MIME类型都不是特别与MS Excel相关联的);没有定义SNV关键字属性。同样,我可以想象Excel知道存储SVN工作副本信息的隐藏.svn子目录的内容。

Do you have any clues as to what is going on here?

你有什么线索在这里发生了什么?

Thanks, Rob.

谢谢,罗布。

3 个解决方案

#1


3  

Excel always locks files on open, setting the timestamp to the current date. When you close without saving, Excel will revert the timestamp back. This causes SVN to ignore the file.

Excel始终锁定打开的文件,将时间戳设置为当前日期。当您关闭而不保存时,Excel将恢复时间戳。这会导致SVN忽略该文件。

As for the changed contents, I'm not sure. Can you reproduce the problem?

至于改变的内容,我不确定。你能重现这个问题吗?

#2


4  

Subversion assumes that the "last modification" time stamp is not lying. If the timestamp is unchanged, the content of the file is not checked for changes. I think all version control system do this, checking for local modifications would be unbearably slow otherwise.

Subversion假定“最后修改”时间戳没有说谎。如果时间戳未更改,则不检查文件的内容是否有更改。我认为所有版本控制系统都会这样做,否则检查本地修改将会无法忍受。

edit: for the details of how SVN works in this regard, questions.c in the source of the SVN working copy library is a good start.

编辑:有关SVN在这方面的工作原理的详细信息,SVN工作副本库源代码中的questions.c是一个好的开始。

#3


1  

Is it possible the file is locked by excel while it is open and svn can't access it to see if it has changed or not?

excel打开时是否有可能锁定文件,svn无法访问它以查看它是否已更改?

#1


3  

Excel always locks files on open, setting the timestamp to the current date. When you close without saving, Excel will revert the timestamp back. This causes SVN to ignore the file.

Excel始终锁定打开的文件,将时间戳设置为当前日期。当您关闭而不保存时,Excel将恢复时间戳。这会导致SVN忽略该文件。

As for the changed contents, I'm not sure. Can you reproduce the problem?

至于改变的内容,我不确定。你能重现这个问题吗?

#2


4  

Subversion assumes that the "last modification" time stamp is not lying. If the timestamp is unchanged, the content of the file is not checked for changes. I think all version control system do this, checking for local modifications would be unbearably slow otherwise.

Subversion假定“最后修改”时间戳没有说谎。如果时间戳未更改,则不检查文件的内容是否有更改。我认为所有版本控制系统都会这样做,否则检查本地修改将会无法忍受。

edit: for the details of how SVN works in this regard, questions.c in the source of the SVN working copy library is a good start.

编辑:有关SVN在这方面的工作原理的详细信息,SVN工作副本库源代码中的questions.c是一个好的开始。

#3


1  

Is it possible the file is locked by excel while it is open and svn can't access it to see if it has changed or not?

excel打开时是否有可能锁定文件,svn无法访问它以查看它是否已更改?