简体   繁体   中英

Simulating multiple SVN users on a windows computer

How can I simulate multiple SVN users on a Windows computer for learning SVN?

I'm using the book Version Control by Example by Eric Sink , and want to be able to do all the stuff from page 17 to 20 from one computer, preferably Windows (though I do have Linux as well if need be).

EDIT - I will be adding updating my follow up questions to this question in the comments right below the question. I hope that this will prepare other readers to setup everything correctly to use this book.

My 2 cents.

The whole thing sounds overly complicated. Here's an easy way to do it:

  1. Use svnadmin create to create a repository.
  2. Go into the repo's conf folder. You'll see a passwd and a svnserve.conf file.
  3. In the svnserve.conf file. Look for the line # password-db = passwd and remove the # in front. This was line #27 in my repo.
  4. Open the passwd file, and create multiple logins. They show you two examples, sally and harry . The format is <user> = <password> .
  5. Save the file, and go to the parent directory of your repository.
  6. Run the svnserve -r <repoName> command. Don't close this Window. Instead open another console window to run the other commands below.
  7. Go into another directory, and do a checkout using the svn:// protocol. Add the --username and --password parameter when you do a checkout. This will checkout the repo to the user whom you named.
  8. Go into yet another directory and do another checkout using the svn:// protocol with the --username and --password pointing to yet another user.

Each working directory will be default for those two users. The important thing is not to use file:/// as a protocol. Use svn:// :

C:> svn co --username harry --password harrysecret svn://localhost

By default, the commit will be of the user who did the checkout. The first checkout you do will be the root of the repo. You should add in the trunk , branches , and tags directory to simulate an actual Subversion repository structure.

The file:/// protocol is used for basic testing if you don't want to run a server. It should never be used by multiple users, and you should never run a real repository with it. (The main thing it's used for are for web-based repository browsers like [ViewVC]( http://www.viewvc.org because file:/// is very fast.) There's really little need for file:/// because svnserve is fairly easy to get up and running. And, you can even make it a Windows service .


Following the Exercises in the Book

I added a bounty. Here is the book - ericsink.com/vcbe/vcbe_a4_lo.pdf. I want to be able to do all the stuff from page 17 to 20 from one computer, preferably windows. I have linux as well if need be

The book makes some assumptions about the computer you're using (Looks like a Mac), and is a bit confusing as it switches from Harry to Sally and back. We'll simplify this by using one Console window when you are Sally and one when you are Harry .

You need to get a good Windows text editor. Do not use Notepad!! . Notepad is not a programming editor. Get Notepad++ . It's GUI oriented, and simple, but powerful. It's also open source and free.

Below I list the differences between the directions in the book and what you'd do on your Windows box. I'm assuming you have Administrator access on your Windows box.

Page 15

Creating the Repository on a Windows computer. We'll create the repo under C:\\repos\\lottery>:

C:\> mkdir repos
C:\> cd repos
C:\repos> svnadmin create lottery
C:\repos> cd lottery\conf
C:\repos\lottery\conf> notepad++ svnserver.conf

You will find the line that sets where you are setting the password database. It's line #27 in my repository. You'll see the # . Remove this from the line. The # comments out the line. You want the line to read password-db = passwd . Then save the file. This tells the Subversion server process that the file passwd will contain the users and passwords for your repository.

Now edit the passwd file with notepad++ . You want it to look like this:

### This file is an example password file for svnserve.
### Its format is similar to that of svnserve.conf. As shown in the
### example below it contains one section labelled [users].
### The name and password for each user follow, one account per line.

[users]
harry = harryssecret
sally = sallyssecret

All I did was remove the comment sign ( # ) from the two example users. Save the passwd file. Your repository has two users that are allowed to commit and make changes. Sally's password is sallysecret and Harry's password is harrysecret .

You currently are in the directory C:\\repos\\lottery\\conf . Let's fire up the repo:

C:\repos\lottery\conf> cd C:\>
C:\> svnserve -d --root=repos

Page 16:

On the same machine, go make a directory called C:\\workdirs . This is where we'll make Harry's and Sally's working directories. Open another Console Window for this. This Console Window will be for Harry's work:

C:\> cd \
C:\> mkdir workdirs
C:\> cd workdirs
C:\workdirs> mkdir harry

Now, do Harry's Checkout:

C:\workdirs> cd harry
C:\workdirs\harry> svn co --username harry --password harrysecret svn://localhost/lottery

You may get asked if you want to store the passwords in your client configuration, and a warning that they'll be stored in plaintext. Go ahead and say yes to those questions. This way, you don't have to keep entering in the password each time.

Now go into Harry's working directory

C:\workdirs\harry> cd lottery

You're now in Harry's working directory.

Don't touch the .svn directory! This stores the information on your working copy: Who checked it out. What repository. What version, etc.

You should be able to do everything until you get down to Chapter 3 on the bottom of Page 17:

Now, create Sally's working directory:

Open another Console window. You now have three console windows open:

  1. This is the svnserve process that's running. Closing this window will shut down svnserve . You can minimize this.
  2. This is Harry's working copy.
  3. This will be Sally's working copy.

It's easier to keep everything in separate Console windows. In fact, you can change the window color scheme to help you quickly recognize which window you're in. Create Sally's working copy:

C:\> cd \workdirs
C:\workdirs> mkdir sally
C:\workddirs> cd sally

C:\workdirs\sally> svn co --username sally svn://localhost/lottery
password: •••••••

Because you didn't use the --password parameter, you're asked for Sally's password. Again, if you're asked about storing the passwords, go ahead and say yes for now. This way, you don't have to keep typing in Sally's password.

Finally:

C:\\workdirs\\sally> cd lottery

This is Sally's working directory.

You should be fine using Sally's Window to Page 19 when we switch back to Harry's working copy.

From now on, if you are working with Harry's working copy, simply switch to Harry's window. If you are working as Sally, switch to Sally's window. Everything else should be fine, and just follow the examples all the way through.

If you want to simulate multiple users working on the same project, then you can setup a Subversion + Apache HTTP Server package (VisualSVN Server, SVN Edge) and then use multiple working copies under different users to "work" on the project.

I don't actually see any practical or learning value in your instruction.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM