From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Glenn Hutchings Newsgroups: gmane.emacs.bugs Subject: bug#22032: 24.3; VC doesn't handle hg hidden revisions Date: Sun, 13 Dec 2015 10:54:37 +0000 Message-ID: <566D4E6D.2060804@gmail.com> References: <56584054.5080100@gmail.com> <56591524.3010806@yandex.ru> <5659C34E.4070300@gmail.com> <5659EDD4.7030503@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="------------030605080501090408090106" X-Trace: ger.gmane.org 1450004127 18127 80.91.229.3 (13 Dec 2015 10:55:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 13 Dec 2015 10:55:27 +0000 (UTC) Cc: 22032@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Dec 13 11:55:16 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1a84J6-0000qr-7Y for geb-bug-gnu-emacs@m.gmane.org; Sun, 13 Dec 2015 11:55:12 +0100 Original-Received: from localhost ([::1]:54700 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a84J5-0007Xk-5S for geb-bug-gnu-emacs@m.gmane.org; Sun, 13 Dec 2015 05:55:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37781) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a84J1-0007WI-DS for bug-gnu-emacs@gnu.org; Sun, 13 Dec 2015 05:55:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a84Iw-00088a-BY for bug-gnu-emacs@gnu.org; Sun, 13 Dec 2015 05:55:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:42296) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a84Iw-00088W-7b for bug-gnu-emacs@gnu.org; Sun, 13 Dec 2015 05:55:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1a84Iv-0005Jk-T9 for bug-gnu-emacs@gnu.org; Sun, 13 Dec 2015 05:55:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Glenn Hutchings Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 13 Dec 2015 10:55:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22032 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 22032-submit@debbugs.gnu.org id=B22032.145000408520412 (code B ref 22032); Sun, 13 Dec 2015 10:55:01 +0000 Original-Received: (at 22032) by debbugs.gnu.org; 13 Dec 2015 10:54:45 +0000 Original-Received: from localhost ([127.0.0.1]:49898 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1a84If-0005J9-J0 for submit@debbugs.gnu.org; Sun, 13 Dec 2015 05:54:45 -0500 Original-Received: from mail-wm0-f46.google.com ([74.125.82.46]:38797) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1a84Ie-0005Iw-2D for 22032@debbugs.gnu.org; Sun, 13 Dec 2015 05:54:44 -0500 Original-Received: by wmpp66 with SMTP id p66so26283599wmp.1 for <22032@debbugs.gnu.org>; Sun, 13 Dec 2015 02:54:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type; bh=2v1njKxH7MIhCv4iWvFRfOj9148Us1kFOgU3/qyS4As=; b=gBwkYXY+DSl4Z6M9ap+HjdvY9vsgtVhjEo2y6xhmc0VUhJQE1HzL3Lss+YlaoMgT// Io9GeGRi6oEvUGQD0AOuez/GNF+uhZm0PpETTA2wRpnjuBRQslaWeCqV3PG4FE2u3ij8 LiS/jXYLmaYT6z6OaszkHeV5yDtS9CZpM5xenuzpyYAKw6inT1tJ/DBxOh68LoCieIqf 3uRpY1YUKO0Z4sWZCEIqAl1ra5HtZO8AnJGagBxFInPuflDBqD3NO8B6pk6KB3j83A3W 5SlzPaL9wY3mhsHDTmf1VX5OwGII6cqiyJVoW6zCt9/NY8yCAK7l2ppjTTzzdDhJRYGE dg7g== X-Received: by 10.28.158.75 with SMTP id h72mr17587315wme.74.1450004078496; Sun, 13 Dec 2015 02:54:38 -0800 (PST) Original-Received: from [192.168.1.6] (cpc19-flit3-2-0-cust141.9-1.cable.virginm.net. [82.9.65.142]) by smtp.googlemail.com with ESMTPSA id m191sm11149108wma.3.2015.12.13.02.54.37 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 13 Dec 2015 02:54:37 -0800 (PST) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 In-Reply-To: <5659EDD4.7030503@yandex.ru> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:109920 Archived-At: This is a multi-part message in MIME format. --------------030605080501090408090106 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 11/28/15 18:09, Dmitry Gutov wrote: > 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. I tried this, and it works fine. But I discovered another problem for VC with the changeset evolution features: if a repository has any changesets that are marked 'obsolete', and any mercurial command is issued by a user who hasn't enabled the extension, a warning message is printed to stderr: obsolete feature not enabled but markers found! If VC grabs this output as part of the mercurial response, and uses it in subsequent commands, it (unsurprisingly) fails: hg: parse error at 9: invalid token Looking at mercurial sources, there's no way to suppress this warning. I guess one workaround would be to have vc-hg-command skip over it if it's there. Glenn --------------030605080501090408090106 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
On 11/28/15 18:09, Dmitry Gutov wrote:
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.
I tried this, and it works fine.  But I discovered another problem for VC with the changeset evolution features: if a repository has any changesets that are marked 'obsolete', and any mercurial command is issued by a user who hasn't enabled the extension, a warning message is printed to stderr:
obsolete feature not enabled but <N> markers found!
If VC grabs this output as part of the mercurial response, and uses it in subsequent commands, it (unsurprisingly) fails:
hg: parse error at 9: invalid token
Looking at mercurial sources, there's no way to suppress this warning.  I guess one workaround would be to have vc-hg-command skip over it if it's there.

Glenn
--------------030605080501090408090106--