bos@559: bos@559: bos@559: bos@559: Command reference bos@559: bos@559: \cmdref{add}{add files at the next commit} bos@133: \optref{add}{I}{include} bos@133: \optref{add}{X}{exclude} bos@559: \optref{add}{n}{dry-run} bos@559: bos@559: \cmdref{diff}{print changes in history or working directory} bos@559: bos@559: Show differences between revisions for the specified files or bos@132: directories, using the unified diff format. For a description of the dongsheng@625: unified diff format, see section . bos@559: bos@559: By default, this command does not print diffs for files that Mercurial bos@133: considers to contain binary data. To control this behaviour, see the bos@559: and options. bos@559: bos@559: bos@559: Options bos@559: bos@559: \loptref{diff}{nodates} bos@559: bos@559: Omit date and time information when printing diff headers. bos@559: bos@559: \optref{diff}{B}{ignore-blank-lines} bos@559: bos@559: Do not print changes that only insert or delete blank lines. A line bos@133: that contains only whitespace is not considered blank. bos@559: bos@559: bos@559: \optref{diff}{I}{include} bos@559: bos@559: bos@559: Include files and directories whose names match the given patterns. bos@559: bos@559: bos@559: \optref{diff}{X}{exclude} bos@559: bos@559: bos@559: Exclude files and directories whose names match the given patterns. bos@559: bos@559: bos@559: \optref{diff}{a}{text} bos@559: bos@559: bos@559: If this option is not specified, hg diff will refuse to print bos@559: diffs for files that it detects as binary. Specifying bos@559: forces hg diff to treat all files as text, and generate diffs for bos@132: all of them. bos@559: bos@559: bos@559: This option is useful for files that are mostly text but have a bos@133: few embedded NUL characters. If you use it on files that contain a bos@133: lot of binary data, its output will be incomprehensible. bos@559: bos@559: bos@559: \optref{diff}{b}{ignore-space-change} bos@559: bos@559: bos@559: Do not print a line if the only change to that line is in the amount bos@133: of white space it contains. bos@559: bos@559: bos@559: \optref{diff}{g}{git} bos@559: bos@559: bos@559: Print git-compatible diffs. XXX reference a format bos@133: description. bos@559: bos@559: bos@559: \optref{diff}{p}{show-function} bos@559: bos@559: bos@559: Display the name of the enclosing function in a hunk header, using a bos@133: simple heuristic. This functionality is enabled by default, so the bos@559: option has no effect unless you change the value of bos@559: the showfunc config item, as in the following example. bos@559: bos@559: bos@559: bos@559: \optref{diff}{r}{rev} bos@559: bos@559: bos@559: Specify one or more revisions to compare. The hg diff command bos@559: accepts up to two options to specify the revisions to bos@133: compare. bos@559: bos@559: bos@559: bos@559: Display the differences between the parent revision of the bos@133: working directory and the working directory. bos@559: bos@559: bos@559: Display the differences between the specified changeset and the bos@132: working directory. bos@559: bos@559: bos@559: Display the differences between the two specified changesets. bos@559: bos@559: bos@559: bos@559: You can specify two revisions using either two bos@132: options or revision range notation. For example, the two revision bos@132: specifications below are equivalent. bos@559: bos@559: hg diff -r 10 -r 20 bos@559: hg diff -r10:20 bos@559: bos@559: When you provide two revisions, Mercurial treats the order of those bos@559: revisions as significant. Thus, hg diff -r10:20 will bos@132: produce a diff that will transform files from their contents as of bos@559: revision 10 to their contents as of revision 20, while bos@559: hg diff -r20:10 means the opposite: the diff that will bos@559: transform files from their revision 20 contents to their revision 10 bos@132: contents. You cannot reverse the ordering in this way if you are bos@132: diffing against the working directory. bos@559: bos@559: bos@559: \optref{diff}{w}{ignore-all-space} bos@559: bos@559: bos@559: \cmdref{version}{print version and copyright information} bos@559: bos@559: bos@559: This command displays the version of Mercurial you are running, and bos@133: its copyright license. There are four kinds of version string that bos@133: you may see. bos@559: bos@559: bos@559: The string unknown. This version of Mercurial was bos@133: not built in a Mercurial repository, and cannot determine its own bos@133: version. bos@559: bos@559: bos@559: A short numeric string, such as 1.1. This is a bos@133: build of a revision of Mercurial that was identified by a specific bos@133: tag in the repository where it was built. (This doesn't necessarily bos@133: mean that you're running an official release; someone else could bos@133: have added that tag to any revision in the repository where they bos@133: built Mercurial.) bos@559: bos@559: bos@559: A hexadecimal string, such as 875489e31abe. This bos@133: is a build of the given revision of Mercurial. bos@559: bos@559: bos@559: A hexadecimal string followed by a date, such as bos@559: 875489e31abe+20070205. This is a build of the given bos@133: revision of Mercurial, where the build repository contained some bos@133: local changes that had not been committed. bos@559: bos@559: bos@559: bos@559: bos@559: bos@559: Tips and tricks bos@559: dongsheng@625: bos@559: Why do the results of <command role="hg-cmd">hg diff</command> and <command role="hg-cmd">hg status</command> differ? bos@559: bos@559: When you run the hg status command, you'll see a list of files bos@132: that Mercurial will record changes for the next time you perform a bos@559: commit. If you run the hg diff command, you may notice that it bos@559: prints diffs for only a subset of the files that hg status bos@132: listed. There are two possible reasons for this. bos@559: bos@559: bos@559: The first is that hg status prints some kinds of modifications bos@559: that hg diff doesn't normally display. The hg diff command bos@132: normally outputs unified diffs, which don't have the ability to bos@132: represent some changes that Mercurial can track. Most notably, bos@132: traditional diffs can't represent a change in whether or not a file is bos@132: executable, but Mercurial records this information. bos@559: bos@559: bos@559: If you use the option to hg diff, it will bos@559: display git-compatible diffs that can display this bos@132: extra information. bos@559: bos@559: bos@559: The second possible reason that hg diff might be printing diffs bos@559: for a subset of the files displayed by hg status is that if you bos@559: invoke it without any arguments, hg diff prints diffs against the bos@559: first parent of the working directory. If you have run hg merge bos@132: to merge two changesets, but you haven't yet committed the results of bos@559: the merge, your working directory has two parents (use hg parents bos@559: to see them). While hg status prints modifications relative to bos@559: both parents after an uncommitted merge, hg diff still bos@132: operates relative only to the first parent. You can get it to print bos@132: diffs relative to the second parent by specifying that parent with the bos@559: option. There is no way to print diffs relative to bos@132: both parents. bos@559: bos@559: bos@559: bos@559: bos@559: Generating safe binary diffs bos@559: bos@559: If you use the option to force Mercurial to print bos@559: diffs of files that are either mostly text or contain lots of bos@132: binary data, those diffs cannot subsequently be applied by either bos@559: Mercurial's hg import command or the system's patch bos@559: command. bos@559: bos@559: bos@559: If you want to generate a diff of a binary file that is safe to use as bos@559: input for hg import, use the hg diff{--git} option when you bos@559: generate the patch. The system patch command cannot handle bos@132: binary patches at all. bos@559: bos@559: bos@559: bos@559: bos@559: bos@559: bos@559: