if (copyingRev == toLatestRevision) { copyRevisionProperties(fromRepos, toRepos, toLatestRevision); lastMergedRevision = toLatestRevision;
if (copyingRev < lastMergedRevision || copyingRev > lastMergedRevision + 1 || (toLatestRevision != lastMergedRevision && toLatestRevision != copyingRev)) { SVNErrorMessage err = SVNErrorMessage .create( SVNErrorCode.IO_ERROR, "Revision being currently copied ({0,number,integer}), last merged revision ({1,number,integer}), and destination HEAD ({2,number,integer}) are inconsistent; have you committed to the destination without using svnsync?", new Long[] { new Long(copyingRev), new Long(lastMergedRevision), new Long(toLatestRevision) }); SVNErrorManager.error(err); } else if (copyingRev == toLatestRevision) { if (copyingRev > lastMergedRevision) { copyRevisionProperties(fromRepos, toRepos, toLatestRevision); lastMergedRevision = copyingRev; }
    public void doSynchronize(SVNURL toURL) throws SVNException {        SVNRepository toRepos = createRepository(toURL, true);        checkIfRepositoryIsAtRoot(toRepos, toURL);                SVNException error = null;        lock(toRepos);        try {            SessionInfo info = openSourceRepository(toRepos);            SVNRepository fromRepos = info.myRepository;            long lastMergedRevision = info.myLastMergedRevision;            String currentlyCopying = toRepos.getRevisionPropertyValue(0, SVNRevisionProperty.CURRENTLY_COPYING);            long toLatestRevision = toRepos.getLatestRevision();                        if (currentlyCopying != null) {                long copyingRev = Long.parseLong(currentlyCopying);                                if (copyingRev == toLatestRevision) {                    copyRevisionProperties(fromRepos, toRepos, toLatestRevision);                    lastMergedRevision = toLatestRevision;                    toRepos.setRevisionPropertyValue(0, SVNRevisionProperty.LAST_MERGED_REVISION, SVNProperty.toString(lastMergedRevision));                    toRepos.setRevisionPropertyValue(0, SVNRevisionProperty.CURRENTLY_COPYING, null);                } else if (copyingRev < toLatestRevision) {                    SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "Currently copying rev {0,number,integer} in source is less than latest rev in destination ({1,number,integer})", new Long[] {new Long(copyingRev), new Long(toLatestRevision)});                    SVNErrorManager.error(err);                }            }                        long fromLatestRevision = fromRepos.getLatestRevision();            if (fromLatestRevision < lastMergedRevision) {                return;            }                        for (long currentRev = lastMergedRevision + 1; currentRev <= fromLatestRevision; currentRev++) {                toRepos.setRevisionPropertyValue(0, SVNRevisionProperty.CURRENTLY_COPYING, SVNProperty.toString(currentRev));                ISVNEditor commitEditor = toRepos.getCommitEditor("", null, false, null);                SVNSynchronizeEditor syncEditor = new SVNSynchronizeEditor(commitEditor, toURL, myHandler, currentRev - 1);                ISVNEditor cancellableEditor = SVNCancellableEditor.newInstance(syncEditor, this, getDebugLog());                fromRepos.replay(0, currentRev, true, cancellableEditor);                if (syncEditor.getCommitInfo().getNewRevision() != currentRev) {                    SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "Commit created rev {0,number,integer} but should have created {1,number,integer}", new Long[] {new Long(syncEditor.getCommitInfo().getNewRevision()), new Long(currentRev)});                    SVNErrorManager.error(err);                }                copyRevisionProperties(fromRepos, toRepos, currentRev);                toRepos.setRevisionPropertyValue(0, SVNRevisionProperty.LAST_MERGED_REVISION, SVNProperty.toString(currentRev));                toRepos.setRevisionPropertyValue(0, SVNRevisionProperty.CURRENTLY_COPYING, null);            }        } finally {            try {                unlock(toRepos);            } catch (SVNException svne) {                error = svne;            }        }                if (error != null) {            throw error;        }    }