<commit_before>using System;
using System.IO;
using Microsoft.TeamFoundation.VersionControl.Client;
using CheckinOptions=Sep.Git.Tfs.Commands.CheckinOptions;

namespace Sep.Git.Tfs.Core
{
    public class TfsWorkspace : ITfsWorkspace
    {
        private readonly Workspace _workspace;
        private readonly string _localDirectory;
        private readonly TextWriter _stdout;
        private readonly TfsChangesetInfo _contextVersion;
        private readonly IGitTfsRemote _remote;
        private readonly CheckinOptions _checkinOptions;

        public TfsWorkspace(Workspace workspace, string localDirectory, TextWriter stdout, TfsChangesetInfo contextVersion, IGitTfsRemote remote, CheckinOptions checkinOptions)
        {
            _workspace = workspace;
            _contextVersion = contextVersion;
            _remote = remote;
            _checkinOptions = checkinOptions;
            _localDirectory = localDirectory;
            _stdout = stdout;
        }

        public void Shelve(string shelvesetName)
        {
            var pendingChanges = _workspace.GetPendingChanges();

            if (pendingChanges.Length == 0)
            {
                _stdout.WriteLine(" nothing to shelve");
            }
            else
            {
                var shelveset = new Shelveset(_workspace.VersionControlServer, shelvesetName, _workspace.OwnerName);
                shelveset.Comment = _checkinOptions.CheckinComment;
                _workspace.Shelve(shelveset, _workspace.GetPendingChanges(), ShelvingOptions.Replace);
            }
        }

        public string GetLocalPath(string path)
        {
            return Path.Combine(_localDirectory, path);
        }

        public void Add(string path)
        {
            _stdout.WriteLine(" add " + path);
            var added = _workspace.PendAdd(GetLocalPath(path));
            if (added != 1) throw new Exception("One item should have been added, but actually added " + added + " items.");
        }

        public void Edit(string path)
        {
            _stdout.WriteLine(" edit " + path);
            GetFromTfs(path);
            var edited = _workspace.PendEdit(GetLocalPath(path));
            if(edited != 1) throw new Exception("One item should have been edited, but actually edited " + edited + " items.");<commit_msg>Don't clobber shelvesets, unless the user asks for it.<commit_after>using System;
using System.IO;
using Microsoft.TeamFoundation.VersionControl.Client;
using CheckinOptions=Sep.Git.Tfs.Commands.CheckinOptions;

namespace Sep.Git.Tfs.Core
{
    public class TfsWorkspace : ITfsWorkspace
    {
        private readonly Workspace _workspace;
        private readonly string _localDirectory;
        private readonly TextWriter _stdout;
        private readonly TfsChangesetInfo _contextVersion;
        private readonly IGitTfsRemote _remote;
        private readonly CheckinOptions _checkinOptions;

        public TfsWorkspace(Workspace workspace, string localDirectory, TextWriter stdout, TfsChangesetInfo contextVersion, IGitTfsRemote remote, CheckinOptions checkinOptions)
        {
            _workspace = workspace;
            _contextVersion = contextVersion;
            _remote = remote;
            _checkinOptions = checkinOptions;
            _localDirectory = localDirectory;
            _stdout = stdout;
        }

        public void Shelve(string shelvesetName)
        {
            var pendingChanges = _workspace.GetPendingChanges();

            if (pendingChanges.Length == 0)
            {
                _stdout.WriteLine(" nothing to shelve");
            }
            else
            {
                var shelveset = new Shelveset(_workspace.VersionControlServer, shelvesetName, _workspace.OwnerName);
                shelveset.Comment = _checkinOptions.CheckinComment;
                _workspace.Shelve(shelveset, _workspace.GetPendingChanges(), _checkinOptions.Force ? ShelvingOptions.Replace : ShelvingOptions.None);
            }
        }

        public string GetLocalPath(string path)
        {
            return Path.Combine(_localDirectory, path);
        }

        public void Add(string path)
        {
            _stdout.WriteLine(" add " + path);
            var added = _workspace.PendAdd(GetLocalPath(path));
            if (added != 1) throw new Exception("One item should have been added, but actually added " + added + " items.");
        }

        public void Edit(string path)
        {
            _stdout.WriteLine(" edit " + path);
            GetFromTfs(path);
            var edited = _workspace.PendEdit(GetLocalPath(path));
            if(edited != 1) throw new Exception("One item should have been edited, but actually edited " + edited + " items.");
{'fraction_non_alphanumeric': 0.07405063291139241, 'fraction_numerical': 0.0012658227848101266, 'mean_word_length': 2.310754189944134, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2237434', 'n_tokens_mistral': 1202, 'n_tokens_neox': 1182, 'n_words': 305}