Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

TFSVC is listing all changes from the tfs workspace not the current visual studio code workspa #179

Closed
fforjan opened this issue Apr 15, 2017 · 18 comments · Fixed by #186
Closed

Comments

@fforjan
Copy link

fforjan commented Apr 15, 2017

My TFS workspace has plenty of changes.
The status displayed in visual studio code is the status of the TFS workspace which is a bit useless.

It should be displaying the current visual studio code workspace status.

Note:
I'm using the proper status with this command line
tf.exe status -noprompt -format:detailed -recursive C:\Path\to\my\vscode\workspace

@fromthewoods
Copy link

Yeah it would be nice if change/add/deletes were isolated to the current vscode dir.

@jeffyoung
Copy link
Contributor

I believe this is the same issue (or similar) to @175.

Can either of you turn on logging and make the log available here? When we initialize TFVC, we use workspace.rootPath (the open folder in VS Code) and the debug log should contain a line similar to Looking for TFVC repository at {foldername} where foldername should be the value of the folder you have opened. If the issue is the same as @175, we may be defaulting to the first project we find.

@fforjan
Copy link
Author

fforjan commented Apr 18, 2017

This is the log :

2017-04-18T17:19:34.079Z - info:   [30232] *** FOLDER: c:\TfsWorkspaces\Main\Dev\Tools ***
2017-04-18T17:19:34.081Z - debug:  [30232] Looking for an External Context at c:\TfsWorkspaces\Main\Dev\Tools
2017-04-18T17:19:34.082Z - debug:  [30232] No External Context at c:\TfsWorkspaces\Main\Dev\Tools
2017-04-18T17:19:34.082Z - debug:  [30232] Looking for TFVC repository at c:\TfsWorkspaces\Main\Dev\Tools
2017-04-18T17:19:34.082Z - debug:  [30232] TFVC Creating Tfvc object with localPath='undefined'
2017-04-18T17:19:34.083Z - debug:  [30232] Using TFS proxy: undefined
2017-04-18T17:19:34.083Z - debug:  [30232] TFVC Retrieved from settings; localPath='C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/TF.exe'
2017-04-18T17:19:34.083Z - debug:  [30232] TFVC Repository created with repositoryRootFolder='c:\TfsWorkspaces\Main\Dev\Tools'
2017-04-18T17:19:34.083Z - debug:  [30232] TFVC Repository.CheckVersion
2017-04-18T17:19:34.083Z - debug:  [30232] TFVC: tf add -noprompt -?
2017-04-18T17:19:34.087Z - debug:  [30232] TFVC: spawned new process (duration: 3ms)
2017-04-18T17:19:34.176Z - debug:  [30232] TFVC: add exit code: 0 (duration: 93ms)
2017-04-18T17:19:34.176Z - debug:  [30232] TFVC Repository.FindWorkspace with localPath='c:\TfsWorkspaces\Main\Dev\Tools'
2017-04-18T17:19:34.178Z - debug:  [30232] TFVC: tf workfold -noprompt ********
2017-04-18T17:19:34.183Z - debug:  [30232] TFVC: spawned new process (duration: 5ms)
2017-04-18T17:19:44.144Z - debug:  [30232] TFVC: workfold exit code: 0 (duration: 9965ms)
2017-04-18T17:19:44.144Z - debug:  [30232] Found a TFVC repository for url: '{url}' and team project: '{project}'.
2017-04-18T17:19:44.144Z - debug:  [30232] Parsing values from repositoryInfo as string url
2017-04-18T17:19:44.145Z - debug:  [30232] TFVC Creating Tfvc object with localPath='undefined'
2017-04-18T17:19:44.145Z - debug:  [30232] Using TFS proxy: undefined
2017-04-18T17:19:44.145Z - debug:  [30232] TFVC Retrieved from settings; localPath='C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/TF.exe'
2017-04-18T17:19:44.146Z - debug:  [30232] TFVC Repository created with repositoryRootFolder='c:\TfsWorkspaces\Main\Dev\Tools'
2017-04-18T17:19:44.146Z - debug:  [30232] No account-specific token or global token found.
2017-04-18T17:19:44.183Z - debug:  [30232] Started ApplicationInsights telemetry
2017-04-18T17:19:44.183Z - info:   [30232] Getting repository information with repositoryInfoClient
2017-04-18T17:19:44.184Z - debug:  [30232] RemoteUrl = {url}
2017-04-18T17:19:44.184Z - debug:  [30232] Getting repository information for a TFVC repository at {url}
2017-04-18T17:19:44.184Z - debug:  [30232] Parsing values from repositoryInfo as string url
2017-04-18T17:19:44.186Z - debug:  [30232] Validated the TFS TFVC repository. Collection name: '{project}', {url}
2017-04-18T17:19:44.186Z - debug:  [30232] Getting project collection...  url: '{url}', and collection name: '{project}'
2017-04-18T17:19:44.242Z - debug:  [30232] TFVC: status exit code: 0 (duration: 10254ms)
2017-04-18T17:19:44.521Z - error:  [30232] Failed Request: Forbidden(403) - Access Denied: Fred Forjan needs the following permission(s) to perform this action: Edit instance-level information Error: Error: Failed Request: Forbidden(403) - Access Denied: Fred Forjan needs the following permission(s) to perform this action: Edit instance-level information
2017-04-18T17:19:44.521Z - debug:  [30232] Error: Failed Request: Forbidden(403) - Access Denied: Fred Forjan needs the following permission(s) to perform this action: Edit instance-level information
2017-04-18T17:19:44.523Z - debug:  [30232] TFVC Repository.CheckVersion
2017-04-18T17:19:44.523Z - debug:  [30232] TFVC: tf add -noprompt -?
2017-04-18T17:19:44.529Z - debug:  [30232] TFVC: spawned new process (duration: 5ms)
2017-04-18T17:19:44.560Z - debug:  [30232] TFVC: add exit code: 0 (duration: 36ms)
2017-04-18T17:19:44.561Z - debug:  [30232] TFVC Repository.GetStatus
2017-04-18T17:19:44.562Z - debug:  [30232] TFVC: tf status -noprompt -format:detailed -recursive
2017-04-18T17:19:44.566Z - debug:  [30232] TFVC: spawned new process (duration: 4ms)
2017-04-18T17:20:00.505Z - debug:  [30232] TFVC: status exit code: 0 (duration: 15943ms)

