how to add patch

J

jimgardener

hi
I have some demo python code hosted on a public host that uses
subversion..and I want to modify one of the files using a patch file
handed to me by another person..How do I do this?Generally I checkout
the code and make the change and then commit again..I have never done
through patch..Can somebody tell me how to do this?
thanks
jim
 
D

Diez B. Roggisch

jimgardener said:
hi
I have some demo python code hosted on a public host that uses
subversion..and I want to modify one of the files using a patch file
handed to me by another person..How do I do this?Generally I checkout
the code and make the change and then commit again..I have never done
through patch..Can somebody tell me how to do this?

This is not really python specific. Which is not to say that you are
wrong here asking, but there are a bazillion of sources out there to
help you. Google. Read man-pages. Try it out.

My first attempt would be

cd my_project
patch -p0 < the.patch

But it might not work, depending on how the patch was created.

Diez
 
L

Lawrence D'Oliveiro

My first attempt would be

cd my_project
patch -p0 < the.patch

But it might not work, depending on how the patch was created.

If the OP can post some initial part of the patch (probably the first dozen
lines should be ample), we can get a better idea of how to proceed.

Most patches follow the format of output from diff -u or diff -c; I think
the former is slightly more common.
 
S

Steve Howell

hi
I have some demo python  code hosted on a public host that uses
subversion..and I want to modify one of the files using a patch file
handed to me by another person..How do I do this?Generally I checkout
the code and make the change and then commit again..I have never done
through patch..Can somebody tell me how to do this?
thanks

Obviously "man patch" is where you should start, but like many Unix
man pages, the man page for "patch" is surprisingly obtuse for such an
elegant and useful program.

(BTW we are slightly off-topic for Python, but I am sympathetic to
your basic problem.)

The "patch" program is pretty smart about doing the correct thing once
you grok its options, but if you are concerned about doing the wrong
thing, I recommend you simply play around with it with some toy
examples.

Hopefully the example below demonstrates the basic premise behind
"patch," which I think you already understand. The bells and whistles
are mostly about "patch" being able to recognize that a diff applies
to a specific file. Again, I would take a few minutes to experiment
with a couple small files and diffs that you generate yourself before
applying other people's patches.

I haven't used "patch" a ton myself, so I'm no expert, but it's
definitely a cool program, so it's worth learning.


$ echo foo > foo
$ cp foo foobetter
$ echo better >> foobetter
$ cat foo
foo
$ cat foobetter
foo
better
$ diff foo foobetter
1a2
$ diff foo foobetter > make_foo_better
$ patch foo make_foo_better
patching file foo
$ cat foo
foo
better
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,111
Latest member
KetoBurn
Top