Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I stop accidentally checking in a file in TFS

I have a web.config that occasionally I'll checkout and modify to use a hardcoded password instead of reading it from the registry.

How can I prevent myself from absent-mindedly checking it back in and annoying my co-workers?

I could achieve this in the past with Perforce by creating a separate pending changelist.

edit - I'd rather not make it writable, I was wondering if there's anything in TFS or planned for TFS to support this?

like image 602
koregan Avatar asked May 28 '09 09:05

koregan


3 Answers

Here is a solution:

1) Right click on the file (in Source Control Explorer) and select properties.

2) Then go to security and add your self (make sure you select the user radio button)

3) Then deny yourself checkin rights. (Click the deny checkbox under checkin)

This will stop you from checking in the file. To be able to check it in later just do these steps again, but select the Allow check box.

Note: you may need to get your administrator to give you "Manipulate Security Settings" for that file (done the same as above, but in step 3 select allow under "Manipulate Security Setting".)

like image 144
Vaccano Avatar answered Nov 18 '22 16:11

Vaccano


Option 1: You could just make the web.config writeable locally without checking out (this would be helped by setting VS to prompt for checkout).

Option 2: Move the password out of the web.config. Using a configSource attribute to put that configuration into a local, not in TFS, file. Each developer then maintains their own copy.

E.g. in web.config:

<configuration>
  ...
  <connectionStrings configSource="LocalConnectionStrings.config"/>
</configuration>

and in LocalConnectionStrings.config:

<connectionStrings>
  <add name="MyConnectionString"
    connectionString="Data Source=.;Initial Catalog=Test1;Integrated Security=True"
    providerName="System.Data.SqlClient"/>
</connectionStrings>

NB. configSource is implemented by ASP.NET's config runtime and is supported on all configuration elements for ASP.NET (and, thus, not for arbitrary (including custom) configuration elements).

(Also note the <linkedConfiguration> Element provides another include mechanism, but is limited to assemblyBinding element.)

like image 29
Richard Avatar answered Nov 18 '22 16:11

Richard


Source controlled items by TFS use the 'Read Only' attribute of the file to evaluate file status. You can go to the physical folder where the web.config exists in your machine through the explorer. Make sure your web.config is checked in before you begin. Then :

  1. Right click on the web.config file and select 'Properties'
  2. Uncheck the 'Read Only' checkbox. Click Ok/Apply
  3. Edit your web.config in notepad or other text editor and save the changes
  4. Right click on the web.config file and select 'Properties'
  5. Check the 'Read Only' checkbox. Click Ok/Apply

You would have to do a get specific on the file to get any changes from TFS after that.

like image 1
Console.WriteLine Avatar answered Nov 18 '22 14:11

Console.WriteLine