The status is showing 99+ changes in VSCode

But :

>tf.exe status -noprompt -format:detailed -recursive  c:\TfsWorkspaces\Main\Dev\Tools
[....]
2 change(s), 8 detected change(s)

Note: the error access is the same as defect #172

@fforjan
Copy link
Author

fforjan commented Apr 18, 2017

I don't think this is the same issue as #175 :.
The TFS workspace is mapped to c:\TfsWorkspaces\Main\Dev but I'm only working within the tools folder with Visual Studio Code

@jeffyoung
Copy link
Contributor

Hi everyone.

So I've been thinking about this for a bit (and spoke with a few TFVC experts) and I'm not sure if I'll make any changes in this area. Read on! 😉

A TFVC workspace is the container for all of the work that should be grouped together (think of it like the contents of a Git repository). Now if I open a sub-folder of a Git repository in VS Code and I've made changes at a folder that's higher up (that is, one I didn't explicitly open), the Git SCM still shows those files. It doesn't only show the files modified for the folder that I've got open. I believe that's the same behavior as what the TFVC support is currently showing (as indicated by this issue and by @MindGirl in #175).

Granted, in Git, there's currently not functionality that allows you to 'cloak' a part of the repository (it's one dependent grouping of files). A TFVC workspace is considered to be the same (although I understand you can look at it, and use it, differently). So, to support this scenario with the current extension, you'd need to create multiple workspaces (one for each project). But who wants to do that? 😄 I understand the desire not to have to create individual workspaces which is why I haven't said I won't ever provide that support. Still considering.

Thoughts?

@MindGirl
Copy link

MindGirl commented Apr 20, 2017

As @fforjan mentioned in the first message, when adding the VS Code workspace root path to the tf status command, only the changes in this folder and subfolders are returned. The same holds true for the tf workfold command: the correct (and only one) team project is returned.

I cloned the code, made some tests and got following results:
Adding the localPath to the GetArguments method of the FindWorkspace command will return the correct team project.

    public GetArguments(): IArgumentProvider {
       return new ArgumentBuilder("workfold")
            .Add(this._localPath)
            .AddSwitchWithValue("login", "fake,fake", true);
    }

For the Status command the only change is to supply the repositoryRootFolder as 3rd parameter to the
constructor in tfvcrepository.ts:

    public async GetStatus(ignoreFiles?: boolean): Promise<IPendingChange[]> {
        Logger.LogDebug(`TFVC Repository.GetStatus`);
        return this.RunCommand<IPendingChange[]>(
            new Status(this._serverContext, ignoreFiles === undefined ? true : ignoreFiles, [this._repositoryRootFolder]));
    }

Now only the changes relative to the workspace root folder (VS code) are shown as pending changes.
I tested this on Windows 10 with the tf.exe of Visual Studio 2017. I do not know if this will also work with the TEE CLC.

@jeffyoung Do you think you can add this?

BTW: While stepping through the code, I noticed that tf status is used with the argument -format:xml. This option is not available in the tf.exe of Visual Studio 2015 (version 14.102.25619.0):
Edit: scratch that, tf.exe version 14.x works

@fforjan
Copy link
Author

fforjan commented Apr 20, 2017

Short answer : could we have a vscode workspace option to switch between the 2 modes ?

Long answer : this is my workspace as i n Visual Studio
image

The first thing, this is an old project before .tfignore was added so you can notice plenty of of detected add.
We - as a team- don't really bother and people are ok with such number of detected add items - I'm not saying this is the right way to do it...
The second point is I can group all the items in my pending view so I don't see 50 pending changes but just their containing folder.
What you will notice is that there is plenty of changes done today, just because I needed to do some hack on our server, wanted to see how the UI and our excel report will interact, etc.. New project was added and is also also be part of the installer so I can create a shelveset and trigger a product build

From my point of view, the VScodee view being a flat view, there is too much pollution, I woudl really love to see this limited to my workspace ...

To complete the picture, we're using nodejs for integration testing and I would like to allow part of my team- testers typically- to use VSCode instead of Visual Studio for development - git migration is not planned in short term for some internal reasons.

On a side note, I have multiple workspaces, one for each branch/version so I don't see or accidentally do a checkin between branches. Our (unique) VS solution is 100+ projects and most of us rebuild the full solution - client/server/report as we don't need to install the product in that case. Not sure how you would manage to have an 'atomic' checkin across multiple projects

@jeffyoung
Copy link
Contributor

It's certainly possible @MindGirl and @fforjan.

I'll mark it as an enhancement and see what the effect might be to the extension. As @fforjan mentioned, I'd need a VS Code setting to control it and would likely want to make sure I could scope any of the Build and WIT features (including running commands provided by the extension) to the folder ('team project') opened in VS Code. I imagine the TEE CLC would work fine too but would have to make sure that was the case.

@fforjan
Copy link
Author

fforjan commented Apr 21, 2017

Let me know if you need any beta testing, as #172 is closed, I can know access TFS :)

@jeffyoung
Copy link
Contributor

Hi everyone.

I've been working on some changes that would enable this scenario. I've attached a private drop that I'd appreciate some testing on. First, you need to uninstall the current extension and then side-load this VSIX. After downloading the ZIP file, you'll need to rename it by dropping the .ZIP extension. Then, after selecting the Extension viewlet, click the ... menu and choose Install from VSIX... and then select that VSIX file.

After installing the extension, you'll need to set the tfvc.restrictWorkspace flag to true (is VS Code settings) and then open the sub-folder you want to work within.

team-0.116.1.vsix.zip

I tried it with the tf.exe that comes with VS2017 Professional and also TEE CLC 114 (which behaves differently than tf.exe; as @MindGirl mentioned before tf.exe returns just the single mapping when workfold is provided a local_path, the CLC still returns all of the mappings in the workspace effectively ignoring the local_path).

@MindGirl
Copy link

I tried the private build, but got the error 'Cannot read property 'serverPath' of undefined' after enabling restrictWorkspace. With the help of some printf-Debugging I was able to track it down to the FindWorkspace command:

for (let i = 0; i <= mappings.length; i++) {
}

should be

for (let i = 0; i < mappings.length; i++) {
}

After fixing this in the JavaScript file, the extension was able to find the correct team project and the only changes below the workspace root are detected.

Thank you for looking into this issue.

@jeffyoung
Copy link
Contributor

Thanks for debugging @MindGirl! 😄 I've attached an updated version here for anyone else who wants to give it a try (in my limited testing, I tested with the 1st and 3rd project out of 4 😉).

team-0.116.1.vsix.zip

@fforjan
Copy link
Author

fforjan commented Apr 23, 2017

Seems to be working for me :)

