Applying a .patch file - diff

I want to apply a .patch file to one file.
I placed both in the same folder and I tried this
trinity#Zion ~/Desktop $ patch -i lalala.patch
patching file install.sub
patch unexpectedly ends in middle of line
Hunk #1 FAILED at 1562.
1 out of 1 hunk FAILED -- saving rejects to file install.sub.rej
But as you see in the output, it failed. The content of install.sub.rej is basically all the code from lalala.patch
I tried similar commands but I got the same results. I guess I'm doing something wrong.
I know applying a patch is just 1 command but I'm so lost at this. If someone tells me the command or directly patches the file (and also tells me the command) thanks
original file
http://pastebin.com/raw.php?i=PKru8m5r
patch:
http://pastebin.com/raw.php?i=kkMUHtj8

Your patch command is fine. It is the patch file itself that gives the problem (at least for me (Kubuntu 11.04), as looking at the link you gave in the comment, all patch files contain the same error...?!)
To solve the problem for me, find this line in the patch file:
## -1562,6 +1562,8 ## set_timezone() {
and remove the set_timezone() { part and the error you describe is gone.
This part is showing the function where the changes are made. When looking at the patches on the page you gave in your comment, it shows that all of them contain this extra information. As far as I know (but I am not a patch guru, so please correct me) is this not accepted by the default patch command.
(Unfortunately enough, your patch still fails and the expected lines in the patch file compared to the original file do not match...)

Quite likely, the generated patch is "correct" but double-check the encode of it and be sure it's UTF-8.

Related

AEM: Issue using Command Line DAM Workflow

I like to execute a command line programm as a DAM workflow. I tried to implement the ImageMagic example from here: Best Practices for Configuring ImageMagick:
I addded a new Workflow Model,
added "command line" from the "DAM Workflow" list.
In the Argument tab set Mime type to "image/jpeg" (even tried wihtout Mime type)
and in Commands: "C:\Program Files\ImageMagick-7.0.7-Q16\magick.exe" convert ${file} -flip ${file}-flipped.jpg (instead of magick convet ... because in another discussion using an absolute path instead of global name helped people Re: CommmandLineProcess : ImageMagick)
I then added a luncher. And uploaded an Image to the DAM.
In the workflow > instances overview, i see that the workflow was started, it's running and the command line job is set to active.
Unfortunantly this state is never chnaged and no new asset is generated via imageMagic.
I even tried replacing the command with something simple like "ren C:\test\foo.txt bar.txt" which renames a local file. The chnage never happend either.
My question is what am i doing wrong, and how can i debug / find the command outputs? in \crx-quickstart\logs i couldn't find any logs regarding CommandLineProcess.
Thanx

Preventing the accidentally marking of all conflicts as resolved in Mercurial

It doesn't happen too often, but every once in a while I'll fumble with my typing and accidentally invoke "hg resolve -m" without a file argument. This then helpfully marks all the conflicts resolved. Is there any way to prevent it from resolving without one or more file arguments?
You can do this with a pre-resolve hook but you'd have to parse the arguments yourself to ensure that they are valid which could be tricky.
The relevant environment variables that you might need to look at are:
HG_ARGS - the contents of the whole command line e.g. resolve -m
HG_OPTS - a dictionary object containing options specified. This would have an an entry called mark with a value of True if -m had been specified
HG_PATS - this is the list of files specified
Depending upon the scripting language you would use, you should be able to test if HG_OPTS contains a value of True for mark and fail if it does and the HG_PATS array is empty.
It starts to get complicated when you take into account the --include and --exclude arguments.
If you specify the files to resolve as part of the --include option then the files to include would be in HG_OPTS, not HG_PATS. Also, I don't know what would happen if you specified hg resolve -m test.txt --exclude test.txt. I'd hope that it would not resolve anything but you'd need to test that.
Once you've parsed the command arguments, you'd return either 0 to allow the command or 1 to prevent it. You should echo a reason for the failure if you return 1 to avoid confusion later.
If you don't know how to do this then you'd need to specify what OS and shell you are using for anyone to provide more specific help.

Unsure of how to proceed with creating ec2-consisten-snapshot

I was just put on a task to try and debug and figure out why our ec2-consistent-snapshot script isn't working.
Our lead programmer followed this blog post.
We have a .sh script that we'd like to take the snapshot and it looks like this:
#!/bin/sh
/opt/aws/bin/ec2-consistent-snapshot --aws-access-key-id MYACCESSKEY --aws-secret-access-key MYSECRETKEY --freeze-filesystem /vol --mysql --mysql-host localhost --mysql-socket /var/lib/mysql/mysql.sock --mysql-username USERNAME --mysql-password PASSWORD --description "Demo MySQL data volume: $(date +%c)" vol-MYVOL
If I run this by doing sudo ./snapshot_script.sh I get a single error:
ec2-consistent-snapshot: ERROR: create_snapshot: File does not exist: at /usr/share/perl5/vendor_perl/Net/Amazon/EC2.pm line 232
I of course followed this error and line 232 in EC2.pm is this:
my $ref = $xs->XMLin($xml);
I have 0 perl experience and I don't know what this could be doing.
Any help would be wonderful.
The Net::Amazon::EC2 that I'm looking at on CPAN has that line at 252, not 232 so perhaps you are not on the latest version. Looking above that line, the program has attempted to do a "query to sign" using lots of the security parms. I suspect there is a problem with the authentication keys you are using. There is a debug flag, you might want to turn that on to generate more messages.
If you go to this page, you will see that XMLin() is a function of XML::Simple, and it takes a file as an argument. So, $xml is presumably a variable that contains an xml file name. That file does not exist.
The next step would be to trace the error back into the source code of ec2-consistent-snapshot, in order to see how it is calling XML::Simple and where the bad value gets passed in.

How to find exactly why patch failed?

I have a unified diff patch which patch rejects. A visual inspection of the diff file and the original code finds the code contains all text expected by the diff file in the correct location. I have tried --ignore-whitespace and -F3 for good measure but patch still fails. Does an option exist to report exactly what is causing the patch to fail?

How to patch with a .diff file?

I found this patch on source forge (cocoa.diff), and it implies that I can patch using the cocoa.diff file. However, I can't seem to figure out how to use the .diff file.
Thanks for any help!
EDIT: I tried "patch p1 < cocoa.diff" and the output was "patch: ** Only garbage was found in the patch input." Does this mean that the .diff file is corrupt or incorrect? Also, I'm using Mac OSX 10.6.
the file cocoa.diff seems OK, however the link failed the first time I tried and returned some error HTML which indeed looks like garbage to patch. Your command seems nearly OK (lacks a dash: patch -p1 < cocoa.diff seems better).