예제 #1
0
        public void should_be_lesser_when_second_quality_is_a_real()
        {
            var first = new Revision();
            var second = new Revision(real: 1);

            first.Should().BeLessThan(second);
        }
예제 #2
0
        public void should_be_greater_when_first_is_a_proper_for_a_real()
        {
            var first = new Revision(real: 1, version: 2);
            var second = new Revision(real: 1);

            first.Should().BeGreaterThan(second);
        }
예제 #3
0
        public void should_be_lesser_when_second_is_a_proper_for_a_real()
        {
            var first = new Revision(real: 1);
            var second = new Revision(real: 1, version: 2);

            first.Should().BeLessThan(second);
        }
예제 #4
0
        public void should_be_lesser_when_second_quality_is_a_proper()
        {
            var first = new Revision();
            var second = new Revision(version: 2);

            first.Should().BeLessThan(second);
        }
예제 #5
0
        public void should_be_equal_when_both_real_and_version_match()
        {
            var first = new Revision();
            var second = new Revision();

            first.CompareTo(second).Should().Be(0);
        }
예제 #6
0
        public void should_be_equal_when_both_real_and_version_match_for_real_proper()
        {
            var first = new Revision(version: 2, real: 1);
            var second = new Revision(version: 2, real: 1);

            first.CompareTo(second).Should().Be(0);
        }
 /// <summary>
 /// Constructs reporter.
 /// </summary>
 public ProjectStatisticsReporter(Revision[] revisions, GroupingPeriod groupBy, DateTime fromDate, DateTime toDate)
 {
     m_revisions = revisions;
       m_groupBy = groupBy;
       m_fromDate = fromDate;
       m_toDate = toDate;
 }
예제 #8
0
        public void should_be_greater_when_first_quality_is_a_proper()
        {
            var first = new Revision(version: 2);
            var second = new Revision();

            first.Should().BeGreaterThan(second);
        }
예제 #9
0
        public void should_be_greater_when_first_quality_is_a_real()
        {
            var first = new Revision(real: 1);
            var second = new Revision();

            first.Should().BeGreaterThan(second);
        }
예제 #10
0
        public object Post(RevisionDTO request)
        {
            var revision = new Revision
                {
                    Fecha = new DateTime().Date,
                    Hora = new DateTime(),
                    IdEquipo = request.Equipo,
                    //Usuario = request.Usuario,
                    Entidad = RpEntidad.Cargar((Int64) 2),
                    Tipo = Revision.TipoDocumento.TrasladoDeposito
                };

            foreach (var documento in request.Documentos)
            {
                revision.Documento.Add(new RevisionDocumento
                    {
                        Documento = documento,
                    });
            }

            foreach (var detalle  in request.Detalles)
            {
                revision.Detalle.Add(new RevisionDetalle
                    {
                        Articulo = RpArticulo.Cargar(detalle.Articulo.Codigo, revision.Entidad.Empresa.Codigo),
                        Bultos = detalle.Bultos,
                        Cantidad = detalle.Cantidad,
                        UnidadesBulto = detalle.UnidadesBulto,
                    });
            }

            RpRevision.Procesar(revision);

            return revision;
        }
예제 #11
0
        public override void CommitRevision(Revision revision, string folder)
        {
            var filename = GetFileFromAlias(revision.Name, folder);

            if (File.Exists(filename))
                File.Delete(filename);

            if (File.Exists(filename))
                throw new Exception("An archive with the same name already exists.");

            using (var package = Package.Open(filename, FileMode.Create, FileAccess.ReadWrite, FileShare.None))
            {
                package.PackageProperties.Identifier = revision.Name;
                package.PackageProperties.Title = "Umbraco Courier 2.0 Package - " + revision.Name;
                package.PackageProperties.LastModifiedBy = "Umbraco Courier 2.0";
                package.PackageProperties.Creator = "Umbraco Courier 2.0";
                package.PackageProperties.Created = DateTime.Now;
                package.PackageProperties.Modified = DateTime.Now;
                package.PackageProperties.ContentType = "application/courierPackage";

                foreach (var item in revision.RevisionCollection)
                    AddPackagePart(package, item.Value.FilePath, item.Value.FileContent, "Revision");

                foreach (var item in revision.ResourceCollection)
                    AddPackagePart(package, item.Value.FilePath, item.Value.FileContent, "Resource");

                foreach (var item in revision.VirtualResourceCollection)
                    AddPackagePart(package, item.Value.FilePath, item.Value.FileContent, "VirtualResource");
            }
        }
        public static int GetChahngesetId(Revision revision)
        {
            int prevLinksCount = revision.Index == 0
                ? 0
                : revision.WorkItem.Revisions[revision.Index - 1].Links.Count;
            if (prevLinksCount == revision.Links.Count)
                return 0;

            ExternalLink lastChangeset = null;
            for (int i = 0; i < revision.Links.Count; i++)
            {
                var link = revision.Links[i];
                if (link.BaseType == BaseLinkType.ExternalLink)
                {
                    var extLink = link as ExternalLink;
                    if (extLink.ArtifactLinkType.Name != "Fixed in Changeset")
                        continue;
                    lastChangeset = extLink;
                }
                if (lastChangeset != null && link.BaseType != BaseLinkType.ExternalLink)
                    break;
            }

            if (lastChangeset == null)
                return 0;

            string url = lastChangeset.LinkedArtifactUri;
            int lastInd = url.LastIndexOf('/');
            return int.Parse(url.Substring(lastInd + 1, url.Length - 1 - lastInd));
        }
 public void ShortVersionOfLongHashComparesEqual()
 {
     var longRevision = new Revision("e0e50f0f23264cb59ab059fa049741f3e0e50f0f");
     var shortRevision = new Revision("e0e50f0f2326");
     Assert.That(longRevision, Is.EqualTo(shortRevision));
     Assert.That(shortRevision, Is.EqualTo(longRevision));
 }
        public static Content SetupTestContentData(Guid newGuid, Guid newGuidRedHerring, ProviderSetup providerSetup)
        {
            var baseEntity = HiveModelCreationHelper.MockTypedEntity();
            var entity = new Content(baseEntity); 
            entity.Id = new HiveId(newGuid);
            entity.EntitySchema.Alias = "schema-alias1";

            var existingDef = entity.EntitySchema.AttributeDefinitions[0];
            var newDef = HiveModelCreationHelper.CreateAttributeDefinition("aliasForQuerying", "", "", existingDef.AttributeType, existingDef.AttributeGroup, true);
            entity.EntitySchema.AttributeDefinitions.Add(newDef);
            entity.Attributes.Add(new TypedAttribute(newDef, "my-new-value"));

            entity.Attributes[1].DynamicValue = "not-on-red-herring";
            entity.Attributes[NodeNameAttributeDefinition.AliasValue].Values["UrlName"] = "my-test-route";

            var redHerringEntity = HiveModelCreationHelper.MockTypedEntity();
            redHerringEntity.Id = new HiveId(newGuidRedHerring);
            redHerringEntity.EntitySchema.Alias = "redherring-schema";

            using (var uow = providerSetup.UnitFactory.Create())
            {
                var publishedRevision = new Revision<TypedEntity>(entity)
                    { MetaData = { StatusType = FixedStatusTypes.Published } };

                uow.EntityRepository.Revisions.AddOrUpdate(publishedRevision);
                // Only add extra entity if caller wants it
                if (newGuidRedHerring != Guid.Empty) uow.EntityRepository.AddOrUpdate(redHerringEntity);
                uow.Complete();
            }

            return entity;
        }
예제 #15
0
		public static void Show (VersionControlItemList items, Revision since)
		{
			foreach (VersionControlItem item in items) {
				var document = IdeApp.Workbench.OpenDocument (item.Path);
				ComparisonView.AttachViewContents (document, item);
				document.Window.SwitchView (4);
			}
		}
예제 #16
0
		/// <summary>
		/// Add a tag to the file.
		/// </summary>
		public void AddTag(string name, Revision revision)
		{
			if (revision.IsBranch)
				throw new ArgumentException(String.Format("Invalid tag revision: {0} is a branch tag revision", revision));

			m_revisionForTag[name] = revision;
			m_tagsForRevision.Add(revision, name);
		}
예제 #17
0
		/// <summary>
		/// Add a branch tag to the file. This is a pseudo revision that marks the revision that the branch
		/// starts at along with the branch "number" (since multiple branches can be made at a specific revision).
		/// E.g. revision 1.5.0.4 is a branch at revision 1.5 and its revisions will be 1.5.4.1, 1.5.4.2, etc.
		/// </summary>
		public void AddBranchTag(string name, Revision revision)
		{
			if (!revision.IsBranch)
				throw new ArgumentException(String.Format("Invalid branch tag revision: {0}", revision));

			m_revisionForBranch[name] = revision;
			m_branchForRevision[revision.BranchStem] = name;
		}
예제 #18
0
        //�Public�Methods�(4)
        public override void CommitRevision(Revision revision)
        {
            string path = System.IO.Path.Combine(Path, revision.Name);

            RevisionStorage revstorage = new RevisionStorage();
            revstorage.Save(revision, path);
            revstorage.Dispose();
        }
예제 #19
0
 public ChangeSet GetChanges(Revision revision)
 {
     var changes = new ChangeSet();
     changes.Inserts = RetriveInserts(revision);
     changes.Updates = RetriveUpdates(revision);
     changes.Deletes = RetriveDeletes(revision);
     return changes;
 }
        public static double GetCompletedWork(Revision revision)
        {
            if (revision == null)
                return 0;

            object obj = revision["Completed Work"];
            return obj == null ? 0 : (double)obj;
        }
        public void CleanStorageTest()
        {
            // Add some records to all collections
              var app = new Application {Title = "App1"};
              app = Provider.CreateApplicaton(app);

              var person = new Person {Login = "******", Title = "User Clever"};
              person = Provider.CreatePerson(person);

              var module = new Module {AppId = app.Id, Title = "Module1"};
              module = Provider.CreateModule(module);

              var subModule = new SubModule {ModuleId = module.Id, Title = "SubModule1"};
              subModule = Provider.CreateSubModule(subModule);

              var release = new Release {AppId = app.Id, Title = "Release1"};
              release = Provider.CreateRelease(release);

              var revision = new Revision
                       {
                         AppId = app.Id,
                         BugNumber = 10,
                         Rev = 1,
                         Date = DateTime.Now,
                         Type = BugType.Bug,
                         FoundReleaseId = release.Id,
                         TargetReleaseId = release.Id,
                         Severity = BugSeverity.Critical,
                         Priority = 1,
                         Status = BugStatus.Open,
                         ContributorId = person.Id,
                         ModuleId = module.Id,
                         SubModuleId = subModule.Id,
                         Summary = "Summary text"
                       };

              Provider.CreateRevision(revision);

              // Check that everything is added to storage
              Assert.AreNotEqual(0, Provider.GetApplications().Length);
              Assert.AreNotEqual(0, Provider.GetModules(app.Id).Length);
              Assert.AreNotEqual(0, Provider.GetSubModules(module.Id).Length);
              Assert.AreNotEqual(0, Provider.GetStaff().Length);
              //      Assert.AreNotEqual(0, Provider.GetBugs().Length);
              Assert.AreNotEqual(0, Provider.GetRevisions(10).Length);
              //      Assert.AreNotEqual(0, Provider.GetReleases().Length);

              // Clean storage
              Provider.CleanStorage();
              // And check that it is cleared
              Assert.AreEqual(0, Provider.GetApplications().Length);
              Assert.AreEqual(0, Provider.GetModules(app.Id).Length);
              Assert.AreEqual(0, Provider.GetSubModules(module.Id).Length);
              Assert.AreEqual(0, Provider.GetStaff().Length);
              //      Assert.AreEqual(0, Provider.GetBugs().Length);
              Assert.AreEqual(0, Provider.GetRevisions(10).Length);
              //      Assert.AreEqual(0, Provider.GetReleases().Length);
        }
예제 #22
0
		public DiffView (VersionControlDocumentInfo info, Revision baseRev, Revision toRev) : base (GettextCatalog.GetString ("Changes"))
		{
			this.info = info;
			widget = new DiffWidget (info);
			ComparisonWidget.SetRevision (ComparisonWidget.DiffEditor, baseRev);
			ComparisonWidget.SetRevision (ComparisonWidget.OriginalEditor, toRev);
			
			widget.ShowAll ();
		}
