当前位置: 首页>>代码示例>>C#>>正文


C# HgRepository.Update方法代码示例

本文整理汇总了C#中HgRepository.Update方法的典型用法代码示例。如果您正苦于以下问题:C# HgRepository.Update方法的具体用法?C# HgRepository.Update怎么用?C# HgRepository.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HgRepository的用法示例。


在下文中一共展示了HgRepository.Update方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MakeCloneFromLocalToLocal

        //TODO: get rid of this, or somehow combine it with the other Clone() options out there
        /// <returns>path to clone, or empty if it failed</returns>
        private static string MakeCloneFromLocalToLocal(string sourcePath, string targetDirectory, bool cloningFromUsb, IProgress progress)
        {
            RequireThat.Directory(sourcePath).Exists();
            //Handled by GetUniqueFolderPath call now down in CloneLocal call. RequireThat.Directory(targetDirectory).DoesNotExist();
            RequireThat.Directory(targetDirectory).Parent().Exists();

            HgRepository local = new HgRepository(sourcePath, progress);

            if (!local.RemoveOldLocks())
            {
                progress.WriteError("Chorus could not create the clone at this time.  Try again after restarting the computer.");
                return string.Empty;
            }

            using (new ConsoleProgress("Trying to Create repository clone at {0}", targetDirectory))
            {
                // Make a backward compatibile clone if cloning to USB (http://mercurial.selenic.com/wiki/UpgradingMercurial)
                targetDirectory = local.CloneLocalWithoutUpdate(targetDirectory, cloningFromUsb ? null : "--config format.dotencode=false --pull");
                File.WriteAllText(Path.Combine(targetDirectory, "~~Folder has an invisible repository.txt"), "In this folder, there is a (possibly hidden) folder named '.hg' that contains the actual data of this Chorus repository. Depending on your Operating System settings, that leading '.' might make the folder invisible to you. But Chorus clients (WeSay, FLEx, OneStory, etc.) can see it and can use this folder to perform Send/Receive operations.");

                if (cloningFromUsb)
                {
                    var clone = new HgRepository(targetDirectory, progress);
                    clone.Update();
                }
                return targetDirectory;
            }
        }
开发者ID:regnrand,项目名称:chorus,代码行数:30,代码来源:HgHighLevel.cs

示例2: MakeCloneFromLocalToLocal

        //TODO: get rid of this, or somehow combine it with the other Clone() options out there
        /// <returns>path to clone, or empty if it failed</returns>
        public static string MakeCloneFromLocalToLocal(string sourcePath, string targetDirectory, bool alsoDoCheckout, IProgress progress)
        {
            RequireThat.Directory(sourcePath).Exists();
            //Handled by GetUniqueFolderPath call now down in CloneLocal call. RequireThat.Directory(targetDirectory).DoesNotExist();
            RequireThat.Directory(targetDirectory).Parent().Exists();

            HgRepository local = new HgRepository(sourcePath, progress);

            if (!local.RemoveOldLocks())
            {
                progress.WriteError("Chorus could not create the clone at this time.  Try again after restarting the computer.");
                return string.Empty;
            }

            using (new ConsoleProgress("Trying to Create repository clone at {0}", targetDirectory))
            {
                targetDirectory = local.CloneLocalWithoutUpdate(targetDirectory);
                File.WriteAllText(Path.Combine(targetDirectory, "~~Folder has an invisible repository.txt"), "In this folder, there is a (possibly hidden) folder named '.hg' that contains the actual data of this Chorus repository. Depending on your Operating System settings, that leading '.' might make the folder invisible to you. But Chorus clients (WeSay, FLEx, OneStory, etc.) can see it and can use this folder to perform Send/Receive operations.");

                if (alsoDoCheckout)
                {
                    // string userIdForCLone = string.Empty; /* don't assume it's this user... a repo on a usb key probably shouldn't have a user default */
                    var clone = new HgRepository(targetDirectory, progress);
                    clone.Update();
                }
                return targetDirectory;
            }
        }
开发者ID:JessieGriffin,项目名称:chorus,代码行数:30,代码来源:HgHighLevel.cs

示例3: StartWorking

		/// <summary>
		/// Start doing whatever is needed for the supported type of action.
		/// </summary>
		public void StartWorking(Dictionary<string, string> commandLineArgs)
		{
			// undo_export_lift: -p <$fwroot>\foo where 'foo' is the project folder name
			// Calling Utilities.LiftOffset(commandLineArgs["-p"]) will use the folder: <$fwroot>\foo\OtherRepositories\foo_Lift
			var pathToRepository = Utilities.LiftOffset(commandLineArgs["-p"]);
			var repo = new HgRepository(pathToRepository, new NullProgress());
			repo.Update();
			// Delete any new files (except import failure notifier file).
			var newbies = repo.GetChangedFiles();
			foreach (var goner in newbies.Where(newFile => newFile.Trim() != LiftUtilties.FailureFilename))
			{
				File.Delete(Path.Combine(pathToRepository, goner.Trim()));
			}
		}
