Different `diff` output for null repository
Stephen Rasku
mercurial at srasku.net
Tue Nov 15 00:49:26 UTC 2016
Hi Mischa,
Thanks for your answer. I've tested it and I see that's how it works.
This clause from `hg help diff` should probably be corrected, then:
If only one revision is specified then that revision is compared to the
working directory
because it's not accurate if you are at the null revision. Personally, I
would prefer that the behaviour was changed to match the documentation
rather than the documentation being changed to match the behaviour.
However, I know the project takes great pains to not modify the command
line behaviour so I understand why they wouldn't want to do that.
In any case, thanks again for the answer. It gives me a workaround for
what I'm trying to do.
...Stephen
On Mon, Nov 14, 2016 at 11:59 AM, Becker, Mischa J <mischa.becker at kroger.com
> wrote:
> > 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.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial/attachments/20161114/a0ffe96c/attachment-0002.html>
More information about the Mercurial
mailing list