예제 #23
0
		public Revision[] GetHistory (Repository repo, FilePath sourcefile, Revision since)
		{
			SvnRevision startrev = SvnRevision.Working;
			SvnRevision sincerev = SvnRevision.First;
			if (since != null)
				sincerev = (SvnRevision) since;

			return Log (repo, sourcefile, startrev, sincerev).ToArray ();
		}
예제 #24
0
		public static bool CanShow (VersionControlItemList items, Revision since)
		{
			bool found = false;
			foreach (VersionControlItem item in items) {
				if (item.Repository.IsHistoryAvailable (item.Path)) {
					return true;
				}
			}
			return found;
		}
예제 #25
0
        public void GetRevisionReturnsRevision()
        {
            var revision = new Revision();
            var table = new TestTable();
            table.Revision = revision;

            Revision revision1 = table.GetRevision();

            Assert.AreEqual(revision, revision1);
        }
예제 #26
0
		public FileRevision(FileInfo file, Revision revision, Revision mergepoint, DateTime time, string author,
				string commitId, bool isDead = false)
		{
			this.File = file;
			this.Revision = revision;
			this.Mergepoint = mergepoint;
			this.Time = time;
			this.Author = author;
			this.CommitId = commitId;
			this.IsDead = isDead;
		}
예제 #27
0
		public static void Show (VersionControlItemList items, Revision since)
		{
			foreach (VersionControlItem item in items) {
				if (!item.IsDirectory) {
					var document = IdeApp.Workbench.OpenDocument (item.Path);
					DiffView.AttachViewContents (document, item);
					document.Window.SwitchView (document.Window.FindView (typeof(LogView)));
				} else if (item.Repository.IsHistoryAvailable (item.Path)) {
					new Worker (item.Repository, item.Path, item.IsDirectory, since).Start ();
				}
			}
		}
        public static double GetCompletedWorkChange(Revision revision)
        {
            double curVal = GetCompletedWork(revision);
            if (curVal <= 0)
                return 0;

            Revision prevRevision = revision.Index == 0
                ? null
                : revision.WorkItem.Revisions[revision.Index - 1];
            double prevVal = GetCompletedWork(prevRevision);
            return curVal - prevVal;
        }
        public static void SetRevision(this IIntegrationResult integrationResult, Revision revision)
        {
            if (integrationResult == null)
            {
                throw new ArgumentNullException("integrationResult");
            }

            var sourceControlProperties = NameValuePair.ToDictionary(integrationResult.SourceControlData);
            sourceControlProperties[RevisionKey] = revision.ToString();
            integrationResult.SourceControlData.Clear();
            NameValuePair.Copy(sourceControlProperties, integrationResult.SourceControlData);
        }
예제 #30
0
		public static void Show (VersionControlItemList items, Revision since)
		{
			foreach (VersionControlItem item in items) {
				if (!item.IsDirectory) {
					var document = IdeApp.Workbench.OpenDocument (item.Path, OpenDocumentOptions.Default | OpenDocumentOptions.OnlyInternalViewer);
					DiffView.AttachViewContents (document, item);
					document.Window.SwitchView (document.Window.FindView (typeof(LogView)));
				} else if (item.VersionInfo.CanLog) {
					new Worker (item.Repository, item.Path, item.IsDirectory, since).Start ();
				}
			}
		}
