lquitadamo
lquitadamo

Reputation: 653

Apply "Eclipse Workspace Patch" using command line

For our project we use cvs and we want share changes using patch created using eclipse with configuration in image: enter image description here

The patch is like this:

### Eclipse Workspace Patch 1.0
#P project2
Index: testFile2.txt
===================================================================
RCS file: testFile2.txt
diff -N testFile2.txt
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ testFile2.txt   1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,5 @@
+
+xxxxxx
#P project1
Index: testFile1.txt
===================================================================
RCS file: testFile1.txt
diff -N testFile1.txt
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ testFile1.txt   1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,5 @@
+
+yyyyyy

Is there a command/library allows to apply this patch without eclipse? I try 'patch' command but seems doesn't supports this patch format.

Upvotes: 1

Views: 450

Answers (1)

lquitadamo
lquitadamo

Reputation: 653

The problem has no simple solution because the format of Multi-project is not standard and only eclipse know how to apply that format. Standard patch format doesn't know command:

#P project1

My workaround is:

  • generate one patch for single project with name of project follow by '.patch' (Example projectName=project1; patchName=project1.patch);
  • genarate patch using format show in follow image

enter image description here

  • apply patch using ant task (wrapping patch command)

     <target name="applyPatch">
     <echo message="Apply patch:${patchFileName}"/>
     <echo message="workspace.home:${workspace.home}"/>
     <sequential>
         <local name="projectName" />
         <basename  property="projectName" file="${patchFileName}" suffix=".patch" />
         <echo message="${projectName}"/>
    
         <exec executable="patch">
             <arg value="-d"/>
             <arg value="${workspace.home}/${projectName}"/>
             <arg value="-i"/>
             <arg value="${patchFileName}"/>
             <arg value="-p" />
             <arg value="0" />
             <arg value="-u" />
             <arg value="-N" />
         </exec>
     </sequential>
     </target>
    

Upvotes: 1

Related Questions