darcs

Patch 1177 Show a unique patch identifier in 'darcs changes'.

Title Show a unique patch identifier in 'darcs changes'.
Superseder Nosy List jrm3000
Related Issues
Status accepted Assigned To
Milestone

Created on 2014-07-01.12:14:58 by jrm3000, last changed 2014-10-16.18:26:59 by gh.

Files
File name Status Uploaded Type Edit Remove
patch-preview.txt jrm3000, 2014-07-01.12:14:57 text/x-darcs-patch
patch-preview.txt gh, 2014-07-21.15:28:59 text/x-darcs-patch
patch-preview.txt gh, 2014-07-22.14:13:22 text/x-darcs-patch
patch-preview.txt gh, 2014-07-22.15:07:43 text/x-darcs-patch
patch-preview.txt gh, 2014-07-24.13:40:51 text/x-darcs-patch
patch-preview.txt gh, 2014-10-08.21:08:06 text/x-darcs-patch
show-a-unique-patch-identifier-in-_darcs-changes__.dpatch jrm3000, 2014-07-01.12:14:57 application/x-darcs-patch
show-metadata-hash-in-ui-and-put-author-and-date-on-separate-lines.dpatch gh, 2014-07-21.15:28:59 application/x-darcs-patch
show-patch-hash-in-ui-and-put-author-and-date-on-separate-lines.dpatch gh, 2014-07-22.14:13:22 application/x-darcs-patch
show-patch-hash-in-ui-and-put-author-and-date-on-separate-lines.dpatch gh, 2014-07-22.15:07:43 application/x-darcs-patch
show-patch-hash-in-ui-and-put-author-and-date-on-separate-lines.dpatch gh, 2014-07-24.13:40:52 application/x-darcs-patch
unnamed jrm3000, 2014-07-01.12:14:57
unnamed gh, 2014-07-21.15:28:59
unnamed gh, 2014-07-22.14:13:22
unnamed gh, 2014-07-22.15:07:43
unnamed gh, 2014-07-24.13:40:52
unnamed gh, 2014-10-08.21:08:06
use-now-_h-and-__hash-as-shortcut-flags-to-match-on-patch-hash.dpatch gh, 2014-10-08.21:08:06 application/x-darcs-patch
See mailing list archives for discussion on individual patches.
Messages
msg17585 (view) Author: jrm3000 Date: 2014-07-01.12:14:57
1 patch for repository http://darcs.net/screened:

Fri Jun 20 13:41:44 EDT 2014  jrm3000@gmx.com
  * Show a unique patch identifier in 'darcs changes'.

With this patch, darcs changes will print the unique
'patch hash' on a separate line after the date/author
line. This is intended to provide Git/Hg/Etc converts
with the changeset-hashes they so sorely miss and to
satisfy people who like RCS-style expansions in their
files.
Attachments
msg17619 (view) Author: gh Date: 2014-07-21.15:28:59
First, this patch affects not only the output of "darcs changes" (log)
but also of every command that shows patches (push/pull/obliterate/...).

Second, I'm open to showing the patch hash in the UI. However, people
may find it quite "un-darcs-y", since we don't often match on hashes,
but rather on patch names.

So, here's what we have with your patch:

-----------8<--------------
Fri Jun 20 14:41:44 ART 2014  jrm3000@gmx.com
20140620174144-9e968-ae264ec6b4dfc874cccc7cc273bc0886fcab42c0
  * Show a unique patch identifier in 'darcs changes'.

Mon Jul 21 10:19:56 ART 2014  Guillaume Hoffmann <guillaumh@gmail.com>
20140721131956-5ef8f-e10e31c9878c7a1382d3ff1815f96ccf84709b7e
  * document pull --reorder

[...]
------------->8-------------

It's quite hard to read, because the hash is big and also the date and
author name are on the same line (while git/hg put them on separate lines).

Note that the metadata-hash shown above is *not* the contents-hash used as
name of a patch in `_darcs/patches/`. This is because the contents-hash can
change when the context changes (eg, when patch is pulled to another
repository), while the metadata-hash never changes. (See
<http://darcs.net/Internals/Hashes>).

The metadata-hash is generated by Darcs.Patch.Info.makePatchname. It has
3 parts: A-B-C, with A the patch date, B the author hash (prefix) and C
a hash of the whole metadata (also including patch date and author date).
So A-B-C does not "contain" more information than C alone, except if we
want the date and author to be easily read by humans.

The metadata-hash is never written on disk by darcs itself, except
in two cases: a) in the patch index and b), in the marksfile generated
by `darcs convert export`. Both features are absent of any official
release yet.

So I think we can drop A-B and just use C as the metadata-hash. This hash
has already changed in the past (see patch "Remove the .gz suffix") without
much hassle since it was already observed that it was never written on disk.


I've made changes to make the output a little more git-tish, this is what
I get with the alternative patch I'm sending now:

-----------------8<--------------
patch a264ec6b4dfc874cccc7cc273bc0886fcab42c0
Author: jrm3000@gmx.com
Date:   Fri Jun 20 14:41:44 ART 2014

  * Show a unique patch identifier in 'darcs changes'.

patch e10e31c9878c7a1382d3ff1815f96ccf84709b7e
Author: Guillaume Hoffmann <guillaumh@gmail.com>
Date:   Mon Jul 21 10:19:56 ART 2014

  * document pull --reorder

[...]
------------------>8--------------

Note that the metadata-hash is not robust against forgery. You can make
a patch by hand that has the same metadata as another patch, but with
distinct contents. OTOH, with Git, the hash shown in "git log" is
directly the contents-hash.

We could solve this by never using the metadata-hash, but I'm not sure
of the implications yet.