예제 #31
0
파일: Program.cs 프로젝트: liyanh/TFS
        static void Main(string[] args)
        {
            Console.WriteLine("123!");
            while (true)
            {
                System.Console.Write("Input IA/Prism: ");
                tpName = Console.ReadLine();
                System.Console.Write("Input SprintNum: ");
                sprintNum = Console.ReadLine();
                if ("IA".Equals(tpName, StringComparison.OrdinalIgnoreCase))
                {
                    tpURI    = "https://tfs.slb.com/tfs/Real-Time_Collection/";
                    queryStr = "SELECT * FROM WorkItems WHERE [System.TeamProject] = 'InterACT Core' AND  [System.IterationPath] = 'InterACT Core\\Sprint " + sprintNum + "'" +
                               " AND [Slb.Interact.Team] = 'Real Time' AND [System.WorkItemType] = 'Task' AND  [System.State] != 'Removed'";
                    break;
                }
                else if ("Prism".Equals(tpName, StringComparison.OrdinalIgnoreCase))
                {
                    tpURI    = "https://tfs.slb.com/tfs/SLB1/";
                    queryStr = "SELECT * FROM WorkItems WHERE [System.TeamProject] = 'Prism' AND  [System.IterationPath] = 'Prism\\Sprint " + sprintNum + "'" +
                               "AND [System.WorkItemType] = 'Task' AND  [System.State] != 'Removed'";
                    break;
                }
            }
            //创建文件
            //StreamWriter sw = File.AppendText(System.Environment.CurrentDirectory + "\\AnalysisResult.csv");
            FileStream fs = new FileStream(Environment.CurrentDirectory + "\\" + tpName + "_Sprint_" + sprintNum + "_Result.csv", FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read);

            fs.SetLength(0);
            StreamWriter sw = new StreamWriter(fs);

            //服务器连接,相关对象的获取
            TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri(tpURI));

            //版本控制
            version = tpc.GetService(typeof(VersionControlServer)) as VersionControlServer;

            WorkItemStore workItemStore = tpc.GetService <WorkItemStore>();

            WorkItemCollection wc = workItemStore.Query(queryStr);
            int sumCount          = wc.Count;

            Console.WriteLine("num: {0}", sumCount);

            Dictionary <string, int[]> status     = new Dictionary <string, int[]>();
            Dictionary <string, int[]> effort     = new Dictionary <string, int[]>();
            Dictionary <string, int[]> actiEffort = new Dictionary <string, int[]>();

            actiEffort.Add("Grand Total", new int[2]);

            foreach (WorkItem wi in wc)
            {
                string   creator = wi.CreatedBy;
                int      revs    = wi.Revision;
                Revision rev     = wi.Revisions[revs - 1];

                /*
                 * foreach (Field fi in wi.Fields)
                 * {
                 *  Console.WriteLine(fi.Name);
                 *  Console.WriteLine(rev.Fields[fi.Name].Value);
                 * }
                 * Thread.Sleep(500000);
                 *
                 */
                //Activity VS effort----------------------------------------
                string[] effortType = new string[] { "Test automation", "Testing", "Development", "Meeting", "defect", "Training", "Review", "Knowledge transfer", "Commercial support", "Requirements" };
                foreach (string ty in effortType)
                {
                    //string activity = (string)rev.Fields["Activity"].Value;
                }
                int[]  activity;
                string actiName;
                if ("".Equals((string)rev.Fields["Activity"].Value) == false)
                {
                    actiName = (string)rev.Fields["Activity"].Value;
                }
                else
                {
                    actiName = "(blank)";
                }

                int[] totalEffort = actiEffort["Grand Total"];
                totalEffort[0] = totalEffort[0] + Convert.ToInt32(rev.Fields["Original Estimate"].Value);
                totalEffort[1] = totalEffort[1] + Convert.ToInt32(rev.Fields["Completed work"].Value);
                if (actiEffort.ContainsKey(actiName))
                {
                    activity = actiEffort[actiName];
                }
                else
                {
                    activity = new int[2];
                    actiEffort.Add(actiName, activity);
                }
                activity[0] = activity[0] + Convert.ToInt32(rev.Fields["Original Estimate"].Value);
                activity[1] = activity[1] + Convert.ToInt32(rev.Fields["Completed work"].Value);

                //Sprint original estimation of real time team------------------------
                int[]  effortCount;
                string associated = (string)rev.Fields["Assigned to"].Value;
                //Console.WriteLine(associated);
                if (effort.ContainsKey(associated))
                {
                    effortCount = effort[associated];
                }
                else
                {
                    effortCount = new int[2];
                    effort.Add(associated, effortCount);
                }

                effortCount[0] = effortCount[0] + Convert.ToInt32(rev.Fields["Original Estimate"].Value);
                effortCount[1] = effortCount[1] + Convert.ToInt32(rev.Fields["Completed work"].Value);

                //Sprint planned committed tasks VS status-------------
                if (wi.Title.StartsWith("[C"))
                {
                    int[] staCount;
                    if (status.ContainsKey(creator))
                    {
                        staCount = status[creator];
                    }
                    else
                    {
                        staCount = new int[3];
                        status.Add(creator, staCount);
                    }
                    if ("New".Equals(wi.State))
                    {
                        staCount[0]++;
                    }
                    else if ("Active".Equals(wi.State))
                    {
                        staCount[1]++;
                    }
                    else if ("Closed".Equals(wi.State))
                    {
                        staCount[2]++;
                    }
                }
            }

            //写入文件-----------------------------------------------
            sw.WriteLine("Sprint original estimation of real time team");
            sw.WriteLine("Name,Sum of Original Estimate,Sum of Completed Work");
            foreach (KeyValuePair <string, int[]> item in effort)
            {
                sw.WriteLine("" + item.Key + ',' + item.Value[0] + ',' + item.Value[1]);
            }
            sw.WriteLine();
            sw.WriteLine();
            sw.WriteLine("Sprint planned committed tasks VS status");
            sw.WriteLine("Name,New,Active,Closed");
            foreach (KeyValuePair <string, int[]> item in status)
            {
                sw.WriteLine("" + item.Key + ',' + item.Value[0] + ',' + item.Value[1] + ',' + item.Value[2]);
            }
            sw.WriteLine();
            sw.WriteLine();
            sw.WriteLine("Activity VS effort");
            sw.WriteLine("Activity,Sum of Original Estimate,% Original,Sum of Completed Work,% Real");
            double totalOrig = actiEffort["Grand Total"][0];
            double totalReal = actiEffort["Grand Total"][1];

            foreach (KeyValuePair <string, int[]> item in actiEffort)
            {
                if ("Grand Total".Equals(item.Key) == false)
                {
                    sw.WriteLine("" + item.Key + ',' + item.Value[0] + ',' + (item.Value[0] / totalOrig * 100).ToString("f2") + "%" + ',' + item.Value[1] + ',' + (item.Value[1] / totalReal * 100).ToString("f2") + "%");
                }
            }
            sw.WriteLine("" + "Grand Total" + ',' + totalOrig + ',' + 1 + ',' + totalReal + ',' + 1);
            Console.WriteLine("*************end*************");
            sw.Close();
            fs.Close();
            Thread.Sleep(5000);
        }
 protected override string OnGetTextAtRevision(FilePath repositoryPath, Revision revision)
 {
     return(Svn.GetTextAtRevision(repositoryPath, revision, RootPath));
 }
예제 #33
0
 public override void Checkout(FilePath path, Revision rev, bool recurse, IProgressMonitor monitor)
 {
     Svn.Checkout(this.Url, path, rev, recurse, monitor);
 }
예제 #34
0
        public override DiffInfo[] PathDiff(FilePath localPath, Revision fromRevision, Revision toRevision)
        {
            string diff = Svn.GetUnifiedDiff(localPath, (SvnRevision)fromRevision, localPath, (SvnRevision)toRevision, true);

            return(GenerateUnifiedDiffInfo(diff, localPath, null));
        }
예제 #35
0
 public override Revision[] GetHistory(FilePath sourcefile, Revision since)
 {
     return(Svn.GetHistory(this, sourcefile, since));
 }
예제 #36
0
 public override int CompareRevisions(Library library)
 {
     // Not a valid request, if the two libraries are not the same.
     Debug.Assert(IsSameLibrary(library));
     return(Revision.CompareTo(((MidasLibrary)library).Revision));
 }
예제 #37
0
 public override string GetTextAtRevision(string repositoryPath, Revision revision)
 {
     return(null);
 }
예제 #38
0
        public override async Task <DiffInfo []> PathDiffAsync(FilePath localPath, Revision fromRevision, Revision toRevision, CancellationToken cancellationToken)
        {
            string diff = Svn.GetUnifiedDiff(localPath, (SvnRevision)fromRevision, localPath, (SvnRevision)toRevision, true);

            return(GenerateUnifiedDiffInfo(diff, localPath, null));
        }
 internal static void Add <T>(this IEnumerable <IProviderRevisionRepository <T> > repositories, Revision <T> item, Uri idRoot)
     where T : class, IVersionableEntity
 {
     foreach (var revisionRepository in repositories)
     {
         revisionRepository.AddOrUpdate(item);
     }
     GroupSessionHelper.MakeIdsAbsolute(item, idRoot);
 }
