示例#1
0
        private IGitTfsRemote InitTfsRemoteOfChangeset(IBranchObject tfsBranch, int parentChangesetId, IRenameResult renameResult = null)
        {
            if (tfsBranch.IsRoot)
            {
                return(InitTfsBranch(this.remoteOptions, tfsBranch.Path));
            }

            var branchesDatas = Tfs.GetRootChangesetForBranch(tfsBranch.Path, parentChangesetId);

            IGitTfsRemote remote = null;

            foreach (var branch in branchesDatas)
            {
                var rootChangesetId = branch.RootChangeset;
                remote = InitBranch(this.remoteOptions, tfsBranch.Path, rootChangesetId, true);
                if (remote == null)
                {
                    stdout.WriteLine("warning: root commit not found corresponding to changeset " + rootChangesetId);
                    stdout.WriteLine("=> continuing anyway by creating a branch without parent...");
                    return(InitTfsBranch(this.remoteOptions, tfsBranch.Path));
                }

                if (branch.IsRenamedBranch)
                {
                    remote.Fetch(renameResult: renameResult);
                }
            }

            return(remote);
        }
示例#2
0
        private IGitTfsRemote InitTfsRemoteOfChangeset(IBranchObject tfsBranch, int parentChangesetId)
        {
            if (tfsBranch.IsRoot)
            {
                return(InitTfsBranch(this.remoteOptions, tfsBranch.Path));
            }

            var branchesDatas = Tfs.GetRootChangesetForBranch(tfsBranch.Path, parentChangesetId);

            IGitTfsRemote remote = null;

            foreach (var branch in branchesDatas)
            {
                var rootChangesetId = branch.RootChangeset;
                remote = InitBranch(this.remoteOptions, tfsBranch.Path, rootChangesetId, true);
                if (remote == null)
                {
                    stdout.WriteLine("error: root commit not found corresponding to changeset " + rootChangesetId);
                    return(null);
                }

                if (branch.IsRenamedBranch)
                {
                    remote.Fetch();
                }
            }

            return(remote);
        }
示例#3
0
文件: IBranch.cs 项目: runt18/git-tfs
 public BranchTree(IBranchObject branch, List<BranchTree> childBranches)
 {
     if (childBranches == null)
         throw new ArgumentNullException("childBranches");
     Branch = branch;
     ChildBranches = childBranches;
 }
示例#4
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);
        }
示例#5
0
 public BranchTree(IBranchObject branch, List <BranchTree> childBranches)
 {
     if (childBranches == null)
     {
         throw new ArgumentNullException("childBranches");
     }
     Branch        = branch;
     ChildBranches = childBranches;
 }
示例#6
0
        private IGitTfsRemote InitTfsRemoteOfChangeset(IBranchObject tfsBranch, int parentChangesetId, IRenameResult renameResult = null)
        {
            if (tfsBranch.IsRoot)
            {
                return(InitTfsBranch(this.remoteOptions, tfsBranch.Path));
            }

            var branchesDatas = Tfs.GetRootChangesetForBranch(tfsBranch.Path, parentChangesetId);

            IGitTfsRemote remote = null;

            foreach (var branch in branchesDatas)
            {
                var rootChangesetId = branch.RootChangeset;
                remote = InitBranch(this.remoteOptions, tfsBranch.Path, rootChangesetId, true);
                if (remote == null)
                {
                    stdout.WriteLine("warning: root commit not found corresponding to changeset " + rootChangesetId);
                    stdout.WriteLine("=> continuing anyway by creating a branch without parent...");
                    return(InitTfsBranch(this.remoteOptions, tfsBranch.Path));
                }

                if (branch.IsRenamedBranch)
                {
                    try
                    {
                        remote.Fetch(renameResult: renameResult);
                    }
                    finally
                    {
                        Trace.WriteLine("Cleaning...");
                        remote.CleanupWorkspaceDirectory();

                        if (remote.Repository.IsBare)
                        {
                            remote.Repository.UpdateRef(GitRepository.ShortToLocalName(remote.Id), remote.MaxCommitHash);
                        }
                    }
                }
            }

            return(remote);
        }
