[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Commits files to subversion from 2 different directories

From: B. Smith-Mannschott <benpsm_at_gmail.com>
Date: 2007-01-14 19:22:46 CET

On Jan 14, 2007, at 17:27, ying lcs wrote:

> Hi,
> i have 2 directories of source code:
> 1. org-source
> 2. modified-source (org-source + modified source code, don't exactly
> remember which files have changed).
> and i want to use subversion to do version control. Here is what I
> did:
> 1. create a new repository 'source' in subversion
> 2. cd to org-source and
> svn import . file:///srv/svn/repositories/source --message
> "Initial import"
> Then, I want to
> 3: tag all the files in the source with a label called 'VERSION1"
> 4: commit all files in the directory 'modified-source' to subversion
> so that subversion can figure out what files are different. And it
> will create a new version if the files is different and add the files
> to the repository if it is a new file.
> 5. tag all the files in trunk with a label called VERSION2"

> Can you please tell me if step 3 and 4 are possible?

Yes, they are possible. In fact, they sound a lot like the final
assignment for the half-day subversion introduction we're putting
together at my place of work.

OK. Let's assume you start with an empty repository. I've got one
here, and I'm accessing it using the "file" protocol. It's called

Here's what my org-source looks like. Yours will be different, of


First, I'm going to import modified-source into the repository as

$ svn import . file:///Users/bsmith/tmp/lcs-repos/trunk
Adding charles.txt
Adding adam.txt
Adding ben.txt
Adding daria.txt
Committed revision 1.

OK, in order to tag this I'll need a place to put the tag in your
repository. A tags directory will do the trick:

$ svn mkdir file:///Users/bsmith/tmp/lcs-repos/tags
Committed revision 2.

Now I'll tag trunk by copying it to tags under a new name

$ svn cp file:///Users/bsmith/tmp/lcs-repos/trunk \
Committed revision 3.

Now we're going to need to check out a copy of trunk so that we can
modify it with the sources from modified-source.

$ svn co file:///Users/bsmith/tmp/lcs-repos/trunk trunk
A trunk/charles.txt
A trunk/adam.txt
A trunk/ben.txt
A trunk/daria.txt
Checked out revision 3.

This is what my modified-source looks like. You'll notice that
ben.txt is missing and elric.txt is new.


Now, I *could* just copy the contents of modified-source over those
in the copy of trunk that I just checked out, except this wouldn't
detect deletions. I'd miss the fact that modified-source no longer
contains ben.txt.

Instead, I'm going to first remove all working files from trunk.
Notice that this doesn't disturb the .svn administrative directory.
That's important.

$ cd trunk
trunk $ ls
adam.txt ben.txt charles.txt daria.txt
trunk $ rm *.txt

Now, I'll copy the contents of modified-source into the working
copy. Note what svn status tells me once this has been done.

trunk $ cp ../modified-source/*.txt .
trunk $ svn status
? elric.txt
M charles.txt
! ben.txt
M daria.txt

This means that 'elric.txt' is new in modified-source and needs to be
added. 'ben.txt' is missing in modified source and needs to be removed.

trunk $ svn add elric.txt
A elric.txt
trunk $ svn remove ben.txt
D ben.txt

Now svn status comes up clean:

trunk $ svn status
M charles.txt
D ben.txt
A elric.txt
M daria.txt

So, now we commit the changes and tag the result.

trunk $ svn ci .
Deleting ben.txt
Sending charles.txt
Sending daria.txt
Adding elric.txt
Transmitting file data ...
Committed revision 4.

$ svn cp file:///Users/bsmith/tmp/lcs-repos/trunk \

Committed revision 5.

You can now ask the repository for a list of the differences between
your two versions by comparing the tags. I'm using the '--summarize'
option of svn diff, which was introduced in the 1.4 series. If
you're running an older version of svn, just leave it off and you'll
get the full textual differences of the files that have changed.

$ svn --summarize diff file:///Users/bsmith/tmp/lcs-repos/tags/

D file:///Users/bsmith/tmp/lcs-repos/tags/VERSION1/ben.txt
M file:///Users/bsmith/tmp/lcs-repos/tags/VERSION1/charles.txt
A file:///Users/bsmith/tmp/lcs-repos/tags/VERSION1/elric.txt
M file:///Users/bsmith/tmp/lcs-repos/tags/VERSION1/daria.txt

// Ben

To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Sun Jan 14 19:23:13 2007

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.