table of contents
fhist(1) | General Commands Manual | fhist(1) |
NAME¶
fhist - file history
SYNOPSIS¶
fhist filename... option...
fhist -Help
fhist -VERSion
DESCRIPTION¶
The fhist program is used to keep track of the successive versions of a file. Using this program, you can remember all of your changes to a file, and get back any one of the old versions. The uses of this ability are:
- 1.
- You can make a series of tentative edits to the file, and if necessary back up to the last "good" edit.
- 2.
- You can delete old subroutines and code from your file which are obsolete, but still be able to get them back in the future in case a need for them arises.
- 3.
- You can compare two versions of the file to see how you fixed some old problem, so that you can check up on the correctness of the fix at a later date.
- 4.
- You get a record of your remarks for each version, so that you can quickly know what bugs were fixed, and what features were implemented.
- 5.
- The date the file was last edited can be automatically stored in the file.
The fhist program manipulates modules. A module is simply any text file that you are interested in keeping versions of. For example, a source file doit.c is a module, and so is a documentation file howto.doc. The module name includes the suffix of the file (as in the above examples). However, pathnames are not part of a module name, so that /usr/dbell/bar.c cannot be a legal module name. A module name is limited to 12 characters since the fhist program needs two extra characters for its own purpose.
Keyword Substitution¶
It is possible to have information about the state of the file inserted into the file. See the -Modify and -No‐Keywords options, below, for more infromation.
OPTIONS¶
The following options are understood:
The files inside of the storage directory should not be changed by you. Doing so will probably corrupt your edit history, causing errors when you extract old revisions. For your information, though, each module is stored as two files in the directory. The one with the .s suffix is a copy of the newest version of the module, with one extra line at the beginning. The one with the .e suffix is the edit history of the module, and contains the information needed to extract previous revisions of the module. Thus if the edit history is ever corrupted, you will at least have the most recent version of the module.
- -MaKe_Path
- This option may be used to request that the path directory be created automatically if it does not yet exist. This works for both the directory specified by the -Path option, and for the default. Intermediate directories will also be created if necessary.
- -BINary
- This option may be used to specify that the file is binary, that it may contain NUL characters. It is essential that you have consistent presence or absence of the -BINary option for each file when combined with the -CReate, -Update, -Conditional_Update and -Extract options. Failure to do so will produce inconsistent results. Note: this is different behaviour to the fcomp(1) option of the same name. Note: the -BINary option does not imply the -No‐Keywords option.
- -CReate
-
To start using a module under fhist, you must first use the -CReate option. This creates the initial edit for that module in the storage directory, with the contents of the specified module as the initial edit. Thus, if you have a source file prog.c, then the command:
fhist prog.c -create
The -CReate option may be combined with the -Update or -Conditional_Update options to create the file if required.
fhist prog.c -u
The fhist program handles quota or disk full problems during a create or update operation without damage occurring to the edit history files. If an edit cannot be completed because of such problems, the edit is backed out completely, and you will get an error message about the disk problem. There is no need for any error recovery in this case, other than retrying the update when more disk space is available. The fhist program also disables signals during the critical file operations, so you do not have to worry about damaging the edit history files because of attempts to quit out of the program.
The -CReate option may be combined with the -Update or -Conditional_Update options to create the file if required.
fhist prog.c -u -i newprog.c
fhist prog.c -u -r
- -Remark_String text
- It is also possible to specify the remarks directly on the command line. You may only use this option once.
- -Extract [ edit ]
-
Edit numbers can also be zero, negative, or be a name with an optional offset. The number zero represents the latest edit number, and negative numbers indicate edit numbers backwards from the latest edit number. Edit names represent edit numbers whose name had been set by using the -Name option. For example, if edit number 10 was associated with the name foo, then the edit name foo represents 10, foo‐4 represents edit number6, and foo+2 represents edit number 12. The special reserved names oldest and newest refer to the oldest and newest versions of the module in the edit history.
As an example of retrievals, assume that you have saved ten versions of the module prog.c. The following commands will then extract the versions of the file with the specified edit numbers:
- fhist prog.c
- version 10 (the latest)
- fhist prog.c -e 9
- version 9 (the version just prior)
- fhist prog.c -e oldest
- version 1 (the oldest version)
- fhist prog.c -e -2
- version 8 (latest version - 2)
The output filename is again defaulted to the module name. So when the module prog.c is extracted, the specified version of the module is written to the prog.c file.
In order to prevent accidental overwriting of a file, the fhist program will by default ask you if overwriting is permitted if that would occur. A common mistake is to edit prog.c, and then try to update the module, but forget to specify the -u option. Then the fhist program would try to extract the newest version of the module, and thus overwrite the file with the new changes. Asking the question allows you to notice your mistake, and prevent the overwriting.
fhist prog.c -o newprog.c
- -Force_Write
-
This option will force overwriting of the file, thus never asking you if overwriting is permitted. This is often useful in shell scripts, or when you are sure that you want to overwrite any existing file. - -No_Write
-
This option is the no‐overwrite option, and will cause any existing files to not be overwritten, again without asking you. This is useful if you already have some of the modules in your directory, and you want to extract the rest of the modules without overwriting the ones you already have. Specifying both -Fore_Write and -No_Write is an error. - -Terminal [ edit ]
-
This option is used to output an extracted module to the standard output, instead of writing it to a file. This is useful in order to view the beginning of a version of the file. This can be interrupted if you do not want to see the whole file. - -Modify number
Each special sequence is of the form [# keyword value, keyword value, ..., keyword value #] , where each keyword describes an item, and each value is the value for the preceding keyword. The keywords can be in upper or lower case, or both. The single space following the [#, following each comma, and preceding the #] must be present. If the sequence is wrong, an unknown keyword is used, the line is longer than 200 characters, or more than four keywords are used, then the whole line will not be changed. The current keywords which can be used are the following:
- edit
- The edit number
- date
- The date that the edit was created
- user
- The user name of the user who created the edit
- module
- The module name
In order to use this special character sequence, you simply insert it into your module inside of a comment (within the first few lines). When this is done, the value parts of the sequence can be null. For example, if you want to put a special sequence into a program called delete.c, then you could edit the first few lines as follows:
/*
* Delete - program to delete files
* [# Edit, Date #]
*/
/*
* Delete - program to delete files
* [# Edit 23, Date 8‐Aug‐89 #]
*/
When updating a module, it is never necessary to edit these sequences, as any old values will be removed and replaced with the new ones. Also, when using the -d or -du options (described below), lines with these sequences compare as if the values were null, and thus will not cause spurious differences.
During an update, the special character sequences are read and any edit value found is compared against the current edit number of the module. If they differ, then the update fails. This provides an interlock check for the case of two users extracting the same version of a file, editing it, and then both updating it without knowledge of each other. In this case, the second user would fail, and then he can merge his edits with the previous user's edit and then retry the update. This checking is disabled if there is no special character sequence containing the edit keyword, the edit number value is null, or if the -Forced_Update option is used to indicate that the check is not needed.
- -No_Keywords
- This option may be used to disable the use of the keyword special character sequences described above. Text containing keyword sequences is treated as plain text. Note: the -No_Keywords option does not imply the -BINary option.
- -Name string
-
This option is used to associate a name for the newest version of a module. It can be given along with the -CReate, -Update, or -Difference_Update options, to specify a name for the new version of the module. It can also be given by itself in order to specify a name for the newest version of a module. Each edit number can have many names associated with it, so this will not remove any previously defined name for the edit. This option is useful to correlate many modules together. For example, when a new version of a program is ready to be released, you could give each module of the program the same name release1. Then in the future, you can recreate the sources making up that release by extracting the edits with the name release1 for every module. Edit names cannot begin with a digit, and cannot contain plus or minus signs. These rules prevent ambiguous parsing of edit numbers for the -Extract, -Terminal, -ALL, and -List options. - -List [ edit1 [ edit2 ]]
-
This option prints a list of edits for the module, giving the user name, date, user remarks, and names specified for the edits. If no edit number is supplied, then all edits are printed in reverse order. If a single edit number is supplied, then only that edit number is printed. If two edit numbers are supplied, then all edits in the specified range are printed. The output from this option defaults to the terminal. You can use the -Output option to save the results to a file. - -Difference [ edit1 [ edit2 ]]
-
- fhist foo.c -d
- Compare latest version against file "foo.c"
- fhist foo.c -d 3
- Compare version 3 against file "foo.c"
- fhist foo.c -d 3 4
- Compare version 3 against version 4
This option accepts the -Input option to specify the file to be compared. When using the -Difference option, the output defaults to the terminal. Therefore, you must use -Output if you wish the differences saved to a file. Using -Quick with -Difference will only output a quick summary of the changes, instead of the detailed changes. This summary only supplies the number of lines inserted, deleted, and unchanged between the files. Using -What with -Difference will display all of both files, showing in detail what the differences are using change bars.
The -Difference option may need to write one or two temporary files in order to extract old versions of a module to be compared. These files have names like T$n_nnn . They are deleted again just before differences are output, so that stopping the output before it is complete will not leave these files around. The temporary files are usually written to the current directory. If this is not reasonable because of permission or quota problems, then you can specify the directory for writing the temporary files into. This is done by defining the TMPDIR environment variable to be the path of the directory.
You may specify both of the -Difference and -Update options, or you may use this option. The results are identical.
The -CReate option may be combined with the -Update or -Conditional_Update options to create the file if required.
- -CLean
-
This option is used to remove files which match the newest versions of modules. If a file exists which matches the newest version of a module, then the file is deleted, otherwise it is kept. This option is used to clean up a work directory after building a new version of a product. This option is especially useful when used with the -ALL option. It will also accept the -Input option to specify a directory containing the files to be cleaned. - -CHeck
fhist -CHeck
fhist file -prune -10
When using multiple modules or the -ALL option, the -Input and -Output options have a slightly different meaning. In these cases, the -Input and -Output arguments are a directory name which contains filenames with the same name as the module names. If the argument is not a directory, then an error is given. This feature is useful for example, to extract all the modules and place them into some remote directory, as in:
fhist -all -e -o tempdir
You should be careful when specifying numeric edit numbers for multiple modules. Most probably, a particular edit number is not appropriate for multiple modules, since changes corresponding to a particular edit number are not usually related. Using named edits avoids these problems. As an example, if you wanted to extract every module which had an edit that was named rev3, then you could use the command:
fhist -all -e rev3
Some other useful examples of commands which use multiple modules are:
fhist *.c -create fhist -check -all fhist -cu -all
- 0
- No output at all (except for errors).
- 1
- Single‐line output describing action (default).
- 2
- Detailed status as action proceeds.
- -Help
-
Give some help on how to use the fhist program. - -VERSion
-
Show what version of fhist is running.
All options may be abbreviated; the abbreviation is documented as the upper case letters, all lower case letters and underscores (_) are optional. You must use consecutive sequences of optional letters.
All options are case insensitive, you may type them in upper case or lower case or a combination of both, case is not important.
For example: the arguments "-help, "-HELP" and "-h" are all interpreted to mean the -Help option. The argument "-hlp" will not be understood, because consecutive optional characters were not supplied.
Options and other command line arguments may be mixed arbitrarily
on the command line.
The GNU long option names are understood. Since all option names
for fhist are long, this means ignoring the extra leading '-'. The
"-option=value" convention is also
understood.
FILE NAME EXPANSION¶
As a convenience, if a pathname begins with a period and a environment variable exists with that name, then the value of the environment variable will be used as the actual pathname. For example, if a environment variable of .FOO has the value this.is.a.long.name, then the command
fhist -o .FOO
fhist -o this.is.a.long.name
fhist -o ./.FOO
BINARY FILES¶
In general, fhist can handle all text files you throw at it, even international text with unusual encodings. However, fhist is unable to cope elegantly with files which contain the NUL character.
The fcomp(1) program simply prints a warning, and continues, you need to know that it converts NUL characters into an 0x80 value before performing the comparison.
The fmerge(1) program also converts the NUL character to an 0x80 value before merging, after a warning, and any output file will contain this value, rather than the original NUL character.
The fhist(1) program, however, generates a fatal error if
any input file contains NUL characters. This is intended to protect your
source files for unintentional corruption. Use -BINary for files
which absolutely must contain NUL characters.
EXIT STATUS¶
The fhist program will exit with a status of 1 on any error. The fhist program will only exit with a status of 0 if there are no errors.
REFERENCES¶
This program is based on the algorithm in
COPYRIGHT¶
fhist version 1.18.D001
Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 Peter Miller;
This program is derived from a work
Copyright (C) 1990 David I. Bell.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
AUTHORS¶
Peter Miller | Web: | http://miller.emu.id.au/pmiller/ |
/\/\* | E‐Mail: | pmiller@opensource.org.au |
David I. Bell | Web: | http://www.canb.auug.org.au/~dbell |
E‐Mail: | dbell@canb.auug.org.au |
FHist | Reference Manual |