Udostępnij za pośrednictwem


It's the little things that help

Adam Singer had pointed out the little helpful "remap" functionality we have in our command-line interface to Team Foundation Source Control.  Hopefully you'll find that we do a lot of nice things that help your day-to-day productivity.  Along those lines, I wanted to point out a couple more having to do with rename, specifically that "add + rename = add" and "rename + rename = rename".

First, say we pended an add on a file.

C:\test\tfs\50622-take2>echo foo > newfile.txt

C:\test\tfs\50622-take2>h add newfile.txt
newfile.txt

C:\test\tfs\50622-take2>h status
File name   Change Local path
----------- ------ -------------------------------------------
$/50622-take2
newfile.txt add    C:\test\tfs\50622-take2\newfile.txt

1 change(s)

Whoops, that's actually the wrong file name. We meant to add a file called newfile.cs instead.  As a feature, we let you use rename and we'll both rename the actual file on disk and rename the pended add for you.  This keeps you from having to do an undo on the add, rename of the file, then pend the add again on the new filename.

C:\test\tfs\50622-take2>h rename newfile.txt newfile.csnewfile.cs

C:\test\tfs\50622-take2>dir newfile.cs
 Volume in drive C has no label.
 Volume Serial Number is 2088-B3A5

 Directory of C:\test\tfs\50622-take2

06/22/2005  08:18 AM                 6 newfile.cs
               1 File(s)              6 bytes
               0 Dir(s)   7,727,419,392 bytes free

C:\test\tfs\50622-take2>h status
File name  Change Local path
---------- ------ -------------------------------------
$/50622-take2
newfile.cs add    C:\test\tfs\50622-take2\newfile.cs

1 change(s)

Another mini-feature related to using rename:  Let's say a week later you decide you want to rename the file to foo.cs - so you do the expected thing and perform the h rename:

C:\test\tfs\50622-take2>h rename newfile.cs foo.csfoo.cs

C:\test\tfs\50622-take2>h status
File name Change Local path
--------- ------ ---------------------------------------------
$/50622-take2
foo.cs    rename C:\test\tfs\50622-take2\foo.cs

1 change(s)

C:\test\tfs\50622-take2>dir foo.cs
 Volume in drive C has no label.
 Volume Serial Number is 2088-B3A5

 Directory of C:\test\tfs\50622-take2

06/22/2005  08:18 AM                 6 foo.cs
               1 File(s)              6 bytes
               0 Dir(s)   7,727,648,768 bytes free

C:\test\tfs\50622-take2>

Of course, then you find out about 5 minutes later that you should have renamed it to bar.cs instead.  Instead of having to undo the existing rename and pend a new rename, we let you rename the existing pending rename.

C:\test\tfs\50622-take2>h rename foo.cs bar.csbar.cs

C:\test\tfs\50622-take2>h status
File name Change Local path
--------- ------ ---------------------------------------------
$/50622-take2
bar.cs    rename C:\test\tfs\50622-take2\bar.cs

1 change(s)

C:\test\tfs\50622-take2>dir bar.cs
 Volume in drive C has no label.
 Volume Serial Number is 2088-B3A5

 Directory of C:\test\tfs\50622-take2

06/22/2005  08:18 AM                 6 bar.cs
               1 File(s)              6 bytes
               0 Dir(s)   7,727,644,672 bytes free

There's a lot more interesting things in terms of pending change combination that happens with merge, but we'll save that topic for another day.

Comments

  • Anonymous
    June 22, 2005
    As a suggestion, you many want to give some context at the start of your entry. Not knowing what you're doing in general, I'm not sure what the post is about at all.
  • Anonymous
    June 22, 2005
    Good point - edited, thanks :)
  • Anonymous
    July 04, 2005

    Abhinaba Basu on marking required fields in work items ⊕ and build types ⊕
    Adam Singer on the latest...