private string CheckOut(TFSSourceControlProvider sourceControlProvider, CheckoutData request, string path)
        {
            string activityId = PathParser.GetActivityId(request.ActivitySet.href);

            if (path.Contains("/bln"))
            {
                return(GetLocalPath("//!svn/wbl/" + activityId + path.Substring(9)));
            }

            if (path == "/!svn/vcc/default")
            {
                //    int latestVersion = sourceControlProvider.GetLatestVersion();
                int latestVersion = GetSDKObject().GetLastestVersionNum(path);
                return(GetLocalPath("//!svn/wbl/" + activityId + "/" + latestVersion.ToString()));
            }

            int    revisionStart = path.IndexOf("/ver/") + 5;
            int    version;
            string itemPath;

            if (path.IndexOf('/', revisionStart + 1) != -1)
            {
                int revisionEnd = path.IndexOf('/', revisionStart + 1);
                version  = int.Parse(path.Substring(revisionStart, revisionEnd - revisionStart));
                itemPath = path.Substring(revisionEnd);
            }
            else
            {
                version  = int.Parse(path.Substring(revisionStart));
                itemPath = "/";
            }

            itemPath = itemPath.Replace("//", "/");
            string location = GetLocalPath("//!svn/wrk/" + activityId + itemPath);


            int ver = GetSDKObject().GetLastestVersionNum(itemPath);

            if (ver > version)
            {
                throw new ConflictException();
            }

            return(location);
        }
Example #2
0
        private string CheckOut(TFSSourceControlProvider sourceControlProvider, CheckoutData request, string path)
        {
            string activityId = PathParser.GetActivityId(request.ActivitySet.href);

            if (path.Contains("/bln"))
            {
                return(GetLocalPath("//!svn/wbl/" + activityId + path.Substring(9)));
            }

            if (path == "/!svn/vcc/default")
            {
                int latestVersion = sourceControlProvider.GetLatestVersion();
                return(GetLocalPath("//!svn/wbl/" + activityId + "/" + latestVersion.ToString()));
            }

            int    revisionStart = path.IndexOf("/ver/") + 5;
            int    version;
            string itemPath;

            if (path.IndexOf('/', revisionStart + 1) != -1)
            {
                int revisionEnd = path.IndexOf('/', revisionStart + 1);
                version  = int.Parse(path.Substring(revisionStart, revisionEnd - revisionStart));
                itemPath = path.Substring(revisionEnd);
            }
            else
            {
                version  = int.Parse(path.Substring(revisionStart));
                itemPath = "/";
            }

            itemPath = itemPath.Replace("//", "/");
            string location = GetLocalPath("//!svn/wrk/" + activityId + itemPath);

            ItemMetaData item = sourceControlProvider.GetItemsWithoutProperties(-1, Helper.Decode(itemPath), Recursion.None);

            if (item.ItemRevision > version || item.PropertyRevision > version)
            {
                throw new ConflictException();
            }

            return(location);
        }
Example #3
0
        protected override void Handle(IHttpContext context,
                                       TFSSourceControlProvider sourceControlProvider)
        {
            IHttpRequest  request  = context.Request;
            IHttpResponse response = context.Response;

            MergeData data = Helper.DeserializeXml <MergeData>(request.InputStream);

            string activityId = PathParser.GetActivityId(data.Source.Href);

            response.AppendHeader("Cache-Control", "no-cache");

            try
            {
                MergeActivityResponse mergeResponse = sourceControlProvider.MergeActivity(activityId);
                SetResponseSettings(response, "text/xml", Encoding.UTF8, 200);
                response.SendChunked = true;
                using (StreamWriter output = new StreamWriter(response.OutputStream))
                {
                    WriteMergeResponse(request, mergeResponse, output);
                }
            }
            catch (ConflictException ex)
            {
                SetResponseSettings(response, "text/xml; charset=\"utf-8\"", Encoding.UTF8, 409);
                string responseContent =
                    "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
                    "<D:error xmlns:D=\"DAV:\" xmlns:m=\"http://apache.org/dav/xmlns\" xmlns:C=\"svn:\">\n" +
                    "<C:error/>\n" +
                    "<m:human-readable errcode=\"160024\">\n" +
                    ex.Message + "\n" +
                    "</m:human-readable>\n" +
                    "</D:error>\n";
                WriteToResponse(response, responseContent);
            }
        }
Example #4
0
        protected override void Handle(IHttpContext context,
                                       TFSSourceControlProvider sourceControlProvider)
        {
            IHttpRequest  request  = context.Request;
            IHttpResponse response = context.Response;

            MergeData data       = Helper.DeserializeXml <MergeData>(request.InputStream);
            string    activityId = PathParser.GetActivityId(data.Source.Href);

            response.AppendHeader("Cache-Control", "no-cache");

            try
            {
                // MergeActivityResponse mergeResponse = sourceControlProvider.MergeActivity(activityId);
                int             version = 0;
                System.DateTime date    = System.DateTime.Now;

                ActivityRepository.Use(activityId, delegate(Activity activity)
                {
                    if (activity.MergeList.Count != 0)
                    {
                        for (int i = 0; i < activity.MergeList.Count; i++)
                        {
                            string path = activity.MergeList[i].Path;
                            if (path.StartsWith("//!svn/wrk"))
                            {
                                path = Helper.Decode(path.Substring(11 + activityId.Length));
                            }
                            int ver = GetSDKObject().GetLastestVersionNum(path);
                            System.DateTime d;
                            version = ver > version ? ver : version;
                            GetSDKObject().GetFileModifiedDate(path, out d);
                            date = d > date ? d : date;
                        }
                    }
                });

                MergeActivityResponse mergeResponse = new MergeActivityResponse(version, date, this.UserInfo.strUserName);
                ActivityRepository.Use(activityId, delegate(Activity activity)
                {
                    foreach (ActivityItem t in activity.MergeList)
                    {
                        string path = t.Path;
                        if (path.StartsWith("//!svn/wrk"))
                        {
                            path = Helper.Decode(path.Substring(11 + activityId.Length));
                        }
                        MergeActivityResponseItem item = new MergeActivityResponseItem(t.FileType, path);
                        mergeResponse.Items.Add(item);
                    }
                });

                SetResponseSettings(response, "text/xml", Encoding.UTF8, 200);
                response.SendChunked = true;
                using (StreamWriter output = new StreamWriter(response.OutputStream))
                {
                    WriteMergeResponse(request, mergeResponse, output);
                }
            }
            catch (ConflictException ex)
            {
                SetResponseSettings(response, "text/xml; charset=\"utf-8\"", Encoding.UTF8, 409);
                string responseContent =
                    "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
                    "<D:error xmlns:D=\"DAV:\" xmlns:m=\"http://apache.org/dav/xmlns\" xmlns:C=\"svn:\">\n" +
                    "<C:error/>\n" +
                    "<m:human-readable errcode=\"160024\">\n" +
                    ex.Message + "\n" +
                    "</m:human-readable>\n" +
                    "</D:error>\n";
                WriteToResponse(response, responseContent);
            }
        }