1 patch for repository http://darcs.net:

patch 502a8ddd98f74a62cd9dded47df0fcf5f1813cb6
Author: Guillaume Hoffmann <guillaumh@gmail.com>
Date:   Mon Jul 21 12:09:49 ART 2014
  * show metadata hash in UI and put author and date on separate lines
Attachments
msg17620 (view) Author: gh Date: 2014-07-22.14:13:22
I went further with the following patch, fixing OF repositories
reading (which does use the A-B-C.gz format for patch names) and
removing unused code in Darcs.Patch.Info.

1 patch for repository http://darcs.net:

patch 5dece7576fb1607ecf6d4fa16a4e4f9a123ad4c1
Author: Guillaume Hoffmann <guillaumh@gmail.com>
Date:   Tue Jul 22 11:08:55 ART 2014
  * show patch hash in UI and put author and date on separate lines
  
  some cleanups:
  * use correctly makePatchname instead of makeFilename in other
    places of the code
  * remove unused RepoPatchInfo
  * remove unused idpatchinfo
  * remove unused makeAltFilename
  * remove unused HTML class instance of PatchInfo
Attachments
msg17621 (view) Author: gh Date: 2014-07-22.15:07:43
A forgotten documentation change in the first patch, and
the second patch (enable to mach on hash prefix) enables
to write stuff like:

  darcs pull --matches "hash 5fe25"

which is what will probably happen if users start to see
the patch hashes all over the place.

As I said, the patch hash does not depend on patch contents,
however it does change when one does "darcs amend --keep-date"
since the (hidden) random salt is generated again each time
a patch is recorded/amended. Good news.


2 patches for repository http://darcs.net:

patch 2444e7b3415dfa88119e873fe71b17041bc39f43
Author: Guillaume Hoffmann <guillaumh@gmail.com>
Date:   Tue Jul 22 11:28:43 ART 2014
  * show patch hash in UI and put author and date on separate lines
  
  some cleanups:
  * use correctly makePatchname instead of makeFilename in other
    places of the code
  * remove unused RepoPatchInfo
  * remove unused idpatchinfo
  * remove unused makeAltFilename
  * remove unused HTML class instance of PatchInfo 

patch 5fe25bc5a88b7e5f81125dff9c0f57c4c939231f
Author: Guillaume Hoffmann <guillaumh@gmail.com>
Date:   Tue Jul 22 11:39:00 ART 2014
  * enable to match on hash prefix
Attachments
msg17628 (view) Author: gh Date: 2014-07-24.13:40:52
More changes:

* using cyan colour to output patch hash (a la git)
* ignoring case in hash matchers

I'm going to screen this and see how it goes.

Three tests do not pass yet, I was lazy (as for sigPIPE.sh,
anyone who understands what is going on and wants to help
is very welcome).

2 patches for repository http://darcs.net:

patch 9b7a74effd65b6d4d7b9d9e4a06b444066149c4a
Author: Guillaume Hoffmann <guillaumh@gmail.com>
Date:   Thu Jul 24 10:16:44 ART 2014
  * show patch hash in UI and put author and date on separate lines
  
  some cleanups:
  * use correctly makePatchname instead of makeFilename in other
    places of the code
  * remove unused RepoPatchInfo
  * remove unused idpatchinfo
  * remove unused makeAltFilename
  * remove unused HTML class instance of PatchInfo 

patch 55d36fed62e27d8cb8b8d35fb81e9b15781e1ae4
Author: Guillaume Hoffmann <guillaumh@gmail.com>
Date:   Thu Jul 24 10:28:50 ART 2014
  * enable to match on patch hash prefix and ignore case
Attachments
msg17686 (view) Author: gh Date: 2014-10-08.21:08:06
Here's a followup patch.

The idea of using -h/--hash comes from this discussion:
http://lists.osuosl.org/pipermail/darcs-users/2014-August/027036.html

There is a couple of tests that remain to be fixed (send-output*.sh).

1 patch for repository http://darcs.net:

patch 9e0049ec59834dc924d7b76019dd483d3f95be89
Author: Guillaume Hoffmann <guillaumh@gmail.com>
Date:   Wed Oct  8 15:58:29 ART 2014
  * use now -h and --hash as shortcut flags to match on patch hash
Attachments
msg17693 (view) Author: gh Date: 2014-10-16.18:26:59
Oh, Ganesh took care of fixing the aforementioned tests
http://bugs.darcs.net/patch1195  . I'm self-accepting the whole bundle
according to the one-week rule.
History
Date User Action Args
2014-07-01 12:14:58jrm3000create
2014-07-21 15:28:59ghsetfiles: + patch-preview.txt, show-metadata-hash-in-ui-and-put-author-and-date-on-separate-lines.dpatch, unnamed
messages: + msg17619
2014-07-22 14:13:23ghsetfiles: + patch-preview.txt, show-patch-hash-in-ui-and-put-author-and-date-on-separate-lines.dpatch, unnamed
messages: + msg17620
2014-07-22 15:07:43ghsetfiles: + patch-preview.txt, show-patch-hash-in-ui-and-put-author-and-date-on-separate-lines.dpatch, unnamed
messages: + msg17621
2014-07-24 13:40:52ghsetfiles: + patch-preview.txt, show-patch-hash-in-ui-and-put-author-and-date-on-separate-lines.dpatch, unnamed
messages: + msg17628
2014-10-08 21:08:06ghsetfiles: + patch-preview.txt, use-now-_h-and-__hash-as-shortcut-flags-to-match-on-patch-hash.dpatch, unnamed
messages: + msg17686
2014-10-16 18:26:59ghsetstatus: needs-screening -> accepted
messages: + msg17693