Example #1
0
        private IGitTfsRemote FindOrInitTfsRemoteOfChangeset(int parentChangesetId, bool mergeChangeset, IRenameResult renameResult, out string omittedParentBranch)
        {
            omittedParentBranch = null;
            IGitTfsRemote tfsRemote;
            IChangeset    parentChangeset = Tfs.GetChangeset(parentChangesetId);
            //I think you want something that uses GetPathInGitRepo and ShouldSkip. See TfsChangeset.Apply.
            //Don't know if there is a way to extract remote tfs repository path from changeset datas! Should be better!!!
            var remote = Repository.ReadAllTfsRemotes().FirstOrDefault(r => parentChangeset.Changes.Any(c => r.GetPathInGitRepo(c.Item.ServerItem) != null));

            if (remote != null)
            {
                tfsRemote = remote;
            }
            else
            {
                // If the changeset has created multiple folders, the expected branch folder will not always be the first
                // so we scan all the changes of type folder to try to detect the first one which is a branch.
                // In most cases it will change nothing: the first folder is the good one
                IBranchObject tfsBranch   = null;
                string        tfsPath     = null;
                var           allBranches = Tfs.GetBranches(true);
                foreach (var change in parentChangeset.Changes)
                {
                    tfsPath = change.Item.ServerItem;
                    tfsPath = tfsPath.EndsWith("/") ? tfsPath : tfsPath + "/";

                    tfsBranch = allBranches.SingleOrDefault(b => tfsPath.StartsWith(b.Path.EndsWith("/") ? b.Path : b.Path + "/"));
                    if (tfsBranch != null)
                    {
                        // we found a branch, we stop here
                        break;
                    }
                }

                if (mergeChangeset && tfsBranch != null &&
                    string.Equals(Repository.GetConfig(GitTfsConstants.IgnoreNotInitBranches), true.ToString(), StringComparison.InvariantCultureIgnoreCase))
                {
                    Trace.TraceInformation("warning: skip not initialized branch for path " + tfsBranch.Path);
                    tfsRemote           = null;
                    omittedParentBranch = tfsBranch.Path + ";C" + parentChangesetId;
                }
                else if (tfsBranch == null)
                {
                    Trace.TraceInformation("error: branch not found. Verify that all the folders have been converted to branches (or something else :().\n\tpath {0}", tfsPath);
                    tfsRemote           = null;
                    omittedParentBranch = ";C" + parentChangesetId;
                }
                else
                {
                    tfsRemote = InitTfsRemoteOfChangeset(tfsBranch, parentChangeset.ChangesetId, renameResult);
                    if (tfsRemote == null)
                    {
                        omittedParentBranch = tfsBranch.Path + ";C" + parentChangesetId;
                    }
                }
            }
            return(tfsRemote);
        }
Example #2
0
        private string FindMergedRemoteAndFetch(int parentChangesetId, bool stopOnFailMergeCommit)
        {
            var tfsRemotes = FindTfsRemoteOfChangeset(Tfs.GetChangeset(parentChangesetId));

            foreach (var tfsRemote in tfsRemotes.Where(r => string.Compare(r.TfsRepositoryPath, this.TfsRepositoryPath, StringComparison.InvariantCultureIgnoreCase) != 0))
            {
                var fetchResult = tfsRemote.Fetch(stopOnFailMergeCommit);
            }
            return(Repository.FindCommitHashByChangesetId(parentChangesetId));
        }
Example #3
0
        private IGitTfsRemote FindOrInitTfsRemoteOfChangeset(int parentChangesetId, bool mergeChangeset, out string omittedParentBranch)
        {
            omittedParentBranch = null;
            IGitTfsRemote tfsRemote;
            IChangeset    parentChangeset = Tfs.GetChangeset(parentChangesetId);
            //I think you want something that uses GetPathInGitRepo and ShouldSkip. See TfsChangeset.Apply.
            //Don't know if there is a way to extract remote tfs repository path from changeset datas! Should be better!!!
            var remote = Repository.ReadAllTfsRemotes().FirstOrDefault(r => parentChangeset.Changes.Any(c => r.GetPathInGitRepo(c.Item.ServerItem) != null));

            if (remote != null)
            {
                tfsRemote = remote;
            }
            else
            {
                var tfsPath = parentChangeset.Changes.First().Item.ServerItem;
                tfsPath = tfsPath.EndsWith("/") ? tfsPath : tfsPath + "/";
                var tfsBranch = Tfs.GetBranches(true).SingleOrDefault(b => tfsPath.StartsWith(b.Path.EndsWith("/") ? b.Path : b.Path + "/"));

                if (mergeChangeset && tfsBranch != null && Repository.GetConfig(GitTfsConstants.IgnoreNotInitBranches) == true.ToString())
                {
                    stdout.WriteLine("warning: skip not initialized branch for path " + tfsBranch.Path);
                    tfsRemote           = null;
                    omittedParentBranch = tfsBranch.Path + ";C" + parentChangesetId;
                }
                else if (tfsBranch == null)
                {
                    stdout.WriteLine("error: branch  not found. Verify that all the folders have been converted to branches (or something else :().\n\tpath {0}", tfsPath);
                    tfsRemote           = null;
                    omittedParentBranch = ";C" + parentChangesetId;
                }
                else
                {
                    tfsRemote = InitTfsRemoteOfChangeset(tfsBranch, parentChangeset.ChangesetId);
                    if (tfsRemote == null)
                    {
                        omittedParentBranch = tfsBranch.Path + ";C" + parentChangesetId;
                    }
                }
            }
            return(tfsRemote);
        }
Example #4
0
 public void QuickFetch(int changesetId, bool ignoreRestricted, bool printRestrictionHint)
 {
     try
     {
         ITfsChangeset changeset;
         if (changesetId < 0)
         {
             changeset = GetLatestChangeset();
         }
         else
         {
             changeset = Tfs.GetChangeset(changesetId, this);
         }
         quickFetch(changeset);
     }
     catch (Exception ex)
     {
         Trace.WriteLine("Quick fetch failed: " + ex.Message);
         if (!IgnoreException(ex.Message, ignoreRestricted, printRestrictionHint))
         {
             throw;
         }
     }
 }
Example #5
0
 public ITfsChangeset GetChangeset(long changesetId)
 {
     return(Tfs.GetChangeset((int)changesetId, this));
 }
Example #6
0
        public void QuickFetch(int changesetId)
        {
            var changeset = Tfs.GetChangeset(changesetId, this);

            quickFetch(changeset);
        }
Example #7
0
 public ITfsChangeset GetChangeset(int changesetId)
 {
     return(Tfs.GetChangeset(changesetId, this));
 }