开发者ID:gmartin7,项目名称:flexbridge,代码行数:17,代码来源:UndoExportLiftActionHandler.cs

示例4: UpdateToTheDescendantRevision

        /// <summary>
        /// If everything got merged, then this is trivial. But in case of a merge failure,
        /// the "tip" might be the other guy's unmergable data (maybe because he has a newer
        /// version of some application than we do) We don't want to switch to that!
        ///
        /// So if there are more than one head out there, we update to the one that is a descendant
        /// of our latest checkin (which in the simple merge failure case is the the checkin itself,
        /// but in a 3-or-more source scenario could be the result of a merge with a more cooperative
        /// revision).
        /// </summary>
        private void UpdateToTheDescendantRevision(HgRepository repository, Revision parent)
        {
            try
            {
                var heads = repository.GetHeads();
                //if there is only one head for the branch we started from just update
                if (heads.Count(rev => rev.Branch == parent.Branch) == 1)
                {
                    repository.Update(); //update to the tip
                    _sychronizerAdjunct.SimpleUpdate(_progress, false);
                    return;
                }
                if (heads.Count == 0)
                {
                    return;//nothing has been checked in, so we're done! (this happens during some UI tests)
                }

                //  when there are more than 2 people merging and there's a failure or a no-op merge happened
                foreach (var head in heads)
                {
                    if (parent.Number.Hash == head.Number.Hash || (head.Branch == parent.Branch && head.IsDirectDescendantOf(parent)))
                    {
                        repository.RollbackWorkingDirectoryToRevision(head.Number.LocalRevisionNumber);
                        _sychronizerAdjunct.SimpleUpdate(_progress, true);
                        return;
                    }
                }

                _progress.WriteWarning("Staying at previous-tip (unusual). Other users recent changes will not be visible.");
            }
            catch (UserCancelledException)
            {
                throw;
            }
            catch (Exception error)
            {
                  ExplainAndThrow(error, "Could not update.");
            }
        }
开发者ID:JessieGriffin,项目名称:chorus,代码行数:49,代码来源:Synchronizer.cs

示例5: SendToOneOther

        private void SendToOneOther(RepositoryAddress address, Dictionary<RepositoryAddress, bool> connectionAttempt, HgRepository repo)
        {
            try
            {
                string resolvedUri = address.GetPotentialRepoUri(Repository.Identifier, RepoProjectName, _progress);

                bool canConnect;
                if (connectionAttempt.ContainsKey(address))
                {
                    canConnect = connectionAttempt[address];
                }
                else
                {
                    canConnect = address.CanConnect(repo, RepoProjectName, _progress);
                    connectionAttempt.Add(address, canConnect);
                }
                if (canConnect)
                {
                    if(s_testingDoNotPush)
                    {
                        _progress.WriteWarning("**Skipping push because s_testingDoNotPush is true");
                    }
                    else
                    {
                        repo.Push(address, resolvedUri);
                    }

                    // For usb, it's safe and desireable to do an update (bring into the directory
                    // the latest files from the repo) for LAN, it could be... for now we assume it is.
                    // For me (RandyR) including the shared network folder
                    // failed to do the update and killed the process, which left a 'wlock' file
                    // in the shared folder's '.hg' folder. No more S/Rs could then be done,
                    // because the repo was locked.
                    // For now, at least, it is not a requirement to do the update on the shared folder.
                    // JDH Oct 2010: added this back in if it doesn't look like a shared folder
                    if (address is UsbKeyRepositorySource  ||
                        (address is DirectoryRepositorySource && ((DirectoryRepositorySource)address).LooksLikeLocalDirectory))
                    {
                        var otherRepo = new HgRepository(resolvedUri, _progress);
                        otherRepo.Update();
                    }
                }
                else if (address is UsbKeyRepositorySource || address is DirectoryRepositorySource)
                {
                    // If we cannot connect to a USB or Directory source (the repository doesn't exist),
                    // try to clone our repository onto the source
                    TryToMakeCloneForSource(address);
                    //nb: no need to push if we just made a clone
                }
            }
            catch (UserCancelledException)
            {
                throw;
            }
            catch (Exception error)
            {
                ExplainAndThrow(error, "Failed to send to {0} ({1}).", address.Name, address.URI);
            }
        }
