Example #1
0
        protected string getSpecificCommandArguments()
        {
            StringBuilder arguments = new StringBuilder();

            arguments.Append("lock ");

            if (Changelist != null)
            {
                if (Changelist.ToLower() == "default")
                {
                    arguments.Append("-c default ");
                }
                else
                {
                    arguments.Append(string.Format("-c {0} ", NAnt.Contrib.Tasks.Perforce.Perforce.GetChangelistNumber(User, Client, Changelist, true)));
                }
            }

            if (File != null)
            {
                arguments.Append(string.Format(" {0} ", File));
            }

            return(arguments.ToString());
        }
Example #2
0
        /// <summary>
        /// Builds the command string for this particular command.
        /// </summary>
        /// <returns>
        /// The command string for this particular command.
        /// </returns>
        protected string getSpecificCommandArguments( )
        {
            StringBuilder arguments = new StringBuilder();

            arguments.Append("reopen ");

            if (Changelist != null)
            {
                if (Changelist.ToLower() == "default")
                {
                    arguments.Append("-c default ");
                }
                else
                {
                    arguments.Append(string.Format("-c {0} ", Perforce.GetChangelistNumber(
                                                       User, Client, Changelist, true)));
                }
            }
            if (Type != null)
            {
                arguments.Append(string.Format("-t {0} ", Type));
            }
            arguments.Append(View);

            return(arguments.ToString());
        }
Example #3
0
            private static ImageId GetCommitTypeIcon(Changelist commit)
            {
                var helixCatalog = new Guid("{c030418b-0259-44d7-bbcf-4e8c03ef4d95}");
                int submitted    = 0;

                return(new ImageId(helixCatalog, submitted));
            }
Example #4
0
        public void SubmitFile()
        {
            connected = con.Connect(null);
            if (connected)
            {
                try
                {
                    // Submit the edit
                    comment              = tbComment.Text;
                    myChange             = p4.GetChangelist(myChange.Id);
                    myChange.Description = comment;
                    p4.UpdateChangelist(myChange);
                    myChange.Submit(new Options());

                    EnableFileEdit();

                    Console.WriteLine("The file is submitted!");
                }
                catch (P4Exception e)
                {
                    MessageBox.Show("サブミットに失敗しました。\n" +
                                    "正常にチェックアウトされているファイルか確認してください。");
                    Console.WriteLine("Couldn't submit file!\n {0} : {1}", e.ErrorCode, e.Message);
                }
            }
            else
            {
                MessageBox.Show("ワークスペースに正しく接続できているか確認してください。");
            }
        }
Example #5
0
        private void addBtn_Click(object sender, EventArgs e)
        {
            // add changelist to list if it exists
            Int32 changeNum = 0;

            if (changelistTB.Text != null)
            {
                changeNum = Convert.ToInt32(changelistTB.Text);
            }
            Changelist change = scm.GetChangelist(changeNum);

            if (change != null)
            {
                addChangeToFixesLV(change);
                attachedFixes.Add(change);
                changelistTB.Text = "";
            }
            else if (scm.Connection.Repository.Connection.LastResults.ErrorList != null)
            {
                if (scm.Connection.Repository.Connection.LastResults.ErrorList[0].ErrorMessage.Contains("no such"))
                {
                    messageLbl.Text = "Changelist  '" + changelistTB.Text + "' does not exist.";
                }
                addBtn.Enabled = false;
            }
        }
Example #6
0
            public Task <CodeLensDataPointDescriptor> GetDataAsync(CodeLensDescriptorContext context, CancellationToken token)
            {
                try
                {
                    Changelist commit = HelixUtility.GetLastCommit(rep, descriptor.FilePath);
                    if (commit == null)
                    {
                        return(Task.FromResult <CodeLensDataPointDescriptor>(null));
                    }
                    CodeLensDataPointDescriptor response = new CodeLensDataPointDescriptor()
                    {
                        Description = commit.OwnerName, //commit.Author.Name,
                        TooltipText = $"Last change committed by {commit.OwnerName} at {commit.ModifiedDate.ToString(CultureInfo.CurrentCulture)}",
                        IntValue    = null,             // no int value
                        ImageId     = GetCommitTypeIcon(commit),
                    };

                    return(Task.FromResult(response));
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(
                        "file: " + descriptor.FilePath + "\r\n" +
                        "port: " + this.rep.Server.Address + "\r\n" +
                        "user: "******"\r\n" +
                        "client: " + this.rep.Connection.Client.Name + "\r\n" +
                        "Exception:" + "\r\n" + ex.ToString());
                    return(Task.FromResult <CodeLensDataPointDescriptor>(null));
                }
            }
Example #7
0
        public void SubmitOptionsNoneTest()
        {
            bool unicode = false;

            string uri       = "localhost:6666";
            string user      = "******";
            string pass      = string.Empty;
            string ws_client = "admin_space";


            for (int i = 0; i < 1; i++) // run once for ascii, once for unicode
            {
                Process p4d    = Utilities.DeployP4TestServer(TestDir, 6, unicode);
                Server  server = new Server(new ServerAddress(uri));
                try
                {
                    Repository rep = new Repository(server);

                    using (Connection con = rep.Connection)
                    {
                        con.UserName    = user;
                        con.Client      = new Client();
                        con.Client.Name = ws_client;
                        Assert.AreEqual(con.Status, ConnectionStatus.Disconnected);

                        Assert.AreEqual(con.Server.State, ServerState.Unknown);

                        Assert.IsTrue(con.Connect(null));

                        Assert.AreEqual(con.Server.State, ServerState.Online);

                        Assert.AreEqual(con.Status, ConnectionStatus.Connected);

                        Assert.AreEqual("admin", con.Client.OwnerName);
                        Utilities.SetClientRoot(rep, TestDir, unicode, ws_client);

                        Changelist change = new Changelist(5, true);
                        change.initialize(con);

                        SubmitCmdOptions submitOptions = new SubmitCmdOptions(Perforce.P4.SubmitFilesCmdFlags.None, 5, null, null, null);
                        SubmitResults    sr            = change.Submit(submitOptions);

                        FileSpec             fs       = FileSpec.DepotSpec("//depot/MyCode/NewFile.txt");
                        Options              ops      = new Options();
                        IList <FileMetaData> actual   = rep.GetFileMetaData(ops, fs);
                        FileAction           expected = FileAction.None;
                        Assert.AreEqual(expected, actual[0].Action);

                        Assert.IsNotNull(sr);
                        Assert.AreEqual(1, sr.Files.Count);
                    }
                }
                finally
                {
                    Utilities.RemoveTestServer(p4d, TestDir);
                }
                unicode = !unicode;
            }
        }
