Exemplo n.º 1
0
        public void ExportFiles(SourceControlContext context, string targetDirectory)
        {
            var tfsContext = (TfsSourceControlContext)context;

            this.LogDebug("Exporting files from \"{0}\" to \"{1}\"...", tfsContext.WorkspaceDiskPath, targetDirectory);
            this.CopyNonTfsFiles(tfsContext.WorkspaceDiskPath, targetDirectory);
        }
Exemplo n.º 2
0
        public override void EnsureLocalWorkspace(SourceControlContext context)
        {
            var repoPath = context.Repository.GetDiskPath(this.Agent);

            if (!this.Agent.DirectoryExists(repoPath) || !this.Agent.DirectoryExists(this.Agent.CombinePath(repoPath, ".hg")))
            {
                this.Agent.CreateDirectory(repoPath);
                this.Clone(context);
            }
        }
        public void ApplyLabel(string label, SourceControlContext context)
        {
            if (string.IsNullOrEmpty(label))
                throw new ArgumentNullException("label");

            if (context.Repository == null)
                throw new ArgumentException(context.ToLegacyPathString() + " does not represent a valid Git path.", "sourcePath");

            this.EnsureLocalRepository(context);
            this.UpdateLocalRepository(context, null);
            this.GitClient.ApplyTag(context.Repository, label);
        }
Exemplo n.º 4
0
 private void EnsureLocalWorkspaceInternal(SourceControlContext context)
 {
     this.LogDebug("Ensuring local workspace disk path: " + context.WorkspaceDiskPath);
     if (!Directory.Exists(context.WorkspaceDiskPath))
     {
         this.LogDebug("Creating workspace disk path...");
         Directory.CreateDirectory(context.WorkspaceDiskPath);
     }
     else
     {
         this.LogDebug("Workspace disk path exists.");
     }
 }
Exemplo n.º 5
0
        public ChangesTodayWidget()
        {
            sourceControlContext = new SourceControlContext();

            View = new ChangesTodayView()
            {
                DataContext = sourceControlContext.Changesets
            };

            var timer = new Timer((o) =>
            {
                LoadTodaysChangesets();
            }, null, 0, 30000);
        }
Exemplo n.º 6
0
        public override IEnumerable <string> EnumerateBranches(SourceControlContext context)
        {
            this.EnsureLocalWorkspace(context);
            this.UpdateLocalWorkspace(context);

            var result = this.ExecuteHgCommand(context.Repository, "heads", "--template \"{branch}\\r\\n\"");

            if (result.ExitCode != 0)
            {
                throw new InvalidOperationException(Util.CoalesceStr(string.Join(Environment.NewLine, result.Error), "Exit code was nonzero: " + result.ExitCode));
            }

            return(result.Output);
        }
Exemplo n.º 7
0
        public void OnInitialize()
        {
            Changesets = new ObservableCollection<ChangesetViewModel>();

            sourceControlContext = new SourceControlContext();
            lastSixChangesetsQuery = sourceControlContext.GetAllQuery().
                OrderByDescending(e => e.Time).Take(6);


            timer = new Timer((o) =>
            {
                LoadChangesets(lastSixChangesetsQuery);
            }, null, 0, 15000);
        }
Exemplo n.º 8
0
        public override void UpdateLocalWorkspace(SourceControlContext context)
        {
            if (string.IsNullOrEmpty(context.Repository.RemoteUrl))
            {
                return;
            }

            // pull changes if remote repository is used
            if (!string.IsNullOrEmpty(context.Repository.RemoteUrl))
            {
                this.ExecuteHgCommand(context.Repository, "pull", context.Repository.RemoteUrl);
            }

            // update the working repository, and do not check out the files
            this.ExecuteHgCommand(context.Repository, "update", "-C", context.Branch);
        }
Exemplo n.º 9
0
        public override object GetCurrentRevision(SourceControlContext context)
        {
            if (context.Repository == null)
            {
                throw new ArgumentException("Path must specify a Mercurial repository.");
            }

            this.UpdateLocalWorkspace(context);
            var res = this.ExecuteHgCommand(context.Repository, "log -r \"branch('default') and reverse(not(desc('Added tag ') and file(.hgtags)))\" -l1 --template \"{node}\"");

            if (!res.Output.Any())
            {
                return(string.Empty);
            }

            return(res.Output[0]);
        }
Exemplo n.º 10
0
        private void UpdateLocalWorkspaceInternal(SourceControlContext context)
        {
            using (var tfs = this.GetTeamProjectCollection())
            {
                var versionControlServer = tfs.GetService <VersionControlServer>();

                var workspace = this.GetMappedWorkspace(versionControlServer, (TfsSourceControlContext)context);
                if (context.Label != null)
                {
                    string sourcePath = ((TfsSourceControlContext)context).SourcePath;
                    var    getRequest = new GetRequest(new ItemSpec(sourcePath, RecursionType.Full), VersionSpec.ParseSingleSpec("L" + context.Label, versionControlServer.AuthorizedUser));
                    workspace.Get(getRequest, GetOptions.Overwrite);
                }
                else
                {
                    workspace.Get(VersionSpec.Latest, GetOptions.Overwrite);
                }
            }
        }
