Ejemplo n.º 1
0
        void ExecuteDiff(CommandEventArgs e, ICollection <SvnOrigin> targets, SvnRevisionRange range)
        {
            if (targets.Count != 1)
            {
                return;
            }

            SvnTarget diffTarget = EnumTools.GetSingle(targets).Target;

            IAnkhDiffHandler diff = e.GetService <IAnkhDiffHandler>();
            AnkhDiffArgs     da   = new AnkhDiffArgs();

            string[] files = diff.GetTempFiles(diffTarget, range.StartRevision, range.EndRevision, true);

            if (files == null)
            {
                return;
            }

            da.BaseFile  = files[0];
            da.MineFile  = files[1];
            da.BaseTitle = diff.GetTitle(diffTarget, range.StartRevision);
            da.MineTitle = diff.GetTitle(diffTarget, range.EndRevision);
            da.ReadOnly  = true;
            diff.RunDiff(da);
        }
Ejemplo n.º 2
0
        public void ForEachChild(string path, int revision, Change change, Action <PathChange> action)
        {
            SvnClient client = AllocSvnClient();
            SvnTarget target = MakeTarget(path, change == Change.Delete ? revision - 1 : revision);

            try
            {
                SvnListArgs args = new SvnListArgs {
                    Depth = SvnDepth.Infinity
                };
                client.List(target, args, delegate(object s, SvnListEventArgs e)
                {
                    if (string.IsNullOrEmpty(e.Path))
                    {
                        return;
                    }

                    var pc = new PathChange();
                    {
                        pc.Change   = change;
                        pc.Revision = revision;
                        // to be compatible with the log output (which has no trailing '/' for directories)
                        // we need to remove trailing '/'
                        pc.Path = (e.BasePath.EndsWith("/") ? e.BasePath : e.BasePath + "/") + e.Path.TrimEnd('/');
                    }
                    action(pc);
                });
            }
            finally
            {
                FreeSvnClient(client);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="strFileName"></param>
        /// <param name="strError"></param>
        /// <returns></returns>
        public SvnInfoEventArgs GetTargetInformation(string strFileName, ref string strError)
        {
            try
            {
                // Create Target Information
                SvnTarget target = SvnTarget.FromString(strFileName);

                SvnInfoEventArgs args;

                // Get Target Information
                bool boolRetrievedInfo = this.Connection.GetInfo(target, out args);

                // Validation
                if (boolRetrievedInfo == false || args == null)
                {
                    return(null);
                }

                return(args);
            }
            catch (Exception ex)
            {
                strError = ex.ToString();
                Console.WriteLine(strError);

                return(null);
            }
        }
Ejemplo n.º 4
0
        private void CopyProperties(SvnTarget source, string destinationPath)
        {
            Collection <SvnPropertyListEventArgs> props;

            _g.Svn.GetPropertyList(source, out props);
            var keys = new HashSet <string>();

            foreach (var prop in props)
            {
                foreach (var p in prop.Properties)
                {
                    var key = p.Key;
                    keys.Add(key);
                    _g.Svn.SetProperty(destinationPath, key, p.RawValue);
                    _g.Interaction.Trace("\t\tSet {0}=>{1}", key, p.StringValue);
                }
            }
            _g.Svn.GetPropertyList(new SvnPathTarget(destinationPath), out props);
            foreach (var prop in props)
            {
                foreach (var p in prop.Properties)
                {
                    var key = p.Key;
                    if (keys.Contains(key))
                    {
                        continue;
                    }
                    _g.Svn.DeleteProperty(destinationPath, key);
                    _g.Interaction.Trace("\t\tDelete {0}", key);
                }
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Returns a list of the contents of the directory
 /// </summary>
 /// <param name="svnTarget"></param>
 /// <returns></returns>
 public static Collection<SvnListEventArgs> FetchListing(SvnTarget svnTarget, SvnListArgs args = null)
 {
     args = args == null ? new SvnListArgs() : args;
     var result = new Collection<SvnListEventArgs>();
     _client.Value.GetList(svnTarget, args, out result);
     return result;
 }
Ejemplo n.º 6
0
        internal bool CreateBranch(SvnListEventArgs selectedTag, string branchName)
        {
            try
            {
                if (selectedTag != null)
                {
                    using (SvnClient client = new SvnClient())
                    {
                        // Bind the SharpSvn UI to our client for SSL certificate and credentials
                        SvnUIBindArgs bindArgs = new SvnUIBindArgs();
                        SvnUI.Bind(client, bindArgs);

                        string relativeComponentPath = string.Join(string.Empty, selectedTag.BaseUri.Segments.Take(selectedTag.BaseUri.Segments.Count() - 1).ToArray());
                        string server = selectedTag.BaseUri.GetComponents(UriComponents.SchemeAndServer, UriFormat.SafeUnescaped);

                        Uri barnchUri = new Uri(server + relativeComponentPath + "branches/project/" + branchName);

                        SvnTarget source = SvnTarget.FromUri(selectedTag.Uri);

                        SvnCopyArgs arg = new SvnCopyArgs();
                        arg.CreateParents = false;
                        arg.LogMessage    = string.Format("ADMIN-0: Branch Created from Tag {0}", selectedTag.Name);

                        return(client.RemoteCopy(source, barnchUri, arg));
                    }
                }
                return(false);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 7
0
        private MemoryStream GetSVNFileStream(SvnRevisionId changeset, string path)
        {
            var       memoryStream = new MemoryStream();
            SvnTarget target;

            //If you use Uri you should encode '#' as %23, as Uri's define the # as Fragment separator.
            //And in this case the fragment is not send to the server.
            path = path.Replace("#", "%23");
            if (SvnTarget.TryParse(GetPath(path).AbsolutePath, out target))
            {
                if (FileWasDeleted(path, changeset))
                {
                    return(new MemoryStream());
                }

                var uriTarget    = new SvnUriTarget(_root + path, changeset.Value);
                var svnWriteArgs = new SvnWriteArgs {
                    Revision = changeset.Value
                };

                Client.Write(uriTarget, memoryStream, svnWriteArgs);
                return(memoryStream);
            }
            return(new MemoryStream());
        }
Ejemplo n.º 8
0
        public CommitDiff GetRevisionDiffs(long revision)
        {
            CommitDiff result = null;

            SvnChangeHandler handler = new SvnChangeHandler();

            using (SvnClient svnClient = new SvnClient())
            {
                svnClient.LoadConfiguration(Path.Combine(Path.GetTempPath(), "Svn"), true);
                svnClient.Authentication.ForceCredentials(Username, Password);

                svnClient.Log(
                    RemoteRepro,
                    new SvnLogArgs()
                {
                    Range = new SvnRevisionRange(revision, revision)
                },
                    handler.Handler);


                SvnTarget target = SvnTarget.FromUri(RemoteRepro);

                using (MemoryStream ms = new MemoryStream())
                {
                    svnClient.Diff(target, new SvnRevisionRange(revision - 1, revision), ms);
                    ms.Position = 0;
                    StreamReader reader = new StreamReader(ms);
                    result = GetRevisionDiffs(revision, handler.FileChanges, reader);
                }
            }
            return(result);
        }
Ejemplo n.º 9
0
        public void My_Load()
        {
            svn.Authentication.UserNamePasswordHandlers += new EventHandler <SharpSvn.Security.SvnUserNamePasswordEventArgs>(
                delegate(Object s, SharpSvn.Security.SvnUserNamePasswordEventArgs e1)
            {
                e1.UserName = GlobalVariable.svnUserName;
                e1.Password = GlobalVariable.svnPassword;
            });
            dir = redis.Get <string>(RedisKeyName.svnBaseDirKey);
            SvnTarget repos = (SvnTarget)dir;
            Collection <SvnListEventArgs> list = new Collection <SvnListEventArgs>();

            try
            {
                if (svn.GetList(repos, out list))
                {
                    list.RemoveAt(0);
                    foreach (var file in list)
                    {
                        TreeViewItem item = new TreeViewItem();
                        item.Header = file.Name;
                        item.Tag    = dir + file.Name;
                        item.Items.Add(_dummyNode);
                        item.Expanded += folder_Expanded;
                        TreeViewItemProps.SetFileType(item, "folder");
                        folderTree.Items.Add(item);
                    }
                }
            }
            catch (SvnException ex)
            {
                MessageBox.Show(ex.Message, ex.Source, MessageBoxButton.OK, MessageBoxImage.Warning);
                this.Close();
            }
        }
Ejemplo n.º 10
0
        public static string GetInfo(string[] args, string revision)
        {
            Parameters parameters;

            if (!Parameters.TryParse(args, out parameters))
            {
                return("False");
            }

            using (var client = new SharpSvn.SvnClient())
            {
                SetUpClient(parameters, client);

                var target = SvnTarget.FromString(parameters.Path);
                SvnInfoEventArgs svnInfoEventArgs;
                SvnUpdateResult  svnUpdateResult;

                if (!client.GetInfo(target, out svnInfoEventArgs))
                {
                    throw new Exception("SVN info failed");
                }
                Uri svnUrl = svnInfoEventArgs.Uri;
                return(svnInfoEventArgs.Revision.ToString());

                throw new Exception("SVN update failed");
            }
            return("jhgjg");
        }
Ejemplo n.º 11
0
        static IEnumerable <DirectoryEntry> List(SvnTarget target, bool recurse)
        {
            var list = new List <DirectoryEntry> ();
            var args = new SvnListArgs {
                Depth = recurse ? SvnDepth.Infinity : SvnDepth.Children,
            };

            lock (client)
                client.List(target, args, delegate(object o, SvnListEventArgs a) {
                    if (string.IsNullOrEmpty(a.Path))
                    {
                        return;
                    }
                    list.Add(new DirectoryEntry {
                        CreatedRevision = ToBaseRevision(a.Entry.Revision).Rev,
                        HasProps        = a.Entry.HasProperties,
                        IsDirectory     = a.Entry.NodeKind == SvnNodeKind.Directory,
                        LastAuthor      = a.Entry.Author,
                        Name            = a.Path,
                        Size            = a.Entry.FileSize,
                        Time            = a.Entry.Time,
                    });
                });
            return(list);
        }
Ejemplo n.º 12
0
        public string Search(string path, bool recurseUp, string propName)
        {
            if (!String.IsNullOrEmpty(_base))
            {
                path = Path.Combine(_base, path);
            }

            if (!Directory.Exists(path))
            {
                if (!File.Exists(path))
                {
                    throw new FileNotFoundException(path);
                }
                path = Path.GetDirectoryName(path);
            }

            using (var client = new SvnClient())
            {
                string result;
                Guid   guid;
                do
                {
                    client.TryGetProperty(SvnTarget.FromString(path), propName, out result);
                    Debug.Assert(path != null, "path != null");
                    path = Directory.GetParent(path).FullName;
                } while (result == null && recurseUp && client.TryGetRepositoryId(path, out guid));
                return(result ?? string.Empty);
            }
        }
Ejemplo n.º 13
0
        public override Revision GetRevision(string alias)
        {
            string url        = Url.TrimEnd('/');
            string tempFolder = Context.Current.MapPath(Core.Settings.rootPath + "/svnRepoTemp/");

            if (System.IO.Directory.Exists(tempFolder))
            {
                System.IO.Directory.Delete(tempFolder);
            }

            using (SvnClient client = new SvnClient())
            {
                client.LoadConfiguration("path");
                client.Authentication.DefaultCredentials = new NetworkCredential(Login, Password);
                SvnTarget folderTarget = SvnTarget.FromString(url);
                client.Export(folderTarget, tempFolder);

                RevisionStorage rs = new RevisionStorage();
                var             r  = rs.GetFromDirectory(alias, tempFolder + alias);

                rs.Save(r, alias);

                rs.Dispose();

                return(r);
            }

            return(null);
        }
Ejemplo n.º 14
0
        public override string[] GetAvailableRevisions()
        {
            string url = Url.TrimEnd('/');

            using (SvnClient client = new SvnClient())
            {
                client.LoadConfiguration("path");
                client.Authentication.DefaultCredentials = new NetworkCredential(Login, Password);
                SvnTarget folderTarget = SvnTarget.FromString(url);

                List <String> filesFound = new List <String>();
                Collection <SvnListEventArgs> listResults;

                if (client.GetList(folderTarget, out listResults))
                {
                    foreach (SvnListEventArgs item in listResults)
                    {
                        if (item.Entry.NodeKind == SvnNodeKind.Directory && !string.IsNullOrEmpty(item.Name))
                        {
                            filesFound.Add(item.Name);
                        }
                    }

                    return(filesFound.ToArray());
                }
            }

            return(new string[0]);
        }
Ejemplo n.º 15
0
        private static string[] getItems(SvnClient client, SvnTarget folderTarget, SvnNodeKind tipoObjeto)
        {
            List <String> filesFound = new List <String>();
            Collection <SvnListEventArgs> listResults;

            if (client.GetList(folderTarget, out listResults))
            {
                foreach (SvnListEventArgs item in listResults)
                {
                    if (item.Entry.NodeKind == tipoObjeto)
                    {
                        if (!String.IsNullOrEmpty(item.Path))
                        {
                            filesFound.Add(item.Path);
                        }
                    }
                }

                return(filesFound.ToArray());
            }
            else
            {
                throw new Exception("Failed to retrieve files via SharpSvn");
            }
        }
Ejemplo n.º 16
0
        public void ParseBlame(string fileName, int lineNumber)
        {
            CaseSensFileName = GetProperFilePathCapitalization(fileName);
            Revision         = 0;
            Author           = "unknown";

            try
            {
                using (var client = new SvnClient())
                {
                    client.Authentication.DefaultCredentials = new NetworkCredential("vivabuild", "#%tsargWV45!@^@gvtRSW");
                    SvnTarget target = SvnPathTarget.FromString(CaseSensFileName);
                    Collection <SvnBlameEventArgs> list;
                    client.GetBlame(target, out list);
                    int idx = lineNumber - 1;
                    if (0 <= idx && idx < list.Count)
                    {
                        Revision = list[idx].Revision;
                        Author   = list[idx].Author;
                    }
                }
            }
            catch (Exception)
            {
                ;
            }
            AddAuthor(Author);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Build the target from a uri.
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        private SvnTarget BuildTarget(Uri path)
        {
            SvnTarget target;

            SvnTarget.TryParse(path.OriginalString, out target);
            return(target);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SvnOrigin"/> class from a SvnTarget
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="target">The target.</param>
        /// <param name="reposRoot">The repos root or <c>null</c> to retrieve the repository root from target</param>
        public SvnOrigin(IAnkhServiceProvider context, SvnTarget target, Uri reposRoot)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            else if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            SvnPathTarget pt = target as SvnPathTarget;

            if (pt != null)
            {
                SvnItem item = context.GetService <ISvnStatusCache>()[pt.FullPath];

                if (item == null || !item.IsVersioned)
                {
                    throw new InvalidOperationException("Can only create a SvnOrigin from versioned items");
                }

                _target    = target;
                _uri       = item.Status.Uri;
                _reposRoot = item.WorkingCopy.RepositoryRoot; // BH: Prefer the actual root over the provided
                return;
            }

            SvnUriTarget ut = target as SvnUriTarget;

            if (ut != null)
            {
                _target = ut;
                _uri    = ut.Uri;
                if (reposRoot != null)
                {
                    _reposRoot = reposRoot;
                }
                else
                {
                    using (SvnClient client = context.GetService <ISvnClientPool>().GetClient())
                    {
                        _reposRoot = client.GetRepositoryRoot(ut.Uri);

                        if (_reposRoot == null)
                        {
                            throw new InvalidOperationException("Can't retrieve the repository root of the UriTarget");
                        }

#if DEBUG
                        Debug.Assert(!_reposRoot.MakeRelativeUri(_uri).IsAbsoluteUri);
#endif
                    }
                }

                return;
            }

            throw new InvalidOperationException("Invalid target type");
        }
Ejemplo n.º 19
0
        private string Diff(string pSourcePath, Uri u)
        {
            if (client == null)
            {
                Init();
            }
            try
            {
                MemoryStream objMemoryStream = new MemoryStream();
                SvnDiffArgs  da = new SvnDiffArgs();
                da.IgnoreAncestry = true;
                da.DiffArguments.Add("-b");
                da.DiffArguments.Add("-w");

                bool b = client.Diff(SvnTarget.FromString(pSourcePath), new SvnUriTarget(u, SvnRevision.Head), da, objMemoryStream);
                objMemoryStream.Position = 0;
                StreamReader strReader = new StreamReader(objMemoryStream);
                string       str       = strReader.ReadToEnd();
                return(str);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 20
0
        public void TestGetOnCwd()
        {
            SvnSandBox sbox           = new SvnSandBox(this);
            Uri        CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario);

            string wc = sbox.Wc;

            Client.CheckOut(new Uri(CollabReposUri, "trunk"), wc);

            string dir = Directory.GetCurrentDirectory();

            Directory.SetCurrentDirectory(wc);
            try
            {
                string v;
                Assert.That(Client.TryGetProperty(".", SvnPropertyNames.SvnMergeInfo, out v));
                Assert.That(v, Is.Not.Null);

                Assert.That(Client.TryGetProperty(SvnTarget.FromString("."), SvnPropertyNames.SvnMergeInfo, out v));
                Assert.That(v, Is.Not.Null);
            }
            finally
            {
                Directory.SetCurrentDirectory(wc);
            }
        }
Ejemplo n.º 21
0
        private bool ConexaoOK(string p_URL_SVN, string p_Usuario_SVN, string p_Senha_SVN)
        {
            bool Resp = false;

            SvnClient _SvnClient = new SvnClient();
            SvnTarget _SvnTarget = SvnTarget.FromString(p_URL_SVN);

            _SvnClient.Authentication.DefaultCredentials = new NetworkCredential(p_Usuario_SVN, p_Senha_SVN);
            System.Collections.ObjectModel.Collection <SvnListEventArgs> _Lista;

            for (int i = 0; i < 5; i++)
            {
                try
                {
                    if (_SvnClient.GetList(_SvnTarget, out _Lista))
                    {
                        Resp = true;
                    }
                }
                catch (Exception)
                {
                }
            }
            return(Resp);
        }
Ejemplo n.º 22
0
        private void Run(Stream stream)
        {
            string tmpFolder =
                Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

            try
            {
                using (SvnClient client = new SvnClient())
                {
                    //client.Authentication.Clear();
                    client.Authentication.UserNamePasswordHandlers += Authentication_UserNamePasswordHandlers;

                    SvnUpdateResult res;
                    bool            downloaded = client.Export(SvnTarget.FromUri(SvnUri), tmpFolder, out res);
                    if (downloaded == false)
                    {
                        throw new Exception("Download Failed");
                    }
                }

                using (ZipFile zipFile = new ZipFile())
                {
                    zipFile.AddDirectory(tmpFolder, GetFolderName());
                    zipFile.Save(stream);
                }
            }
            finally
            {
                if (File.Exists(tmpFolder))
                {
                    File.Delete(tmpFolder);
                }
            }
        }
Ejemplo n.º 23
0
        internal bool CreateTag(SvnListEventArgs selectedTrunk, string tagName)
        {
            try
            {
                if (selectedTrunk != null)
                {
                    using (SvnClient client = new SvnClient())
                    {
                        // Bind the SharpSvn UI to our client for SSL certificate and credentials
                        SvnUIBindArgs bindArgs = new SvnUIBindArgs();
                        SvnUI.Bind(client, bindArgs);

                        string relativeComponentPath = selectedTrunk.BaseUri.AbsoluteUri;

                        Uri tagUri = new Uri(relativeComponentPath + "tags/" + tagName);

                        SvnTarget source = SvnTarget.FromUri(selectedTrunk.Uri);

                        SvnCopyArgs arg = new SvnCopyArgs();
                        arg.CreateParents = false;
                        arg.LogMessage    = string.Format("ADMIN-0: Tag Created from Trunk");

                        return(client.RemoteCopy(source, tagUri, arg));
                    }
                }
                return(false);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Returns a list of the contents of the directory
        /// </summary>
        /// <param name="svnTarget"></param>
        /// <returns></returns>
        public static Collection <SvnListEventArgs> FetchListing(SvnTarget svnTarget, SvnListArgs args = null)
        {
            args = args == null ? new SvnListArgs() : args;
            var result = new Collection <SvnListEventArgs>();

            _client.Value.GetList(svnTarget, args, out result);
            return(result);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Extract a file from svn and write it locally (and overwrite what was already taken out!).
        /// </summary>
        /// <param name="ds"></param>
        /// <param name="outfile"></param>
        public static void ExtractFile(SvnTarget ds, FileInfo outfile)
        {
            var args = new SvnExportArgs()
            {
                Overwrite = true
            };

            _client.Value.Export(ds, outfile.FullName, args);
        }
Ejemplo n.º 26
0
        public TTarget GetTarget <TTarget>() where TTarget : SvnTarget
        {
            SvnTarget rslt;

            if (SvnTarget.TryParse(Target, out rslt))
            {
                return(rslt as TTarget);
            }
            return(null);
        }
Ejemplo n.º 27
0
        public TSource GetSource <TSource>() where TSource : SvnTarget
        {
            SvnTarget rslt;

            if (SvnTarget.TryParse(Source, out rslt))
            {
                return(rslt as TSource);
            }
            return(null);
        }
Ejemplo n.º 28
0
        private void folder_Expanded(object sender, RoutedEventArgs e)
        {
            TreeViewItem item = (TreeViewItem)sender;

            if (item.Items.Count == 1 && item.Items[0] == _dummyNode)
            {
                item.Items.Clear();
                try
                {
                    Collection <SvnListEventArgs> list = new Collection <SvnListEventArgs>();
                    string    sub_dir = (string)item.Tag;
                    SvnTarget repos   = (SvnTarget)sub_dir;
                    svn.GetList(repos, out list);
                    if (list.Count > 1 && !TreeViewItemProps.GetFileType(item).Equals("folder"))
                    {
                        TreeViewItemProps.SetFileType(item, "folder");
                    }
                    list.RemoveAt(0);
                    foreach (var file in list)
                    {
                        TreeViewItem sub_item = new TreeViewItem();
                        if (file.Name.Contains(".txt"))
                        {
                            TreeViewItemProps.SetFileType(sub_item, "txt");
                        }
                        else if (file.Name.Contains(".exe"))
                        {
                            TreeViewItemProps.SetFileType(sub_item, "exe");
                        }
                        else
                        {
                            if (file.Name.Contains(".c") ||
                                file.Name.Contains(".py") ||
                                file.Name.Contains(".sh") ||
                                file.Name.Contains(".h") ||
                                file.Name.Contains(".lua") ||
                                file.Name.Contains(".js"))
                            {
                                TreeViewItemProps.SetFileType(sub_item, "code");
                            }
                            else if (file.Name.Contains("."))
                            {
                                TreeViewItemProps.SetFileType(sub_item, "unknown");
                            }
                        }
                        sub_item.Header = file.Name;
                        sub_item.Tag    = sub_dir + "/" + file.Name;
                        sub_item.Items.Add(_dummyNode);
                        sub_item.Expanded += folder_Expanded;
                        item.Items.Add(sub_item);
                    }
                }
                catch (Exception) { }
            }
        }
Ejemplo n.º 29
0
        public void DeleteClosedFeature()
        {
            string featureRootUrl = string.Empty;

            Info(SvnTarget.FromString(WorkingCopyPath), (sender, args) => featureRootUrl = args.Uri.ToString());
            var svnDeleteArgs = new SvnDeleteArgs {
                LogMessage = "Remove closed feature branch"
            };

            RemoteDelete(new Uri(featureRootUrl), svnDeleteArgs);
        }
Ejemplo n.º 30
0
        public static string GetLogText(string[] args, string revision, out Collection <SvnLogEventArgs> logItemsColl)
        {
            Parameters parameters;

            if (!Parameters.TryParse(args, out parameters))
            {
                throw new Exception("TryParse failed");
            }

            using (var client = new SharpSvn.SvnClient())
            {
                SetUpClient(parameters, client);

                var target = SvnTarget.FromString(parameters.Path);
                SvnInfoEventArgs svnInfoEventArgs;
                SvnUpdateResult  svnUpdateResult;

                if (!client.GetInfo(target, out svnInfoEventArgs))
                {
                    throw new Exception("SVN info failed");
                }

                Uri  svnUrl       = svnInfoEventArgs.Uri;
                long revisionLong = long.Parse(revision);

                long revisionLongTo = svnInfoEventArgs.Revision;


                SvnLogArgs Logargs = new SvnLogArgs
                {
                    Range = new SvnRevisionRange(revisionLong, revisionLongTo)
                };
                Collection <SvnLogEventArgs> logItems;
                //  client.GetLog(svnUrl, Logargs, out logItems);
                client.GetLog(svnUrl, out logItemsColl);

                string AlllogText = "";
                for (int i = logItemsColl.Count - 1; i > 0; i--)
                {
                    AlllogText = AlllogText + (Char)13 + (Char)10 +
                                 logItemsColl[i].Revision.ToString() + " " + logItemsColl[i].Time.ToString() + " " + logItemsColl[i].LogMessage;
                }



                return(AlllogText);

                throw new Exception("SVN update failed");
            }



            return("jhgjg");
        }
Ejemplo n.º 31
0
        public override bool TestConnection(ref string error)
        {
            try
            {
                ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(
                    delegate
                {
                    return(true);
                }
                    );
                WebResponse response = null;
                bool        result   = false;
                if (SourceControlURL.ToUpper().Trim().StartsWith("HTTP"))
                {
                    if (!SourceControlURL.EndsWith("/"))
                    {
                        SourceControlURL = SourceControlURL + "/";
                    }
                    WebRequest request = WebRequest.Create(SourceControlURL);
                    request.Timeout     = 15000;
                    request.Credentials = new System.Net.NetworkCredential(SourceControlUser, SourceControlPass);
                    response            = (WebResponse)request.GetResponse();
                }
                else if (SourceControlURL.ToUpper().Trim().StartsWith("SVN"))
                {
                    using (SvnClient sc = new SvnClient())
                    {
                        sc.Authentication.DefaultCredentials = new System.Net.NetworkCredential(SourceControlUser, SourceControlPass);
                        Uri targetUri = new Uri(SourceControlURL);
                        var target    = SvnTarget.FromUri(targetUri);
                        Collection <SvnInfoEventArgs> info;
                        result = sc.GetInfo(target, new SvnInfoArgs {
                            ThrowOnError = false
                        }, out info);
                    }
                }

                if (response != null || result)
                {
                    return(true);
                }
                else
                {
                    error = "No Details";
                    return(false);
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
Ejemplo n.º 32
0
        public string[] GetTempFiles(SvnTarget target, SvnRevision from, SvnRevision to, bool withProgress)
        {
            if (target == null)
                throw new ArgumentNullException("target");
            else if (from == null)
                throw new ArgumentNullException("from");
            else if (to == null)
                throw new ArgumentNullException("to");

            string f1;
            string f2;

            if (from.RevisionType == SvnRevisionType.Number && to.RevisionType == SvnRevisionType.Number && from.Revision + 1 == to.Revision)
            {
                f1 = GetTempPath(target.FileName, from);
                f2 = GetTempPath(target.FileName, to);

                int n = 0;
                ProgressRunnerResult r = Context.GetService<IProgressRunner>().RunModal("Getting revisions",
                    delegate(object sender, ProgressWorkerArgs e)
                    {
                        SvnFileVersionsArgs ea = new SvnFileVersionsArgs();
                        ea.Start = from;
                        ea.End = to;

                        e.Client.FileVersions(target, ea,
                            delegate(object sender2, SvnFileVersionEventArgs e2)
                            {
                                if (n++ == 0)
                                    e2.WriteTo(f1);
                                else
                                    e2.WriteTo(f2);
                            });
                    });

                if (!r.Succeeded)
                    return null;

                if (n != 2)
                {
                    // Sloooooow workaround for SvnBridge / Codeplex

                    f1 = GetTempFile(target, from, withProgress);
                    if (f1 == null)
                        return null; // Canceled
                    f2 = GetTempFile(target, to, withProgress);
                }
            }
            else
            {
                f1 = GetTempFile(target, from, withProgress);
                if (f1 == null)
                    return null; // Canceled
                f2 = GetTempFile(target, to, withProgress);
            }

            if (string.IsNullOrEmpty(f1) || string.IsNullOrEmpty(f2))
                return null;

            string[] files = new string[] { f1, f2 };

            foreach (string f in files)
            {
                if (File.Exists(f))
                    File.SetAttributes(f, FileAttributes.ReadOnly);
            }

            return files;
        }
Ejemplo n.º 33
0
        /// <summary>
        /// Given a listing, return an item.
        /// </summary>
        /// <param name="ds"></param>
        /// <returns></returns>
        private IEnumerable<string> GetSvnFileLines(SvnTarget ds)
        {
            // Next, fetch the file down.
            var targetTempPath = Path.GetTempFileName();
            WriteVerbose($"Downloading svn file {ds.TargetName}");
            MCJobSVNHelpers.ExtractFile(ds, new FileInfo(targetTempPath));

            // Transfer process the lines
            var lines = new FileInfo(targetTempPath)
                .ReadLines()
                .SelectMany(l => ReplaceIncludeFiles(l, ExpandIncludeFiles));
            return lines;
        }
Ejemplo n.º 34
0
 /// <summary>
 /// Extract a file from svn and write it locally (and overwrite what was already taken out!).
 /// </summary>
 /// <param name="ds"></param>
 /// <param name="outfile"></param>
 public static void ExtractFile(SvnTarget ds, FileInfo outfile)
 {
     var args = new SvnExportArgs() { Overwrite = true };
     _client.Value.Export(ds, outfile.FullName, args);
 }
Ejemplo n.º 35
0
        public string GetTitle(SvnTarget target, SvnRevision revision)
        {
            if (target == null)
                throw new ArgumentNullException("target");
            if (revision == null)
                throw new ArgumentNullException("revision");

            return GetTitle(target.FileName, revision);
        }
Ejemplo n.º 36
0
        /// <summary>
        /// Fetch the files, and if requested, all the include files as well.
        /// </summary>
        /// <param name="ds"></param>
        /// <param name="extractionPath"></param>
        /// <returns></returns>
        private IEnumerable<FileInfo> GetSvnFiles(SvnTarget ds, PathInfo extractionPath)
        {
            // Build the location of this file to write out.
            var outfile = new FileInfo(Path.Combine(extractionPath.Path, ds.FileName));

            WriteVerbose($"Downloading svn file {ds.TargetName}");
            MCJobSVNHelpers.ExtractFile(ds, outfile);
            yield return outfile;

            // Next, we need to dip into all the levels down to see if we can't
            // figure out if there are includes.
            var includeFiles = outfile
                .ReadLines()
                .SelectMany(l => ExtractIncludedFiles(l, extractionPath));

            foreach (var l in includeFiles)
            {
                yield return l;
            }
        }
Ejemplo n.º 37
0
        public override SvnRevisionRange GetMergeInfo(SvnTarget projectUrl, string branch, string parent)
        {
            var svnPath = GetSvnPath(projectUrl.ToString(), branch);

            return base.GetMergeInfo(svnPath, branch, parent);
        }
Ejemplo n.º 38
0
		static IEnumerable<DirectoryEntry> List (SvnTarget target, bool recurse)
		{
			var list = new List<DirectoryEntry> ();
			var args = new SvnListArgs {
				Depth = recurse ? SvnDepth.Infinity : SvnDepth.Children,
			};
			lock (client) 
				client.List (target, args, delegate (object o, SvnListEventArgs a) {
					if (string.IsNullOrEmpty (a.Path))
						return;
					list.Add (new DirectoryEntry {
						CreatedRevision = ToBaseRevision (a.Entry.Revision).Rev,
						HasProps = a.Entry.HasProperties,
						IsDirectory = a.Entry.NodeKind == SvnNodeKind.Directory,
						LastAuthor = a.Entry.Author,
						Name = a.Path,
						Size = a.Entry.FileSize,
						Time = a.Entry.Time,
					});
				});
			return list;
		}
Ejemplo n.º 39
0
		IEnumerable<DirectoryEntry> List (SvnTarget target, bool recurse)
		{
			List<DirectoryEntry> list = new List<DirectoryEntry> ();
			SvnListArgs args = new SvnListArgs ();
			args.Depth = recurse ? SvnDepth.Infinity : SvnDepth.Children;
			lock (client) 
				client.List (target, args, delegate (object o, SvnListEventArgs a) {
				if (string.IsNullOrEmpty (a.Path))
					return;
				DirectoryEntry de = new DirectoryEntry ();
				de.CreatedRevision = ToBaseRevision (a.Entry.Revision).Rev;
				de.HasProps = a.Entry.HasProperties;
				de.IsDirectory = a.Entry.NodeKind == SvnNodeKind.Directory;
				de.LastAuthor = a.Entry.Author;
				de.Name = a.Path;
				de.Size = a.Entry.FileSize;
				de.Time = a.Entry.Time;
				list.Add (de);
			});
			return list;
		}
Ejemplo n.º 40
0
 private string GetMergeInfo(SvnTarget target)
 {
     string mergeInfo;
     _client.GetProperty(target, "svn:mergeinfo", out mergeInfo);
     return mergeInfo;
 }