コード例 #1
0
ファイル: ModelTests.cs プロジェクト: Jeffjewett27/EChest
 public void MakeChangelog()
 {
     Version   v1        = directory.GetVersion("updateTest");
     Version   v2        = directory.GetVersion("originalTest");
     Changelog changelog = v2.GetChangelog(v1);
     int       count     = changelog.Added.Count;
 }
コード例 #2
0
        /// <summary>
        /// Converts this object to a Commit object
        /// </summary>
        /// <param name="directory">The directory dependency for proxies</param>
        /// <param name="loader">The loader object which specifies which objects to load</param>
        /// <returns></returns>
        public Commit GetCommit(DirectoryStructure directory, CommitDependencyLoader loader)
        {
            Commit[] parents = new Commit[Parents.Length];
            for (int i = 0; i < parents.Length; i++)
            {
                string p = Parents[i];
                if (loader.LoadParents && loader.ShouldLoadParent(p))
                {
                    parents[i] = directory.GetCommit(p, loader.GetParent(p));
                }
                else
                {
                    parents[i] = new CommitProxy(p, directory);
                }
            }

            Changelog changelog = loader.LoadChangelog ?
                                  directory.GetChangelog(Changelog) :
                                  new ChangelogProxy(Changelog, directory);

            Version version = loader.LoadVersion ?
                              directory.GetVersion(Hash, loader.LoadVersionData) :
                              new VersionProxy(Version, directory);

            CommitMetadata metadata = Metadata != null?Metadata.GetMetadata()
                                          : throw new FormatException("Commit must contain metadata");

            return(new Commit(parents, changelog, version, metadata, Hash));
        }
コード例 #3
0
ファイル: ModelTests.cs プロジェクト: Jeffjewett27/EChest
        public void DiffWorkingVersion()
        {
            Version   v1        = directory.GetVersion("updateTest");
            Version   v2        = directory.GetVersion("originalTest");
            Changelog changelog = v2.GetChangelog(v1);
            Version   v         = v1.GetChangelogVersion(changelog);

            directory.CreateVersion(v);
        }
コード例 #4
0
ファイル: VersionProxy.cs プロジェクト: Jeffjewett27/EChest
 /// <summary>
 /// Loads the Version to access Data
 /// </summary>
 private void Load()
 {
     if (changelog == null)
     {
         version = directory.GetVersion(Hash);
     }
     else
     {
         version = directory.GetVersion(Hash, changelog);
     }
 }
コード例 #5
0
ファイル: ModelTests.cs プロジェクト: Jeffjewett27/EChest
        public void AggregateChanges()
        {
            Commit c1 = directory.GetCommit("init");
            Commit c2 = directory.GetCommit("mainBranch2");
            AggregatedChangelog aggregated = c2.AncestorChangelog(c1);
            string  test = "";
            Version v    = directory.AggregateVersion(aggregated);

            test = "";
            directory.CreateVersion(v);
        }
コード例 #6
0
ファイル: ModelTests.cs プロジェクト: Jeffjewett27/EChest
        public void GetVersion()
        {
            Version v  = directory.GetVersion("init", false);
            string  vh = v.Data.Hash;

            Assert.AreEqual(v.Hash, "init");
            VersionData  f1txt  = v.Data.Children["file1.txt"];
            StreamReader sr     = new StreamReader(f1txt.Data);
            string       result = sr.ReadToEnd();

            Assert.AreEqual(result, "file1 v1");
            sr.Dispose();
        }
コード例 #7
0
        /// <summary>
        /// Saves a Version into the file directory
        /// </summary>
        /// <param name="directory">The directory in which to save it</param>
        /// <param name="filename">The filename of the Version file</param>
        /// <param name="version">The Version to save</param>
        public static void CreateVersion(string directory, string filename, Version version)
        {
            string path = Path.Combine(directory, filename);

            if (System.IO.Directory.Exists(path))
            {
                throw new IOException("Directory " + path + " already exists");
            }
            System.IO.Directory.CreateDirectory(path);
            foreach (var child in version.Data.Children)
            {
                VersionDataFileManager.CreateVersionData(path, child);
            }
        }
コード例 #8
0
ファイル: CommitCommand.cs プロジェクト: Jeffjewett27/EChest
        public void Create(string message)
        {
            //Loads the files in the working directory
            Version working = directory.GetWorkingVersion();
            //Aggregates the files from all commits up to HEAD
            Head   head         = directory.GetHead();
            Commit parentCommit = head.GetTarget();
            AggregatedChangelog parentAggregate = parentCommit.AggregateChangelog();
            Version             parent          = directory.AggregateVersion(parentAggregate);
            //Creates the data fields for commit
            Changelog      diffChangelog = parent.GetChangelog(working);
            Version        diffVersion   = working.GetChangelogVersion(diffChangelog);
            CommitMetadata metadata      = new CommitMetadata(message);
            //Creates the commit
            Commit newCommit = new Commit(parentCommit, diffChangelog, diffVersion, metadata);

            //Adds the data fields to the file directory
            directory.CreateVersion(diffVersion);
            directory.CreateChangelog(diffChangelog);
            directory.CreateCommit(newCommit);
            //Update the position of the HEAD
            directory.UpdateHead(head, newCommit);
        }
コード例 #9
0
ファイル: ModelTests.cs プロジェクト: Jeffjewett27/EChest
        public void CreateVersion()
        {
            Version v = directory.GetWorkingVersion();

            directory.CreateVersion(v);
        }
コード例 #10
0
        /// <summary>
        /// Saves a Version to the file directory
        /// </summary>
        /// <param name="version"></param>
        public void CreateVersion(Version version)
        {
            string directory = Path.Combine(path, VERSION_PATH);

            VersionFileManager.CreateVersion(directory, version.Hash, version);
        }