开发者ID:JessieGriffin,项目名称:chorus,代码行数:59,代码来源:Synchronizer.cs

示例6: UpdateToTheCorrectBranchHeadIfPossible

		private static void UpdateToTheCorrectBranchHeadIfPossible(Dictionary<string, string> commandLineArgs,
				ActualCloneResult cloneResult,
				string cloneLocation)
		{
			var repo = new HgRepository(cloneLocation, new NullProgress());
			Dictionary<string, Revision> allHeads = Utilities.CollectAllBranchHeads(cloneLocation);
			var desiredBranchName = commandLineArgs["-fwmodel"];
			var desiredModelVersion = uint.Parse(desiredBranchName);
			Revision desiredRevision;
			if (!allHeads.TryGetValue(desiredBranchName, out desiredRevision))
			{
				// Remove any that are too high.
				var gonerKeys = new HashSet<string>();
				foreach (var headKvp in allHeads)
				{
					uint currentVersion;
					if (headKvp.Key == Default)
					{
						repo.Update(headKvp.Value.Number.LocalRevisionNumber);
						var modelVersion = FLExProjectUnifier.GetModelVersion(cloneLocation);
						currentVersion = (modelVersion == null)
											 ? uint.MaxValue // Get rid of the initial default commit by making it max for uint. It had no model version file.
											 : uint.Parse(modelVersion);
					}
					else
					{
						currentVersion = uint.Parse(headKvp.Value.Branch);
					}
					if (currentVersion > desiredModelVersion)
					{
						gonerKeys.Add((headKvp.Key == Default) ? Default : headKvp.Key);
					}
				}
				foreach (var goner in gonerKeys)
				{
					allHeads.Remove(goner);
				}

				// Replace 'default' with its real model number.
				if (allHeads.ContainsKey(Default))
				{
					repo.Update(allHeads[Default].Number.LocalRevisionNumber);
					var modelVersion = FLExProjectUnifier.GetModelVersion(cloneLocation);
					if (modelVersion != null)
					{
						if (allHeads.ContainsKey(modelVersion))
						{
							// Pick the highest revision of the two.
							var defaultHead = allHeads[Default];
							var otherHead = allHeads[modelVersion];
							var defaultRevisionNumber = int.Parse(defaultHead.Number.LocalRevisionNumber);
							var otherRevisionNumber = int.Parse(otherHead.Number.LocalRevisionNumber);
							allHeads[modelVersion] = defaultRevisionNumber > otherRevisionNumber ? defaultHead : otherHead;
						}
						else
						{
							allHeads.Add(modelVersion, allHeads[Default]);
						}
					}
					allHeads.Remove(Default);
				}

				// 'default' is no longer present in 'allHeads'.
				// If all of them are higher, then it is a no go.
				if (allHeads.Count == 0)
				{
					// No useable model version, so bailout with a message to the user telling them they are 'toast'.
					cloneResult.FinalCloneResult = FinalCloneResult.FlexVersionIsTooOld;
					cloneResult.Message = CommonResources.kFlexUpdateRequired;
					Directory.Delete(cloneLocation, true);
					return;
				}

				// Now. get to the real work.
				var sortedRevisions = new SortedList<uint, Revision>();
				foreach (var kvp in allHeads)
				{
					sortedRevisions.Add(uint.Parse(kvp.Key), kvp.Value);
				}
				desiredRevision = sortedRevisions.Values[sortedRevisions.Count - 1];
			}
			repo.Update(desiredRevision.Number.LocalRevisionNumber);
			cloneResult.ActualCloneFolder = cloneLocation;
			cloneResult.FinalCloneResult = FinalCloneResult.Cloned;
		}
开发者ID:gmartin7,项目名称:flexbridge,代码行数:85,代码来源:ObtainProjectStrategyFlex.cs

