unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Andy Moreton <andrewjmoreton@gmail.com>
To: 22032@debbugs.gnu.org
Subject: bug#22032: 24.3; VC doesn't handle hg hidden revisions
Date: Tue, 15 Dec 2015 23:53:08 +0000	[thread overview]
Message-ID: <868u4vxo9n.fsf@gmail.com> (raw)
In-Reply-To: <56584054.5080100@gmail.com>

On Sat 28 Nov 2015, Dmitry Gutov wrote:

> Hi Glenn,
>
> Please keep the bug address in Cc. I'm reproducing the entirety of your email
> here for posterity.
>
> On 11/28/2015 05:07 PM, Glenn Hutchings wrote:
>
>> Thanks for the quick response.  I've been doing a bit more digging for
>> info about this, and think I've figured out exactly how I got into the
>> situation.  There's an experimental set of features called Changeset
>> Evolution <https://www.mercurial-scm.org/wiki/ChangesetEvolution> that
>> modifies the way mercurial rewrites history: instead of stripping a
>> changeset, it marks it 'obsolete'.  Looks like these features were
>> introduced at version 2.9, but by default none of them are used by the
>> core mercurial commands.  But a recent extension called Evolve
>> <https://www.mercurial-scm.org/wiki/EvolveExtension> does use it.  If
>> you enable that extension, and then perform a "commit --amend", instead
>> of updating the head changeset, it creates a new one and makes the
>> previous one obsolete (and 'hidden' by default in the change log).
>>
>> Long story short: the gap in rev numbers only occurs if you enable the
>> 'evolve' extension (or another which uses the changeset-evolution
>> features) and use a history-modifying command.  I recently tried the
>> extension out, which is when I came across the bug.
>
> I see.
>
>>> Is there a reason why we wouldn't want to use that argument and just
>>> always display them?
>>>
>>
>> Well, the hidden revs are really only used internally, and shouldn't be
>> seen by users.
>>
>>> Would calling 'hg diff --hidden' help?
>>>
>>
>> Unfortunately not -- that would only do a diff between the current rev
>> and the internal hidden one.  Not what the user really wants.
>
> That makes sense.

This problem with revision IDs also accurs if the repo contains named
branches. in that case the numerically previous revision may be on a
different branch, resulting in a meaningless diff that is slow to
compute.

For example (from a non-public repo with named branches), where rev
59951 and rev 59950 are on different named branches:
  $ hg diff -r59951 -r59950 | wc -l
  88188
  $ hg diff -r59951 -r59951^ | wc -l
  70
  $ hg id -n -r59951^
  59925

The first example diffs agaist the previous revision ID (which is on a
different branch), and produces large and useless diff output. The second
example diffs against the (first) parent, and is what is actually wanted.

>> I managed to come up with this, using mercurial's 'revset' feature:
>>
>>     hg id --hidden -n -r 'first(X:0 and not hidden())'
>
> Thanks. Please try this definition and see if it resolves the problem:
>
> (defun vc-hg-previous-revision (_file rev)
>   (let ((newrev (1- (string-to-number rev))))
>     (when (>= newrev 0)
>       (with-temp-buffer
>         (vc-hg-command t 0 nil
>                        "id" "--hidden" "-n" "-r"
>                        (format "first(%d:0 and not hidden())" newrev))
>         ;; Trim the trailing newline.
>         (buffer-substring (point-min) (1- (point-max)))))))
>
>> This says to look at all non-hidden revs from X down to zero, choose the
>> first one, and print its numeric rev number.  If the current rev is X+1,
>> that gives the first previous non-hidden rev.  But I'm sure there must
>> be a better way, without having to examine all previous changesets.
>
> If you anticipated that we'd have to make one process call per revision, then
> I think the above definition does better.

To also work with named branches, something like this (untested) would be better:
    (format "last(ancestors(%d) and not hidden())" newrev)

>> Given the experimental nature of all this evolution stuff, I'm inclined
>> to think that it's not all that urgent a problem to resolve right now.
>> But if it ever becomes part of core mercurial, it's something to bear in
>> mind.
>
> Indeed, it seems there's no hurry. On the other hand, I don't expect much harm
> from installing the new vc-hg-previous-revision definition either: it works
> fine with the version of Mercurial installed on my machine (3.4), although in
> all cases I've tried it basically returned the revision passed to it as X.
>
> If it would cause earlier versions of Mercurial to error out, however, that
> would be a reason to hold off on it.

Indeed - even after the evolution stuff has matured further, there will
still be a large population of machines that are running older versions
of Mercurial, and will not understand the "hidden()" predicate.

    AndyM






  parent reply	other threads:[~2015-12-15 23:53 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-27 11:36 bug#22032: 24.3; VC doesn't handle hg hidden revisions Glenn Hutchings
2015-11-28  2:44 ` Dmitry Gutov
     [not found]   ` <5659C34E.4070300@gmail.com>
2015-11-28 18:09     ` Dmitry Gutov
2015-12-13 10:54       ` Glenn Hutchings
2015-12-14  3:30         ` Dmitry Gutov
     [not found]           ` <CA+hLqocwRQqXHZj1i8YOQiJS2c1nL7ahVP7OrdS=oizy=ct1XQ@mail.gmail.com>
2015-12-15 14:08             ` Dmitry Gutov
2015-12-15 23:53       ` Andy Moreton [this message]
2015-12-16  0:03         ` Dmitry Gutov
2015-12-16  3:02           ` Andy Moreton
2015-12-18  5:02             ` Dmitry Gutov
2015-12-22 20:17               ` Glenn Hutchings
2015-12-22 21:33                 ` Dmitry Gutov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=868u4vxo9n.fsf@gmail.com \
    --to=andrewjmoreton@gmail.com \
    --cc=22032@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).