简体   繁体   中英

SVNKit - commit a working copy and force repository to be an exact copy

Writing a Java application using SVNKit library I'm facing the following problem

_1. Commit

  • a client should commit his working copy who could be outdated
  • After the commit, the repository must contain exactly the same content as the working copy before commit even if working copy was outdated
  • If working copy was outdated, server changes are lost

_ 2. Update

  • a client should update his working copy who could contain local changes
  • After update, working copy must contain exactly the same content as the repository
  • If working copy had local changes they must be lots after update

Is it easily possible using SVNKit library ?

My actual idea for the «forced commit» part

a. Repository side : process a revert to «working copy version»

b. Client side : process an update accepting for any conflicts local changes

c. Client side : process a commit

I'm not sure it will be easy especially for the second point, is there any high-level API method to do that ? «Forced commit» part is the most urgent for me..

My actual idea for the «forced update» part

  • I process a simple update but I'm not sure to lose local changes

      final File localProjectDirectory = new File(localProjectDirectoryPath); final SVNClientManager cm = SVNClientManager.newInstance(new DefaultSVNOptions()); final SVNUpdateClient uc = cm.getUpdateClient(); final SVNRevision svnHeadRevision = SVNRevision.HEAD; final SVNDepth svnRecursiveDepth = SVNDepth.fromRecurse(true); final boolean allowUnversionedObstructions = false; final boolean depthIsSticky = true; uc.doUpdate(localSyncProjectDirectory, svnHeadRevision, svnRecursiveDepth, allowUnversionedObstructions, depthIsSticky); 

Thanks!

Ok this sounds a little bit messy. svn job is that multiple programmers are working on the same source code. so saying you want the repo to become an exact copy of your working copy means you want to delete/revert the changes of the others in the repo. which doesn't make sense. What you are asking is actually an everyday task.you checked out code, changed it a bit, and during that time other people checked out the same code, changed it, and then committed the changes

Now you have to commit your changes in a manner that you won't "undone" the effort of the others, right? Do an svn synchronize using eclipse or whatever svn tool you are using. If you are uncertain, take a backup of the whole project before proceeding to the next section

If there are no CONFLICTS and this is important, then FIRST check out the code from the repository, and SECOND check in your code.

What if there are conflicts, in this case you have to resolve them before updating and committing, so go to the conflicting lines one by one, integrate them into your code, and when you are done with a class/file then mark it as "conflict is resolved".

Once all conflicts have been resolved, then do as described in the first step, ie update from the repo, then commit your code

I'm using SVNnotifier to sync everything together.

http://svnnotifier.tigris.org/ also another program that I forgot the name but I'll get it tomorrow.

Hope it helps!

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