all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Albinus <michael.albinus@gmx.de>
To: Jonas Bernoulli <jonas@bernoul.li>
Cc: Emacs developers <emacs-devel@gnu.org>, Dmitry Gutov <dgutov@yandex.ru>
Subject: Re: git-handler.el
Date: Sat, 12 Aug 2017 21:17:25 +0200	[thread overview]
Message-ID: <87inhstx2y.fsf@detlef> (raw)
In-Reply-To: <877ey9cb9l.fsf@bernoul.li> (Jonas Bernoulli's message of "Sat, 12 Aug 2017 12:48:22 +0200")

Jonas Bernoulli <jonas@bernoul.li> writes:

Hi Jonas,

>> A revisioned filename is something like "/path/to/file@@revision".
>> "revision" could be a revision like "81656add81", a branch like
>> "scratch/kqueue", or a tag like "emacs-19.34". Of course, the syntax
>> could be changed.
>
> I would prefer /path/to/repo/@git:REVISION:path/to/file.  I don't have
> a strong opinion about what the magic cookie should look like, but I
> think it should be inserted at the root of the working tree.

No, we are speaking about file name handlers. So we must give the syntax
a chance to address just one file. As Eli said, think about other VCSes,
like CVS. Your syntax wouldn't match.

I believe we should not use the VCS name, like "git", in the file name
syntax. There is no need for it, because we could offer a variable
`vc-handler-backend' or so, in which a user could tell us the preferred
backend. It could be one of the values of `vc-handled-backends' like
`Git', or it could be something different like the symbol `Magit'.

If this variable is declared directory-local at project root, the user
don't need to think about ever. If that variable is nil, the fallback
would be the vc mechanism via the `vc-responsible-backend' call, as I
have already implemented. Or something else.

I would also recommend to avoid using ":" in the file name. Although we
haven't the case yet, I fear that we would clash some day with Tramp
file name syntax.

So I'm back to the syntax "/path/to/file@@<backend specific>" or
"/path/to/directory@@<backend specific>". Note the /path/to/directory
case I haven't mentioned before, and which isn't implemented yet in the
code. There's no need to use the slash prior the cookie @@, because this
will be detected by ordinary file operations. About the
/path/to/directory@@... semantics more below.

>> vc-handler.el is the common part. There is the alist
>> `vc-file-name-handler-alist', which lists for every magic file name
>> function the responsible handler function. The majority of them is also
>> implemented in vc-handler.el, because they don't need any vcs specific
>> handling.
>>
>> For every different backend, there could be a respective backend
>> package. I've implemented vc-git-handler.el, because I know more about
>> vc-git than magit. But there's no problem to implement vc-magit.el, for
>> example. I plan also to write at least vc-cvs.el.
>
> As I said I haven't looked at the code much yet, so I don't know what
> the implications of having alternative handlers for the same vc would
> be.  But I fear that it would reduce interoperability.  But packages
> other than VC should be able to customize the behavior to some extend
> and that could probably be implemented using a few hooks and *-function
> variables.

I don't see yet what you have in mind. Implementing all magic file name
operations is sufficient in my understanding. vc-handler.el shall be
the common part for all VCSes, and vc-<backend>-handler.el shall be the
backend specific part. Beside the `vc-responsible-backend' call I've
mentioned above, there is no vc*.el functionality used in
vc-handler.el. Maybe the name is misleading here.

I have established a mechanism, allowing backend specific handlers to
overrule common ones. `vc-git-handle-file-attributes' takes priority
over `vc-handle-file-attributes' in my implementation. So could
(vc-)magit-handle-* functions.

>> You might play a little bit to see how it looks like. Maybe the most
>> simple start is to enter dired, because it uses many of the magic file
>> name operations. Just do "C-x d ~/src/emacs/src/emacs.c@@" (supposed
>> your Emacs git is located at ~/src/emacs, as in my case).
>
> Speaking of Dired, trees (directories) should be supported in addition
> to blobs (files), among other things that would allow visiting them in
> Dired.

Dired itself doesn't matter too much for the file name handler
business. It is just a proper UI in order to explore the possibilities.

In my previous mail I have described how a file oriented view would
look like. Take the Emacs source tree, and file
lisp/display-line-numbers.el as example (I take it, because it has a
short commit history :-) In dired, there exists then

--8<---------------cut here---------------start------------->8---
  /home/albinus/src/emacs/lisp/display-line-numbers.el@@:
  total 12
  lr--r--r--  1 Paul Eggert     UNKNOWN 3922 08-03 04:46 emacs23 -> a8a81df8da
  lr--r--r--  1 Michael Albinus UNKNOWN 3922 08-01 10:13 HEAD -> master
  dr-xr-xr-x  1 Michael Albinus UNKNOWN 3922 08-01 10:13 master

  /home/albinus/src/emacs/lisp/display-line-numbers.el@@/master:
  total 23
  -r--r--r--  1 Michael Albinus   UNKNOWN 3846 07-23 09:28 012487bc41
  -r--r--r--  1 Mark Oteiza       UNKNOWN 3937 07-25 02:17 32daa3cb54
  -r--r--r--  1 Alexander Gramiak UNKNOWN 3831 07-22 11:16 ebb78a7bfa
  -r--r--r--  1 Michael Albinus   UNKNOWN 3922 08-01 10:13 ef7a18a071
  -r--r--r--  1 Mark Oteiza       UNKNOWN 3960 07-23 21:41 f57c710772
  lr--r--r--  1 Michael Albinus   UNKNOWN 3922 08-01 10:13 HEAD -> 81e22163eb
--8<---------------cut here---------------end--------------->8---

The file belongs only to the master branch so far; if it would belong to
other branches, there would be respective subdirectories. And there is
only one label on that file so far, emacs23. (Btw, where does it come from?)

A revision oriented view would start with a directory, and not with a
file. Let's use lisp/, and revision ef7a18a071

--8<---------------cut here---------------start------------->8---
  /home/albinus/src/emacs/lisp@@:
  total 12
  lr--r--r--  1 Paul Eggert     UNKNOWN 3922 08-03 04:46 emacs23 -> a8a81df8da
  lr--r--r--  1 Michael Albinus UNKNOWN 3922 08-01 10:13 HEAD -> master
  dr-xr-xr-x  1 Michael Albinus UNKNOWN 3922 08-01 10:13 master
  [... Other branches] 
  dr-xr-xr-x  1 Michael Albinus   UNKNOWN 3922 08-01 10:13 ef7a18a071
  [... Other revisions] 

  /home/albinus/src/emacs/lisp@@/ef7a18a071:
  total 23
  -r--r--r--  1 Michael Albinus   UNKNOWN   3922 08-01 10:13 display-line-numbers.el
  -r--r--r--  1 Michael Albinus   UNKNOWN 109714 08-01 10:13 menu-bar.el
--8<---------------cut here---------------end--------------->8---

(This example I have written manually, it is not implemented yet).

You see the difference. In the file oriented view, we have
"/home/albinus/src/emacs/lisp/display-line-numbers.el@@/master" being a
directory, containing all revisions and labels as regulary files.

In the revision oriented view, we have
"/home/albinus/src/emacs/lisp@@/ef7a18a071" being a directory,
containing the files which have been modified by this commit.

This is just the basic idea, and it would work for other backends as
well. For CVS, the revision oriented view would just offer one file for
a given commit, and likely several files for a given label (which is a
directory or a symlink to a directory).

>> Both packages are far from being complete. Performance is terrible (a
>> proper cache mechanism is needed),
>
> In what way is performance terrible?  I would have expected that asking
> git for information about one blob would not be that much more expensive
> than asking the file-system for the same information about one file.
> (I.e. the the difference would only become relevant if you needed
> information about many files.)

For one blob it might perform better. But I have implemented the file
oriented view first, which asks information for every file containing to
a blob again and again. `vc-git-handle-file-attributes', for example,
raises two process calls. Much place for improvement, of course.

> What happens when you visit say HEAD:file and then HEAD is updated?  I
> think this should behave much the same as for files that are modified on
> disk.  The user could then use `revert-buffer' to update the buffer.

Yep. See the comment in vc-git-handler.el:

;; TODO: We shall add also functions to expire the caches.  Best would
;; be file notification, which watches respective git files (indexes).

Once the cache expires the information of a file, let's say the
`file-attributes' information, new information is retrieved next time
`file-attributes' is called. Emacs will warn you then that the buffer
contents is not current. You could revert.

> You mentioned in another message that this is read-only.  While that's a
> good default, I think it should be possible for Magit or something else
> to provide a `modified-p' and a `save-file' function by setting some
> `*-function' variables.

I don't understand. What do you need, which is not handled by basic file
operations, like `verify-visited-file-modtime'?

> It would help me and others that are not very familiar with VC's
> internals to understand the file-handler parts if you could create one
> commit that implements those parts without taking advantage of any
> caching provided by VC and then add that caching in a separate commit.

I have no plan yet for committing something, because I don't know where
it shall go. Emacs core? ELPA?

>   Cheers,
>   Jonas
>
> Ps: I'll probably be unavailable for a few days.

No problem, take your time.

Best regards, Michael.



  parent reply	other threads:[~2017-08-12 19:17 UTC|newest]

Thread overview: 136+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-05 15:29 In support of Jonas Bernoulli's Magit (was: comparing code on different branches) John Yates
2017-07-05 16:15 ` Kaushal Modi
2017-07-05 16:22 ` In support of Jonas Bernoulli's Magit Óscar Fuentes
2017-07-05 16:27   ` Kaushal Modi
2017-07-05 16:38   ` Stefan Monnier
2017-07-05 18:15     ` Óscar Fuentes
2017-07-05 23:03   ` Richard Stallman
2017-07-06  0:24     ` Clément Pit-Claudel
2017-07-06  1:46       ` Glenn Morris
2017-07-06  2:17         ` Clément Pit-Claudel
2017-07-10  9:26           ` Richard Stallman
2017-07-06  2:29         ` Jean-Christophe Helary
2017-07-14 14:34       ` Philippe Vaucher
2017-07-16  1:51         ` Richard Stallman
2017-07-06  1:50     ` Glenn Morris
2017-07-06 14:12       ` Ted Zlatanov
2017-07-06 14:47         ` Kaushal Modi
2017-07-06 17:11         ` Óscar Fuentes
2017-07-06 16:02       ` Richard Stallman
2017-07-06 16:52         ` Ken Manheimer
2017-07-07 18:23           ` Richard Stallman
2017-07-07 18:49             ` Stefan Monnier
2017-07-07 22:08             ` Phillip Lord
2017-07-07 22:22               ` Stefan Monnier
2017-07-08  6:58                 ` Eli Zaretskii
2017-07-08  6:57               ` Eli Zaretskii
2017-07-08  9:05                 ` Phillip Lord
2017-07-08 10:20                   ` Eli Zaretskii
2017-07-08 20:34                     ` Phillip Lord
2017-07-09  2:33                       ` Eli Zaretskii
2017-07-10  9:28                       ` Richard Stallman
2017-07-10 13:15                         ` Phillip Lord
2017-07-11 11:45                           ` Richard Stallman
2017-07-08 17:04                   ` Richard Stallman
2017-07-08 20:52                     ` Phillip Lord
2017-07-10  9:30                       ` Richard Stallman
2017-07-08 17:02                 ` Richard Stallman
2017-07-10  9:26               ` Richard Stallman
2017-07-10 12:47                 ` Phillip Lord
2017-07-10 23:26                   ` Richard Stallman
2017-07-11  9:40                     ` Phillip Lord
2017-07-11 22:56                       ` Richard Stallman
2017-07-10 23:27                   ` Richard Stallman
2017-07-10 16:31                 ` Marcin Borkowski
2017-07-10 23:30                   ` Richard Stallman
2017-07-11  4:20                     ` Marcin Borkowski
2017-07-11 11:48                       ` Richard Stallman
2017-07-06 23:01         ` Dmitry Gutov
2017-07-07 18:27           ` Richard Stallman
2017-07-07 18:52             ` Stefan Monnier
2017-07-08 17:01               ` Richard Stallman
2017-07-08 17:42                 ` raman
2017-07-08 18:58                   ` Eli Zaretskii
2017-07-08 20:57                   ` Phillip Lord
2017-07-08 22:57                   ` John Yates
2017-07-09  0:04                     ` raman
2017-07-09  9:25                   ` Marcin Borkowski
2017-07-09 14:19                     ` Eli Zaretskii
2017-07-10  1:01                     ` In defense of VC [was: In support of Jonas Bernoulli's Magit] Juliusz Chroboczek
2017-07-10  7:09                       ` Michael Albinus
2017-07-10  8:34                         ` Lars Ingebrigtsen
2017-07-10  8:47                           ` Juliusz Chroboczek
2017-07-10  8:59                             ` Yuri Khan
2017-07-10 16:28                               ` Marcin Borkowski
2017-07-10 17:12                               ` Eli Zaretskii
2017-07-16 18:01                               ` Dmitry Gutov
2017-07-16 19:09                                 ` Marcin Borkowski
2017-07-16 19:17                                   ` Dmitry Gutov
2017-07-10 23:26                       ` Richard Stallman
2017-07-11  4:15                         ` Marcin Borkowski
2017-07-11 11:48                           ` Richard Stallman
2017-07-11 14:10                             ` Marcin Borkowski
2017-07-11 14:27                               ` Juliusz Chroboczek
2017-07-11 22:56                               ` Richard Stallman
2017-07-11 14:37                           ` Eli Zaretskii
2017-07-11 16:03                             ` Dmitry Gutov
2017-07-11  7:10                         ` Andreas Schwab
2017-07-11  7:26                           ` Michael Albinus
2017-07-11 22:55                           ` Richard Stallman
2017-07-10  9:29                     ` In support of Jonas Bernoulli's Magit Richard Stallman
2017-07-10 16:32                       ` Marcin Borkowski
2017-07-10 23:30                         ` Richard Stallman
2017-07-11  4:14                           ` Marcin Borkowski
2017-07-06 15:24     ` Phillip Lord
2017-07-10  9:26       ` Richard Stallman
2017-07-10 13:09         ` Phillip Lord
2017-07-11 11:45           ` Richard Stallman
2017-07-05 16:29 ` Stefan Monnier
2017-07-05 18:37   ` Ingo Lohmar
2017-07-05 18:14 ` In support of Jonas Bernoulli's Magit (was: comparing code on different branches) Noam Postavsky
2017-07-06  5:06   ` Paul Michael Reilly
2017-07-06  8:46     ` In support of Jonas Bernoulli's Magit Toon Claes
2017-07-07  1:38       ` Mike Gerwitz
2017-07-07  8:16         ` Trying out GitLab (was Re: In support of Jonas Bernoulli's Magit) Nicolas Petton
2017-07-07  8:27           ` Tino Calancha
2017-07-07  8:29             ` Nicolas Petton
2017-07-07 12:08               ` Ted Zlatanov
2017-07-08 11:02                 ` Ævar Arnfjörð Bjarmason
2017-07-08 11:13                   ` Dmitry Gutov
2017-07-08 11:53                     ` Eli Zaretskii
2017-07-08 12:04                       ` Dmitry Gutov
2017-07-08 21:02                         ` Phillip Lord
2017-07-08 23:19                           ` Tim Cross
2017-07-08 12:43                       ` Ævar Arnfjörð Bjarmason
2017-07-08 12:54                         ` Eli Zaretskii
2017-07-08 11:29                   ` Jean-Christophe Helary
2017-07-07 16:55             ` Mike Gerwitz
2017-07-07 18:23       ` In support of Jonas Bernoulli's Magit Richard Stallman
2017-07-07 18:23     ` In support of Jonas Bernoulli's Magit (was: comparing code on different branches) Richard Stallman
2017-07-13 16:13   ` Jonas Bernoulli
2017-07-14  1:20     ` Richard Stallman
2017-07-14 18:24       ` Jonas Bernoulli
2017-07-14  3:31     ` In support of Jonas Bernoulli's Magit Stefan Monnier
2017-07-14 18:09       ` Jonas Bernoulli
2017-07-14  7:14     ` git-handler.el (was: In support of Jonas Bernoulli's Magit) Michael Albinus
2017-07-14 17:57       ` Jonas Bernoulli
2017-08-11 10:26         ` git-handler.el Michael Albinus
2017-08-12 10:48           ` git-handler.el Jonas Bernoulli
2017-08-12 12:01             ` git-handler.el Eli Zaretskii
2017-08-12 17:26               ` git-handler.el Jonas Bernoulli
2017-08-12 17:43                 ` git-handler.el Eli Zaretskii
2017-08-12 19:32                 ` git-handler.el Michael Albinus
2017-08-12 18:22             ` git-handler.el John Wiegley
2017-08-12 18:28               ` git-handler.el Michael Albinus
2017-08-12 19:52               ` git-handler.el Jonas Bernoulli
2017-08-13  9:26                 ` git-handler.el Michael Albinus
2017-08-12 19:17             ` Michael Albinus [this message]
2017-08-12 19:46               ` git-handler.el Yuri Khan
2017-08-13  9:14                 ` git-handler.el Michael Albinus
2017-08-13 10:08                   ` git-handler.el Yuri Khan
2017-08-13 14:31                     ` git-handler.el Eli Zaretskii
2017-08-13 15:08                       ` git-handler.el Yuri Khan
2017-08-13 15:26                         ` git-handler.el Eli Zaretskii
2017-08-14 16:42                         ` git-handler.el Michael Albinus
2017-08-14 16:40                     ` git-handler.el Michael Albinus
2017-07-10 16:16 ` In support of Jonas Bernoulli's Magit (was: comparing code on different branches) Filipe Silva

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

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

  git send-email \
    --in-reply-to=87inhstx2y.fsf@detlef \
    --to=michael.albinus@gmx.de \
    --cc=dgutov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    --cc=jonas@bernoul.li \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.