Example #8
0
 /// <summary>
 /// Construct a SerializableChangelist from a Changelist
 /// </summary>
 /// <param name="InChangelistRecord">P4Record containing changelist data, retrived from the P4.NET API</param>
 public SerializableChangelist(Changelist InChangelistRecord)
 {
     mId           = InChangelistRecord.Id;
     mModifiedDate = InChangelistRecord.ModifiedDate;
     mClientId     = InChangelistRecord.ClientId;
     mOwnerName    = InChangelistRecord.OwnerName;
     mDescription  = InChangelistRecord.Description;
 }
Example #9
0
        //-------------------------------------------------------------------------

        public SelectChangelist(Changelist changelist,
                                string file)
        {
            SelectedChangelist = changelist;
            SelectedFile       = file;

            InitializeComponent();
        }
 /// <summary>
 /// Construct a SerializableChangelist from a Changelist
 /// </summary>
 /// <param name="InChangelistRecord">P4Record containing changelist data, retrived from the P4.NET API</param>
 public SerializableChangelist(Changelist InChangelistRecord)
 {
     mId = InChangelistRecord.Id;
     mModifiedDate = InChangelistRecord.ModifiedDate;
     mClientId = InChangelistRecord.ClientId;
     mOwnerName = InChangelistRecord.OwnerName;
     mDescription = InChangelistRecord.Description;
 }
        public static int CreateNewChangelist()
        {
            var repo = GetRepository();

            var cl = new Changelist { Description = Language.Message("MissingImagesNewChangelistDesc") };

            return repo.CreateChangelist(cl).Id;
        }
        public void UpdateSubmittedChangelistTest()
        {
            bool unicode = false;

            string uri       = "localhost:6666";
            string user      = "******";
            string pass      = string.Empty;
            string ws_client = "admin_space";

            for (int i = 0; i < 2; i++) // run once for ascii, once for unicode
            {
                Process p4d    = Utilities.DeployP4TestServer(TestDir, 7, unicode);
                Server  server = new Server(new ServerAddress(uri));
                try
                {
                    Repository rep = new Repository(server);

                    using (Connection con = rep.Connection)
                    {
                        con.UserName    = user;
                        con.Client      = new Client();
                        con.Client.Name = ws_client;

                        bool connected = con.Connect(null);
                        Assert.IsTrue(connected);

                        Assert.AreEqual(con.Status, ConnectionStatus.Connected);

                        Changelist c = rep.GetChangelist(12);
                        c.Description += "\n\tModified!";
                        rep.UpdateSubmittedChangelist(c, null);

                        Changelist d = rep.GetChangelist(12);
                        Assert.IsTrue(d.Description.Contains("Modified!"));

                        // on the non-unicode server edit the description
                        // of Alex's changelist 8 as an admin
                        if (!unicode)
                        {
                            c              = rep.GetChangelist(8);
                            c.Description += "\n\tModified!";
                            Options opts = new Options();
                            opts["-f"] = null;
                            rep.UpdateSubmittedChangelist(c, opts);

                            d = rep.GetChangelist(8);
                            Assert.IsTrue(d.Description.Contains("Modified!"));
                        }
                    }
                }
                finally
                {
                    Utilities.RemoveTestServer(p4d, TestDir);
                }
                unicode = !unicode;
            }
        }
