You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Craig <su...@gmail.com> on 2009/04/21 05:30:52 UTC

help creating a patch

Hi all,

I was trying to create a patch to send to someone the other day, and
ran into an interesting problem. I had "svn mv"ed a file, and changed
a few others, then used TortoiseSVN to create the patch. All of the
changes were included in the patch except the newly added file
resulting from the move. The end result is that the patch did not
represent all of the changes in the working copy, and hence was not
very useful. The same thing happened with "svn diff".

Any ideas?

The recipe below shows the issue:

> svnadmin create testrepo
> svn co file:///path/to/testrepo/ testwc
> cd testwc/

#add and commit f1
> echo "some f1 text" > f1.txt
> svn add f1.txt
> svn ci -m ''

#move f1
> svn mv f1.txt f1.txt.new

#add f2
> echo "some f2 text" > f2.txt
> svn add f2.txt

#status is correct
> svn st

#diff shows shows deletion of f1.txt, addition of f2.txt, but there is
no mention at all of f1.txt.new
> svn diff

regards,
Craig

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=1837535

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].

Re: help creating a patch

Posted by Craig <su...@gmail.com>.
I just found some design docs on an enhanced svn patch format, which,
I would assume, would fix the above issue.

https://svn.collab.net/viewvc/svn/trunk/notes/svnpatch?revision=36404&view=markup

I'm not sure when or if this code is scheduled to go into a release,
but it was merged from a branch to the trunk recently, so looks good.

On Wed, Apr 22, 2009 at 9:21 AM, Craig <su...@gmail.com> wrote:
> thanks all...so I wasn't going crazy.
>
> On Wed, Apr 22, 2009 at 1:43 AM, Stefan Sperling <st...@elego.de> wrote:
>> There is a bunch of issues for this, too. One of them is
>> http://subversion.tigris.org/issues/show_bug.cgi?id=2543
>
> thanks for that link. I think I finally understand what is going on.
> From the linked bug:
>
> "Also, there is no way to record the ancestry with traditional patch,
> thus there's no way to actually generate a 'correct' patch in this
> case." and "The result from a patch which includes the add is *not*
> the correct result, since the fact that the add stems from a rename is
> lost (i.e. the fact that the original add was *with history*)."
>
> So it seems there is currently no way to do this correctly, so it
> isn't done at all. That certainly seems like a bug or at least a
> serious limitation to me.
>
> Moving on, how does one work around this? I know the subersion project
> itself depends a lot on submitted patches. Surely these run into the
> same problems on occasion?
>
> regards,
> Craig
>

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=1956789

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].

Re: help creating a patch

Posted by Craig <su...@gmail.com>.
thanks all...so I wasn't going crazy.

On Wed, Apr 22, 2009 at 1:43 AM, Stefan Sperling <st...@elego.de> wrote:
> There is a bunch of issues for this, too. One of them is
> http://subversion.tigris.org/issues/show_bug.cgi?id=2543

thanks for that link. I think I finally understand what is going on.

Re: help creating a patch

Posted by Stefan Sperling <st...@elego.de>.
On Tue, Apr 21, 2009 at 07:01:14PM +0400, Andrey Repin wrote:
> Greetings, Craig!
> 
> > I was trying to create a patch to send to someone the other day, and
> > ran into an interesting problem. I had "svn mv"ed a file, and changed
> > a few others, then used TortoiseSVN to create the patch. All of the
> > changes were included in the patch except the newly added file
> > resulting from the move. The end result is that the patch did not
> > represent all of the changes in the working copy, and hence was not
> > very useful. The same thing happened with "svn diff".
> 
> > Any ideas?
> 
> Unfortunately, nothing you can do about moved/renamed files with diff/patch
> approach.
> You need to supply exact instructions to follow your movement in this case.

Yes, it's not possible for added files to show up in a diff.
IMO it is a bug that needs to be fixed. They should show up
by default, and maybe there should be a switch so they don't
show up. But I don't really know why anyone would want them
not to show up.

There is a bunch of issues for this, too. One of them is
http://subversion.tigris.org/issues/show_bug.cgi?id=2543

Stefan

Re: help creating a patch

Posted by Andrey Repin <an...@freemail.ru>.
Greetings, Craig!

> I was trying to create a patch to send to someone the other day, and
> ran into an interesting problem. I had "svn mv"ed a file, and changed
> a few others, then used TortoiseSVN to create the patch. All of the
> changes were included in the patch except the newly added file
> resulting from the move. The end result is that the patch did not
> represent all of the changes in the working copy, and hence was not
> very useful. The same thing happened with "svn diff".

> Any ideas?

Unfortunately, nothing you can do about moved/renamed files with diff/patch
approach.
You need to supply exact instructions to follow your movement in this case.


--
WBR,
 Andrey Repin (anrdaemon@freemail.ru) 21.04.2009, <19:00>

Sorry for my terrible english...

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=1844824

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].

Re: help creating a patch

Posted by "B. Smith-Mannschott" <bs...@gmail.com>.
On Tue, Apr 21, 2009 at 07:30, Craig <su...@gmail.com> wrote:
> Hi all,
>
> I was trying to create a patch to send to someone the other day, and
> ran into an interesting problem. I had "svn mv"ed a file, and changed
> a few others, then used TortoiseSVN to create the patch. All of the
> changes were included in the patch except the newly added file
> resulting from the move. The end result is that the patch did not
> represent all of the changes in the working copy, and hence was not
> very useful. The same thing happened with "svn diff".
>
> Any ideas?

A patch can't represent moves. The best it could do is representing
deletion of all lines from the file under its old name long with
insertion of all lines into the file under its new name.

$ cp design.txt added.txt
$ svn add added.txt
A         added.txt
$ svn cp design.txt copied.txt
A         copied.txt
$ svn mv design.txt moved.txt
A         moved.txt
D         design.txt

When I svn mv a file, diff on the *uncommitted* working copy shows the
deletion of the fille (well, it's contents) under the old name (this
can be turned off with the option --no-diff-deleted), but does not
show creation of the file under its new name (and I find no option to
turn this on).

If I *commit* the local changes first and then ask for a diff of that
change, then all the changes show up. (but applying this as a patch to
a working copy would lose the historical connection between design.txt
and moved.txt.)

$ svn ci -m "moves, adds, and deletes"
Adding         docs/added.txt
Adding         docs/copied.txt
Deleting       docs/design.txt
Adding         docs/moved.txt
Transmitting file data .
Committed revision 215.

$ svn diff -c215 | diffstat
 added.txt  |   20 ++++++++++++++++++++
 copied.txt |   20 ++++++++++++++++++++
 design.txt |   20 --------------------
 moved.txt  |   20 ++++++++++++++++++++

So to summarize:
You're right, svn diff is a little strange.
However, it still couldn't accurately represent svn mv and svn cp even
if it wasn't "strange".

// ben

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=1844882

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].