예제 #40
0
        void HandleTreeviewFilesTestExpandRow(object o, TestExpandRowArgs args)
        {
            TreeIter iter;

            if (changedpathstore.IterChildren(out iter, args.Iter))
            {
                string[] diff = changedpathstore.GetValue(iter, colDiff) as string[];
                if (diff != null)
                {
                    return;
                }

                string path = (string)changedpathstore.GetValue(args.Iter, colPath);
                changedpathstore.SetValue(iter, colDiff, new string[] { GettextCatalog.GetString("Loading data...") });
                var rev = SelectedRevision;
                ThreadPool.QueueUserWorkItem(delegate {
                    string text;
                    try {
                        text = info.Repository.GetTextAtRevision(path, rev);
                    } catch (Exception e) {
                        Application.Invoke(delegate {
                            LoggingService.LogError("Error while getting revision text", e);
                            MessageService.ShowError("Error while getting revision text.", "The file may not be part of the working copy.");
                        });
                        return;
                    }
                    Revision prevRev = null;
                    try {
                        prevRev = rev.GetPrevious();
                    } catch (Exception e) {
                        Application.Invoke(delegate {
                            LoggingService.LogError("Error while getting previous revision", e);
                            MessageService.ShowException(e, "Error while getting previous revision.");
                        });
                        return;
                    }
                    string[] lines;
                    var changedDocument = new Mono.TextEditor.TextDocument(text);
                    if (prevRev == null)
                    {
                        lines = new string[changedDocument.LineCount];
                        for (int i = 0; i < changedDocument.LineCount; i++)
                        {
                            lines[i] = "+ " + changedDocument.GetLineText(i + 1).TrimEnd('\r', '\n');
                        }
                    }
                    else
                    {
                        string prevRevisionText = "";
                        try {
                            prevRevisionText = info.Repository.GetTextAtRevision(path, prevRev);
                        } catch (Exception e) {
                            // The file did not exist at this point in time, so just treat it as empty
                        }

                        var originalDocument      = new Mono.TextEditor.TextDocument(prevRevisionText);
                        originalDocument.FileName = "Revision " + prevRev.ToString();
                        changedDocument.FileName  = "Revision " + rev.ToString();
                        lines = Mono.TextEditor.Utils.Diff.GetDiffString(originalDocument, changedDocument).Split('\n');
                    }
                    Application.Invoke(delegate {
                        changedpathstore.SetValue(iter, colDiff, lines);
                    });
                });
            }
        }
예제 #41
0
        void TreeSelectionChanged(object o, EventArgs args)
        {
            Revision d = SelectedRevision;

            changedpathstore.Clear();
            textviewDetails.Buffer.Clear();

            if (d == null)
            {
                return;
            }
            Gtk.TreeIter selectIter = Gtk.TreeIter.Zero;
            bool         select     = false;

            foreach (RevisionPath rp in info.Repository.GetRevisionChanges(d))
            {
                Gdk.Pixbuf actionIcon;
                string     action = null;
                if (rp.Action == RevisionAction.Add)
                {
                    action     = GettextCatalog.GetString("Add");
                    actionIcon = ImageService.GetPixbuf(Gtk.Stock.Add, Gtk.IconSize.Menu);
                }
                else if (rp.Action == RevisionAction.Delete)
                {
                    action     = GettextCatalog.GetString("Delete");
                    actionIcon = ImageService.GetPixbuf(Gtk.Stock.Remove, Gtk.IconSize.Menu);
                }
                else if (rp.Action == RevisionAction.Modify)
                {
                    action     = GettextCatalog.GetString("Modify");
                    actionIcon = ImageService.GetPixbuf("gtk-edit", Gtk.IconSize.Menu);
                }
                else if (rp.Action == RevisionAction.Replace)
                {
                    action     = GettextCatalog.GetString("Replace");
                    actionIcon = ImageService.GetPixbuf("gtk-edit", Gtk.IconSize.Menu);
                }
                else
                {
                    action     = rp.ActionDescription;
                    actionIcon = ImageService.GetPixbuf(MonoDevelop.Ide.Gui.Stock.Empty, Gtk.IconSize.Menu);
                }
                Gdk.Pixbuf fileIcon = DesktopService.GetPixbufForFile(rp.Path, Gtk.IconSize.Menu);
                var        iter     = changedpathstore.AppendValues(actionIcon, action, fileIcon, System.IO.Path.GetFileName(rp.Path), System.IO.Path.GetDirectoryName(rp.Path), rp.Path, null);
                changedpathstore.AppendValues(iter, null, null, null, null, null, rp.Path, null);
                if (rp.Path == preselectFile)
                {
                    selectIter = iter;
                    select     = true;
                }
            }
            if (!string.IsNullOrEmpty(d.Email))
            {
                imageUser.Show();
                imageUser.LoadUserIcon(d.Email, 32);
            }
            else
            {
                imageUser.Hide();
            }

            labelAuthor.Text = d.Author;
            labelDate.Text   = d.Time.ToString();
            string rev = d.Name;

            if (rev.Length > 15)
            {
                currentRevisionShortened = true;
                rev = d.ShortName;
            }
            else
            {
                currentRevisionShortened = false;
            }

            labelRevision.Text          = GettextCatalog.GetString("revision: {0}", rev);
            textviewDetails.Buffer.Text = d.Message;

            if (select)
            {
                treeviewFiles.Selection.SelectIter(selectIter);
            }
        }
