Different `diff` output for null repository

Becker, Mischa J mischa.becker at kroger.com
Mon Nov 14 19:59:07 UTC 2016


> From: Mercurial [mailto:mercurial-bounces at mercurial-scm.org] On Behalf Of Stephen Rasku
> Sent: Sunday, November 13, 2016 4:31 PM
> To: mercurial at mercurial-scm.org
> Subject: Different `diff` output for null repository
>
> I have the following test file.
>  $ hg init diff
>  $ cd diff
>  $ echo foo > foo
>  $ hg add foo
>  $ hg ci -m "foo"
>  $ echo bar >> foo
>  $ hg ci -m "foo+bar"
>  $ hg up -r 1
>  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
>  $ hg cat -r tip foo > foo
>  $ cat foo
>  foo
>  bar
>  $ hg diff -r tip
>  $ hg up null
>  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
>  $ hg cat -r tip foo > foo
>  $ cat foo
>  foo
>  bar
>  $ hg diff -r tip
>
> I would expect the two diff  commands to have the same output (i.e. nothing).  However,
> I get the following output:
>
> $ cram diff.t
>!
> --- diff.t
> +++ diff.t.err
> @@ -19,3 +19,9 @@
>   foo
>   bar
>   $ hg diff -r tip
> +  diff -r 6695c077f203 foo
> +  --- a/foo\tMon Nov 14 00:29:46 2016 +0000 (esc)
> +  +++ /dev/null\tThu Jan 01 00:00:00 1970 +0000 (esc)
> +  @@ -1,2 +0,0 @@
> +  -foo
> +  -bar
>
> # Ran 1 tests, 0 skipped, 1 failed.
> Am I wrong in my expectations?  Is this documented anywhere?
>...Stephen

If you were doing the above diff test on revisions 0 and 1 then it would work as expected.  The null revision however is before revision 0.  At that point foo is not a tracked file and will be ignored by hg diff until you hg add it again.  Running hg stat --all will show you the difference.

Same thing would happen if foo wasn't added to your repo until revision 4 and you ran the above test on revision 3 instead of null.

Mischa

________________________________

This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is confidential and protected by law from unauthorized disclosure. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.


More information about the Mercurial mailing list