SVN: one working copy, two repositories?

2019-01-22 13:26发布

问题:

I'd like to know how can I set two repositories for my one working copy. I need one repository in my server, so that I can check in/out between two pcs; I need another repository in my local pc, so that I can see the result of diff quickly (my svn server is on a slow shared host)

How can I do that?

回答1:

Have a look at repository replication.

You can set up a cron job to periodically synch from one repository to the other. But you have to make sure that commits only happen to one of the two.

If commits will happen to both repositories, maybe a distributed versioning system such as git, Bazaar or Mercurial is more up your alley? Git, for one, even lets you pull from and push to a Subversion repository directly.



回答2:

Subversion doesn't use network access for its diff operation. This is one of the great benefits of Subversion over CVS. So I'm not sure why you would be encountering that specific problem.

An alternative is to use Git and specifically git-svn on your local PC. You get a full copy of the entire repository history on your local machine, with the ability to diff and view history locally (along with the many other features Git gives you). Whenever possible, I now use git-svn to access Subversion repositories.



回答3:

If you don't have to use SVN, you may be better to use a distributed version control system, such as Mercurial or Git. Each PC will have its own copy of the repository, and changes can be synchronized either directly between PCs or via another copy on a central server. Since each PC has the full repository stored locally you can do diff or any other operation without network access.



回答4:

If your local box is linux, you could create a crontab entry to svn update every X minutes to keep it synced with the server in the background. From there you would have the most recent copy on your local svn server to diff from.



回答5:

You could try using svk as your local client instead of svn. Svk is a pseudo-distributed version control system using svn repositories.

You would use svk to set up a mirror of the repository, synchronise it, and you can diff to your heart's content, as many revisions back as you like and it is all local.

You could also make a branch of the mirrored repository and use that as your checkout, then your commits are also a local-only operation, and when you're ready with a batch of commits you push them to the remote svn repository (and pull other user's changed back, similar to an svn update command).

Two caveats:

  1. Be prepared to use the command line. There is no TortoiseSVK or other GUI to my knowledge.
  2. I've only used svk on linux. If you're using windows, I'm not sure how good the client is.

Other than that, I second using bazaar, mercurial or git as others have suggested. Bazaar is probably the easiest to use, and has a TortoiseBzr GUI which a collegue of mine says is pretty solid.

Git is the hardest to use. It is like the swiss-army knife that is almost wider than it is long, with all the little gadgets and do-dads in it and hanging off it, with the springs so tight that you occasionally slice a finger open trying to prise a blade out.



回答6:

SVN is not inherently suited for such use cases. You'll have to tweak with things here and there (like writing crons). If you want something which works out of the box to suit such use cases, try GIT.



回答7:

I'm not convinced that standard repository replication will give you what you want. With that setup, one proxy is always read-only, and I don't think in your situation that's the case.

You would have to do the svn switch --relocate thing to switch which repository you're looking at just before checkin. Somewhat error prone.

What you're after is a write through proxy.

If you set this up using apache and mod_svn_dav on your local machine, you'll have a local repository which receives all updates and that you can diff against and checkout against easily, but for which all writes go back to the actual repository that everyone else is using and getting updates from.



回答8:

The result of svn diff doesn't depend on the speed of your connection to the server; it's a fully local operation.