1
Vote

SVN workspace corruption after failed SVN UPDATE

description

If you checkout a repo to a local workspace

then add a conflicting file locally which is not yet downloaded.. or manually delete a file which is about to be deleted on the next update..

the update will fail .. expected..

what is not expected is that the next SVN UPDATE command then fails compeltely complaining about local directories not existing.. it looks like SVN reports <open directory> requests back up the tree to the root for some reason.

2014-06-24 21:43:22 10.205.8.163 PROPFIND /PAS/Release/compass/2014.06/os/include - 8180 - 10.205.8.40 SVN/1.4.3+(r23084)+neon/0.25.5 401 2 5 367
2014-06-24 21:43:27 10.205.8.163 PROPFIND /PAS/Release/compass/2014.06/os/include - 8180 pabneptc002\tfs_exporter 10.205.8.40 SVN/1.4.3+(r23084)+neon/0.25.5 404 0 0 1704
2014-06-24 21:43:27 10.205.8.163 PROPFIND /PAS/Release/compass/2014.06/os - 8180 pabneptc002\tfs_exporter 10.205.8.40 SVN/1.4.3+(r23084)+neon/0.25.5 404 0 0 234
2014-06-24 21:43:27 10.205.8.163 PROPFIND /PAS/Release/compass/2014.06 - 8180 pabneptc002\tfs_exporter 10.205.8.40 SVN/1.4.3+(r23084)+neon/0.25.5 404 0 0 237
2014-06-24 21:43:27 10.205.8.163 PROPFIND /PAS/Release/compass - 8180 pabneptc002\tfs_exporter 10.205.8.40 SVN/1.4.3+(r23084)+neon/0.25.5 404 0 0 238
2014-06-24 21:43:28 10.205.8.163 PROPFIND /PAS/Release - 8180 pabneptc002\tfs_exporter 10.205.8.40 SVN/1.4.3+(r23084)+neon/0.25.5 404 0 0 241
2014-06-24 21:43:28 10.205.8.163 PROPFIND /PAS - 8180 pabneptc002\tfs_exporter 10.205.8.40 SVN/1.4.3+(r23084)+neon/0.25.5 404 0 0 239
2014-06-24 21:43:28 10.205.8.163 PROPFIND / - 8180 pabneptc002\tfs_exporter 10.205.8.40 SVN/1.4.3+(r23084)+neon/0.25.5 401 3 0 219
2014-06-24 21:43:28 10.205.8.163 PROPFIND / - 8180 pabneptc002\tfs_exporter 10.205.8.40 SVN/1.4.3+(r23084)+neon/0.25.5 401 3 0 2

This is an example dump.. it will do a propfind up the tree...

i'll do a little more digging.. its quite annoying having your local workspace corrupted

comments

BadBiki wrote Aug 18, 2014 at 4:01 AM

ok got to the bottom of it.

for some reason if it fails a commit or update, the next update requests to continue from where it was last up to.. at a folder path somewhere up or down the tree.. this causes SvnBridge to add entries above the CheckoutRootPath which TOTALLY screws up the report.

the root FolderMetaData element is then set above your checkout root.. and thus reports <OpenDirectory /> to paths above your checkout root.. helpful

I've added a function that will look for this error and resolve it before it gives you the report..
 private static void RemoveItemsBelowCheckoutRoot(string checkoutRootPath, FolderMetaData root)
        {
            foreach (ItemMetaData data in new List<ItemMetaData>(root.Items))
            {
                string nameMatchingSourceItemConvention = data.Name;
                if (data.Name.StartsWith("/"))
                    nameMatchingSourceItemConvention = data.Name.Substring(1);

                // a child of the currently renamed item
                if (!nameMatchingSourceItemConvention.StartsWith(checkoutRootPath, StringComparison.Ordinal)
                   || nameMatchingSourceItemConvention.Equals(checkoutRootPath,StringComparison.Ordinal) )
                {
                    logger.Trace("RemoveItemsBelowCheckoutRoot() nameMatchingSourceItemConvention='{0}' data.Name='{1}' chRoot='{2}'",
                        nameMatchingSourceItemConvention, data.Name, checkoutRootPath);

                    root.Items.Remove(data);

                    if (data is FolderMetaData)
                    {
                        foreach (ItemMetaData subData in ((FolderMetaData)data).Items)
                            root.Items.Add(subData);

                        // Recursively enter this function
                        RemoveItemsBelowCheckoutRoot(checkoutRootPath, root);
                    }
                    else
                    {
                        logger.Trace("RemoveItemsBelowCheckoutRoot() '{0}'", data.Name);
                    }
                } else if (data is FolderMetaData)
                {
                    RemoveItemsBelowCheckoutRoot(checkoutRootPath, (FolderMetaData)data);
                }
            }
        }
add this to
        public void CalculateDiff(string checkoutRootPath, int versionTo, int versionFrom, FolderMetaData checkoutRoot, UpdateReportData updateReportData)
        {
        ...
        RemoveItemsBelowCheckoutRoot(checkoutRootPath, checkoutRoot);
        }
fixed :) w00t!

BadBiki wrote Aug 18, 2014 at 4:01 AM

Oh.. remove the logger references.. i've put in nlog to assist me in this task