| 12 |
|
import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory; |
| 13 |
|
import org.tmatesoft.svn.core.internal.io.fs.FSRepositoryFactory; |
| 14 |
|
import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl; |
| 15 |
+ |
import org.tmatesoft.svn.core.wc.ISVNStatusHandler; |
| 16 |
|
import org.tmatesoft.svn.core.wc.SVNClientManager; |
| 17 |
|
import org.tmatesoft.svn.core.wc.SVNInfo; |
| 18 |
|
import org.tmatesoft.svn.core.wc.SVNRevision; |
| 19 |
+ |
import org.tmatesoft.svn.core.wc.SVNStatus; |
| 20 |
+ |
import org.tmatesoft.svn.core.wc.SVNStatusType; |
| 21 |
|
import org.tmatesoft.svn.core.wc.SVNWCUtil; |
| 22 |
|
|
| 23 |
|
/** |
| 101 |
|
* Local working copy path to compare against |
| 102 |
|
* @return -1: No local working copy yet<br> |
| 103 |
|
* 0: Revisions are equal<br> |
| 104 |
< |
* 1: SVN contains newer revisions |
| 104 |
> |
* 1: SVN contains newer revisions<br> |
| 105 |
> |
* 2: WC has manually deleted files |
| 106 |
|
* @throws Exception |
| 107 |
|
* If destination is not a WC of the given repository |
| 108 |
|
*/ |
| 117 |
|
int remoteRev = getRemoteHeadRevision(repos); |
| 118 |
|
if (remoteRev > localRev) |
| 119 |
|
return 1; |
| 120 |
< |
else |
| 121 |
< |
return 0; |
| 120 |
> |
else { |
| 121 |
> |
if (getMissingFiles(wcDir)) |
| 122 |
> |
return 2; |
| 123 |
> |
else |
| 124 |
> |
return 0; |
| 125 |
> |
} |
| 126 |
|
} else { |
| 127 |
|
return -1; |
| 128 |
|
} |
| 129 |
|
} |
| 130 |
|
|
| 131 |
+ |
private boolean getMissingFiles(File wcDir) { |
| 132 |
+ |
try { |
| 133 |
+ |
final Vector<String> files = new Vector<String>(); |
| 134 |
+ |
svnCManager.getStatusClient().doStatus(wcDir, null, |
| 135 |
+ |
SVNDepth.INFINITY, false, false, false, false, |
| 136 |
+ |
new ISVNStatusHandler() { |
| 137 |
+ |
@Override |
| 138 |
+ |
public void handleStatus(SVNStatus status) |
| 139 |
+ |
throws SVNException { |
| 140 |
+ |
SVNStatusType stat = status |
| 141 |
+ |
.getCombinedNodeAndContentsStatus(); |
| 142 |
+ |
if (stat == SVNStatusType.MISSING |
| 143 |
+ |
|| stat == SVNStatusType.STATUS_MISSING) { |
| 144 |
+ |
files.add(status.getFile().getPath()); |
| 145 |
+ |
} |
| 146 |
+ |
} |
| 147 |
+ |
}, null); |
| 148 |
+ |
return files.size() > 0; |
| 149 |
+ |
} catch (SVNException e) { |
| 150 |
+ |
e.printStackTrace(); |
| 151 |
+ |
} |
| 152 |
+ |
return false; |
| 153 |
+ |
} |
| 154 |
+ |
|
| 155 |
|
private int getRemoteHeadRevision(SVNURL reposUrl) { |
| 156 |
|
try { |
| 157 |
|
SVNInfo info = svnCManager.getWCClient().doInfo(reposUrl, |
| 188 |
|
SVNRevision.create(fromRev + 1), SVNRevision.HEAD, true, |
| 189 |
|
true, 0, new LogEntryHandler(list, reposUrl.getPath())); |
| 190 |
|
} catch (Exception e) { |
| 191 |
< |
if (e.getMessage().startsWith("svn: No such revision ")) |
| 192 |
< |
return null; |
| 193 |
< |
err.println("Error while getting the list of updated files of the location '" |
| 194 |
< |
+ reposUrl + "': " + e.getMessage()); |
| 195 |
< |
e.printStackTrace(); |
| 191 |
> |
if (!e.getMessage().contains("No such revision ")) { |
| 192 |
> |
err.println("Error while getting the list of updated files of the location '" |
| 193 |
> |
+ reposUrl + "': " + e.getMessage()); |
| 194 |
> |
e.printStackTrace(); |
| 195 |
> |
} |
| 196 |
|
} |
| 197 |
|
|
| 198 |
|
return list; |
| 203 |
|
Vector<String> updatedFiles = getUpdatedFilesInRepository(reposUrl, |
| 204 |
|
fromRev); |
| 205 |
|
|
| 174 |
– |
if (updatedFiles == null) |
| 175 |
– |
return true; |
| 176 |
– |
|
| 206 |
|
svnCManager.getUpdateClient().setEventHandler( |
| 207 |
|
new UpdateEventHandler(updatedFiles, listener)); |
| 208 |
|
|