开发者

svn repository set up

I'm trying to set up a repository on a FreeBSD system for my course project. The code is in ~/OSI, then I type开发者_如何学编程d the following commands:

   % svnadmin create ///home/SVN/repo
   % svn co file:///home/SVN/repo
   % cd ~/OSI
   % chmod -R u+w include
   % svn add include

Then an error "." is not a working copy. Do I have to import ~/OSI to /home/SVN/repo first?


% svnadmin create ///home/SVN/repo
% svn co file:///home/SVN/repo
% cd ~/OSI

You're completely confused by the difference between the Subversion Repository Directory, and your working directory. I've been teaching Subversion for a long time, and this is the most common thing that happens. You cannot use the Subversion repository as your working directory. You'll have to start over because you've probably damaged the repository structure.


One step at a time.

  • Your repository is where the Subversion Server stores all versions of all the files in your repository. You don't touch. You might not even know where this is, and it might not even be on your local machine.
  • Your working directory contains a copy of a particular revision of the repository. This is done through the Subversion Client. This is where you do everything, and it's located on your local machine, usually in a directory under your $HOME.

So, first you need to create a repository. You use the svnadmin command for that. That command does stuff to the repository. The command is:

$ svnadmin create <directoryName>

Notice there's no URL in the command. In fact the svnadmin never takes a URL, only a physical file located on the local machine. Same is true with the svnlook command. These run on the server. In your case, you want to do this:

$ rm -rf /home/SVN/repo    #Remove the old copy if its still there.
$ svnadmin create /home/SVN/repo

Only a single slash is needed in the front. This is the name of a directory. You could have also done this:

$ cd /home/SVN
$ svnadmin create repo

And maybe even this:

$ svnadmin create ~SVN/repo   #Hope you have write access in this dir!

I highly recommend that you use the svnserve as your Subversion repository server. This makes it easier to type in URLs. Plus, it helps separate yourself from the repository location. Beginners find it less confusing.

To do this, you need to do two things:

  1. Edit the /home/SVN/conf/svnserve.conf file.
  2. Create a /hone/SVN/conf/passwd file.

First, editing the svnserve.conf file. You'll need to modify two lines:

There will be two lines (11 and 12 in my version of the file) that look like this:

# anon-access = read
# auth-accesss = write

Remove the # from in front. Actually, this is the default, so it really doesn't matter. If this is your personal repo, you can change anon-access to write. That way, you don't need to log in. I personally keep them both the way they are.

Around line #20 is this:

# password-db = passwd

Again, remove the # from the front of the line. That's it. Save this file.

Now, in the same directory, edit the passwd file. Under the [Users] line put something like this:

 david = swordfish

The david is your User ID. I suggest that you make it the same ID as your Unix ID. The swordfish is the password. Make it whatever you want. If you want others to be able to access this repository, simply put them in here, one user per line, in the same format as your user name and password. Save the passwd file. You'll never have to touch these files again.

Now, we'll start the svnserve. You'll need to do this whenever you restart your system. You might even want to put a startup script under your /etc/init.d directory:

$ svnserve -r /home/SVN/repo -d

(One little detail... Make sure that the user running svnserve owns the directory and all the files under /home/SVN/repo. Otherwise, the svnserve command won't be able to read/write the required files. Since you're doing all of this under your user ID, that should be fine).

That's it, now you can go elsewhere and create a working directory. Do this under YOUR HOME directory. Pretend that /home/SVN/repo doesn't even exist.

 $ cd $HOME
 $ svn co svn://localhost my_workdir
 $ cd my_workdir
 $ svn mkdir trunk tags branches     #Why the hell not?
 $ svn commit -m "Made the basic directory layout"

Somewhere along the line, it might ask for your password. Just put in the same one you used in the passwd file. What you've just done is create your first commit. You created the three base directories trunk, branches, and tags. Did you need to do this? Nope.

Notice that your in the ~/my_workdir and not in /home/SVN/repo. Notice, because I'm using svnserve, I didn't even mention that directory. The /home/SVN/repo is the Server's directory. You don't touch! As I said, it's very possible -- as a client -- you don't even know where it's located.

Now, your import:

 $ cd trunk
 $ cp ~/OSI .
 $ svn add -R OSI

Whoa! No svn import? Nope, we have a working directory (~/my_workdir), so we can simply add the files. The Subversion svn add command will recursively add in the OSI directory and all files and sub directories. You can run the svn status command and verify that all the files were added.

Now, all you have to do is submit your changes:

 $ svn commit -m"Added in OSI files"

Notice that I needed the URL svn://localhost only for the svn co command. My working directory already knows the URL it was checked out from. You can run svn info and see that information.

Now, try this:

 $ cd ~
 $ rm -rf my_workdir

We have completely removed all the work you just did. However, the Subversion repository still has it. Let's check it out again:

 $ svn co svn:/localhost/trunk/OSI

This will create an OSI directory with all of your OSI you've imported into your Subversion repository right there. This is your new working directory. Notice that I specified trunk/OSI. Now, you can do all of your work there, and commit all of your changes.

I hope this helps clarifies things for you. Now, read the on line Subversion User Guide. Now that you've done this, you'll find the beginning chapters making a lot more sense.


Yes. See http://svnbook.red-bean.com/en/1.5/svn.tour.importing.html.


The answer to your question is "Yes", you need to import ~/OSI to /home/SVN/repo first.

After you import that folder into SVN repository, then you can blow away your OSI directory and checkout a fresh workspace from the repository and continue with your next step.

% svn import ~/OSI file://home/SVN/repo/trunk
% rm -rf ~/OSI
% svn co file://home/SVN/repo/trunk/OSI
% cd ~/OSI
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