Tutorial :Difficulty splitting mercurial patches up



Question:

I've got a web application I want to be able to create patches for. Specifically I want to create patches for enabling specific functionality in the web server.

JAVA_OPTS="-Xms128m -Xmx256m $JAVA_OPTS -Djava.awt.headless=true -Datlassian.standalone=JIRA -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true "    # Perm Gen size needs to be increased if encountering OutOfMemoryError: PermGen problems. Specifying PermGen size is not valid on IBM JDKs  PRGDIR=`dirname $0`  JIRA_MAX_PERM_SIZE=128m  if [ -f "${PRGDIR}/permgen.sh" ]; then      echo "Detecting JVM PermGen support..."  . ${PRGDIR}/permgen.sh  if [ $JAVA_PERMGEN_SUPPORTED = "true" ]; then      echo "PermGen switch is supported. Setting to ${JIRA_MAX_PERM_SIZE}"      JAVA_OPTS="-XX:MaxPermSize=${JIRA_MAX_PERM_SIZE} ${JAVA_OPTS}"      else          echo "PermGen switch is NOT supported and will NOT be set automatically."      fi  fi    # use this if you want to import data without notifications  #JAVA_OPTS=" -Datlassian.mail.senddisabled=true -Datlassian.mail.fetchdisabled=true -Datlassian.mail.popdisabled=true $JAVA_OPTS "    export JAVA_OPTS    echo "If you encounter issues starting up JIRA Standalone Edition, please see the Troubleshooting guide at http://confluence.atlassian.com/display/JIRA/Installation+Troubleshooting+Guide"  

What I want to do is save a patch for each individual modification I need to make to this file in such a way that the patches can be applied individually (using qpush -move) or all together (qpush -a)

I first tried the following with a clean version of the file:

hg qnew jmx.patch  

Then I modified the first line of the file to include the following

-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8089 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false  

then refreshed the patch

hg qrefresh  

The popped the patch to begin work on the second modification from the clean base

hg qpop  hg qnew jelly.patch  

The I modified the first line of the file to include the following

-Djira.jelly.on=true  

then refreshed the patch

When I then tried to qpush the older patch, it failed to apply. Then I tried an alternate approach, which was to first create a base patch:

hg qpop -a  hg qnew base.patch  

,that added the following to the file

JMX_OPTS=  JELLY_OPTS=  JAVA_OPTS=" ${JAVA_OPTS} ${JELLY_OPTS} ${JMX_OPTS} "  

,then refresh base.patch

hg qrefresh  

Then create a new patch for jmx while base.patch was still applied:

hg qnew jmx.new  

edit the file as follows:

JMX_OPTS=" -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8089 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false "  

refresh the patch and pop :

hg qrefresh  hg qpop  

Create new patch for jelly:

hg qnew jelly.patch  

Edited the file as follows:

JELLY_OPTS=" -Djira.jelly.on=true "  

refreshed the patch:

hg qrefresh  

But again, when I tried to qpush the jmx.patch on top of the newly created jelly.patch, there was conflicts.

I thinking Mercurial is behaving as expected, but I'm wondering if I can structure the patches I'm making differently so they can apply individually or combined without rejection


Solution:1

Your second approach will work if you insert at least 3 empty lines between the lines you want to change.

And you could also shuffle your queue (after qpop!), apply jmx first, then jelly. You'll get "offset x lines" but the file will be correctly patched.

MQ has a hardcoded fuzz number 3 (see patchfile() in patch.py). When you have your JMX_OPTS and JELLY_OPTS in adjacent lines, MQ can't find the context in jmx.patch because it's changed in jelly.patch.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »