3

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.

Steam
  • 9,368
  • 27
  • 83
  • 122

2 Answers2

8

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.

Community
  • 1
  • 1
David W.
  • 105,218
  • 39
  • 216
  • 337
  • 1
    OK, but "1. Install VisualSVN Server 2. Add 2 users in GUI" will be shorter way :-) – Lazy Badger Dec 26 '14 at 11:16
  • @LazyBadger - Thats what I did before I got this answer. I had no clue what to do after that. – Steam Dec 28 '14 at 02:35
  • @DavidW - What does this code `password-db = passwd` do ? I'll be running steps soon and giving feedback. – Steam Dec 28 '14 at 02:38
  • 1
    That tells `svnserve` (after all, it's the `svnserve.conf` file!) that the password database is in a file called `passwd`. Removing the `#` in front makes the line active. Then you add the users in `passwd`. You can use a different working directory (checkout) for each user. – David W. Dec 29 '14 at 04:24
  • @DavidW. - The svnserve command needs to be changed to `svnserve -d -r `. Otherwise, you get the error - You must specify exactly one of -d, -i, -t, --service or -X. Type 'svnserve --help' for usage. – Steam Dec 31 '14 at 23:49
  • @DavidW. - Step 7 "Go into another directory". Which directory ? Would any random directory do ? "This will checkout the repo to the user whom you named." Where is the directory for this repo ? – Steam Dec 31 '14 at 23:53
  • Create two directories called harry and sally somewhere,say in the parent directory of your svn repo. Then, do the checkouts for each user into their respective directories. – Steam Jan 01 '15 at 00:04
  • @Steam Are each user a separate project? Multiple users can use the same _repo_. – David W. Jan 01 '15 at 00:32
  • @DavidW. - I don't understand what this means - each user a separate project. This is what the book author does first `~ harry$ svn checkout svn://server.futilisoft.com/lottery` for harry. Then, he does some commiting and after that `~ sally$ svn checkout svn://server.futilisoft.com/lottery`. So, I thought I should make separate folders for each user where he can keep his copy of the repo. – Steam Jan 01 '15 at 00:37
  • 1
    @Steam About the `svnserve` command. Try it with `svnserve -d -r `. That's what I use Unix/Linux/Mac. However, Windows doesn't have the concept of `daemons`, and since you're not making this a service, I figure you wouldn't want any options. Try the `-d`, but I bet the `svnserve` still runs in the foreground, so don't close the console window. Or try it with `-X` instead of `-d` which is the debug mode. – David W. Jan 01 '15 at 00:37
  • @Steam Don't create separate folders in the repo. The whole purpose of version control is to let multiple people edit the same files and project in an organized way. Both will checkout the same URL. However, each user should have their own folders for their checkout. – David W. Jan 01 '15 at 00:40
  • @DavidW. - I did not create in repo. I made two user folders in folder above repo folder. Now, people can checkout their code to their own folders - harry and sally respectively. Thanks. – Steam Jan 01 '15 at 00:41
  • @DavidW. - I am now having problems. The author does this - `~ harry$ svn checkout svn://server.futilisoft.com/lottery` and `~ harry$ cd lottery`. When I do the second command, i get an error - `The system cannot find the path specified.` – Steam Jan 01 '15 at 00:46
  • @DavidW. - I added a bounty. Here is the book - http://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. – Steam Jan 01 '15 at 02:25
  • @Steam See **Following the Book Exercises** addendum on my answer. These are changes to the book's directions. – David W. Jan 01 '15 at 22:11
  • On a Windows box, you can run as a service by using the SRVANY.EXE (see https://support.microsoft.com/KB/137890). I have had success with this method in the past. – user700390 Jan 07 '15 at 18:29
  • @DavidW. - One last question. In page17, harry makes some C code and checks it into the repo. Which folder do I put the C code in and where do I put the compiled code ? Do both need to be checked into repo, or only the C code. Thank you very much. You saved me !!! – Steam Jan 07 '15 at 22:16
  • PS - I did not enable the passwords. For anyone learning this, note that the SVN client and svn server versions should be the same, otherwise, when you checkout into harry, you get the error given here - https://stackoverflow.com/questions/17259360/subversion-svn-e160043-expected-fs-format-between-1-and-4 . NOTE that I did this on windows 7 64 bit. I will try to get a commandline based C-compiler for windows or use gcc of MinGW. Lets see where this goes. – Steam Jan 07 '15 at 22:17
  • Don't check compiled code into Subversion or any version control system. It takes up a lot of room in the repository and isn't necessary. You have the source, and you can create the compiled code from that. – David W. Jan 08 '15 at 00:41
  • NOTE - Put a user's code inside his lottery folder. Then do the check in. – Steam Jan 08 '15 at 01:25
  • @DavidW. - Sorry ! One last question - Would it help to create that trunk, branch etc. folder structure ? Thanks! – Steam Jan 08 '15 at 01:26
  • You usually have that trunk, tags, branches somewhere in your repo. Either at the root of the repo, or the root of all projects in your repo. In this lesson, it wasn't done. – David W. Jan 08 '15 at 01:47
  • @DavidW. - When I run the command on page 18 - lottery harry$ svn commit -m "initial implementation", I get the error in the below comment. Could this be because I did not set passwords for harry and sally ? – Steam Jan 08 '15 at 23:14
  • `c:\workdirs\harry\lottery>svn commit -m "initial implementation" Authentication realm: some-code-here Password for 'steam': **** Authentication realm: some-code-here Username: steam Password for 'steam': **** Authentication realm: some-code-here Username: harry Password for 'harry': svn: E170001: Commit failed (details follow): svn: E170001: Unable to connect to a repository at URL 'svn://localhost/lottery' svn: E170001: Authentication error from server: Username not found` – Steam Jan 08 '15 at 23:14
  • It could be. The `svnserve.conf` has two important configurations in it: Do you want anonymous read/write or read access? (default is read-only), and what file you're using for authentication (if you're using one). I told you to set it up for harry and sally with passwords. BTW, who is steam and why are you being asked about steam's password? – David W. Jan 08 '15 at 23:24
  • @DavidW. - Steam is the name of a windows 7 user account, for me. – Steam Jan 15 '15 at 22:33
  • Subversion and Windows are using two different sets of accounts. You can setup a "steam" account in the `passwd` file, but it will use the password set in the `passwd` file. You can setup Subversion using LDAP that can connect to your Windows Active Directory server, but that's a bit tricker to do, and not when you're learning SVN. – David W. Jan 16 '15 at 14:03
  • It now WORKS !!! Steps - Install visual svn server. Create repo and users in the same locations, but only using the visual svn interface and not commands. Then, create the workdirs folder with its two users and follow the answer. This was my svn server `https://localhost/svn/lottery/`. Now, check out and commit using this server and the commands given in David's answer. Related post - https://stackoverflow.com/questions/27975987/cannot-connect-to-local-svn-server. – Steam Jan 16 '15 at 17:12
  • @DavidW. - David, I have one new problem in this book. Can you please help ? https://stackoverflow.com/questions/28035602/resolving-a-merge-conflict-when-i-do-svn-update – Steam Jan 20 '15 at 00:00
2

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.

bahrep
  • 29,961
  • 12
  • 103
  • 150
  • "different *windows-users*" is single weak point. Can be avoided – Lazy Badger Dec 23 '14 at 17:57
  • @LazyBadger I regret that I don't fully understand the comment T__T – bahrep Dec 23 '14 at 18:27
  • If you use sifferent SVN-users under the same Windows users - without additional tricks SVN will remember auth details for first SVN-user (`# store-auth-creds = no` by default in config) and use it later in ech and every WC of this Win-user. Single repo, single Win-iser, many SVN-users means *uncommented* `store-auth-creds = no` – Lazy Badger Dec 23 '14 at 18:37
  • @bahrep - How do I simulate the same svn commandline codes with the visual svn server gui ? – Steam Dec 25 '14 at 19:00
  • @bahrep - My progress so far - Created two users harry and sally. Created a lottery repo which is accessible to all users. Now, how do I make harry checkout the blank repo ? – Steam Dec 25 '14 at 19:15