示例#7
0
        private IGitTfsRemote InitTfsRemoteOfChangeset(IBranchObject tfsBranch, int parentChangesetId, IRenameResult renameResult = null)
        {
            if (tfsBranch.IsRoot)
            {
                return InitTfsBranch(this.remoteOptions, tfsBranch.Path);
            }

            var branchesDatas = Tfs.GetRootChangesetForBranch(tfsBranch.Path, parentChangesetId);

            IGitTfsRemote remote = null;
            foreach (var branch in branchesDatas)
            {
                var rootChangesetId = branch.RootChangeset;
                remote = InitBranch(this.remoteOptions, tfsBranch.Path, rootChangesetId, true);
                if (remote == null)
                {
                    stdout.WriteLine("warning: root commit not found corresponding to changeset " + rootChangesetId);
                    stdout.WriteLine("=> continuing anyway by creating a branch without parent...");
                    return InitTfsBranch(this.remoteOptions, tfsBranch.Path);
                }

                if (branch.IsRenamedBranch)
                {
                    try
                    {
                        remote.Fetch(renameResult: renameResult);
                    }
                    finally
                    {
                        Trace.WriteLine("Cleaning...");
                        remote.CleanupWorkspaceDirectory();

                        if (remote.Repository.IsBare)
                            remote.Repository.UpdateRef(GitRepository.ShortToLocalName(remote.Id), remote.MaxCommitHash);
                    }
                }
            }

            return remote;
        }
示例#8
0
 public BranchTree(IBranchObject branch, IEnumerable <BranchTree> childBranches)
     : this(branch, childBranches.ToList())
 {
 }
示例#9
0
 public BranchTree(IBranchObject branch)
     : this(branch, new List <BranchTree>())
 {
 }
示例#10
0
 public BranchTree(IBranchObject branch, IEnumerable<BranchTree> childBranches)
     : this(branch, childBranches.ToList())
 {
 }
示例#11
0
 public BranchTree(IBranchObject branch)
     : this(branch, new List<BranchTree>())
 {
 }
示例#12
0
        private IGitTfsRemote InitTfsRemoteOfChangeset(IBranchObject tfsBranch, int parentChangesetId, IRenameResult renameResult = null)
        {
            if (tfsBranch.IsRoot)
            {
                return InitTfsBranch(this.remoteOptions, tfsBranch.Path);
            }

            var branchesDatas = Tfs.GetRootChangesetForBranch(tfsBranch.Path, parentChangesetId);

            IGitTfsRemote remote = null;
            foreach (var branch in branchesDatas)
            {
                var rootChangesetId = branch.RootChangeset;
                remote = InitBranch(this.remoteOptions, tfsBranch.Path, rootChangesetId, true);
                if (remote == null)
                {
                    stdout.WriteLine("warning: root commit not found corresponding to changeset " + rootChangesetId);
                    stdout.WriteLine("=> continuing anyway by creating a branch without parent...");
                    return InitTfsBranch(this.remoteOptions, tfsBranch.Path);
                }

                if (branch.IsRenamedBranch)
                    remote.Fetch(renameResult:renameResult);
            }

            return remote;
        }
示例#13
0
        private IGitTfsRemote InitTfsRemoteOfChangeset(IBranchObject tfsBranch, int parentChangesetId)
        {
            if (tfsBranch.IsRoot)
            {
                return InitTfsBranch(this.remoteOptions, tfsBranch.Path);
            }

            var branchesDatas = Tfs.GetRootChangesetForBranch(tfsBranch.Path, parentChangesetId);

            IGitTfsRemote remote = null;
            foreach (var branch in branchesDatas)
            {
                var rootChangesetId = branch.RootChangeset;
                remote = InitBranch(this.remoteOptions, tfsBranch.Path, rootChangesetId, true);
                if (remote == null)
                {
                    stdout.WriteLine("error: root commit not found corresponding to changeset " + rootChangesetId);
                    return null;
                }

                if (branch.IsRenamedBranch)
                    remote.Fetch();
            }

            return remote;
        }