tags:

views:

285

answers:

2

Hello! I have a problem doing commit with sharpsvn. Now i´m adding all the files of my working copy (if the file is added throws an exception), and after it i do commit. It works but it trows exceptions. There is some way to get the status of the repository before do add() and only add the new files or the files who are changed? And if i delete one file or folder on my working copy , How can i delete these files or folder on the repository? Code:

 String[] folders;
 folders = Directory.GetDirectories(direccionLocal,"*.*", SearchOption.AllDirectories);
 foreach (String folder in folders)
            {
                String[] files;
                files = Directory.GetFiles(folder);
                foreach (String file in files)
                {
                    if (file.IndexOf("\\.svn") == -1)
                    {
                        Add(file, workingcopy);
                    }
                }

            }


            Commit(workingcopy, "change"); 

Add:

    public bool Add(string path, string direccionlocal)
    {
        using (SvnClient client = new SvnClient())
        {
            SvnAddArgs args = new SvnAddArgs();
            args.Depth = SvnDepth.Empty;
            Console.Out.WriteLine(path);
            args.AddParents = true;


            try
            {
                return client.Add(path, args);
            }
            catch (Exception ex)
            {
                return false;
            }

        }
    }

Commit:

    public bool Commit(string path, string message)
    {
        using (SvnClient client = new SvnClient())
        {
            SvnCommitArgs args = new SvnCommitArgs();


            args.LogMessage = message;
            args.ThrowOnError = true;
            args.ThrowOnCancel = true;

            try
            {
                return client.Commit(path, args);
            }
            catch (Exception e)
            {
                if (e.InnerException != null)
                {
                    throw new Exception(e.InnerException.Message, e);
                }

                throw e;
            }
        }
    }
+1  A: 
Bert Huijben
A: 

But actually my problem is how to know what files or folder are changed before do commit. I can add all the new files in my working copy before do commit, and the repository changes, but if for example i delete one file of the working copy i dont know the way to add this change before do commit. When you use the tortoise for example before do commit the program shows all the changes of the working copy and you can choose what changes commit and what changes dont. There is some way to do this usin sharp svn?? thanks for your answer!!!

Pedro