emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: emacs-repository-version not defined when cloned with mercurial


From: Uwe Brauer
Subject: Re: emacs-repository-version not defined when cloned with mercurial
Date: Sat, 10 Aug 2019 12:09:55 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

>>> "EZ" == Eli Zaretskii <address@hidden> writes:

   >> From: Stefan Monnier <address@hidden>
   >> Date: Sat, 10 Aug 2019 05:17:15 -0400
   >> Cc: Uwe Brauer <address@hidden>
   >> 
   >> > Command. Not sure what to do with emacs-repository-get-version though.
   >> > Maybe I should define a new variable
   >> >
   >> >  emacs-use-hg 
   >> >
   >> > Which per default is nil.
   >> 
   >> I think catching an error signaled by `git` and then trying `hg` instead
   >> is a better plan.

   > Why not simply ask users who clone into a Mercurial repository to hack
   > up a 'git' shell script that will do what Emacs expects using
   > Mercurial?  I mean, this is an unusual situation which we don't have
   > to support too actively.  The hash is only important when reporting
   > bugs.  

I am not sure I understand your proposal.
I am currently compiling GNU emacs for a commit which 
corresponds to the git hash 
1d75604eaded6a8482d28d57bc8e6a4d99d5caee 

In my mercurial clone this is hash
48e6ea8e6e9f08075949468971312b4c607eb291

Mercurial can without problems translate between both hashes.

However suppose I run the compiled version for a while (and suppose I
even have deleted the cloned mercurial repository) and want to
report a bug, then I don't know for which mercurial I compiled that
version, and I cannot calculate the corresponding git hash.

This is why I try to have a function which would tell me the mercurial
hash.

What is your proposal?


I have to admit that I don't understand who currently emacs is
calculating the git hash. 

I see that it uses shell command 

 git rev-parse HEAD

But where and for which repository.

How can I debug emacs-repository-version?

I am asking this, since my generalization for mercurial did not work


(defun emacs-repository-version-hg (dir)
  "Ask git itself for the version information for directory DIR."
  (message "Waiting for git...")
  (with-temp-buffer
    (let ((default-directory (file-name-as-directory dir)))
      (and (eq 0
               (with-demoted-errors "Error running hg parent --template: %S"
                 (call-process "hg" nil '(t nil) nil "parent" "--template 
'{node}\n'")))
           (progn (goto-char (point-min))
                  (looking-at "[0-9a-fA-F]\\{40\\}"))
           (match-string 0)))))

(defun emacs-repository-version-git (dir)
  "Ask git itself for the version information for directory DIR."
  (message "Waiting for git...")
  (with-temp-buffer
    (let ((default-directory (file-name-as-directory dir)))
      (and (eq 0
               (with-demoted-errors "Error running git rev-parse: %S"
                 (call-process "git" nil '(t nil) nil "rev-parse" "HEAD")))
           (progn (goto-char (point-min))
                  (looking-at "[0-9a-fA-F]\\{40\\}"))
           (match-string 0)))))

(defun emacs-repository-get-version (&optional dir external)
  "Try to return as a string the repository revision of the Emacs sources.
The format of the returned string is dependent on the VCS in use.
Value is nil if the sources do not seem to be under version
control, or if we could not determine the revision.  Note that
this reports on the current state of the sources, which may not
correspond to the running Emacs.

Optional argument DIR is a directory to use instead of `source-directory'.
Optional argument EXTERNAL is ignored."
  (emacs-repository-version-hg (or dir source-directory)))


Attachment: smime.p7s
Description: S/MIME cryptographic signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]