Esempio n. 1
0
        public static Task FetchOrPullAsync(
            Repository repository, Remote remote, bool pull,
            IProgress <OperationProgress> progress, CancellationToken cancellationToken)
        {
            var affectedReferences = ReferenceType.RemoteBranch | ReferenceType.Tag;

            if (pull)
            {
                affectedReferences |= ReferenceType.LocalBranch;
            }
            var suppressedNotifications = repository.Monitor.BlockNotifications(
                RepositoryNotifications.BranchChanged, RepositoryNotifications.TagChanged);
            var  state1 = RefsState.Capture(repository, affectedReferences);
            Task task;

            if (pull)
            {
                var p = new PullParameters();
                if (remote != null)
                {
                    p.Repository = remote.Name;
                }
                task = repository.Accessor.Pull.InvokeAsync(p, progress, cancellationToken);
            }
            else
            {
                var p = new FetchParameters();
                if (remote != null)
                {
                    p.Repository = remote.Name;
                }
                task = repository.Accessor.Fetch.InvokeAsync(p, progress, cancellationToken);
            }
            return(task.ContinueWith(
                       t =>
            {
                progress.Report(new OperationProgress(Resources.StrRefreshingReferences.AddEllipsis()));
                repository.Refs.Refresh(affectedReferences);
                var state2 = RefsState.Capture(repository, affectedReferences);
                var changes = RefsDiff.Calculate(state1, state2);
                suppressedNotifications.Dispose();
                if (changes != null && changes.Length != 0)
                {
                    repository.OnUpdated();
                }
                TaskUtility.PropagateFaultedStates(t);
                if (pull)
                {
                    repository.Remotes.OnPullCompleted(remote, changes);
                }
                else
                {
                    repository.Remotes.OnFetchCompleted(remote, changes);
                }
            }));
        }
Esempio n. 2
0
        public static void FetchOrPull(Repository repository, Remote remote, bool pull)
        {
            var affectedReferences = ReferenceType.RemoteBranch | ReferenceType.Tag;

            if (pull)
            {
                affectedReferences |= ReferenceType.LocalBranch;
            }
            ReferenceChange[] changes;
            var state1 = RefsState.Capture(repository, affectedReferences);

            using (repository.Monitor.BlockNotifications(
                       RepositoryNotifications.BranchChanged,
                       RepositoryNotifications.TagChanged))
            {
                try
                {
                    if (pull)
                    {
                        var p = new PullParameters();
                        if (remote != null)
                        {
                            p.Repository = remote.Name;
                        }
                        repository.Accessor.Pull.Invoke(p);
                    }
                    else
                    {
                        var p = new FetchParameters();
                        if (remote != null)
                        {
                            p.Repository = remote.Name;
                        }
                        repository.Accessor.Fetch.Invoke(p);
                    }
                }
                finally
                {
                    repository.Refs.Refresh(affectedReferences);
                    var state2 = RefsState.Capture(repository, affectedReferences);
                    changes = RefsDiff.Calculate(state1, state2);
                    if (changes != null && changes.Length != 0)
                    {
                        repository.OnUpdated();
                    }
                }
            }
            if (pull)
            {
                repository.Remotes.OnPullCompleted(remote, changes);
            }
            else
            {
                repository.Remotes.OnFetchCompleted(remote, changes);
            }
        }
Esempio n. 3
0
        public virtual Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;

            Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Document   doc   = uidoc.Document;

            if (!Utils.CheckFamilyDocument(doc))
            {
                return(Result.Cancelled);                                    //The method should only be used inside a FamilyDocument
            }
            PullParameters pull = new PullParameters(app, uidoc, doc);

            pull.Pull();

            return(Result.Succeeded);
        }
Esempio n. 4
0
        public Command GetPullCommand(PullParameters parameters, bool isAsync)
        {
            Assert.IsNotNull(parameters);

            var args = new List<ICommandArgument>();
            InsertPullParameters(parameters, args);
            if(isAsync && GitFeatures.ProgressFlag.IsAvailableFor(_gitCLI))
            {
                args.Add(FetchCommand.Progress());
            }
            return new PullCommand(args);
        }
Esempio n. 5
0
 private static void InsertPullParameters(PullParameters parameters, IList<ICommandArgument> args)
 {
     if(parameters.NoFastForward)
     {
         args.Add(MergeCommand.NoFastForward());
     }
     if(parameters.NoCommit)
     {
         args.Add(MergeCommand.NoCommit());
     }
     if(parameters.Squash)
     {
         args.Add(MergeCommand.Squash());
     }
     var arg = MergeCommand.Strategy(parameters.Strategy);
     if(arg != null)
     {
         args.Add(arg);
     }
     if(!string.IsNullOrEmpty(parameters.StrategyOption))
     {
         args.Add(MergeCommand.StrategyOption(parameters.StrategyOption));
     }
     InsertFetchParameters(parameters, args);
 }