Example #13
0
        public void EditFile()
        {
            if (System.IO.File.Exists(editFilePath))
            {
                connected = con.Connect(null);
                if (connected)
                {
                    // Checking the file if it's in version control
                    if (ChkFileIsManaged())
                    {
                        try
                        {
                            string deaultfComment = "補助ツールによるチェックアウト";

                            // Create a new custom changelist
                            myChange             = new Changelist();
                            myChange.Description = deaultfComment;
                            myChange             = p4.CreateChangelist(myChange);

                            FileSpec editFile    = new FileSpec(new LocalPath(editFilePath));
                            Options  editOptions = new Options();
                            editOptions["-c"] = String.Format("{0}", myChange.Id);

                            try
                            {
                                // Open the file for edit
                                p4.Connection.Client.EditFiles(editOptions, new FileSpec[] { editFile });

                                EnableFileSubmit();

                                Console.WriteLine("The file is checkout!");
                            }
                            catch (P4Exception e)
                            {
                                MessageBox.Show("チェックアウトに失敗しました。\n" +
                                                "すでにチェックアウトされていないか確認してください。");
                                Console.WriteLine("Couldn't open file for edit!\n {0} : {1}", e.ErrorCode, e.Message);
                            }
                        }
                        catch (P4Exception e)
                        {
                            MessageBox.Show("チェンジリスト作成に失敗しました。\n" +
                                            "バージョン管理されているファイルか確認してください。");
                            Console.WriteLine("Couldn't make new changelist!\n {0} : {1}", e.ErrorCode, e.Message);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("ワークスペースに正しく接続できているか確認してください。");
                }
            }
            else
            {
                MessageBox.Show("指定ファイルが存在しません。");
            }
        }
        public void SubmitShelvedFromChangelist()
        {
            bool unicode = false;

            string uri       = "localhost:6666";
            string user      = "******";
            string pass      = string.Empty;
            string ws_client = "admin_space";

            for (int i = 0; i < 2; i++) // run once for ascii, once for unicode
            {
                Process p4d    = Utilities.DeployP4TestServer(TestDir, 13, unicode);
                Server  server = new Server(new ServerAddress(uri));
                try
                {
                    Repository rep = new Repository(server);

                    using (Connection con = rep.Connection)
                    {
                        con.UserName    = user;
                        con.Client      = new Client();
                        con.Client.Name = ws_client;

                        bool connected = con.Connect(null);
                        Assert.IsTrue(connected);
                        Assert.AreEqual(con.Status, ConnectionStatus.Connected);
                        Utilities.SetClientRoot(rep, TestDir, unicode, ws_client);

                        Changelist change = new Changelist(5, true);
                        change.initialize(con);

                        // shelve the files in changelist 5
                        con.Client.ShelveFiles(new ShelveFilesCmdOptions(ShelveFilesCmdFlags.None,
                                                                         null, change.Id));

                        // revert the checked out file that was shelved
                        FileSpec file = new FileSpec(new DepotPath("//..."), null, null, null);
                        con.Client.RevertFiles(new RevertCmdOptions(RevertFilesCmdFlags.None, change.Id),
                                               file);

                        // submit the shelved file
                        SubmitCmdOptions submitOptions = new
                                                         SubmitCmdOptions(Perforce.P4.SubmitFilesCmdFlags.SubmitShelved,
                                                                          5, null, null, null);
                        change.Submit(submitOptions);

                        P4CommandResult last = rep.Connection.LastResults;
                        Assert.IsTrue(last.Success);
                    }
                }
                finally
                {
                    Utilities.RemoveTestServer(p4d, TestDir);
                }
                unicode = !unicode;
            }
        }
Example #15
0
        public void InvalidLargeChangelistTest()
        {
            bool unicode = false;

            string uri       = "localhost:6666";
            string user      = "******";
            string pass      = string.Empty;
            string ws_client = "admin_space";


            for (int i = 0; i < 1; i++) // run once for ascii, once for unicode
            {
                Process p4d    = Utilities.DeployP4TestServer(TestDir, 6, unicode);
                Server  server = new Server(new ServerAddress(uri));
                try
                {
                    Repository rep = new Repository(server);

                    using (Connection con = rep.Connection)
                    {
                        con.UserName    = user;
                        con.Client      = new Client();
                        con.Client.Name = ws_client;
                        Assert.AreEqual(con.Status, ConnectionStatus.Disconnected);

                        Assert.AreEqual(con.Server.State, ServerState.Unknown);

                        Assert.IsTrue(con.Connect(null));

                        Assert.AreEqual(con.Server.State, ServerState.Online);

                        Assert.AreEqual(con.Status, ConnectionStatus.Connected);

                        Assert.AreEqual("admin", con.Client.OwnerName);

                        // Assign changelist the maximum 32 bit integer
                        Changelist change = new Changelist(2147483647, true);

                        try
                        {
                            change.initialize(con);
                        }
                        catch (P4Exception e)
                        {
                            Assert.AreEqual(822220826, e.ErrorCode,
                                            "Changelist should fail with error, \"Change 2147483647 unknown\", instead got " + e.Message);
                        }
                    }
                }
                finally
                {
                    Utilities.RemoveTestServer(p4d, TestDir);
                }
                unicode = !unicode;
            }
        }
Example #16
0
        public void ParseTest()
        {
            Changelist target   = new Changelist();
            string     spec     = testChangelistSpec;
            bool       expected = true;
            bool       actual;

            actual = target.Parse(spec);
            Assert.AreEqual(expected, actual);
        }
        /// <summary>
        /// Construct a P4ParsedChangelist from the provided Changelist
        /// </summary>
        /// <param name="InChangelist">Changelist to use to populate the parsed changelist</param>
        public P4ParsedChangelist(Changelist InChangelist)
        {
            mBaseChangelist = new SerializableChangelist(InChangelist);

            // If the base changelist supports the new tagging system, parse it for tags
            if (ChangelistSupportsTagging(InChangelist))
            {
                ParseSubchanges();
            }
        }
		/// <summary>
		/// Construct a P4ParsedChangelist from the provided Changelist
		/// </summary>
		/// <param name="InChangelist">Changelist to use to populate the parsed changelist</param>
		public P4ParsedChangelist(Changelist InChangelist)
		{
			mBaseChangelist = new SerializableChangelist(InChangelist);

			// If the base changelist supports the new tagging system, parse it for tags
			if (ChangelistSupportsTagging(InChangelist))
			{
				ParseSubchanges();
			}
		}
        public static int CreateNewChangelist()
        {
            var repo = GetRepository();

            var cl = new Changelist {
                Description = Language.Message("MissingImagesNewChangelistDesc")
            };

            return(repo.CreateChangelist(cl).Id);
        }
Example #20
0
        public void FixJobsTest()
        {
            bool unicode = false;

            string uri       = "localhost:6666";
            string user      = "******";
            string pass      = string.Empty;
            string ws_client = "admin_space";


            for (int i = 0; i < 1; i++)             // run once for ascii, once for unicode
            {
                Process p4d    = Utilities.DeployP4TestServer(TestDir, 6, unicode);
                Server  server = new Server(new ServerAddress(uri));
                try
                {
                    Repository rep = new Repository(server);

                    using (Connection con = rep.Connection)
                    {
                        con.UserName    = user;
                        con.Client      = new Client();
                        con.Client.Name = ws_client;
                        Assert.AreEqual(con.Status, ConnectionStatus.Disconnected);

                        Assert.AreEqual(con.Server.State, ServerState.Unknown);

                        Assert.IsTrue(con.Connect(null));

                        Assert.AreEqual(con.Server.State, ServerState.Online);

                        Assert.AreEqual(con.Status, ConnectionStatus.Connected);

                        Assert.AreEqual("admin", con.Client.OwnerName);

                        Changelist change = new Changelist(9, true);
                        change.initialize(con);

                        Job job = new Job();
                        job.Id = "job000001";

                        Options     opt   = new Options(FixJobsCmdFlags.None, -1, null);
                        IList <Fix> fixes = change.FixJobs(null, job);

                        Assert.IsNotNull(fixes);
                        Assert.AreEqual(1, fixes.Count);
                    }
                }
                finally
                {
                    Utilities.RemoveTestServer(p4d, TestDir);
                }
                unicode = !unicode;
            }
        }
        public void GetChangelistTest()
        {
            bool unicode = false;

            string uri       = "localhost:6666";
            string user      = "******";
            string pass      = string.Empty;
            string ws_client = "admin_space";

            for (int i = 0; i < 2; i++)             // run once for ascii, once for unicode
            {
                Process p4d    = Utilities.DeployP4TestServer(TestDir, 6, unicode);
                Server  server = new Server(new ServerAddress(uri));
                try
                {
                    Repository rep = new Repository(server);

                    using (Connection con = rep.Connection)
                    {
                        con.UserName    = user;
                        con.Client      = new Client();
                        con.Client.Name = ws_client;

                        bool connected = con.Connect(null);
                        Assert.IsTrue(connected);

                        Assert.AreEqual(con.Status, ConnectionStatus.Connected);

                        Changelist c = rep.GetChangelist(5, null);

                        Assert.IsNotNull(c);
                        Assert.AreEqual("admin", c.OwnerName);
                        Assert.AreEqual(c.Files.Count, 1);
                        Assert.AreEqual(c.Jobs.Count, 1);
                        Assert.IsTrue(c.Files[0].DepotPath.Path.Contains("//depot/MyCode/NewFile.txt"));

                        if (unicode == false)
                        {
                            c = rep.GetChangelist(4, null);
                            Assert.AreEqual("admin", c.OwnerName);
                            Assert.AreEqual(c.Files.Count, 2);
                            Assert.AreEqual(c.Jobs.Count, 1);
                            Assert.IsTrue(c.Files[0].DepotPath.Path.Contains("//depot/TheirCode/ReadMe.txt"));
                            Assert.AreEqual(c.Files[0].Digest, "C7DECE3DB80A73F3F53AF4BCF6AC0576");
                            Assert.AreEqual(c.Files[0].FileSize, 30);
                        }
                    }
                }
                finally
                {
                    Utilities.RemoveTestServer(p4d, TestDir);
                }
                unicode = !unicode;
            }
        }
Example #22
0
        /// <summary>
        /// Creates a new Changelist and add add a new change to it</summary>
        /// <param name="description">Description of change</param>
        /// <returns>New Changelist with added change</returns>
        public Changelist CreateChangelist(string description)
        {
            Changelist cl = new Changelist();

            cl.Description = description;
            lock (m_lock)
            {
                cl.ClientId = m_connection.Client.Name;
                cl          = m_repository.CreateChangelist(cl);
            }
            return(cl);
        }
Example #23
0
        public void SubmitTest()
        {
            bool unicode = false;

            string uri       = "localhost:6666";
            string user      = "******";
            string pass      = string.Empty;
            string ws_client = "admin_space";


            for (int i = 0; i < 1; i++)             // run once for ascii, once for unicode
            {
                Process p4d    = Utilities.DeployP4TestServer(TestDir, 6, unicode);
                Server  server = new Server(new ServerAddress(uri));
                try
                {
                    Repository rep = new Repository(server);

                    using (Connection con = rep.Connection)
                    {
                        con.UserName    = user;
                        con.Client      = new Client();
                        con.Client.Name = ws_client;
                        Assert.AreEqual(con.Status, ConnectionStatus.Disconnected);

                        Assert.AreEqual(con.Server.State, ServerState.Unknown);

                        Assert.IsTrue(con.Connect(null));

                        Assert.AreEqual(con.Server.State, ServerState.Online);

                        Assert.AreEqual(con.Status, ConnectionStatus.Connected);

                        Assert.AreEqual("admin", con.Client.OwnerName);
                        Utilities.SetClientRoot(rep, TestDir, unicode, ws_client);

                        Changelist change = new Changelist(5, true);
                        change.initialize(con);

                        SubmitResults sr = change.Submit(null);

                        Assert.IsNotNull(sr);
                        Assert.AreEqual(1, sr.Files.Count);
                    }
                }
                finally
                {
                    Utilities.RemoveTestServer(p4d, TestDir);
                }
                unicode = !unicode;
            }
        }
        public void DeleteChangelistTest()
        {
            bool unicode = false;

            string uri       = "localhost:6666";
            string user      = "******";
            string pass      = string.Empty;
            string ws_client = "admin_space";

            for (int i = 0; i < 2; i++)             // run once for ascii, once for unicode
            {
                Process p4d    = Utilities.DeployP4TestServer(TestDir, 7, unicode);
                Server  server = new Server(new ServerAddress(uri));
                try
                {
                    Repository rep = new Repository(server);

                    using (Connection con = rep.Connection)
                    {
                        con.UserName    = user;
                        con.Client      = new Client();
                        con.Client.Name = ws_client;

                        bool connected = con.Connect(null);
                        Assert.IsTrue(connected);

                        Assert.AreEqual(con.Status, ConnectionStatus.Connected);

                        Changelist c = new Changelist();
                        c.Description = "New changelist for unit test";

                        Changelist newGuy = rep.CreateChangelist(c, null);

                        rep.DeleteChangelist(newGuy, null);

                        Changelist deadGuy = null;
                        try
                        {
                            deadGuy = rep.GetChangelist(newGuy.Id);
                        }
                        catch { }

                        Assert.IsNull(deadGuy);
                    }
                }
                finally
                {
                    Utilities.RemoveTestServer(p4d, TestDir);
                }
                unicode = !unicode;
            }
        }
Example #25
0
        public void Checkout(FileSpec filespec, Changelist cl)
        {
            var options = new EditCmdOptions(EditFilesCmdFlags.None, cl?.Id ?? 0, null);
            var list    = this.Repository.Connection.Client.EditFiles(options, filespec);

            if (list != null)
            {
                foreach (var fn in list)
                {
                    //Logger.Log($"Checked out: {fn}");
                }
            }
        }
Example #26
0
        public static Changelist GetLastCommit(Repository repo, string filePath)
        {
            IList <Changelist> Changes = new List <Changelist>();
            // first check cache
            var items  = changelistCache;
            var lookup = items.ToLookup(kvp => kvp.Key, kvp => kvp.Value);

            foreach (Changelist change in lookup[filePath])
            {
                Changes.Add(change);
            }

            if (Changes.Count < 1)
            {
                try
                {
                    ChangesCmdOptions opts = new ChangesCmdOptions(ChangesCmdFlags.FullDescription, null,
                                                                   5, ChangeListStatus.Submitted, null);
                    Changes = repo.GetChangelists(opts, new FileSpec(null,
                                                                     null, new LocalPath(GetSanitisedPath(filePath)), null));
                }
                catch (P4Exception ex)
                {
                    if (!(ex.ErrorCode == P4ClientError.MsgDb_NotUnderRoot))
                    {
                        System.Windows.Forms.MessageBox.Show(ex.Message);
                    }
                }
            }

            if (Changes == null || Changes.Count < 1)
            {
                return(null);
            }
            foreach (Changelist change in Changes)
            {
                var matches = from val in changelistCache
                              where val.Key == filePath
                              select val.Value as Changelist;

                Changelist c = matches.FirstOrDefault(ch =>
                                                      ch.Id == change.Id);

                if (c == null)
                {
                    changelistCache.Add(new KeyValuePair <string, Changelist>(filePath, change));
                }
            }
            return(Changes[0]);
        }
Example #27
0
        public bool Run(TfsTask task, OutgoingRequest req, OutgoingResponse resp)
        {
            var pending = task.Workspace.GetPendingChanges();

            if (pending.Length != 0)
            {
                Changelist cl = new Changelist();

                cl.Description = DefaultChangelist;
                cl.Revision    = ChangelistRevision.kDefaultListRevision;
                resp.ChangeSets.Add(cl);
            }

            resp.Write();
            return(true);
        }
Example #28
0
        /// <summary>
        /// Gets a Helix repo and root path to the repo.
        /// </summary>
        public static Repository GetRepository(string path, out string repoRoot, out Changelist latest)
        {
            string     port, user, client;
            Repository rep;

            // Check if a connection has been sent/saved in the memory
            // mapped file.

            string[] connectionInfo = currentConnectionInfo().Split(',');

            if (connectionInfo != null && connectionInfo.Length > 1)
            {
                port   = connectionInfo[0];
                user   = connectionInfo[1];
                client = connectionInfo[2];
                Server server = new Server(new ServerAddress(port));
                rep = new Repository(server);
                rep.Connection.UserName    = user;
                rep.Connection.Client      = new Client();
                rep.Connection.Client.Name = client;
                rep.Connection.Connect(null);
                repoRoot   = rep.Connection.Client.Root;
                repository = rep;

                // clear changelist cache on new connection
                // at least for this file

                changelistCache.Clear();
                latest = GetLastCommit(rep, path);
                return(rep);
            }
            else if (repository != null && repository.Connection.Status == ConnectionStatus.Connected)
            {
                rep      = repository;
                repoRoot = rep.Connection.Client.Root;
                latest   = GetLastCommit(rep, path);
                return(rep);
            }
            // If connection was not in the memory mapped file,
            // return a null repository.
            else
            {
                repoRoot = null;
                latest   = null;
                return(null);
            }
        }
Example #29
0
        //-------------------------------------------------------------------------

        private void PopulateForm()
        {
            // Id.
            uiId.Text = "Pending";

            if (Review.Id > -1)
            {
                uiId.Text = Review.Id.ToString();
            }

            // General Review fields.
            uiCreatedBy.Text   = Review.CreatedByUser.Username;
            uiCreatedDate.Text = Review.Timestamp.ToString("yyyy/MM/dd hh:mm");
            uiActive.Checked   = Review.Active;

            // Changelist.
            Changelist changelist = Review.Changelist;

            if (changelist != null)
            {
                // User.
                if (changelist.Submitter == null)
                {
                    uiChangelistUser.Text = "UNKNOWN";
                }
                else
                {
                    uiChangelistUser.Text = changelist.Submitter.Username;
                }

                // General.
                uiChangelist.Text            = (changelist.Id > -1 ? changelist.Id.ToString() : "");
                uiSubmittedDate.Text         = changelist.SubmittedDate.ToString("yyyy/MM/dd");
                uiChangelistDescription.Text = changelist.Description;
                uiFile.Text         = Review.FilePath;
                uiFileRevision.Text = Review.FileRevision.ToString();
            }
            else
            {
                uiChangelistUser.Text        = "";
                uiChangelist.Text            = "";
                uiSubmittedDate.Text         = "";
                uiChangelistDescription.Text = "";
                uiFile.Text         = "";
                uiFileRevision.Text = "";
            }
        }
Example #30
0
        //-------------------------------------------------------------------------

        private void uiChangelists_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Reset form section.
            uiChangelistFiles.Items.Clear();

            uiChangelistNumber.Text = "";
            uiChangelistUser.Text   = "";
            uiChangelistDate.Text   = "";

            // Get the selected changelist.
            Changelist changelist = uiChangelists.SelectedItem as Changelist;

            if (changelist == null)
            {
                return;
            }

            uiChangelistNumber.Text = changelist.Id.ToString();
            uiChangelistUser.Text   = changelist.Submitter.Username;
            uiChangelistDate.Text   = changelist.SubmittedDate.ToString("yyyy/MM/dd");

            //-- Get changelist's files from P4.
            string output = Perforce.RunCommand("describe -s " + changelist.Id);

            // Exract files from output.
            int index = output.IndexOf("Affected files ...");

            while ((index = output.IndexOf("... ", index + 1)) > -1)
            {
                // Skip the "... " prefixing the path.
                index += 4;

                // Grab the path from between the ellipses and the revision.
                int revisionIndex = output.IndexOf(' ', index);

                if (revisionIndex < 0)
                {
                    continue;
                }

                string path = output.Substring(index, revisionIndex - index);

                // Add file path to the ui list.
                uiChangelistFiles.Items.Add(path);
            }
        }
Example #31
0
        protected void InitBuildSource(string InProjectName, FileReference InProjectPath, DirectoryReference InUnrealPath, bool InUsesSharedBuildType, string InBuildArgument, Func <string, string> ResolutionDelegate)
        {
            UnrealPath          = InUnrealPath;
            UsesSharedBuildType = InUsesSharedBuildType;

            ProjectPath = InProjectPath;
            ProjectName = InProjectName;

            // Resolve the build argument into something meaningful
            string ResolvedBuildName;
            IEnumerable <string> ResolvedPaths = null;

            if (!ResolveBuildReference(InBuildArgument, ResolutionDelegate, out ResolvedPaths, out ResolvedBuildName))
            {
                throw new AutomationException("Unable to resolve {0} to a valid build", InBuildArgument);
            }

            BuildName  = ResolvedBuildName;
            BuildPaths = ResolvedPaths;

            DiscoveredBuilds = DiscoverBuilds();

            if (DiscoveredBuilds.Count() == 0)
            {
                throw new AutomationException("No builds were discovered from resolved build argument {0}", InBuildArgument);
            }

            // any Branch/CL info?
            Match M = Regex.Match(BuildName, @"(\+\+.+)-CL-(\d+)");

            if (M.Success)
            {
                Branch     = M.Groups[1].Value.Replace("+", "/");
                Changelist = Convert.ToInt32(M.Groups[2].Value);
            }
            else
            {
                Branch     = "";
                Changelist = 0;
            }

            // allow user overrides (TODO - centralize all this!)
            Branch     = Globals.Params.ParseValue("branch", Branch);
            Changelist = Convert.ToInt32(Globals.Params.ParseValue("changelist", Changelist.ToString()));
        }
        public void UpdateChangelistWithMultilineDescTest()
        {
            bool unicode = false;

            string uri       = "localhost:6666";
            string user      = "******";
            string pass      = string.Empty;
            string ws_client = "admin_space";

            for (int i = 0; i < 2; i++) // run once for ascii, once for unicode
            {
                Process p4d    = Utilities.DeployP4TestServer(TestDir, 7, unicode);
                Server  server = new Server(new ServerAddress(uri));
                try
                {
                    Repository rep = new Repository(server);

                    using (Connection con = rep.Connection)
                    {
                        con.UserName    = user;
                        con.Client      = new Client();
                        con.Client.Name = ws_client;

                        bool connected = con.Connect(null);
                        Assert.IsTrue(connected);

                        Assert.AreEqual(con.Status, ConnectionStatus.Connected);

                        Changelist c = rep.GetChangelist(5);
                        c.Description = "new desc";
                        rep.UpdateChangelist(c);

                        Changelist d = rep.GetChangelist(5);
                        Assert.AreEqual(d.Description, "new desc");
                    }
                }
                finally
                {
                    Utilities.RemoveTestServer(p4d, TestDir);
                }
                unicode = !unicode;
            }
        }
        public void GetChangelistTestjob080718()
        {
            bool unicode = false;

            string  uri       = "localhost:6666";
            string  user      = "******";
            string  pass      = string.Empty;
            string  ws_client = "admin_space";
            Process p4d       = Utilities.DeployP4TestServer(TestDir, 17, unicode);
            Server  server    = new Server(new ServerAddress(uri));

            try
            {
                Repository rep = new Repository(server);

                using (Connection con = rep.Connection)
                {
                    con.UserName    = user;
                    con.Client      = new Client();
                    con.Client.Name = ws_client;
                    bool connected = con.Connect(null);
                    Assert.IsTrue(connected);
                    Assert.AreEqual(con.Status, ConnectionStatus.Connected);

                    Changelist c = rep.GetChangelist(156, null);

                    IList <FileSpec> fs = new List <FileSpec>();
                    fs.Add(c.Files[0]);

                    IList <FileMetaData> fmd = rep.GetFileMetaData(fs, null);

                    IList <FileIntegrationRecord> i = rep.GetSubmittedIntegrations(fs, null);
                    Assert.IsNotNull(i);
                    Assert.AreEqual(i[0].ToFile.DepotPath, c.Files[0].DepotPath);
                    Assert.AreNotEqual(i[0].FromFile.DepotPath, c.Files[0].DepotPath);
                }
            }
            finally
            {
                Utilities.RemoveTestServer(p4d, TestDir);
            }
        }
Example #34
0
 public Changelist CreateChangelist(string description)
 {
     Changelist cl = new Changelist();
     cl.Description = description;
     cl.ClientId = m_connection.Client.Name;
     cl = m_repository.CreateChangelist(cl);
     return cl;
 }
Example #35
0
 /// <summary>
 /// Creates a new Changelist and add add a new change to it</summary>
 /// <param name="description">Description of change</param>
 /// <returns>New Changelist with added change</returns>
 public Changelist CreateChangelist(string description)
 {
     var cl = new Changelist {Description = description};
     lock (m_lock)
     {
         cl.ClientId = m_repository.Connection.Client.Name;
         cl = m_repository.CreateChangelist(cl);
     }
     return cl;
 }
Example #36
0
        private void RenameAndDeleteConflictingFile(Folder parentFolder, File file, string reason, Dictionary<User, long> quotaCharge, Changelist changelist)
        {
            string newDisplayName = file.DisplayName + " (" + reason + " " + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss-fff") + ")";
            string newName = newDisplayName.ToUpperInvariant();

            if (parentFolder.Files.AsQueryable().Where(f => f.Name == newName).SingleOrDefault() != null)
            {
                // Our desired name conflicts with an existing file. Start generating random names.

                do
                {
                    newDisplayName = file.DisplayName + " (" + reason + " " + Utilities.GenerateRandomString(Utilities.IdChars, 16) + ")";
                    newName = newDisplayName.ToUpperInvariant();
                } while (parentFolder.Files.AsQueryable().Where(f => f.Name == newName).SingleOrDefault() != null);
            }

            file.Name = newName;
            file.DisplayName = newDisplayName;
            SetFileState(file, ObjectState.Deleted, quotaCharge, changelist);
        }