예제 #42
0
            protected override bool OnExposeEvent(Gdk.EventExpose e)
            {
                using (Cairo.Context cr = Gdk.CairoHelper.Create(e.Window)) {
                    cr.LineWidth = Math.Max(1.0, widget.Editor.Options.Zoom);

                    cr.Rectangle(leftSpacer, 0, Allocation.Width, Allocation.Height);
                    cr.SetSourceRGB(0.95, 0.95, 0.95);
                    cr.Fill();

                    int    startLine = widget.Editor.YToLine((int)widget.Editor.VAdjustment.Value);
                    double startY    = widget.Editor.LineToY(startLine);
                    while (startLine > 1 && startLine < annotations.Count && annotations[startLine - 1] != null && annotations[startLine] != null && annotations[startLine - 1].Revision == annotations[startLine].Revision)
                    {
                        startLine--;
                        startY -= widget.Editor.GetLineHeight(widget.Editor.Document.GetLine(startLine));
                    }
                    double curY = startY - widget.Editor.VAdjustment.Value;
                    int    line = startLine;
                    while (curY < Allocation.Bottom && line <= widget.Editor.LineCount)
                    {
                        double curStart = curY;
//						widget.JumpOverFoldings (ref line);
                        int        lineStart = line;
                        int        authorWidth = 0, revisionWidth = 0, dateWidth = 0, h = 16;
                        Annotation ann = line <= annotations.Count ? annotations[line - 1] : null;
                        if (ann != null)
                        {
                            do
                            {
                                widget.JumpOverFoldings(ref line);
                                line++;
                            } while (line <= annotations.Count && annotations[line - 1] != null && annotations[line - 1].Revision == ann.Revision);

                            double nextY = widget.editor.LineToY(line) - widget.editor.VAdjustment.Value;
                            if (highlightAnnotation != null && highlightAnnotation.Revision == ann.Revision && curStart <= highlightPositon && highlightPositon < nextY)
                            {
                                cr.Rectangle(leftSpacer, curStart + cr.LineWidth, Allocation.Width - leftSpacer, nextY - curStart - cr.LineWidth);
                                cr.SetSourceRGB(1, 1, 1);
                                cr.Fill();
                            }

                            // use a fixed size revision to get a approx. revision width
                            layout.SetText("88888888");
                            layout.GetPixelSize(out revisionWidth, out h);
                            layout.SetText(TruncRevision(ann.Revision));
                            e.Window.DrawLayout(Style.BlackGC, Allocation.Width - revisionWidth - margin, (int)(curY + (widget.Editor.LineHeight - h) / 2), layout);

                            const int dateRevisionSpacing = 16;
                            if (ann.HasDate)
                            {
                                string dateTime = ann.Date.ToShortDateString();
                                // use a fixed size date to get a approx. date width
                                layout.SetText(new DateTime(1999, 10, 10).ToShortDateString());
                                layout.GetPixelSize(out dateWidth, out h);
                                layout.SetText(dateTime);
                                e.Window.DrawLayout(Style.BlackGC, Allocation.Width - revisionWidth - margin - revisionWidth - dateRevisionSpacing, (int)(curY + (widget.Editor.LineHeight - h) / 2), layout);
                            }

                            using (var authorLayout = MonoDevelop.Components.PangoUtil.CreateLayout(this)) {
                                var description = Pango.FontDescription.FromString("Tahoma " + (int)(10 * widget.Editor.Options.Zoom));
                                authorLayout.FontDescription = description;
                                authorLayout.SetText(ann.Author);
                                authorLayout.GetPixelSize(out authorWidth, out h);

                                var maxWidth = Allocation.Width - revisionWidth - margin - revisionWidth - dateRevisionSpacing;

                                /*				if (authorWidth > maxWidth) {
                                 *                                      int idx = ann.Author.IndexOf ('<');
                                 *                                      if (idx > 0)
                                 *                                              authorLayout.SetText (ann.Author.Substring (0, idx) + Environment.NewLine + ann.Author.Substring (idx));
                                 *                                      authorLayout.GetPixelSize (out authorWidth, out h);
                                 *                              }*/

                                cr.Save();
                                cr.Rectangle(0, 0, maxWidth, Allocation.Height);
                                cr.Clip();
                                cr.Translate(leftSpacer + margin, (int)(curY + (widget.Editor.LineHeight - h) / 2));
                                cr.SetSourceRGB(0, 0, 0);
                                cr.ShowLayout(authorLayout);
                                cr.ResetClip();
                                cr.Restore();
                            }

                            curY = nextY;
                        }
                        else
                        {
                            curY += widget.Editor.GetLineHeight(line);
                            line++;
                            widget.JumpOverFoldings(ref line);
                        }

                        if (ann != null && line - lineStart > 1)
                        {
                            string msg = GetCommitMessage(lineStart, false);
                            if (!string.IsNullOrEmpty(msg))
                            {
                                msg = Revision.FormatMessage(msg);

                                layout.SetText(msg);
                                layout.Width = (int)(Allocation.Width * Pango.Scale.PangoScale);
                                using (var gc = new Gdk.GC(e.Window)) {
                                    gc.RgbFgColor    = Style.Dark(State);
                                    gc.ClipRectangle = new Rectangle(0, (int)curStart, Allocation.Width, (int)(curY - curStart));
                                    e.Window.DrawLayout(gc, (int)(leftSpacer + margin), (int)(curStart + h), layout);
                                }
                            }
                        }

                        cr.Rectangle(0, curStart, leftSpacer, curY - curStart);

                        if (ann != null && ann != locallyModified && !string.IsNullOrEmpty(ann.Author))
                        {
                            double a;

                            if (ann != null && (maxDate - minDate).TotalHours > 0)
                            {
                                a = 1 - (ann.Date - minDate).TotalHours / (maxDate - minDate).TotalHours;
                            }
                            else
                            {
                                a = 1;
                            }
                            HslColor color = new Cairo.Color(0.90, 0.90, 1);
                            color.L = 0.4 + a / 2;
                            color.S = 1 - a / 2;
                            cr.SetSourceColor(color);
                        }
                        else
                        {
                            cr.SetSourceColor(ann != null ? new Cairo.Color(1, 1, 0) : new Cairo.Color(0.95, 0.95, 0.95));
                        }
                        cr.Fill();

                        if (ann != null)
                        {
                            cr.MoveTo(0, curY + 0.5);
                            cr.LineTo(Allocation.Width, curY + 0.5);
                            cr.SetSourceRGB(0.6, 0.6, 0.6);
                            cr.Stroke();
                        }
                    }
                }
                return(true);
            }
 protected override void OnRevertToRevision(FilePath localPath, Revision revision, IProgressMonitor monitor)
 {
     Svn.RevertToRevision(localPath, revision, monitor);
 }
예제 #44
0
        public override async Task <Annotation []> GetAnnotationsAsync(FilePath repositoryPath, Revision since, CancellationToken cancellationToken)
        {
            SvnRevision       sinceRev    = since != null ? (SvnRevision)since : null;
            List <Annotation> annotations = new List <Annotation> (Svn.GetAnnotations(this, repositoryPath, SvnRevision.First, sinceRev ?? SvnRevision.Base));
            Annotation        nextRev     = new Annotation(null, GettextCatalog.GetString("<uncommitted>"), DateTime.MinValue, null, GettextCatalog.GetString("working copy"));
            var baseDocument    = Mono.TextEditor.TextDocument.CreateImmutableDocument(await GetBaseTextAsync(repositoryPath, cancellationToken));
            var workingDocument = Mono.TextEditor.TextDocument.CreateImmutableDocument(File.ReadAllText(repositoryPath));

            // "SubversionException: blame of the WORKING revision is not supported"
            if (sinceRev == null)
            {
                foreach (var hunk in baseDocument.Diff(workingDocument, includeEol: false))
                {
                    annotations.RemoveRange(hunk.RemoveStart - 1, hunk.Removed);
                    for (int i = 0; i < hunk.Inserted; ++i)
                    {
                        if (hunk.InsertStart + i >= annotations.Count)
                        {
                            annotations.Add(nextRev);
                        }
                        else
                        {
                            annotations.Insert(hunk.InsertStart - 1, nextRev);
                        }
                    }
                }
            }

            return(annotations.ToArray());
        }
