Esempio n. 1
0
        public int Checkin(string head, string parent, TfsChangesetInfo parentChangeset, CheckinOptions options, string sourceTfsPath = null)
        {
            var changeset = 0;

            WithWorkspace(parentChangeset, workspace => changeset = Checkin(head, parent, workspace, options, sourceTfsPath));
            return(changeset);
        }
Esempio n. 2
0
        public int CheckinTool(string head, TfsChangesetInfo parentChangeset)
        {
            var changeset = 0;

            WithWorkspace(parentChangeset, workspace => changeset = CheckinTool(head, parentChangeset, workspace));
            return(changeset);
        }
Esempio n. 3
0
        private string GetRemoteId(TfsChangesetInfo changeset)
        {
            if (IsAvailable(GitTfsConstants.DefaultRepositoryId))
            {
                Trace.TraceInformation("info: '" + changeset.Remote.TfsRepositoryPath + "' will be bootstraped as your main remote...");
                return(GitTfsConstants.DefaultRepositoryId);
            }

            //Remove '$/'!
            var expectedRemoteId = changeset.Remote.TfsRepositoryPath.Substring(2).Trim('/');
            var indexOfSlash     = expectedRemoteId.IndexOf('/');

            if (indexOfSlash != 0)
            {
                expectedRemoteId = expectedRemoteId.Substring(indexOfSlash + 1);
            }
            var remoteId = expectedRemoteId.ToGitRefName();
            var suffix   = 0;

            while (!IsAvailable(remoteId))
            {
                remoteId = expectedRemoteId + "-" + (suffix++);
            }
            return(remoteId);
        }
Esempio n. 4
0
        public IGitTfsRemote CreateRemote(TfsChangesetInfo changeset)
        {
            IGitTfsRemote remote;

            if (changeset.Remote.IsDerived)
            {
                var remoteId = GetRemoteId(changeset);
                remote = _globals.Repository.CreateTfsRemote(new RemoteInfo
                {
                    Id            = remoteId,
                    Url           = changeset.Remote.TfsUrl,
                    Repository    = changeset.Remote.TfsRepositoryPath,
                    RemoteOptions = _remoteOptions,
                });
                remote.UpdateTfsHead(changeset.GitCommit, changeset.ChangesetId);
                Trace.TraceInformation("-> new remote '" + remote.Id + "'");
            }
            else
            {
                remote = changeset.Remote;
                if (changeset.Remote.MaxChangesetId < changeset.ChangesetId)
                {
                    int oldChangeset = changeset.Remote.MaxChangesetId;
                    _globals.Repository.MoveTfsRefForwardIfNeeded(changeset.Remote);
                    Trace.TraceInformation("-> existing remote {0} (updated from changeset {1})", changeset.Remote.Id, oldChangeset);
                }
                else
                {
                    Trace.TraceInformation("-> existing remote {0} (up to date)", changeset.Remote.Id);
                }
            }
            return(remote);
        }
Esempio n. 5
0
 public TfsChangeset(ITfsHelper tfs, IChangeset changeset, TfsChangesetInfo tfsChangesetInfo, AuthorsFile authors)
 {
     _tfs            = tfs;
     _changeset      = changeset;
     _authors        = authors;
     Summary         = tfsChangesetInfo;
     BaseChangesetId = _changeset.Changes.Max(c => c.Item.ChangesetId) - 1;
 }
Esempio n. 6
0
        public TfsWorkspace(IWorkspace workspace, string localDirectory, TfsChangesetInfo contextVersion, IGitTfsRemote remote, CheckinOptions checkinOptions, ITfsHelper tfsHelper, CheckinPolicyEvaluator policyEvaluator)
        {
            _workspace       = workspace;
            _policyEvaluator = policyEvaluator;
            _contextVersion  = contextVersion;
            _checkinOptions  = checkinOptions;
            _tfsHelper       = tfsHelper;
            _localDirectory  = remote.Repository.IsBare ? Path.GetFullPath(localDirectory) : localDirectory;

            Remote = remote;
        }
Esempio n. 7
0
        private void WithWorkspace(TfsChangesetInfo parentChangeset, Action <ITfsWorkspace> action)
        {
            //are there any subtrees?
            var subtrees = _globals.Repository.GetSubtrees(this);

            if (subtrees.Any())
            {
                Tfs.WithWorkspace(WorkingDirectory, this, subtrees.Select(x => new Tuple <string, string>(x.TfsRepositoryPath, x.Prefix)), parentChangeset, action);
            }
            else
            {
                Tfs.WithWorkspace(WorkingDirectory, this, parentChangeset, action);
            }
        }
Esempio n. 8
0
        public IPendingSet[] QueryPendingSets(TfsChangesetInfo parentChangeset, string[] items, TfsRecursionType recursionType, string queryWorkspace, string queryUser)
        {
            IPendingSet[] ret = null;

            WithWorkspace(parentChangeset, workspace =>
            {
                var workspaceItems = items
                                     .Select(x => workspace.GetLocalPath(x))
                                     .ToArray();

                ret = Tfs.QueryPendingSets(workspaceItems, recursionType, queryWorkspace, queryUser);
            });

            return(ret);
        }
Esempio n. 9
0
 public int Checkin(string head, string parent, TfsChangesetInfo parentChangeset, CheckinOptions options, string sourceTfsPath = null)
 {
     throw DerivedRemoteException;
 }
Esempio n. 10
0
 public int CheckinTool(string head, TfsChangesetInfo parentChangeset)
 {
     throw DerivedRemoteException;
 }
Esempio n. 11
0
 public void Shelve(string shelvesetName, string treeish, TfsChangesetInfo parentChangeset, CheckinOptions options, bool evaluateCheckinPolicies)
 {
     throw DerivedRemoteException;
 }
Esempio n. 12
0
 private int CheckinTool(string head, TfsChangesetInfo parentChangeset, ITfsWorkspace workspace)
 {
     PendChangesToWorkspace(head, parentChangeset.GitCommit, workspace);
     return(workspace.CheckinTool(() => Repository.GetCommitMessage(head, parentChangeset.GitCommit)));
 }
Esempio n. 13
0
 private void Shelve(string shelvesetName, string head, TfsChangesetInfo parentChangeset, CheckinOptions options, bool evaluateCheckinPolicies, ITfsWorkspace workspace)
 {
     PendChangesToWorkspace(head, parentChangeset.GitCommit, workspace);
     workspace.Shelve(shelvesetName, evaluateCheckinPolicies, options, () => Repository.GetCommitMessage(head, parentChangeset.GitCommit));
 }
Esempio n. 14
0
 public void Shelve(string shelvesetName, string head, TfsChangesetInfo parentChangeset, CheckinOptions options, bool evaluateCheckinPolicies)
 {
     WithWorkspace(parentChangeset, workspace => Shelve(shelvesetName, head, parentChangeset, options, evaluateCheckinPolicies, workspace));
 }
Esempio n. 15
0
 public IPendingSet[] QueryPendingSets(TfsChangesetInfo parentChangeset, string[] items, TfsRecursionType recursionType, string queryWorkspace, string queryUser)
 {
     throw DerivedRemoteException;
 }