Exemplo n.º 11
0
        public override void GetLabeled(string label, SourceControlContext context, string targetPath)
        {
            if (string.IsNullOrEmpty(label))
            {
                throw new ArgumentNullException("label");
            }
            if (string.IsNullOrEmpty(targetPath))
            {
                throw new ArgumentNullException("targetPath");
            }

            if (context.Repository == null)
            {
                throw new ArgumentException(context.ToLegacyPathString() + " does not represent a valid Mercurial path.", "context");
            }

            this.UpdateLocalWorkspace(context);

            this.ExecuteHgCommand(context.Repository, "update", "-r \"" + label + "\"");
            this.ExportFiles(context, targetPath);
        }
Exemplo n.º 12
0
 public override void ExportFiles(SourceControlContext context, string targetDirectory)
 {
     this.ExecuteHgCommand(context.Repository, "archive", "\"" + targetDirectory + "\" -S -X \".hg*\"");
 }
        public object GetCurrentRevision(SourceControlContext context)
        {
            if (context.Repository == null)
                throw new ArgumentException(context.ToLegacyPathString() + " does not represent a valid Git path.", "sourcePath");

            this.EnsureLocalRepository(context);
            this.GitClient.UpdateLocalRepo(context.Repository, context.Branch, null);
            return this.GitClient.GetLastCommit(context.Repository, context.Branch);
        }
Exemplo n.º 14
0
 public void ExportFiles(SourceControlContext context, string targetDirectory)
 {
     var tfsContext = (TfsSourceControlContext)context;
     this.LogDebug("Exporting files from \"{0}\" to \"{1}\"...", tfsContext.WorkspaceDiskPath, targetDirectory);
     this.CopyNonTfsFiles(tfsContext.WorkspaceDiskPath, targetDirectory);
 }
Exemplo n.º 15
0
 private void DeleteWorkspaceInternal(SourceControlContext context)
 {
     DirectoryEx.Clear(context.WorkspaceDiskPath);
 }
Exemplo n.º 16
0
 private string GetWorkspaceDiskPathInternal(SourceControlContext context)
 {
     return(context.WorkspaceDiskPath);
 }
Exemplo n.º 17
0
 public override void GetLabeled(string label, SourceControlContext context, string targetPath)
 {
     this.WrappedProvider.GetLabeled(label, context, targetPath);
 }
Exemplo n.º 18
0
 public override void UpdateLocalWorkspace(SourceControlContext context)
 {
     this.WrappedProvider.UpdateLocalRepository(context, null);
 }
 public void DeleteWorkspace(SourceControlContext context)
 {
     this.Agent.ClearFolder(context.WorkspaceDiskPath);
 }
 public void EnsureLocalRepository(SourceControlContext context)
 {
     var fileOps = (IFileOperationsExecuter)this.Agent;
     var repoPath = context.Repository.GetDiskPath(fileOps);
     if (!fileOps.DirectoryExists(repoPath) || !fileOps.DirectoryExists(fileOps.CombinePath(repoPath, ".git")))
     {
         fileOps.CreateDirectory(repoPath);
         this.GitClient.CloneRepo(context.Repository);
     }
 }
Exemplo n.º 21
0
 public void DeleteWorkspace(SourceControlContext context)
 {
     DirectoryEx.Clear(context.WorkspaceDiskPath);
 }
 public void Clone(SourceControlContext context)
 {
     this.GitClient.CloneRepo(context.Repository);
 }
 public void UpdateLocalRepository(SourceControlContext context, string tag)
 {
     this.GitClient.UpdateLocalRepo(context.Repository, context.Branch, tag);
 }
        public void GetLatest(SourceControlContext context, string targetPath)
        {
            if (targetPath == null)
                throw new ArgumentNullException("targetPath");
            if (context.Repository == null)
                throw new ArgumentException(context.ToLegacyPathString() + " does not represent a valid Git path.", "sourcePath");

            this.EnsureLocalRepository(context);
            this.UpdateLocalRepository(context, null);
            this.ExportFiles(context, targetPath);
        }
 public DirectoryEntryInfo GetDirectoryEntryInfo(SourceControlContext context)
 {
     return this.GetDirectoryEntryInfo((GitPath)context);
 }
 public IEnumerable<string> EnumerateLabels(SourceControlContext context)
 {
     throw new NotImplementedException();
 }
 public IEnumerable<string> EnumerateBranches(SourceControlContext context)
 {
     return this.GitClient.EnumBranches(context.Repository);
 }
Exemplo n.º 28
0
 public override object GetCurrentRevision(SourceControlContext context)
 {
     return this.WrappedProvider.GetCurrentRevision(context);
 }
Exemplo n.º 29
0
 public SourceControlTests()
 {
     SourceControlContextMock = new SourceControlContext();
 }
Exemplo n.º 30
0
 public override void GetLatest(SourceControlContext context, string targetPath)
 {
     this.WrappedProvider.GetLatest(context, targetPath);
 }
