我可以为 Windows 使 Subversion + TortoiseSVN 不区分大小写吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14582/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can I make Subversion + TortoiseSVN case-insensitive for Windows?
提问by Kit Roed
I've been using Subversion for code control with TortoiseSVN to interface with the server for the past few months, and in general it's been going great! However, occasionally my FoxPro IDE will change the case of a file extension without warning where "program.prg" becomes "program.PRG") TortoiseSVN apparently takes this to mean the first file was removed, becoming flagged as "missing" and the second name comes up as "non-versioned", wreaking havoc on my ability to track changes to the file. I understand that Subversion has it origins in the case-sensitive world of *nix but, is there any way to control this behavior in either Subversion or TortoiseSVN to be file name case-insensitive when used with Windows?
在过去的几个月里,我一直在使用 Subversion 进行代码控制,通过 TortoiseSVN 与服务器进行交互,总的来说,它进展顺利!但是,有时我的FoxPro IDE将改变文件扩展名的情况下没有警告,其中“ program.prg”变成了“程序。PRG”)的TortoiseSVN显然借此意味着第一个文件已被删除,成为标记为‘失踪’,而第二名称显示为“非版本化”,严重破坏了我跟踪文件更改的能力。我知道 Subversion 起源于 *nix 区分大小写的世界,但是,在与 Windows 一起使用时,有什么方法可以控制 Subversion 或 TortoiseSVN 中的这种行为使文件名不区分大小写?
采纳答案by jacobko
Unfortunately, Subversion is case-sensitive. This is due to the fact that files from Subversion can be checked out on both case-sensitive file systems (e.g., *nix) and case-insensitive file systems (e.g., Windows, Mac).
不幸的是,Subversion 区分大小写。这是因为来自 Subversion 的文件可以在区分大小写的文件系统(例如,*nix)和不区分大小写的文件系统(例如,Windows、Mac)上检出。
This pre-commit hook scriptmay help you avoid problems when you check in files. If it doesn't solve your problem, my best suggestion is to write a little script to make sure that all extensions are lowercase and run it every time before you check in/check out. It'll be a PITA, but maybe your best bet.
这个预提交钩子脚本可以帮助您在签入文件时避免出现问题。如果它不能解决您的问题,我最好的建议是编写一个小脚本以确保所有扩展名都是小写的,并在您签入/签出之前每次都运行它。这将是一个 PITA,但也许是你最好的选择。
回答by TamusJRoyce
Windows does support case sensitivity, but you must send it the correct POSIX flags on CreateFile from the Windows API! A registry key may need changed (SFU/Tools for Unix and Ultimate Windows 7 has this registry entry already set so windows supports case sensitive file names).
Windows 确实支持区分大小写,但您必须从 Windows API 在 CreateFile 上向它发送正确的 POSIX 标志!可能需要更改注册表项(SFU/Tools for Unix and Ultimate Windows 7 已设置此注册表项,因此 Windows 支持区分大小写的文件名)。
Windows is designed off of Unix, but things such as Explorer.exe and other programs are designed to disallow case sensitivity for backwards compatibility and security (mostly when dealing with dos executing notepad.exe vs. NOTEPAD.EXE, where all caps is a virus or malware).
Windows 是基于 Unix 设计的,但 Explorer.exe 和其他程序旨在禁止区分大小写以实现向后兼容性和安全性(主要是在处理执行 notepad.exe 与 NOTEPAD.EXE 的 dos 时,其中所有大写都是病毒)或恶意软件)。
But Vista+ has security attributes which makes this obsolete.
但是 Vista+ 具有安全属性,这使得它过时了。
TortiousSVN just doesn't support passing this posix flag while making and renaming files.
TortiousSVN 只是不支持在创建和重命名文件时传递这个 posix 标志。
回答by TamusJRoyce
I use TortoiseSVN with VFP, and it mostly-seamlessly handles the case flipping. The only time it doesn't is if I have the file open in the IDE when I try to do the commit: the file lock VFP holds confuses it. Is this where your problem comes in, or are there other issues?
我将 TortoiseSVN 与 VFP 一起使用,它主要无缝地处理案例翻转。唯一没有出现的情况是,当我尝试执行提交时,是否在 IDE 中打开了文件:VFP 持有的文件锁会混淆它。这是您的问题所在,还是还有其他问题?
I did a presentation at FoxForward last year about using VFP with Subversion: most of the presentation dealt with the command line, but there are a couple of slides at the end that have links to tools that help you work with Subversion in VFP. http://docs.google.com/Presentation?id=dfxkh6x4_3ghnqc4
去年我在 FoxForward 做了一个关于在 Subversion 中使用 VFP 的演示:大部分演示文稿都涉及命令行,但最后有几张幻灯片提供了指向工具的链接,这些工具可以帮助您在 VFP 中使用 Subversion。http://docs.google.com/Presentation?id=dfxkh6x4_3ghnqc4
回答by SarekOfVulcan
Kit, you comment above that VFP's binary-based source files are tough to work with in Subversion. The link I gave above mentions a couple of tools to make it easier, but the one I work with is Christof Wollenhaupt's TwoFox utility -- it converts a VFP project to text-only. You have to run it manually, but I don't have a problem with that.
Kit,你在上面评论说 VFP 的基于二进制的源文件很难在 Subversion 中使用。我在上面给出的链接提到了一些工具来简化它,但我使用的是 Christof Wollenhaupt 的 TwoFox 实用程序——它将 VFP 项目转换为纯文本。您必须手动运行它,但我对此没有问题。
回答by SarekOfVulcan
I believe the random upper and lower case on the extensions isn't random at all. I remember testing on this. If you modify a program from the project manager. By clicking on the modify button let's say. And then save the changes the extension is lower case. If you do a modify command from the command window and save the changes the extension is upper case. Apparently the coders at Microsoft didn't worry about the extension case being the same.
我相信扩展的随机大小写根本不是随机的。我记得对此进行了测试。如果您从项目经理修改程序。通过点击修改按钮让我们说。然后保存扩展名是小写的更改。如果您从命令窗口执行修改命令并保存更改,则扩展名是大写的。显然,微软的编码人员并不担心扩展案例是否相同。
回答by dewalla
Nope you sure can't. SVN is case-sensitive unless you were to rewrite the code somehow ... it isopen-source.
不,你肯定不能。SVN 区分大小写,除非您要以某种方式重写代码……它是开源的。
回答by Hugo González Castro
We had a similar problem and I found a better solutionthan the ones exposed here, so I'm sharing it now:
我们遇到了类似的问题,我找到了比这里公开的更好的解决方案,所以我现在分享它:
For commits done manualy, now TortoiseSVN fixes the case of the file names automatically: it renames the local files to match the case of the versioned files (just by opening the commit window in that path), so there should be no problemwith that.
For automated commitsyou cannot use TortoiseSVN, as it requires you to manually confirm the commit (it opens the commit window with a specific message, but you still have to click ok). But if you directly use Subversion (svn) to make an automated commit, then you will have the case-sensitive issue on that commit, as Subversion is still case-sensitive...
对于手动完成的提交,现在 TortoiseSVN 会自动修复文件名的大小写:它重命名本地文件以匹配版本化文件的大小写(只需打开该路径中的提交窗口),因此应该没有问题。
对于自动提交,您不能使用 TortoiseSVN,因为它需要您手动确认提交(它会打开带有特定消息的提交窗口,但您仍然必须单击确定)。但是,如果您直接使用 Subversion (svn) 进行自动提交,那么您将在该提交中遇到区分大小写的问题,因为 Subversion 仍然区分大小写...
How to solve this for automated commits? Well, I tried a mixed approach: creating a batch file called FixCaseSensitiveFileNames.bat
that you may call passing the path you want to fix before the commit, for example: call FixCaseSensitiveFileNames.bat C:\MyRepo
. The batch file opens TortoiseSVN for a manual commit, and that automatically fixes the file names, but then it closes the commit window after a predefined pause, so you can continue with the automated commit with the case-sensitive file names already fixed. The pause is emulated with a local ping, and you can change the duration by changing the -n
argument, which is the number of tries. If you don't make a long enough pause, it exist the risk to close the TortoiseSVN window before it makes its magic fix. Here it is the code of the batch file:
如何为自动提交解决这个问题?好吧,我尝试了一种混合方法:创建一个名为的批处理文件FixCaseSensitiveFileNames.bat
,您可以调用该文件在提交之前传递要修复的路径,例如:call FixCaseSensitiveFileNames.bat C:\MyRepo
. 批处理文件打开 TortoiseSVN 以进行手动提交,并自动修复文件名,但在预定义的暂停后关闭提交窗口,因此您可以使用已修复区分大小写的文件名继续自动提交。暂停是通过本地 ping 模拟的,您可以通过更改-n
参数来更改持续时间,即尝试次数。如果您没有进行足够长的暂停,则存在在 TortoiseSVN 窗口进行神奇修复之前关闭它的风险。这是批处理文件的代码:
@echo off
REM *** This BAT uses TortoiseSVN to fix the case-sensitive names of the files in Subversion
REM *** Call it before an automated commit. The Tortoise commit fixes this issue for manual commits,
REM *** so the trick is opening the commit window and close it automatically after a pause (with ping).
REM *** %1 = path to be fixed
start TortoiseProc.exe /command:commit /path:"%1"
ping localhost -n 10 >nul
taskkill /im TortoiseProc.exe
This totally solved the issue for our automated daily build process. The only problem I see is a window will open for a few seconds, which was not a problem for our daily build, but if that is a problem for you there could be workarounds too...
这完全解决了我们自动化日常构建过程的问题。我看到的唯一问题是一个窗口会打开几秒钟,这对我们的日常构建来说不是问题,但是如果这对您来说是个问题,那么也可能有解决方法......
回答by álvaro González
TortoiseSVN has a Repairing File Renamesfeature. It requires manual intervention and it actually issues a file rename operation to be committed but nonetheless addresses current use case by keeping file history.
TortoiseSVN 具有修复文件重命名功能。它需要手动干预,它实际上会发出要提交的文件重命名操作,但仍然通过保留文件历史记录来解决当前用例。