Example #37
0
        private void SetFileState(File file, ObjectState state, IDictionary<User, long> quotaCharge, Changelist changelist)
        {
            if (file is Document)
            {
                if (file.State != state)
                {
                    long size = GetLastDocumentVersion((Document)file).Blob.Size;

                    if (state == ObjectState.Deleted)
                        size = -size;

                    AddQuotaCharge(quotaCharge, file.ParentFolder.Owner, size);
                }
            }
            else if (file is Folder)
            {
                var folder = (Folder)file;

                if (state == ObjectState.Deleted)
                {
                    // Delete all invitations that target this folder.

                    foreach (var invitation in folder.TargetOfInvitations)
                    {
                        var acceptedFolder = invitation.AcceptedFolders.SingleOrDefault();

                        if (acceptedFolder != null)
                        {
                            SetFileState(acceptedFolder, ObjectState.Deleted, quotaCharge, changelist);
                            changelist.Changes.Add(new Change
                            {
                                Type = ChangeType.Delete,
                                FullName = GetFullName(acceptedFolder)
                            });
                        }
                    }

                    _context.Invitations.RemoveRange(folder.TargetOfInvitations);

                    // Remove any linked invitation (but don't delete it).
                    folder.InvitationId = null;
                }

                foreach (var subFile in folder.Files)
                    SetFileState(subFile, state, quotaCharge, changelist);
            }

            file.State = state;
        }