Exemplo n.º 31
0
 public override void GetLatest(SourceControlContext context, string targetPath)
 {
     this.EnsureLocalWorkspace(context);
     this.UpdateLocalWorkspace(context);
     this.ExportFiles(context, targetPath);
 }
Exemplo n.º 32
0
 public override void ApplyLabel(string label, SourceControlContext context)
 {
     this.WrappedProvider.ApplyLabel(label, context);
 }
Exemplo n.º 33
0
 string ILocalWorkspaceProvider.GetWorkspaceDiskPath(SourceControlContext context) => this.GetWorkspaceDiskPathInternal(context);
Exemplo n.º 34
0
 public string GetWorkspaceDiskPath(SourceControlContext context)
 {
     return context.WorkspaceDiskPath;
 }
Exemplo n.º 35
0
 void ILocalWorkspaceProvider.ExportFiles(SourceControlContext context, string targetDirectory) => this.ExportFilesInternal(context, targetDirectory);
Exemplo n.º 36
0
        public void UpdateLocalWorkspace(SourceControlContext context)
        {
            using (var tfs = this.GetTeamProjectCollection())
            {
                var versionControlServer = tfs.GetService<VersionControlServer>();

                var workspace = this.GetMappedWorkspace(versionControlServer, (TfsSourceControlContext)context);
                if (context.Label != null)
                {
                    string sourcePath = ((TfsSourceControlContext)context).SourcePath;
                    var getRequest = new GetRequest(new ItemSpec(sourcePath, RecursionType.Full), VersionSpec.ParseSingleSpec("L" + context.Label, versionControlServer.AuthorizedUser));
                    workspace.Get(getRequest, GetOptions.Overwrite);
                }
                else
                {
                    workspace.Get(VersionSpec.Latest, GetOptions.Overwrite);
                }
            }
        }
 public void ExportFiles(SourceControlContext context, string targetDirectory)
 {
     this.CopyFolder(context.WorkspaceDiskPath, targetDirectory, false);
 }
Exemplo n.º 38
0
 void ILocalWorkspaceProvider.UpdateLocalWorkspace(SourceControlContext context) => this.UpdateLocalWorkspaceInternal(context);
Exemplo n.º 39
0
 public override IEnumerable <string> EnumerateLabels(SourceControlContext context)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 40
0
 void ILocalWorkspaceProvider.DeleteWorkspace(SourceControlContext context) => this.DeleteWorkspaceInternal(context);
Exemplo n.º 41
0
 public void DeleteWorkspace(SourceControlContext context)
 {
     DirectoryEx.Clear(context.WorkspaceDiskPath);
 }
Exemplo n.º 42
0
 public void EnsureLocalWorkspace(SourceControlContext context)
 {
     this.LogDebug("Ensuring local workspace disk path: " + context.WorkspaceDiskPath);
     if (!Directory.Exists(context.WorkspaceDiskPath))
     {
         this.LogDebug("Creating workspace disk path...");
         Directory.CreateDirectory(context.WorkspaceDiskPath);
     }
     else
     {
         this.LogDebug("Workspace disk path exists.");
     }
 }
Exemplo n.º 43
0
 public override IEnumerable<string> EnumerateLabels(SourceControlContext context)
 {
     return this.WrappedProvider.EnumerateLabels(context);
 }
Exemplo n.º 44
0
 public override void ExportFiles(SourceControlContext context, string targetDirectory)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 45
0
 public string GetWorkspaceDiskPath(SourceControlContext context)
 {
     return(context.WorkspaceDiskPath);
 }
 public override void ExportFiles(SourceControlContext context, string targetDirectory)
 {
     this.WrappedProvider.ExportFiles(context, targetDirectory);
 }
Exemplo n.º 47
0
 public override void DeleteWorkspace(SourceControlContext context)
 {
     this.WrappedProvider.DeleteWorkspace(context);
 }
Exemplo n.º 48
0
 public override void DeleteWorkspace(SourceControlContext context)
 {
     this.Agent.ClearDirectory(context.WorkspaceDiskPath);
 }
Exemplo n.º 49
0
 public override void EnsureLocalWorkspace(SourceControlContext context)
 {
     this.WrappedProvider.EnsureLocalRepository(context);
 }
Exemplo n.º 50
0
 private void Clone(SourceControlContext context)
 {
     this.ExecuteHgCommand(context.Repository, "clone", "\"" + context.Repository.RemoteUrl + "\"", ".");
 }
        public void UpdateLocalWorkspace(SourceControlContext context)
        {
            using (var tfs = this.GetTeamProjectCollection())
            {
                var versionControlServer = tfs.GetService<VersionControlServer>();

                var workspace = this.GetMappedWorkspace(versionControlServer, (TfsSourceControlContext)context);
                if (context.Label != null)
                    workspace.Get(VersionSpec.ParseSingleSpec("L" + context.Label, versionControlServer.AuthorizedUser), GetOptions.Overwrite);
                else
                    workspace.Get(VersionSpec.Latest, GetOptions.Overwrite);
            }
        }