private Map fetchLockTokens(SVNRepository repository, Map pathsTokensMap) throws SVNException { Map tokens = new HashMap(); for (Iterator paths = pathsTokensMap.keySet().iterator(); paths.hasNext();) { String path = (String) paths.next(); SVNLock lock = repository.getLock(path); if (lock == null || lock.getID() == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_MISSING_LOCK_TOKEN, "''{0}'' is not locked", path); SVNErrorManager.error(err); continue; } tokens.put(path, lock.getID()); } return tokens; }
SVNLock lock = repos.getLock(""); if (lock != null) { locksMap.put(lock.getPath(), lock);
if (headURL.equals(url)) { try { lock = repos.getLock(""); } catch (SVNException e) { if (!(e.getErrorMessage() != null && e.getErrorMessage().getErrorCode() == SVNErrorCode.RA_NOT_IMPLEMENTED)) {
private Map<String, String> fetchLockTokens(SVNRepository repository, Map<String, String> pathsTokensMap) throws SVNException { Map<String, String> tokens = new SVNHashMap(); for (Iterator<String> paths = pathsTokensMap.keySet().iterator(); paths.hasNext();) { String path = paths.next(); SVNLock lock = repository.getLock(path); if (lock == null || lock.getID() == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_MISSING_LOCK_TOKEN, "''{0}'' is not locked", path); SVNErrorManager.error(err, SVNLogType.WC); continue; } tokens.put(path, lock.getID()); } return tokens; }
lock = repos.getLock(""); } catch (SVNException e) { if (!(e.getErrorMessage() != null &&
private Map fetchLockTokens(SVNRepository repository, Map pathsTokensMap) throws SVNException { Map tokens = new SVNHashMap(); for (Iterator paths = pathsTokensMap.keySet().iterator(); paths.hasNext();) { String path = (String) paths.next(); SVNLock lock = repository.getLock(path); if (lock == null || lock.getID() == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_MISSING_LOCK_TOKEN, "''{0}'' is not locked", path); SVNErrorManager.error(err, SVNLogType.WC); continue; } tokens.put(path, lock.getID()); } return tokens; }
lock = repos.getLock(""); } catch (SVNException e) { if (!(e.getErrorMessage() != null &&
private Map fetchLockTokens(SVNRepository repository, Map pathsTokensMap) throws SVNException { Map tokens = new SVNHashMap(); for (Iterator paths = pathsTokensMap.keySet().iterator(); paths.hasNext();) { String path = (String) paths.next(); SVNLock lock = repository.getLock(path); if (lock == null || lock.getID() == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_MISSING_LOCK_TOKEN, "''{0}'' is not locked", path); SVNErrorManager.error(err, SVNLogType.WC); continue; } tokens.put(path, lock.getID()); } return tokens; }
if (headURL.equals(url)) { try { lock = repository.getLock(""); } catch (SVNException e) { if (!(e.getErrorMessage() != null && e.getErrorMessage().getErrorCode() == SVNErrorCode.RA_NOT_IMPLEMENTED)) {
private Map fetchLockTokens(SVNRepository repository, Map pathsTokensMap) throws SVNException { Map tokens = new SVNHashMap(); for (Iterator paths = pathsTokensMap.keySet().iterator(); paths.hasNext();) { String path = (String) paths.next(); SVNLock lock = repository.getLock(path); if (lock == null || lock.getID() == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_MISSING_LOCK_TOKEN, "''{0}'' is not locked", path); SVNErrorManager.error(err, SVNLogType.WC); continue; } tokens.put(path, lock.getID()); } return tokens; }
public SVNLock getLock() throws SVNException { return getRepository().getLock(getResourceURI().getPath()); }
public void run() throws SVNException { List targets = getEnvironment().combineTargets(null, false); if (!targets.isEmpty()) { targets.remove(0); } String[] locks = (String[]) targets.toArray(new String[targets.size()]); SVNRepository repository = SVNRepositoryFactory.create(SVNURL.fromFile(getLocalRepository())); String userName = System.getProperty("user.name", "administrator"); repository.setAuthenticationManager(new BasicAuthenticationManager(userName, "")); repository.setCanceller(getEnvironment()); for (int i = 0; i < locks.length; i++) { String lockPath = locks[i]; try { SVNLock lock = repository.getLock(lockPath); if (lock == null) { getEnvironment().getOut().println("Path '" + lockPath + "' isn't locked."); continue; } Map pathToToken = new SVNHashMap(); pathToToken.put(lockPath, lock.getID()); repository.unlock(pathToToken, true, this); } catch (SVNException e) { getEnvironment().handleError(e.getErrorMessage()); } } }
public void run() throws SVNException { List targets = getEnvironment().combineTargets(null, false); if (!targets.isEmpty()) { targets.remove(0); } String[] locks = (String[]) targets.toArray(new String[targets.size()]); SVNRepository repository = SVNRepositoryFactory.create(SVNURL.fromFile(getLocalRepository())); String userName = System.getProperty("user.name", "administrator"); repository.setAuthenticationManager(new BasicAuthenticationManager(userName, "")); repository.setCanceller(getEnvironment()); for (int i = 0; i < locks.length; i++) { String lockPath = locks[i]; try { SVNLock lock = repository.getLock(lockPath); if (lock == null) { getEnvironment().getOut().println("Path '" + lockPath + "' isn't locked."); continue; } Map pathToToken = new SVNHashMap(); pathToToken.put(lockPath, lock.getID()); repository.unlock(pathToToken, true, this); } catch (SVNException e) { getEnvironment().handleError(e.getErrorMessage()); } } }
/** * Check to take lock of out-of-date file. * * @throws Exception */ @Test(dataProvider = "all", dataProviderClass = SvnTesterDataProvider.class) public void lockSimple(@NotNull SvnTesterFactory factory) throws Exception { try (SvnTester server = factory.create()) { final SVNRepository repo = server.openSvnRepository(); createFile(repo, "/example.txt", "", propsEolNative); final long latestRevision = repo.getLatestRevision(); createFile(repo, "/example2.txt", "", propsEolNative); Assert.assertNull(repo.getLock("example.txt")); // New lock final SVNLock lock = lock(repo, "example.txt", latestRevision, false, null); Assert.assertNotNull(lock); compareLock(repo.getLock("example.txt"), lock); // Already locked lock(repo, "example.txt", latestRevision, false, SVNErrorCode.FS_PATH_ALREADY_LOCKED); // Lock must not changed compareLock(repo.getLock("example.txt"), lock); unlock(repo, lock, false, null); Assert.assertNull(repo.getLock("example.txt")); // Lock again lock(repo, "example.txt", latestRevision, false, null); } }
/** * Check to break lock. * * @throws Exception */ @Test(dataProvider = "all", dataProviderClass = SvnTesterDataProvider.class) public void unlockForce(@NotNull SvnTesterFactory factory) throws Exception { try (SvnTester server = factory.create()) { final SVNRepository repo = server.openSvnRepository(); createFile(repo, "/example.txt", "", propsEolNative); final long latestRevision = repo.getLatestRevision(); SVNLock oldLock = lock(repo, "example.txt", latestRevision, false, null); Assert.assertNotNull(oldLock); unlock(repo, oldLock, false, null); SVNLock newLock = lock(repo, "example.txt", latestRevision, true, null); Assert.assertNotNull(newLock); compareLock(newLock, repo.getLock("example.txt")); unlock(repo, oldLock, true, null); Assert.assertNull(repo.getLock("example.txt")); } }
/** * Check to stealing lock. * * @throws Exception */ @Test(dataProvider = "all", dataProviderClass = SvnTesterDataProvider.class) public void lockForce(@NotNull SvnTesterFactory factory) throws Exception { try (SvnTester server = factory.create()) { final SVNRepository repo = server.openSvnRepository(); createFile(repo, "/example.txt", "", propsEolNative); final long latestRevision = repo.getLatestRevision(); SVNLock oldLock = lock(repo, "example.txt", latestRevision, false, null); Assert.assertNotNull(oldLock); compareLock(oldLock, repo.getLock("example.txt")); SVNLock badLock = lock(repo, "example.txt", latestRevision, false, SVNErrorCode.FS_PATH_ALREADY_LOCKED); Assert.assertNull(badLock); compareLock(oldLock, repo.getLock("example.txt")); SVNLock newLock = lock(repo, "example.txt", latestRevision, true, null); Assert.assertNotNull(newLock); compareLock(newLock, repo.getLock("example.txt")); } }
/** * Check for commit with keep locks. * * @throws Exception */ @Test(dataProvider = "all", dataProviderClass = SvnTesterDataProvider.class) public void modifyLockedRemoveLock(@NotNull SvnTesterFactory factory) throws Exception { try (SvnTester server = factory.create()) { final SVNRepository repo = server.openSvnRepository(); createFile(repo, "/example.txt", "", propsEolNative); final long latestRevision = repo.getLatestRevision(); // Lock final SVNLock lock = lock(repo, "example.txt", latestRevision, false, null); Assert.assertNotNull(lock); { final Map<String, String> locks = new HashMap<>(); locks.put("/example.txt", lock.getID()); final ISVNEditor editor = repo.getCommitEditor("Intital state", locks, false, null); editor.openRoot(-1); editor.openFile("/example.txt", latestRevision); sendDeltaAndClose(editor, "/example.txt", "", "Source content"); editor.closeDir(); editor.closeEdit(); } Assert.assertNull(repo.getLock("/example.txt")); } }
/** * Check for commit with remove locks. * * @throws Exception */ @Test(dataProvider = "all", dataProviderClass = SvnTesterDataProvider.class) public void modifyLockedKeepLock(@NotNull SvnTesterFactory factory) throws Exception { try (SvnTester server = factory.create()) { final SVNRepository repo = server.openSvnRepository(); createFile(repo, "/example.txt", "", propsEolNative); final long latestRevision = repo.getLatestRevision(); // Lock final SVNLock lock = lock(repo, "example.txt", latestRevision, false, null); Assert.assertNotNull(lock); { final Map<String, String> locks = new HashMap<>(); locks.put("/example.txt", lock.getID()); final ISVNEditor editor = repo.getCommitEditor("Intital state", locks, true, null); editor.openRoot(-1); editor.openFile("/example.txt", latestRevision); sendDeltaAndClose(editor, "/example.txt", "", "Source content"); editor.closeDir(); editor.closeEdit(); } compareLock(repo.getLock("/example.txt"), lock); } }
Assert.assertEquals(e.getErrorMessage().getErrorCode(), SVNErrorCode.FS_BAD_LOCK_TOKEN); compareLock(server.openSvnRepository().getLock("/example.txt"), newLock);