You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by "Ian P. McCullough" <ip...@andrew.cmu.edu> on 2004/01/16 18:26:13 UTC

Understanding copying/replacing

I've been kind of puzzled as to how I shoudl be mapping my particular 
development situtaion to the subversion branch model.  So far I've been 
kind of flailing so I figured I'd poll the other users to see if there are 
any "best practices" out there.

I develop a web application.  There is a "core application" and then I also 
make customized versions of the application for various clients.  When I 
start a new customization project, I make an "svn cp" of my core directory, 
and then I proceed with the customization work from there.

The problem I have is that occasionally (read almost daily) I make bug 
fixes to the core application which then need to be propagated to some or 
all of the branches.

It appears to me that "svn merge" is NOT what I want to do here because I 
dont want any of the custom stuff to be ported back into the core, nor do I 
want the custom branch to be identical to the core because it may have 
customizations.  Often these changes include a small change to one file.

My next thought was that I should "svn rm" the custom version and then "svn 
cp" the new, fixed version of the file from the core application directory 
to the custom version directory.  This is what I have been doing, however 
when working with multiple files, this gets very tedious.  Also it seems 
that every time you execute an "svn rm" on a URL it wants to commit.  So if 
I want to delete 100 files (but not a whole directory), its going to end up 
committing 100 times.  I know that version numbers are arbitrary, but this 
seems like a great way to make the history unusably large really quickly.

Next it seems that if I try to do the rm/cp solution in a working copy that 
its going to take two commits.  Is there no way to replace a file with 
another file in one commit?

I also tried, for a while, "OS copying" the new version over the working 
copy in the custom branch, which works great but then its not clear from 
looking at the history that the file has been replaced by a version from 
the main branch since the original creation of that custom branch.

Overall the best solution so far seems to be "svn rm; svn cp" procedure 
along with all the commits that procedure entails... Am I missing something?

Thanks,
Ian

----------------------------------------------------------------
Ian P. McCullough
Sr. Information Systems Specialist
Center for Arts Management and Technology (CAMT)
H. John Heinz III School of Public Policy and Management
Carnegie Mellon University
Pittsburgh, PA 15213-3890
(412) 268-3748
FAX (412) 268-3590
ipm@andrew.cmu.edu


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Understanding copying/replacing

Posted by John Peacock <jp...@rowman.com>.
Florian Weimer wrote:
> If I read the program description correctly, svk should be able to do
> that.

