Generation of diff files
Coco supports patch file analysis in the CoverageBrowser and in cmreport with the option --patch
(see cmreport – code coverage report generation). For this, a diff
file in the unified format is needed. It is provided by the diff
tool and by most version control systems.
The following examples work both on the UNIX® shell and with a Microsoft® Windows command window.
Comparing directories
If the two versions of the source are in different directories of the file system, the diff
command can be used. It is the standard UNIX file comparison program which gives the functionality its name.
The unified format must be set with the -u
flag, and the result must be redirected to a file, so that the command line will look like:
$ diff -u project/version_1 project/version_2 > project.diff
Then the directories project/version_1
and project/version_2
are compared and the output is written to the file project.diff
. Of the two directories, project/version_1
is viewed as the earlier version.
Version control systems
In a version control system, the diff
functionality is used to compare two revisions of the source tree.
For most of the newer version control systems, there exist GUI wrappers, like Tortoise SVN, especially for Windows. If the underlying version control system supports unified diffs by default, the same can be expected from the GUI wrappers.
- Git: With Git, specify two revisions and redirect the output to a file. Git uses the unified format by default. Compare two revisions with:
$ git diff
<rev1> <rev2> > project.diffThis command creates by default a diff of the whole source tree.
For a list of ways to specify the revisions under Git, see gitrevisions.
- Mercurial: The distributed version system Mercurial generates by default diff files in the unified format. To compare the Mercury change sets <rev1> and <rev2>:
$ hg diff -r
<rev1>-r
<rev2> > project.diff - Subversion: The version control system Subversion generates unified diffs by default. To generate the diff, write:
$ svn diff -r
<rev1>-r
<rev2> > project.diffwhere <rev1> and <rev2> may be tags or revision numbers.
- CVS: The Concurrent Versions System is the oldest of the revision control systems described here. It does not use the unified format by default. With it, one has to write the following to compare two revisions:
$ cvs diff -u -N -r
<rev1>-r
<rev2> > project.diffThe flag
-u
switches unified diffs on, and-N
is necessary to track changes in which a file is added or removed. The revisions <rev1> and <rev2> must be tags or dates, since CVS does not have global version numbers. The command then creates a lot of additional console output, but the differences between the two revisions are still written toproject.diff
.Note that the command only lists the differences in the current directory and its subdirectories.
Coco v7.2.1 ©2024 The Qt Company Ltd.
Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners.