TortoiseSVN补丁文件被错误地应用了。

3

我正在尝试使用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 @@做些什么吗?

3个回答

4

似乎最简单的方法是通过命令行完成。我无法找到在Visual SVN或Tortoise的用户界面中反向应用补丁文件的任何方法,也不知道为什么手动修改补丁文件没有起作用。

在命令行中,导航到工作副本目录并输入以下命令以应用补丁文件:

svn patch [path and name of patch file]

将其应用于反向:

svn patch --reverse-diff [path and name of patch file]

4

我只是好奇,认为这应该可以在互联网上找到。所以我做了以下事情:

看起来这将处理您的常规补丁并执行您想要执行的操作。因此,不需要手工反转修补程序

另一种方法是只需从正确的diff命令开始,通过交换修订的顺序来创建反向补丁。


0

交换 1412 也可以吗?(将 @@ -64,14 +64,12 @@ 改为 @@ -64,12 +64,14


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接