If only I could get svk to work on my machine. :~(

> 
> I hope that tools like svk will become more widespread in the future.
> Merge tracking to make repeated merges from the same branch as easy as
> possible (even if some files were renamed), and merging across different
> repositories are important features for real-world applications.

Mergepoint processing in native subversion should be a post-1.0 goal (I think 
there is even an issue already open).  I would be very interested in getting 
this working because I do a fair amount of work with the Perl core code which 
involves months on a branch.

John

-- 
John Peacock
Director of Information Research and Technology
Rowman & Littlefield Publishing Group
4720 Boston Way
Lanham, MD 20706
301-459-3366 x.5010
fax 301-429-5747


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Understanding copying/replacing

Posted by Florian Weimer <fw...@deneb.enyo.de>.
John Peacock wrote:

> Gareth Lennox wrote:
> 
> >We use a script to do this and it stores the [last-merge-from-trunk] value
> >in a property which it uses the next time you run the script. 
> 
> Please post the script, if you can (if only for reference purposes).

If I read the program description correctly, svk should be able to do
that.

I hope that tools like svk will become more widespread in the future.
Merge tracking to make repeated merges from the same branch as easy as
possible (even if some files were renamed), and merging across different
repositories are important features for real-world applications.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

RE: Understanding copying/replacing

Posted by Gareth Lennox <ga...@dwakn.com>.
Unfortunatly it is at work and I wont be able to get it until Monday :( Also
the script is in php as that is what I was working in when I needed this...
(and I don't know python yet, and I am working on windows at work :) )

Basically the logic goes like this (inside a wc of the branch):

1. Get the last-merge-from-trunk value from the property (svn propget ...)

2. Update the working copy (svn up)

3. Get the latest revision 
This part is kind of a hack as I could not find a way to get the latest
revision easily. It currently takes the last line of the output from #2 and
cuts out the revision number.

4. run the merge using the two revision numbers:
	svn merge -r[last-merge-from-trunk]:[latest-revision] url/to/trunk .

5. Update the last-merge-from-trunk property (svn propset ...)

The user must now fix any conflicts etc., and then commit.

I just bashed this script together the other day, and it seems to work quite
nicely. If anyone knows of a better way to perform step 3, please let me
know!

If anyone would like the script, e-mail me and I will send it to you on
Monday.

Gareth


 

> -----Original Message-----
> From: John Peacock [mailto:jpeacock@rowman.com] 
> Sent: 16 January 2004 08:58 PM
> To: Gareth Lennox
> Cc: 'Ian P. McCullough'; users@subversion.tigris.org
> Subject: Re: Understanding copying/replacing
> 
> Gareth Lennox wrote:
> 
> > We use a script to do this and it stores the 
> [last-merge-from-trunk] value
> > in a property which it uses the next time you run the script. 
> 
> Please post the script, if you can (if only for reference purposes).
> 
> John
> 
> -- 
> John Peacock
> Director of Information Research and Technology
> Rowman & Littlefield Publishing Group
> 4501 Forbes Boulevard
> Suite H
> Lanham, MD  20706
> 301-459-3366 x.5010
> fax 301-429-5748
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Understanding copying/replacing

Posted by John Peacock <jp...@rowman.com>.
Gareth Lennox wrote:

> We use a script to do this and it stores the [last-merge-from-trunk] value
> in a property which it uses the next time you run the script. 

Please post the script, if you can (if only for reference purposes).

John

-- 
John Peacock
Director of Information Research and Technology
Rowman & Littlefield Publishing Group
4501 Forbes Boulevard
Suite H
Lanham, MD  20706
301-459-3366 x.5010
fax 301-429-5748


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Understanding copying/replacing

Posted by Mike Mason <mg...@thoughtworks.net>.
mark benedetto king wrote:

>
>It does need to be -r 767:768.  It doesn't technically need to be
>a single revision; he could just use multiple "svn merge" invocations
>to get each of them (or perhaps a single one specifying a revision
>range, if they happen to be contiguous).  One nice feature of merge
>is that it takes place in the WC; you can do as many merges as you
>want before committing.
>
>Also, your example hints that you keep a WC of your *entire repository*!
>  
>
Yeah, I don't actually do that, but I'm not actually doing any merging 
at all right now and had forgotten about the switch command when writing 
the email.

>That would be a big WC, once you had lots of tags and branches.  This
>is not necessary; you only really need one WC:
>
>svn co http://foo/svn/trunk mywc
>cd mywc
>(apply fix to flibble.c)
>svn commit -m "Fixed word wrap bug in flibble" flibble.c
>Commited revision 768.
>svn switch http://foo/svn/branches/customerA
>svn merge -r 767:768 http://foo/svn/trunk
>svn commit -m "Merged r768 (word wrap bug) to customerA branch" 
>  
>
Nice.

Cheers,
Mike.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Understanding copying/replacing

Posted by mark benedetto king <mb...@lowlatency.com>.
On Sat, Jan 17, 2004 at 11:57:39AM +0000, Mike Mason wrote:
> 
> So going back to Ian's original request, which is to propagate bugfixes 
> from "core" (trunk) to "customer version A" (branches/customerA), he 
> needs to make those bugfixes in a single commit, where he does not 
> change anything else (this is good development practice anyhow). Then he 
> needs to merge the change to the branch:
> 
> cd /myworkingcopy/trunk/src/flibble
> (apply bugfix to flibble.c)
> svn commit -m "Fixed word wrap bug in flibble" flibble.c
> Commited revision 768.
> cd /myworkingcopy
> svn merge -r 768 trunk branches/customerA
> svn commit -m "Merged r768 (word wrap bug) to customerA branch" 
> branches/customerA
> 
> Is that about right? Does the merge argument need to be "-r 767:768" 
> instead?
> 

It does need to be -r 767:768.  It doesn't technically need to be
a single revision; he could just use multiple "svn merge" invocations
to get each of them (or perhaps a single one specifying a revision
range, if they happen to be contiguous).  One nice feature of merge
is that it takes place in the WC; you can do as many merges as you
want before committing.

Also, your example hints that you keep a WC of your *entire repository*!
That would be a big WC, once you had lots of tags and branches.  This
is not necessary; you only really need one WC:

svn co http://foo/svn/trunk mywc
cd mywc
(apply fix to flibble.c)
svn commit -m "Fixed word wrap bug in flibble" flibble.c
Commited revision 768.
svn switch http://foo/svn/branches/customerA
svn merge -r 767:768 http://foo/svn/trunk
svn commit -m "Merged r768 (word wrap bug) to customerA branch" 


--ben


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Understanding copying/replacing

Posted by Mike Mason <mg...@thoughtworks.net>.
kfogel@collab.net wrote:

>
>"merging a file" doesn't actually mean anything in Subversion.  You
>can only merge changes from one place to another.  (A change might be
>the addition or deletion of a file, of course...).
>
>The typical use case is to merge an entire change (i.e., r8330) from
>one branch to another.
>  
>

So going back to Ian's original request, which is to propagate bugfixes 
from "core" (trunk) to "customer version A" (branches/customerA), he 
needs to make those bugfixes in a single commit, where he does not 
change anything else (this is good development practice anyhow). Then he 
needs to merge the change to the branch:

cd /myworkingcopy/trunk/src/flibble
(apply bugfix to flibble.c)
svn commit -m "Fixed word wrap bug in flibble" flibble.c
Commited revision 768.
cd /myworkingcopy
svn merge -r 768 trunk branches/customerA
svn commit -m "Merged r768 (word wrap bug) to customerA branch" 
branches/customerA

Is that about right? Does the merge argument need to be "-r 767:768" 
instead?

Cheers,
Mike.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Understanding copying/replacing

Posted by kf...@collab.net.
"Gareth Lennox" <ga...@dwakn.com> writes:
> As far as I understand it (correct me if I am wrong, anyone), when you
> perform a merge, subversion only merges changes that have ocurred in the
> revisions you specify, it does not merge files that have not changed in
> those revisions. You can do this for entire directories at once as well.

Correct.

"merging a file" doesn't actually mean anything in Subversion.  You
can only merge changes from one place to another.  (A change might be
the addition or deletion of a file, of course...).

The typical use case is to merge an entire change (i.e., r8330) from
one branch to another.

-K

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

RE: Understanding copying/replacing

Posted by Gareth Lennox <ga...@dwakn.com>.
> Does this allow you to leave certain files that may have been 
> customized? 
> In other words is there a way to do this to individual files 
> or do you have 
> to do it a directory at a time?
> 

As far as I understand it (correct me if I am wrong, anyone), when you
perform a merge, subversion only merges changes that have ocurred in the
revisions you specify, it does not merge files that have not changed in
those revisions. You can do this for entire directories at once as well.

I just did a small test (to check that you can keep customised files): 

branched the trunk
made a change in the branch
committed
made a change in the trunk (same file)
committed
merged from trunk to branch (using the revision I created the branch:HEAD)

Subversion merged the files, keeping both changes (in the branch). Obviously
this would conflict if I had changed the same lines in the file. So
therefore you can branch the trunk and customise it, later merging changes
from the trunk and keep your changes in the branch.

Gareth



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

RE: Understanding copying/replacing

Posted by "Ian P. McCullough" <ip...@pobox.com>.
Does this allow you to leave certain files that may have been customized? 
In other words is there a way to do this to individual files or do you have 
to do it a directory at a time?

What I'd really like to do can I guess be described as this: Merge trunk 
into branch only when branch has not changed since last merge with trunk.

Ian


--On Friday, January 16, 2004 8:54 PM +0200 Gareth Lennox 
<ga...@dwakn.com> wrote:

> We are currently doing this using svn merge. We merge the trunk into our
> working copy of the branch, something like this (not at my work pc at the
> moment...so it could be wrong)
>
> svn merge -r[last-merge-from-trunk]:HEAD url/to/trunk .
>
> We use a script to do this and it stores the [last-merge-from-trunk] value
> in a property which it uses the next time you run the script. It seems to
> work pretty well as only the changes in the trunk since the last time you
> merged are merged into your branch. (and you only have one commit)
>
> Gareth
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

RE: Understanding copying/replacing

Posted by Gareth Lennox <ga...@dwakn.com>.
We are currently doing this using svn merge. We merge the trunk into our
working copy of the branch, something like this (not at my work pc at the
moment...so it could be wrong)

svn merge -r[last-merge-from-trunk]:HEAD url/to/trunk .

We use a script to do this and it stores the [last-merge-from-trunk] value
in a property which it uses the next time you run the script. It seems to
work pretty well as only the changes in the trunk since the last time you
merged are merged into your branch. (and you only have one commit)

Gareth

> -----Original Message-----
> From: Ian P. McCullough [mailto:ipm+@andrew.cmu.edu] 
> Sent: 16 January 2004 08:26 PM
> To: users@subversion.tigris.org
> Subject: Understanding copying/replacing
> 
> I've been kind of puzzled as to how I shoudl be mapping my particular 
> development situtaion to the subversion branch model.  So far 
> I've been 
> kind of flailing so I figured I'd poll the other users to see 
> if there are 
> any "best practices" out there.
> 
> I develop a web application.  There is a "core application" 
> and then I also 
> make customized versions of the application for various 
> clients.  When I 
> start a new customization project, I make an "svn cp" of my 
> core directory, 
> and then I proceed with the customization work from there.
> 
> The problem I have is that occasionally (read almost daily) I 
> make bug 
> fixes to the core application which then need to be 
> propagated to some or 
> all of the branches.
> 
> It appears to me that "svn merge" is NOT what I want to do 
> here because I 
> dont want any of the custom stuff to be ported back into the 
> core, nor do I 
> want the custom branch to be identical to the core because it 
> may have 
> customizations.  Often these changes include a small change 
> to one file.
> 
> My next thought was that I should "svn rm" the custom version 
> and then "svn 
> cp" the new, fixed version of the file from the core 
> application directory 
> to the custom version directory.  This is what I have been 
> doing, however 
> when working with multiple files, this gets very tedious.  
> Also it seems 
> that every time you execute an "svn rm" on a URL it wants to 
> commit.  So if 
> I want to delete 100 files (but not a whole directory), its 
> going to end up 
> committing 100 times.  I know that version numbers are 
> arbitrary, but this 
> seems like a great way to make the history unusably large 
> really quickly.
> 
> Next it seems that if I try to do the rm/cp solution in a 
> working copy that 
> its going to take two commits.  Is there no way to replace a 
> file with 
> another file in one commit?
> 
> I also tried, for a while, "OS copying" the new version over 
> the working 
> copy in the custom branch, which works great but then its not 
> clear from 
> looking at the history that the file has been replaced by a 
> version from 
> the main branch since the original creation of that custom branch.
> 
> Overall the best solution so far seems to be "svn rm; svn cp" 
> procedure 
> along with all the commits that procedure entails... Am I 
> missing something?
> 
> Thanks,
> Ian
> 
> ----------------------------------------------------------------
> Ian P. McCullough
> Sr. Information Systems Specialist
> Center for Arts Management and Technology (CAMT)
> H. John Heinz III School of Public Policy and Management
> Carnegie Mellon University
> Pittsburgh, PA 15213-3890
> (412) 268-3748
> FAX (412) 268-3590
> ipm@andrew.cmu.edu
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: users-help@subversion.tigris.org
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org