예제 #45
0
 public static bool CanShow(VersionControlItemList items, Revision since)
 {
     return(items.All(i => i.VersionInfo.CanLog));
 }
예제 #46
0
 private void FindRevision(string text)
 {
     if (!bwFindRevision.IsBusy)
     {
         if ((revisions == null) || (Revision.currentTitle == ""))
         {
             MessageBox.Show("Пожалуйста, загрузите статью сначала!", Program.ProgramName);
             return;
         }
         #region check regular expression
         if (checkBoxFindRevisionRegEx.Checked)
         {
             try
             {
                 Regex r = new Regex(text);
             }
             catch
             {
                 MessageBox.Show("The entered string isn't a valid regular expression", Program.ProgramName);
                 return;
             }
         }
         #endregion
         #region selected revisions
         foreach (Revision rev in revisions)
         {
             rev.selected = true;
         }
         if (comboBox1.SelectedIndex == 1) // selected
         {
             foreach (ListViewItem lvi in listViewEdits.Items)
             {
                 ((Revision)lvi.Tag).selected = lvi.Selected;
             }
         }
         else if (comboBox1.SelectedIndex == 2) // given timespan
         {
             foreach (ListViewItem lvi in listViewEdits.Items)
             {
                 Revision rev = (Revision)lvi.Tag;
                 if ((rev.timestamp < dateTimePicker1.Value) || (rev.timestamp > dateTimePicker2.Value))
                 {
                     rev.selected = false;
                 }
             }
         }
         #endregion
         foreach (Revision rev in revisions)
         {
             rev.displayColor = SystemColors.Window;
         }
         prepareListViewEdits();
         buttonSearchRevision.Text     = "Отменить";
         textBoxSearchRevision.Enabled = false;
         bwFindRevision.RunWorkerAsync(text);
     }
     else
     {
         bwFindRevision.CancelAsync();
         textBoxSearchRevision.Enabled = true;
         buttonSearchRevision.Text     = "Искать!";
     }
 }
예제 #47
0
 protected override Task OnRevertToRevisionAsync(FilePath localPath, Revision revision, ProgressMonitor monitor)
 {
     Svn.RevertToRevision(localPath, revision, monitor);
     return(Task.CompletedTask);
 }
예제 #48
0
 public static void Show(string file, Repository vc, string revPath, Revision revision)
 {
     new Worker(Path.GetFileName(file) + " (revision " + revision.ToString() + ")",
                file, vc, revPath, revision).Start();
 }
예제 #49
0
        protected override Task <RevisionPath []> OnGetRevisionChangesAsync(Revision revision, CancellationToken cancellationToken = default)
        {
            SvnRevision rev = (SvnRevision)revision;

            return(Task.FromResult(rev.ChangedFiles ?? new RevisionPath [0]));
        }
예제 #50
0
 public BranchTest()
 {
     _branch        = new Branch(null);
     _revision      = Revision.Number(3);
     _laterRevision = Revision.Number(4);
 }
예제 #51
0
        protected override RevisionPath[] OnGetRevisionChanges(Revision revision)
        {
            SvnRevision rev = (SvnRevision)revision;

            return(rev.ChangedFiles ?? new RevisionPath [0]);
        }
예제 #52
0
        /// <summary>
        /// Creates a branch new revision based on the revision passed in with the specified status if one is supplied.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="readWriter"></param>
        /// <param name="revision">The Revision in which to create a new one from</param>
        /// <param name="status">Default is Draft</param>
        /// <returns>
        /// Returns the newly created revision object
        /// </returns>
        public static Revision <T> AddNew <T>(this ICoreRevisionRepository <TypedEntity> readWriter, Revision <T> revision, RevisionStatusType status = null)
            where T : TypedEntity
        {
            if (status == null)
            {
                status = FixedStatusTypes.Draft;
            }

            var newRev = revision.CopyToNewRevision(status);

            readWriter.AddOrUpdate(newRev);
            return(newRev);
        }
예제 #53
0
 public override string GetTextAtRevision(FilePath repositoryPath, Revision revision)
 {
     return(Svn.GetTextAtRevision(repositoryPath, revision));
 }