示例7: UpdateToTheCorrectBranchHeadIfPossible

        internal static void UpdateToTheCorrectBranchHeadIfPossible(string cloneLocation, string desiredBranchName, ActualCloneResult cloneResult)
        {
            var repo = new HgRepository(cloneLocation, new NullProgress());
            Dictionary<string, Revision> allHeads = Utilities.CollectAllBranchHeads(cloneLocation);
            var desiredModelVersion = float.Parse(desiredBranchName.Replace("LIFT", null));
            Revision desiredRevision;
            if (!allHeads.TryGetValue(desiredBranchName, out desiredRevision))
            {
                // Remove any that are too high.
                var gonerKeys = new HashSet<string>();
                foreach (var headKvp in allHeads)
                {
                    float currentVersion;
                    if (headKvp.Key == Default)
                    {
                        repo.Update(headKvp.Value.Number.LocalRevisionNumber);
                        currentVersion = GetLiftVersionNumber(cloneLocation);
                    }
                    else
                    {
                        currentVersion = float.Parse(headKvp.Value.Branch);
                    }
                    if (currentVersion > desiredModelVersion)
                    {
                        gonerKeys.Add((headKvp.Key == Default) ? Default : headKvp.Key);
                    }
                }
                foreach (var goner in gonerKeys)
                {
                    allHeads.Remove(goner);
                }

                // Replace 'default' with its real model number.
                if (allHeads.ContainsKey(Default))
                {
                    repo.Update(allHeads[Default].Number.LocalRevisionNumber);
                    var modelVersion = GetLiftVersionNumber(cloneLocation);
                    var fullModelVersion = "LIFT" + modelVersion;
                    if (allHeads.ContainsKey(fullModelVersion))
                    {
                        // Pick the highest revision of the two.
                        var defaultHead = allHeads[Default];
                        var otherHead = allHeads[fullModelVersion];
                        var defaultRevisionNumber = int.Parse(defaultHead.Number.LocalRevisionNumber);
                        var otherRevisionNumber = int.Parse(otherHead.Number.LocalRevisionNumber);
                        allHeads[fullModelVersion] = defaultRevisionNumber > otherRevisionNumber ? defaultHead : otherHead;
                    }
                    else
                    {
                        allHeads.Add(fullModelVersion, allHeads[Default]);
                    }
                    allHeads.Remove(Default);
                }

                // 'default' is no longer present in 'allHeads'.
                // If all of them are higher, then it is a no go.
                if (allHeads.Count == 0)
                {
                    // No useable model version, so bailout with a message to the user telling them they are 'toast'.
                    cloneResult.FinalCloneResult = FinalCloneResult.FlexVersionIsTooOld;
                    cloneResult.Message = CommonResources.kFlexUpdateRequired;
                    Directory.Delete(cloneLocation, true);
                    return;
                }

                // Now. get to the real work.
                var sortedRevisions = new SortedList<float, Revision>();
                foreach (var kvp in allHeads)
                {
                    sortedRevisions.Add(float.Parse(kvp.Key.Replace("LIFT", null)), kvp.Value);
                }
                desiredRevision = sortedRevisions.Values[sortedRevisions.Count - 1];
            }
            repo.Update(desiredRevision.Number.LocalRevisionNumber);
            cloneResult.ActualCloneFolder = cloneLocation;
            cloneResult.FinalCloneResult = FinalCloneResult.Cloned;
        }
开发者ID:StephenMcConnel,项目名称:flexbridge,代码行数:77,代码来源:ObtainProjectStrategyLift.cs

示例8: SendToOneOther

        private void SendToOneOther(RepositoryAddress address, Dictionary<RepositoryAddress, bool> connectionAttempt, HgRepository repo)
        {
            try
            {
                string resolvedUri = address.GetPotentialRepoUri(Repository.Identifier, RepoProjectName, _progress);

                bool canConnect;
                if (connectionAttempt.ContainsKey(address))
                {
                    canConnect = connectionAttempt[address];
                }
                else
                {
                    canConnect = address.CanConnect(repo, RepoProjectName, _progress);
                    connectionAttempt.Add(address, canConnect);
                }
                if (canConnect)
                {
                    if(s_testingDoNotPush)
                    {
                        _progress.WriteWarning("**Skipping push because s_testingDoNotPush is true");
                    }
                    else
                    {
                        repo.Push(address, resolvedUri);
                    }

                    // For USB, we do not wish to do an update, since it can cause problems if the working
                    // files are available to the user.
                    // The update is only done for tests, since only tests now use "DirectoryRepositorySource".
                    if (address is DirectoryRepositorySource && ((DirectoryRepositorySource) address).LooksLikeLocalDirectory)
                    {
                        // passes false to avoid updating the hgrc on a send to preserve backward compatibility
                        var otherRepo = new HgRepository(resolvedUri, false, _progress);
                        otherRepo.Update();
                    }
                }
                else if (address is UsbKeyRepositorySource || address is DirectoryRepositorySource)
                {
                    // If we cannot connect to a USB or Directory source (the repository doesn't exist),
                    // try to clone our repository onto the source
                    TryToMakeCloneForSource(address);
                    //nb: no need to push if we just made a clone
                }
            }
            catch (UserCancelledException)
            {
                throw;
            }
            catch (Exception error)
            {
                ExplainAndThrow(error, "Failed to send to {0} ({1}).", address.Name, address.URI);
            }
        }
开发者ID:regnrand,项目名称:chorus,代码行数:54,代码来源:Synchronizer.cs


注:本文中的HgRepository.Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。