Despite Apple showing off the feature, and placing documentation on their website, many questions remain unanswered: Where are the versions saved? How much space do the versions take up? Can you manually access the versions? Well, here's everything you need to know about Versions.
The Basics of Versions
To begin versioning a file, you must first save it. The save process in Lion is the same that you're used to in previous versions of OS X. If the application supports Auto Save, it will begin saving your documents at intervals (or you can press Command + S to save manually).

To access the versioning features, hover your mouse to the right-hand side of the document title in the titlebar of the window. Click on the small triangle that appears. This menu gives you access to Lock, Duplicate, and Browse All Version.
The magic really happens when you select "Browse All Versions", which launches a window with a Time Machine-like interface that lets you select the most current version of the document on the left-hand side of the screen, and previous versions of the same document on the right-hand side of the screen. And just like in Time Machine, you can navigate through the previous versions of the file and restore them by clicking on the Restore button.
If you just want to restore a portion of an old document, you can use copy and paste commands on the previous version to grab just a chunk of the older document and paste it into the newer version while in this interface.
Versions vs. Auto Save
Despite their somewhat similiar functions, Versions and Auto Save are two entirely different features. Versions allows you to easily find and replace previous versions of the document that you may be working on in a text editing application, while Auto Save allows supporting applications to automatically save your documents in the background whenever you close the application, make changes to your existing work, or if you take a break from typing.
These two features work together to make a seamless user experience for automatically saving and retrieving previous versions of your work.
Where are the files saved and how many resources do they use?
Contrary to what you may think, the different versions of a file are not actually stored within the file itself. But where, then, does the magic happen? In a hidden directory, of course.
As it turns out, Apple has a hidden directory at the root of your Mac's hard drive where all of the document versions are stored. Let's take a look at the contents of this directory and see what's inside!

To do this, we're going to open Terminal (located in /Applications/Utilities), and then type in the following commands (do this at your own risk), line-by-line, pressing the enter key after each one. defaults write com.apple.Finder AppleShowAllFiles TRUE
killall Finder
sudo chmod -R 115 /.DocumentRevisions-V100
(type in your password and press enter)
These Terminal commands will turn on hidden file and folder support in Finder, restart the Finder application, and will then change the permissions of the .DocumentRevisions-V100 folder so that we can view the contents of the folder.

Next, open a new Finder window and press Command + Shift + G and type in the following text into the box before pressing Go:
/.DocumentRevisions-V100/
This will take you directly to the .DocumentRevisions-V100 folder that Apple uses to store the document revisions. Next, click on the PerUID folder, then on the numbered subfolder (ours is listed as 501). Inside of this folder, you will find yet more numbered folders corresponding to the documents that have been versioned. Clicking on any of these will present you with the different versions of the files.

The files will have randomized, unique file names, but the date and time will correspond to the time the version was saved.
Note that Versions saves a completely new version of the file each time, not just the changes that have happened to the file over the time period that you have been editing it. This does lead to more resources on your disk being used, but can alleviate problems in the case of the source file being corrupted.

After you have looked around the .DocumentVersions-V100 folder, you may wish to re-hide these folders so they do not appear in the Finder. To do this, open Terminal back up and type in the following two commands: defaults write com.apple.Finder AppleShowAllFiles FALSE
killall Finder
What Happens When I Move or Delete a Versioned File?
Moving a file that has saved versions will not affect the versions saved in the .DocumentVersions-V100 folder in any way. However, when you delete the actual file, Lion will also remove the saved versions immediately, freeing up precious disk space.
How many Versions Can I Save?
As disk space permits, Lion will be able to save an almost unlimited amount of versions in your documents. While working on this article alone, we had over 110 versions saved, all accessible through the Versions interface. The more versions you save, however, the more disk space will be taken up. With these 110 versions written in Pages, we had 10.3MBs of disk space used.
Versions Must Be Built-in to Apps
As you may have noticed by now, not all applications currently support versions. Versions and Auto Save are two tools that are built into the operating system, but in order for applications to take advantage of them developers must write their code to work with the new features, just as a developer would write their applications take advantage of the full screen features in Lion.
If you are a developer and would like to make your application take advantage of the Version and Auto Save functionality in Lion, check out this page in the Apple Developer Center documentation (paid membership required) for information and code samples on how Versions works.
Follow this article's author, Cory Bohon on Twitter.
Sent from my iPhone

沒有留言:
發佈留言