我在开发时尝试使用 SVN 补丁文件从 Web API 中删除身份验证。用于删除身份验证的修补程序文件工作正常,如下所示:
Index: WebApplication.Api/Global.asax.cs
===================================================================
--- WebApplication.Api/Global.asax.cs (revision 18939)
+++ WebApplication.Api/Global.asax.cs (working copy)
@@ -115,7 +115,7 @@
_dependencyRegister.AddRegistration<WebApplication.Application.Aspects.AuthorisationAspect>();
// WebApplication.Application.CurrentUser
- _dependencyRegister.AddRegistration<WebApplication.Application.CurrentUser.ICurrentUserService, WebApplication.Application.CurrentUser.CurrentUserService>();
+ _dependencyRegister.AddRegistration<WebApplication.Application.CurrentUser.ICurrentUserService, WebApplication.Api.DummyServices.CurrentUserService>();
// WebApplication.Application.Interface.Manager
_dependencyRegister.AddRegistration<WebApplication.Application.Interface.Manager.IAspNetMembershipManager, WebApplication.Application.Manager.AspNetMembershipManager>();
Index: WebApplication.Api/Web.config
===================================================================
--- WebApplication.Api/Web.config (revision 18939)
+++ WebApplication.Api/Web.config (working copy)
@@ -64,14 +64,12 @@
</sessionState>
<httpModules>
<add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" />
- <add name="ProtectedResourceModule" type="WebApplication.Api.Modules.ProtectionModule"/>
</httpModules>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" />
- <add name="ProtectedResourceModule" type="WebApplication.Api.Modules.ProtectionModule"/>
</modules>
<httpErrors existingResponse="PassThrough" />
</system.webServer>
如您所见,它更改了接口的 DI 实现,并从 XML 配置文件中删除了两个节点。
由于没有办法(我发现(反向应用补丁(我在Visual Studio中使用VisualSVN来应用补丁(,我基于原始补丁文件创建了一个"反向补丁":
Index: WebApplication.Api/Global.asax.cs
===================================================================
--- WebApplication.Api/Global.asax.cs (revision 18939)
+++ WebApplication.Api/Global.asax.cs (working copy)
@@ -115,7 +115,7 @@
_dependencyRegister.AddRegistration<WebApplication.Application.Aspects.AuthorisationAspect>();
// WebApplication.Application.CurrentUser
+ _dependencyRegister.AddRegistration<WebApplication.Application.CurrentUser.ICurrentUserService, WebApplication.Application.CurrentUser.CurrentUserService>();
- _dependencyRegister.AddRegistration<WebApplication.Application.CurrentUser.ICurrentUserService, WebApplication.Api.DummyServices.CurrentUserService>();
// WebApplication.Application.Interface.Manager
_dependencyRegister.AddRegistration<WebApplication.Application.Interface.Manager.IAspNetMembershipManager, WebApplication.Application.Manager.AspNetMembershipManager>();
Index: WebApplication.Api/Web.config
===================================================================
--- WebApplication.Api/Web.config (revision 18939)
+++ WebApplication.Api/Web.config (working copy)
@@ -64,14 +64,12 @@
</sessionState>
<httpModules>
<add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" />
+ <add name="ProtectedResourceModule" type="WebApplication.Api.Modules.ProtectionModule"/>
</httpModules>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" />
+ <add name="ProtectedResourceModule" type="WebApplication.Api.Modules.ProtectionModule"/>
</modules>
<httpErrors existingResponse="PassThrough" />
</system.webServer>
很简单,我所做的只是将 + 符号更改为 - 反之亦然。这将创建一个对我来说有意义的反向补丁文件。
反向修补程序工作正常,除了 XML 配置文件中的最后一个"行添加"以及添加该行也会删除以下几行,从而导致格式不正确的 XML。
谁能建议为什么会这样?我需要用魔法@@ -64,14 +64,12 @@
做点什么吗?
我只是好奇,我想这应该可以在互联网上找到。这就是我所做的:
- 用谷歌搜索
visualsvn create reverse patch
- 已选择第一个链接:http://www.visualsvn.com/support/svnbook/ref/svn/c/patch/
- 阅读选项部分并找到反向差异
似乎这将处理您的正常补丁并执行您想做的事情。因此,应该不需要手动反转补丁。
另一种方法可能是从正确的diff command
开始,有一个选项可以通过交换修订顺序来创建反向补丁。
似乎最简单的方法是通过命令行。我找不到任何通过Visual SVN或Tortoise的UI反向应用补丁文件的方法,而且我不知道为什么对补丁文件的手动修改不起作用。
在命令行中,导航到工作副本目录并输入以下命令以应用修补程序文件:
svn patch [path and name of patch file]
要反向应用它:
svn patch --reverse-diff [path and name of patch file]
交换14
和12
也可以吗?(将@@ -64,14 +64,12 @@
更改为@@ -64,12 +64,14
(