@fforjan
Copy link
Author

fforjan commented Apr 23, 2017

(small notes, I don't want to raise a defect for this but when you get 5 minutes):
https://github.com/Microsoft/vsts-vscode/blob/19c788d5eda3a4fa2676f9ed78300075d9480cef/src/extensionmanager.ts#L399

  Logger.LogDebug("gitFolder: " + this._repoContext.RepoFolder);
        Logger.LogDebug("gitRemoteUrl: " + this._repoContext.RemoteUrl);

Do you mind to use repositoryFolder and repositoryRemoveUrl instead of gitFolder and gitRemoteUrl in the log ? I was surprised to see git reference while using TFSVC ;)

@jeffyoung
Copy link
Contributor

Thanks for the feedback @fforjan. I'll make those quick changes in the logs too.

@jeffyoung
Copy link
Contributor

I just published 1.117.0 that contains this fix (hopefully it'll keep working like the private builds I provided here). 😄

And if you all are up for it, I'd appreciate a review over at the Marketplace (it seems I've received some unpleasant ones for not having TFVC support in the past).

Thanks for your continued feedback!

@muthukrishnantrv
Copy link

First time I'm using VS Code and im facing some problems like whatever im creating component or module through integrated terminal is not coming in the pending changes. So cant able to checkin. Please help me on this to get resolve asap. Also please let me know if you need more informations.

@adam-marshall
Copy link

Just in case anyone arrived here via a search as they found that this was not working, it seems you have to enable the setting: Tfvc: Restrict Workspace, which for me was unchecked by default.
image

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants