如何保存更改历史记录,同时使用Perforce公司在Visual Studio中重命名文件 [英] How to keep change history while renaming files in Visual Studio using Perforce
问题描述
我知道已经有关于使用版本控制系统重命名文件的几个问题。但我没有找到一个满意的答复的特殊版本控制系统的的 Perforce公司的结果
我的问题:
是有一个插件/解决方案,这使我的C#代码文件的历史版本,当我在的重命名它的的Visual Studio?
I know there are already several questions about renaming files by using a version control system. But I did not found a satisfactory answer to the special version control system Perforce.
My question:
Is there a plug-in/solution which keeps the version history of my C# code files when I renaming it within Visual Studio?
编辑:目前我使用VS2P4插件。
Currently I am using VS2P4 plug-in.
EDIT2:
我已经找到更短一点的方式重命名文件:
I have found a little shorter way to rename a file:
- 开启包含在资源管理器文件夹(在解决方案资源管理器中右键单击打开Windows资源管理器)。
- 选择文件并右键单击Perforce->显示在P4V。
- 请与选定文件中的普通重命名/移动操作。
这情景比得宝Perforce公司在导航P4V,直到我找到正确的文件短。但当然,我要寻找一个较短的方式
That scenario is shorter than navigating in Perforce Depot in P4V until I find the right file. But of course I am looking for a shorter way.
EDIT3:有没有办法直接做展在P4V的与文件选择的在VS?
Is there a way to directly do "Show in P4V" with file selection within VS?
推荐答案
我有一个很好的解决方案,现在。刚刚处理宏观事件SolutionItemsEvents_ItemRenamed。结果
这是通过开放的宏IDE通过点击完成的工具 - > Macros->宏IDE 的。然后下面的事件处理程序添加到您的宏项目:
Macro
I have a good solution now. Just handle macro event SolutionItemsEvents_ItemRenamed.
This is done by open Macros IDE by clicking Tools->Macros->Macros IDE. Then add following event handler to your macro project:
Private Sub SolutionItemsEvents_ItemRenamed(ByVal ProjectItem As EnvDTE.ProjectItem,
ByVal OldName As String)
Handles SolutionItemsEvents.ItemRenamed
Dim process As System.Diagnostics.Process
process.Start("p4", "move -k " & ProjectItem.Properties.Parent.Document.Path &
"\\" & OldName & " " & ProjectItem.Document.Path)
End Sub
看截图:
See screenshot:
正如你所看到的只是所谓的P4移动-k。 -k选项需要的,因为后重命名旧的文件已经被删除,所以Perforce公司将抛出一个错误没有-k。 -k导致的Perforce的文件只重命名服务器。
As you can see it just calls a "p4 move -k". "-k" option is needed because after a rename the old file is already deleted, so Perforce would throw an error without "-k". "-k" causes Perforce to rename the file on server only.
如果你的Perforce的连接错误您需要添加连接的地方被定义一个文件P4CONFIG。这是通过:
If you get Perforce connection errors you need to add a P4CONFIG file where connection is defined. This is done by:
-
添加文件的 p4config.txt 的到你的项目的目录(或任何其父目录)与内容:
Add file p4config.txt to the directory of your project (or any of its parent directories) with content:
P4CLIENT =您的工作结果
P4USER =用户搜索
P4PORT = p4server:1234
P4CLIENT=your workspace
P4USER=user
P4PORT=p4server:1234
设置环境变量= P4CONFIG p4config.txt
Set environment variable P4CONFIG=p4config.txt
现在,你可以通过任何方式(解决方案资源管理用品 - >重命名,解决方案资源管理器用品 - > F2,ReSharper的的的重命名文件,以匹配类型名称的,ReSharper的的类的重命名更改文件青霉>(按Ctrl + R,R),...)。
Now you can change your files by any way (Solution Explorer Item->Rename, Solution Explorer Item->F2, ReSharper's Rename file to match type name, ReSharper's class Rename (Ctrl+R,R),...).
但要记住:我有问题,如果我尝试编辑在一个赤式重命名相同的文件,如果我重命名文件而另一个人有签出同一个文件。
But keep in mind: I have problems if I try to edit and rename same file in one chek-in and if I rename a file while another person has checked-out same file.
这篇关于如何保存更改历史记录,同时使用Perforce公司在Visual Studio中重命名文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!