예제 #54
0
        void HandleTreeviewFilesTestExpandRow(object o, TestExpandRowArgs args)
        {
            TreeIter iter;

            if (changedpathstore.IterChildren(out iter, args.Iter))
            {
                string[] diff = changedpathstore.GetValue(iter, colDiff) as string[];
                if (diff != null)
                {
                    return;
                }

                string path = (string)changedpathstore.GetValue(args.Iter, colPath);

                changedpathstore.SetValue(iter, colDiff, new string[] { GettextCatalog.GetString("Loading data...") });
                var rev = SelectedRevision;
                ThreadPool.QueueUserWorkItem(delegate {
                    string text = "";
                    try {
                        text = info.Repository.GetTextAtRevision(path, rev);
                    } catch (Exception e) {
                        Application.Invoke((o2, a2) => {
                            LoggingService.LogError("Error while getting revision text", e);
                            MessageService.ShowError(
                                GettextCatalog.GetString("Error while getting revision text."),
                                GettextCatalog.GetString("The file may not be part of the working copy.")
                                );
                        });
                        return;
                    }
                    Revision prevRev = null;
                    try {
                        prevRev = rev.GetPrevious();
                    } catch (Exception e) {
                        Application.Invoke((o2, a2) => {
                            MessageService.ShowError(GettextCatalog.GetString("Error while getting previous revision."), e);
                        });
                        return;
                    }
                    string[] lines;
                    // Indicator that the file was binary
                    if (text == null)
                    {
                        lines = new [] { GettextCatalog.GetString(" Binary files differ") };
                    }
                    else
                    {
                        var changedDocument = Mono.TextEditor.TextDocument.CreateImmutableDocument(text);
                        if (prevRev == null)
                        {
                            lines = new string [changedDocument.LineCount];
                            for (int i = 0; i < changedDocument.LineCount; i++)
                            {
                                lines[i] = "+ " + changedDocument.GetLineText(i + 1).TrimEnd('\r', '\n');
                            }
                        }
                        else
                        {
                            string prevRevisionText = "";
                            try {
                                prevRevisionText = info.Repository.GetTextAtRevision(path, prevRev);
                            } catch (Exception e) {
                                Application.Invoke((o2, a2) => {
                                    LoggingService.LogError("Error while getting revision text", e);
                                    MessageService.ShowError(
                                        GettextCatalog.GetString("Error while getting revision text."),
                                        GettextCatalog.GetString("The file may not be part of the working copy.")
                                        );
                                });
                                return;
                            }

                            if (String.IsNullOrEmpty(text))
                            {
                                if (!String.IsNullOrEmpty(prevRevisionText))
                                {
                                    lines = new string [changedDocument.LineCount];
                                    for (int i = 0; i < changedDocument.LineCount; i++)
                                    {
                                        lines [i] = "- " + changedDocument.GetLineText(i + 1).TrimEnd('\r', '\n');
                                    }
                                }
                            }

                            var originalDocument      = Mono.TextEditor.TextDocument.CreateImmutableDocument(prevRevisionText);
                            originalDocument.FileName = GettextCatalog.GetString("Revision {0}", prevRev);
                            changedDocument.FileName  = GettextCatalog.GetString("Revision {0}", rev);
                            lines = Mono.TextEditor.Utils.Diff.GetDiffString(originalDocument, changedDocument).Split('\n');
                        }
                    }
                    Application.Invoke((o2, a2) => {
                        changedpathstore.SetValue(iter, colDiff, lines);
                    });
                });
            }
        }
예제 #55
0
 public override void RevertToRevision(FilePath localPath, Revision revision, IProgressMonitor monitor)
 {
     Svn.RevertToRevision(localPath, revision, monitor);
 }
예제 #56
0
 protected override Task <Revision []> OnGetHistoryAsync(FilePath localFile, Revision since, CancellationToken cancellationToken)
 {
     return(Task.FromResult(Svn.GetHistory(this, localFile, since)));
 }
 protected override Revision[] OnGetHistory(FilePath sourcefile, Revision since)
 {
     return(Svn.GetHistory(this, sourcefile, since));
 }
예제 #58
0
 protected override Task <string> OnGetTextAtRevisionAsync(FilePath repositoryPath, Revision revision, CancellationToken cancellationToken)
 {
     return(Task.FromResult(Svn.GetTextAtRevision(repositoryPath, revision, RootPath)));
 }
예제 #59
0
        public void Deleting_Schema_Removes_All_Entities()
        {
            Action <NhibernateTestSetupHelper> runTest = setupHelper =>
            {
                //Arrange

                Revision <TypedEntity> content1 = HiveModelCreationHelper.MockVersionedTypedEntity();
                Revision <TypedEntity> content2 = HiveModelCreationHelper.MockVersionedTypedEntity();
                //assign ids to create a relation
                content1.Item.Id = HiveId.ConvertIntToGuid(1);
                content2.Item.Id = HiveId.ConvertIntToGuid(2);
                content1.Item.RelationProxies.EnlistChild(content2.Item, FixedRelationTypes.DefaultRelationType);
                //assign ids to schema and create schema relation
                content1.Item.EntitySchema.Id = HiveId.ConvertIntToGuid(10);
                content2.Item.EntitySchema.Id = HiveId.ConvertIntToGuid(20);
                content1.Item.EntitySchema.RelationProxies.EnlistChild(content2.Item.EntitySchema, FixedRelationTypes.DefaultRelationType);

                using (var uow = setupHelper.ProviderSetup.UnitFactory.Create())
                {
                    uow.EntityRepository.Revisions.AddOrUpdate(content1);
                    //make some versions
                    uow.EntityRepository.Revisions.AddOrUpdate(content2);
                    uow.EntityRepository.Revisions.AddOrUpdate(content1);
                    uow.Complete();
                }
                //PostWriteCallback.Invoke();
                setupHelper.SessionForTest.Clear();

                //Act

                // First check that all items are loadable fine
                using (var uow = setupHelper.ProviderSetup.UnitFactory.Create())
                {
                    var attributeType = uow.EntityRepository.Schemas.Get <EntitySchema>(content1.Item.EntitySchema.Id);
                    Assert.IsNotNull(attributeType);
                    var revisionReloaded = uow.EntityRepository.Revisions.Get <TypedEntity>(content1.Item.Id, content1.MetaData.Id);
                    Assert.IsNotNull(revisionReloaded);
                    var contentReloaded = uow.EntityRepository.Get <TypedEntity>(content1.Item.Id);
                    Assert.IsNotNull(contentReloaded);
                }

                using (var uow = setupHelper.ProviderSetup.UnitFactory.Create())
                {
                    uow.EntityRepository.Schemas.Delete <EntitySchema>(content1.Item.EntitySchema.Id);
                    uow.Complete();
                }
                //PostWriteCallback.Invoke();
                setupHelper.SessionForTest.Clear();

                //Assert

                using (var uow = setupHelper.ProviderSetup.UnitFactory.Create())
                {
                    var attributeType = uow.EntityRepository.Schemas.Get <EntitySchema>(content1.Item.EntitySchema.Id);
                    Assert.IsNull(attributeType);
                    var revisionReloaded = uow.EntityRepository.Revisions.Get <TypedEntity>(content1.Item.Id, content1.MetaData.Id);
                    Assert.IsNull(revisionReloaded);
                    var contentReloaded = uow.EntityRepository.Get <TypedEntity>(content1.Item.Id);
                    Assert.IsNull(contentReloaded);
                }
                //PostWriteCallback.Invoke();
                setupHelper.SessionForTest.Clear();
            };

            //runTest(DirectReadWriteProvider);
            runTest(new NhibernateTestSetupHelper());
        }
예제 #60
0
 public ContentRevisionBuilderStep(IHiveManager hiveManager, Revision <TypedEntity> revision)
     : base(hiveManager)
 {
     Revision     = revision;
     RelateToRoot = false;
 }