myUpdateClient = new SVNUpdateClient(scp);
myUpdateClient = new SVNUpdateClient(scp, new UpdateEventListener());
    public static void main(String[] args) {        /*         * Default values:         */        /*         * Assuming that svn://localhost/rep already exists while         * MyRepos is to be created         */        String url = "svn://localhost/rep/MyRepos";        String copyURL = "svn://localhost/rep/MyReposCopy";        String myWorkingCopyPath = "/MyWorkingCopy";        String name = "userName";        String password = "userPassword";        String newDir = "/newDir";        String newFile = newDir + "/" + "newFile.txt";        byte[] fileText = "This is a new file added to the working copy"                .getBytes();        /*         * Initializes the library (it must be done before ever using the         * library itself)         */        setupLibrary();        if (args != null) {            /*             * Obtains a URL that represents a new directory relative to an existing              * path in a repository             */            url = (args.length >= 1) ? args[0] : url;            /*             * Obtains a URL where a copy of the previuos url will be created (with             * history)             */            copyURL = (args.length >= 2) ? args[1] : copyURL;            /*             * Obtains a path to be a working copy root directory             */            myWorkingCopyPath = (args.length >= 3) ? args[2] : myWorkingCopyPath;            /*             * Obtains an account name              */            name = (args.length >= 4) ? args[3] : name;            /*             * Obtains a password             */            password = (args.length >= 5) ? args[4] : password;        }        /*         * Creates a usre's credentials provider.         */        ISVNCredentialsProvider scp = new SVNSimpleCredentialsProvider(name,                password);                /*         * The following 'SVN*Client' objects come from org.tmatesoft.svn.core.io         * package and are only a part of that client's high-level API indended for          * managing working copies.             */                /*         * passing credentials provider when creating an instance of         * SVNCommitClient         */        myCommitClient = new SVNCommitClient(scp);        /*         * passing credentials provider when creating an instance of         * SVNCopyClient         */        myCopyClient = new SVNCopyClient(scp);        /*         * passing credentials provider when creating an instance of         * SVNWCClient         */        myWCClient = new SVNWCClient(scp);        /*         * passing credentials provider when creating an instance of         * SVNStatusClient         */        myStatusClient = new SVNStatusClient(scp);        /*         * passing credentials provider when creating an instance of         * SVNUpdateClient         */        myUpdateClient = new SVNUpdateClient(scp);        long committedRevision = -1;        System.out.println("Making a new directory at '" + url + "'...");        try{            /*             * creating a new version comtrolled directory in a repository and              * displaying what revision the repository was committed to             */            committedRevision = makeDirectory(url, "making a new directory at '" + url + "'").getNewRevision();        }catch(SVNException svne){            error("error while making a new directory at '" + url + "'", svne);        }        System.out.println("Committed to revision " + committedRevision);        System.out.println();                /*         * creates a local directory where the working copy will be checked out         */        File wcDir = new File(myWorkingCopyPath);        if (wcDir.exists()) {            error("the destination directory '"                    + wcDir.getAbsolutePath() + "' already exists!", null);        }        wcDir.mkdirs();        System.out.println("Checking out a working copy from '" + url + "'...");        long checkoutRevision = -1;        try {            /*             * recursively checking out a working copy from url into wcDir,             * SVNRevision.HEAD means the latest revision to be checked out              */            checkoutRevision = checkout(url, SVNRevision.HEAD, wcDir, true);        } catch (SVNException svne) {            error("error while checking out a working copy for the location '"                            + url + "'", svne);        }        System.out.println("Checked out revision " + checkoutRevision);        System.out.println();                /*         * recursively displaying info for wcDir at the current working revision          * in the manner of 'svn info -R' command         */        try {            showInfo(wcDir, SVNRevision.WORKING, true);        } catch (SVNException svne) {            error("error while recursively getting info for the working copy at'"                    + wcDir.getAbsolutePath() + "'", svne);        }        System.out.println();        /*         * creating a new local directory - "wcDir/newDir"         */        File aNewDir = new File(wcDir, newDir);        if (!aNewDir.mkdirs()) {            error("failed to create a new directory '" + aNewDir.getAbsolutePath() + "'.", null);        }        /*         * creating a new file - "/MyWorkspace/newDir/newFile.txt"         */        File aNewFile = new File(aNewDir, PathUtil.tail(newFile));        try {            if (!aNewFile.createNewFile()) {                error("failed to create a new file '"                        + aNewFile.getAbsolutePath() + "'.", null);            }        } catch (IOException ioe) {            aNewFile.delete();            error("error while creating a new file '"                    + aNewFile.getAbsolutePath() + "'", ioe);        }        /*         * writing a text into the file         */        FileOutputStream fos = null;        try {            fos = new FileOutputStream(aNewFile);            fos.write(fileText);        } catch (FileNotFoundException fnfe) {            error("the file '" + aNewFile.getAbsolutePath() + "' is not found", fnfe);        } catch (IOException ioe) {            error("error while writing into the file '"                    + aNewFile.getAbsolutePath() + "'", ioe);        } finally {            if (fos != null) {                try {                    fos.close();                } catch (IOException ioe) {                    //                }            }        }        System.out.println("Recursively scheduling a new directory '" + aNewDir.getAbsolutePath() + "' for addition...");        try {            /*             * recursively scheduling aNewDir for addition             */            addEntry(aNewDir);        } catch (SVNException svne) {            error("error while recursively adding the directory '"                    + aNewDir.getAbsolutePath() + "'", svne);        }        System.out.println();        boolean isRecursive = true;        boolean isRemote = false;        boolean isReportAll = false;        boolean isIncludeIgnored = true;        boolean isCollectParentExternals = true;        System.out.println("Status for '" + wcDir.getAbsolutePath() + "':");        try {            /*             * status will be recursive on wcDir, won't cover the repository              * (only local status), won't cover unmodified entries, will disregard             * svn:ignore property ignores (if any), won't ignore externals definitions             * (if any as well)             */            showStatus(wcDir, isRecursive, isRemote, isReportAll,                    isIncludeIgnored, isCollectParentExternals);        } catch (SVNException svne) {            error("error while recursively performing status for '"                    + wcDir.getAbsolutePath() + "'", svne);        }        System.out.println();        System.out.println("Updating '" + wcDir.getAbsolutePath() + "'...");        long updatedRevision = -1;        try {            /*             * recursively updates wcDir to the latest revision (SVNRevision.HEAD);             * it's useful to do in real life as a working copy may contain out             * of date entries:)              */            updatedRevision = update(wcDir, SVNRevision.HEAD, true);        } catch (SVNException svne) {            error("error while recursively updating the working copy at '"                    + wcDir.getAbsolutePath() + "'", svne);        }        System.out.println("Updated to revision " + updatedRevision);        System.out.println();        System.out.println("Committing changes for '" + wcDir.getAbsolutePath() + "'...");        try {            /*             * commiting changes in wcDir to the repository with saving items locked             * after the commit succeeds (if they were locked); this will add             * aNewDir & aNewFile to the repository.              */            committedRevision = commit(wcDir, true,                    "'/newDir' with '/newDir/newFile.txt' were added")                    .getNewRevision();        } catch (SVNException svne) {            error("error while committing changes to the working copy at '"                    + wcDir.getAbsolutePath()                    + "'", svne);        }        System.out.println("Committed to revision " + committedRevision);        System.out.println();        System.out                .println("Locking (with stealing if the entry is already locked) '"                        + aNewFile.getAbsolutePath() + "'.");        try {            /*             * locking aNewFile with stealing (if it has been already locked by someone             * else) and a lock comment             */            lock(aNewFile, true, "locking '/newDir'");        } catch (SVNException svne) {            error("error while locking the working copy file '"                    + aNewFile.getAbsolutePath() + "'", svne);        }        System.out.println();        System.out.println("Status for '" + wcDir.getAbsolutePath() + "':");        try {            /*             * displaying status once again to see the file is really locked             */            showStatus(wcDir, isRecursive, isRemote, isReportAll,                    isIncludeIgnored, isCollectParentExternals);        } catch (SVNException svne) {            error("error while recursively performing status for '"                    + wcDir.getAbsolutePath() + "'", svne);        }        System.out.println();        System.out.println("Copying '" + url + "' to '" + copyURL + "'...");        try {            /*             * making a branch of url at copyURL - that is URL->URL copying             * with history; not moving url, only copying;             *              * checkoutRevision is to concretize url             */            committedRevision = copy(url,                    SVNRevision.create(checkoutRevision), copyURL, false,                    "remotely copying '" + url + "' to '" + copyURL + "'")                    .getNewRevision();        } catch (SVNException svne) {            error("error while copying '" + url + "' to '"                    + copyURL + "'", svne);        }       /*        * displaying what revision the repository was committed to        */        System.out.println("Committed to revision " + committedRevision);        System.out.println();        System.out.println("Switching '" + wcDir.getAbsolutePath() + "' to '"                + copyURL + "'...");        try {            /*             * recursively switching wcDir to copyURL to the latest revision              * (SVNRevision.HEAD)             */            updatedRevision = switchToURL(wcDir, copyURL,                    SVNRevision.HEAD, true);        } catch (SVNException svne) {            error("error while switching '"                    + wcDir.getAbsolutePath() + "' to '" + copyURL + "'", svne);        }        System.out.println("Updated to revision " + updatedRevision);        System.out.println();        /*         * recursively displaying info for the working copy once again to see         * it was really switched to a new URL         */        try {            showInfo(wcDir, SVNRevision.WORKING, true);        } catch (SVNException svne) {            error("error while recursively getting info for the working copy at'"                    + wcDir.getAbsolutePath() + "'", svne);        }        System.out.println();        System.out.println("Scheduling '" + aNewDir.getAbsolutePath() + "' for deletion ...");        try {            /*             * forcing aNewDir to be scheduled for deletion             */            delete(aNewDir, true);        } catch (SVNException svne) {            error("error while schediling '"                    + wcDir.getAbsolutePath() + "' for deletion", svne);        }        System.out.println();        System.out.println("Status for '" + wcDir.getAbsolutePath() + "':");        try {            /*             * recursively displaying status once more to see whether aNewDir             * was really scheduled for deletion               */            showStatus(wcDir, isRecursive, isRemote, isReportAll,                    isIncludeIgnored, isCollectParentExternals);        } catch (SVNException svne) {            error("error while recursively performing status for '"                    + wcDir.getAbsolutePath() + "'", svne);        }        System.out.println();        System.out.println("Committing changes for '" + wcDir.getAbsolutePath() + "'...");        try {            /*             * lastly committing changes in wcDir to the repository; all locked items             * will be unlocked after the commit succeeds; this commit will remove             * aNewDir from the repository.              */            committedRevision = commit(                    wcDir,                    false,                    "deleting '" + aNewDir.getAbsolutePath()                            + "' from the filesystem as well as from the repository").getNewRevision();        } catch (SVNException svne) {            error("error while committing changes to the working copy '"                    + wcDir.getAbsolutePath()                    + "'", svne);        }        System.out.println("Committed to revision " + committedRevision);        System.exit(0);    }