tags:

views:

191

answers:

1

We are using SharpSVN 1.5 dll for our source control functionalites. Our checkout and CheckIn works as follws

Suppose I want to checkout a folder name TEST and its contain 3 files say file1.txt,file2.txt,file3.txt

Step 1:- Checkout file1.txt from SVN repository
Step 2:- Checkout file2.txt from SVN repository
Step 3:- Checkout file3.txt from SVN repository

During file1.txt checkout operation a .svn folder is created in our working folder.This .svn folder contains a file named as entries. This file contains svn repository and checkout file info(We can see it open via notepad). When file2.txt checkout operation happened(Checkout to the same working folder) there is no new .svn folder creation happened. Sharpsvn uses existing .svn fiolder(previous file checkout .svn folder) and append the file2.txt info into entries file. Same thing happened when checkout file3.txt into same working folder.

During checkin operation first checkin file1.txt then file2 then file3. Svn uses the single .svn folder (in working folder)for all these files to checkin.During file1.txt check in ,entries file contains its info so this file comes under svn version control and it could successfuly checked in.Similar way file2.txt and file3.txt

Now we are trying to use SharpSVN 1.6 dll,but facing some issues in checkout and checkin operation.

During file1.txt checkout .svn folder is created and entries file contains file1.txt info.During file2.txt checkout, existing .svn foder is deleted and new .svn folder is created.So entries contains only file2.txt info not file1.txt info.When I am trying to checkin, the last file which I checked out from svn is only checked in to svn.This is because entries file in .svn folder contains only last checked out file info.

I need to get all file info into entries file using sharpsvn 1.6 dll

My code snippet as follows

public string[] CheckOut(string pSCPath, string pComment, string pLocalPath, int pRevisionNum)// Checks out a file from svn
{
    string[] strCheckoutDetails = new string[2];
    Uri uriSCPath = new Uri(pSCPath);
    SvnCheckOutArgs objChkoutargs = new SvnCheckOutArgs();
    objChkoutargs.Revision = pRevisionNum;
    SvnInfoEventArgs info;
    try
    {
        objChkoutargs.Depth = SvnDepth.Empty;
        string strSingleFiletoCheckout = uriSCPath.ToString();

        string strFolderNameofSingleFileSelected = strSingleFiletoCheckout.Remove(strSingleFiletoCheckout.LastIndexOf('/'));
        Uri UriSingleFileCheckout = new Uri(strFolderNameofSingleFileSelected);
        _objSVNClient.CheckOut(uriSingleFileCheckout, pLocalPath,objChkoutargs);   //empty working folder
        SvnTarget target = new Uri(strSingleFiletoCheckout);
        string strFileNameonlyfromUri = strSingleFiletoCheckout.Substring(strSingleFiletoCheckout.LastIndexOf("/") + 1);
        if (!copyFiletoWorkingCopy(pLocalPath, strFileNameonlyfromUri, _objSVNClient)) //make versioned file available to the current working copy - Biju
        {
            pLocalPath = "";
            throw new SharpSvn.SvnException("Checkout Exception"); 
        }
        _objSVNClient.GetInfo(uriSCPath, out info);
        strCheckoutDetails[0] = info.LastChangeRevision.ToString();
    }

    catch (Exception ex)
    {
        pLocalPath = "";
        throw ex;
    }
    strCheckoutDetails[1] = pLocalPath;
    return strCheckoutDetails;
}

Thanks

Reji

+1  A: 

Checking out files directly is not supported in Subversion. What you can do, and what still works in Subversion / SharpSvn 1.6 is:

  • Checkout a directory with depth=empty. This creates a working copy with no files inside.
  • svn update --set-depth=files file1.txt

This piece of example code checks out an empty working copy, and fetches file1.txt and file2.txt. If you fetch file3.txt at a later point similarly, all 3 files are in entries, and you're able to execute all Subversion commands on them.

using(SvnClient client = new SvnClient())
{
    SvnCheckOutArgs coArgs = new SvnCheckOutArgs();
    coArgs.Depth = SvnDepth.Empty;

    client.CheckOut(new Uri("http://server/repos/directory"), targetDir, coArgs);


    SvnUpdateArgs updateArgs = new SvnUpdateArgs();
    updateArgs.Depth = SvnDepth.Files;

    client.Update(Path.Combine(targetDir, new string[] {"file1.txt", "file2.txt"}), updateArgs);
}
Sander Rijken