Example #38
0
        private Changelist ApplyClientChanges(
            Client client,
            ChangeNode clientNode,
            IDictionary<string, ClientChange> clientChangesByFullName,
            IDictionary<string, Blob> presentHashes
            )
        {
            Dictionary<string, File> fileCache = new Dictionary<string, File>();
            Queue<ChangeNode> queue = new Queue<ChangeNode>();

            fileCache.Add(clientNode.FullName, GetRootFolder());

            foreach (var node in clientNode.Nodes.Values)
                queue.Enqueue(node);

            Changelist changelist = new Changelist
            {
                ClientId = client.Id,
                TimeStamp = DateTime.UtcNow
            };
            var quotaCharge = new Dictionary<User, long>();

            while (queue.Count != 0)
            {
                var node = queue.Dequeue();

                // There is no need to process files that haven't changed.
                if (node.Type == ChangeType.None && !node.IsFolder)
                    continue;

                // Find the associated database file object.
                var parentFolder = (Folder)fileCache[node.Parent.FullName];
                var file =
                    parentFolder.Files.AsQueryable()
                    .Where(f => f.Name == node.Name)
                    .FirstOrDefault();
                bool createChange = false;

                switch (node.Type)
                {
                    case ChangeType.Add:
                        bool createFolder = false;
                        bool createDocument = false;
                        bool createDocumentVersion = false;
                        bool setInvitation = false;
                        bool setDisplayName = false;
                        bool undeleted = false;
                        bool replaced = false;

                        if (file == null)
                        {
                            if (node.IsFolder)
                            {
                                // Nothing -> Folder
                                // Create the folder.
                                createFolder = true;
                                setInvitation = true;
                            }
                            else
                            {
                                // Nothing -> Document
                                // Create the document and the first version.
                                createDocument = true;
                            }
                        }
                        else if (file is Folder)
                        {
                            if (node.IsFolder)
                            {
                                // Folder -> Folder
                                // Only a possible rename or invitation change is needed.
                                setInvitation = true;
                                setDisplayName = true;
                            }
                            else
                            {
                                // Folder -> Document
                                // The folder is implicitly being deleted.

                                RenameAndDeleteConflictingFile(parentFolder, file, "Deleted", quotaCharge, changelist);
                                replaced = true;
                                createDocument = true;
                            }
                        }
                        else if (file is Document)
                        {
                            if (node.IsFolder)
                            {
                                // Document -> Folder
                                // The document is implicitly being deleted.

                                RenameAndDeleteConflictingFile(parentFolder, file, "Deleted", quotaCharge, changelist);
                                replaced = true;
                                createFolder = true;
                                setInvitation = true;
                            }
                            else
                            {
                                // Document -> Document
                                // Add a version.
                                createDocumentVersion = true;
                                setDisplayName = true;
                            }
                        }

                        // Apply the required changes.

                        if (file != null && !replaced)
                        {
                            // Undelete the file if it is deleted.

                            if (file.State != ObjectState.Normal)
                            {
                                file.State = ObjectState.Normal;
                                undeleted = true;
                                createChange = true;
                            }
                        }

                        if (createFolder)
                        {
                            file = _context.Folders.Add(new Folder
                            {
                                Name = node.Name,
                                DisplayName = clientChangesByFullName[node.FullName].DisplayName ?? node.Name,
                                ParentFolder = parentFolder,
                                Owner = parentFolder.Owner
                            });
                            createChange = true;
                        }
                        else if (createDocument)
                        {
                            file = _context.Documents.Add(new Document
                            {
                                Name = node.Name,
                                DisplayName = clientChangesByFullName[node.FullName].DisplayName ?? node.Name,
                                ParentFolder = parentFolder
                            });
                            createDocumentVersion = true;
                            createChange = true;
                        }

                        if (createDocumentVersion)
                        {
                            string hash = clientChangesByFullName[node.FullName].Hash.ToUpperInvariant();
                            bool identicalVersion = false;
                            long latestSize = 0;

                            if (!createDocument)
                            {
                                var latestBlob = GetLastDocumentVersion((Document)file).Blob;

                                latestSize = latestBlob.Size;

                                if (hash == latestBlob.Hash)
                                    identicalVersion = true;
                            }

                            if (!identicalVersion)
                            {
                                var blob = presentHashes[hash];

                                _context.DocumentVersions.Add(new DocumentVersion
                                {
                                    TimeStamp = DateTime.UtcNow,
                                    ClientId = client.Id,
                                    Document = (Document)file,
                                    Blob = blob
                                });
                                createChange = true;

                                AddQuotaCharge(quotaCharge, file.ParentFolder.Owner, (undeleted ? 0 : -latestSize) + blob.Size);
                            }
                            else if (undeleted)
                            {
                                AddQuotaCharge(quotaCharge, file.ParentFolder.Owner, latestSize);
                            }
                        }

                        if (setInvitation)
                        {
                            long? invitationId = clientChangesByFullName[node.FullName].InvitationId;

                            if (invitationId != null)
                            {
                                if (invitationId.Value != 0 && ((Folder)file).OwnerId == client.UserId)
                                {
                                    var invitation = (
                                        from i in client.User.Invitations.AsQueryable()
                                        where i.Id == invitationId.Value
                                        select i
                                        ).SingleOrDefault();

                                    if (invitation != null)
                                    {
                                        // Remove all other folders that link to this invitation.
                                        invitation.AcceptedFolders.Clear();
                                        invitation.AcceptedFolders.Add((Folder)file);
                                    }
                                }
                                else
                                {
                                    ((Folder)file).InvitationId = null;
                                }
                            }
                        }

                        if (setDisplayName && !string.IsNullOrEmpty(clientChangesByFullName[node.FullName].DisplayName))
                        {
                            if (file.DisplayName != clientChangesByFullName[node.FullName].DisplayName)
                            {
                                file.DisplayName = clientChangesByFullName[node.FullName].DisplayName;
                                createChange = true;
                            }
                        }

                        break;

                    case ChangeType.SetDisplayName:
                        if (file != null && !string.IsNullOrEmpty(clientChangesByFullName[node.FullName].DisplayName))
                        {
                            if (file.DisplayName != clientChangesByFullName[node.FullName].DisplayName)
                            {
                                file.DisplayName = clientChangesByFullName[node.FullName].DisplayName;
                                createChange = true;
                            }
                        }

                        break;

                    case ChangeType.Delete:
                        if (file != null && file.State != ObjectState.Deleted)
                        {
                            SetFileState(file, ObjectState.Deleted, quotaCharge, changelist);
                            createChange = true;
                        }
                        break;

                    case ChangeType.Undelete:
                        if (file != null && file is Document && file.State != ObjectState.Normal)
                        {
                            SetFileState(file, ObjectState.Normal, quotaCharge, changelist);
                            createChange = true;
                        }
                        break;
                }

                if (createChange)
                {
                    // Create the associated change object.
                    changelist.Changes.Add(new Change
                    {
                        Type = node.Type,
                        FullName = node.FullName,
                        IsFolder = node.IsFolder
                    });
                }

                if (file != null)
                {
                    fileCache.Add(node.FullName, file);

                    if (node.Nodes != null)
                    {
                        foreach (var subNode in node.Nodes.Values)
                            queue.Enqueue(subNode);
                    }
                }
            }

            // Apply quotas.
            foreach (var pair in quotaCharge)
            {
                if (pair.Key.QuotaCharged + pair.Value > pair.Key.QuotaLimit)
                    throw new Exception("Quota exceeded for user '" + pair.Key.Name + "'");

                pair.Key.QuotaCharged += pair.Value;
            }

            if (changelist.Changes.Count != 0)
                _context.Changelists.Add(changelist);

            return changelist;
        }
		/// <summary>
		/// Checks if a provided changelist supports the new tagging system or not
		/// </summary>
		/// <param name="InChangelist">Changelist to check if it supports the new tagging system</param>
		/// <returns>true if the changelist supports the tagging system; false otherwise</returns>
		public static bool ChangelistSupportsTagging(Changelist InChangelist)
		{
			// See if anything in the changelist description matches the start tag regex pattern
            return Regex.IsMatch(InChangelist.Description, P4StartTag.StartTagPattern, RegexOptions.IgnoreCase);
		}