Continuing the basic command tutorial, today I’ll introduce a couple of more commands: rename, delete, undelete, and undo. Pay attention, because there’s a quiz at the end!
Rename – lets you rename or move items within the repository. The command syntax is “rename <src> <dest>“. The source and dest can be either repository paths (starting with $/), or local paths. For example:
h rename $/killerapp/hatteras $/killerapp/vstsscc
This causes a “rename“ action to be pended to the item “$/killerapp/hatteras“. When you then issue a checkin command for this item, the rename will be committed to the repository. You can also use rename (or more appropriately, it’s alias “move“) to move items in the repository. In this example, I’m renaming and moving an item in one step:
h rename $/files/main.cs $/backups/oldmain.cs
Delete – As its name implies, this command lets you delete items from the repository. But never fear, once they’re deleted, you can still un-delete them with the undelete command:
h delete $/files/main.cs
h undelete $/files/main.cs
Undo lets you un-pend a pending change, such as an add, edit, delete, etc. You can undo all your changes by specifying a wildcard filespec and the /recursive option (or its shortcut /r). Undo is especially friendly too – if you’ve actually modified an item, it will by default ask you to verify your intentions before completing the command.
h undo $/files/main.cs
Update: The quiz question below takes advantage of a feature of the “add“ command I haven’t covered yet – implicit additions of parent folders. If you issue an add on a file under a parent folder that hasn’t already been added to the repository, that parent folder is also added (just the folder, not its contents). Since Hatteras stores files and folders, this saves you the time of having to issue 2 adds (one for the parent folder, one for the child file).
Ok… So try on your tester hat for a second, and think about what happens if I issue these commands starting with an empty repository:
echo foo > main.cs
h add main.cs
h rename $/subfolder $/folder2
echo Hello World! > folder2\readme.txt
h add folder2\readme.txt
h checkin folder2\readme.txt
h undo folder2
I’ll post the answer tomorrow.