darcs

Issue 1304 do we need patch contexts to get inverses? no

Title do we need patch contexts to get inverses? no
Priority wishlist Status wont-fix
Milestone Resolved in
Superseder Nosy List Sassan_M1, darcs-devel, dmitry.kurochkin, kowey, thorkilnaur
Assigned To
Topics

Created on 2009-01-06.17:45:11 by Sassan_M1, last changed 2009-08-27.14:17:21 by admin.

Files
File name Uploaded Type Edit Remove
unnamed Sassan_M1, 2009-01-06.17:45:07 text/html
Messages
msg7004 (view) Author: Sassan_M1 Date: 2009-01-06.17:45:07
Hi,

I am not sure if this is really a defect, but the statement :
The most fundamental and simple property of patches is that they must be
invertible. The inverse of a patch is described by: P-1. In the darcs
implementation, the inverse is required to be computable from knowledge
of the patch only, without knowledge of its context
found in http://darcs.net/manual/node9.html#SECTION00940000000000000000
can be universally held to be true.

What I have in mind is a patch P which deletes from a given directory a
file which has a context made up of a long history of hunk patches .

According to darcs implementation requirement the knowledge of this
patch would have to include the latest content of the removed file
(knowledge which is embedded in its context) as well as its name and
parent directory.

Is this correct?

Sassan
Attachments
msg7445 (view) Author: thorkilnaur Date: 2009-03-13.09:11:33
Thank a lot for this question. I am particularly happy about it because, in spite 
of being rather ignorant about darcs theory, I actually believe that I can provide 
an answer.

Let us create a small test repository that ends by removing a file:

> $ mkdir repo1
> $ cd repo1
> $ darcs init
> $ echo f1.txt contents >f1.txt
> $ darcs add f1.txt
> $ darcs record -a -m 'Add f1.txt' -A thorkil
> Finished recording patch 'Add f1.txt'
> $ rm f1.txt
> $ darcs record -a -m 'Remove f1.txt' -A thorkil
> Finished recording patch 'Remove f1.txt'
> $ darcs changes -v
> Fri Mar 13 09:55:34 CET 2009  thorkil
>   * Remove f1.txt
>     hunk ./f1.txt 1
>     -f1.txt contents
>     rmfile ./f1.txt
>
> Fri Mar 13 09:54:55 CET 2009  thorkil
>   * Add f1.txt
>     addfile ./f1.txt
>     hunk ./f1.txt 1
>     +f1.txt contents
> $

As you can see, the patch that removes the file includes a hunk that removes the 
contents of the file, before removing the file itself. Hence, it seems a simple 
matter to invert the patch, even without its context.

I am setting status wont-fix on this issue, assuming that this answers your 
question. If not, feel free to re-open. You are probably already aware that you 
may direct questions to the darcs-users mailing list.

Best regards
Thorkil
msg7446 (view) Author: kowey Date: 2009-03-13.09:27:42
Just adding my approval to Thorkil's reply (I'm no patch theory expert either,
but two voices should help, right?).

The key is that darcs does not allow to generate a file removal patch unless the
file is already empty.

So the trick in darcs is to have patch definitions that lend themselves to this
property of being easily invertible.  In the case of file removal, we do it by
only allowing empty files to be removed.
msg7447 (view) Author: kowey Date: 2009-03-13.09:35:05
(oops, re-marking wont-fix)
History
Date User Action Args
2009-01-06 17:45:11Sassan_M1create
2009-03-13 09:11:38thorkilnaursetstatus: unread -> wont-fix
nosy: kowey, simon, thorkilnaur, dmitry.kurochkin, Sassan_M1
messages: + msg7445
2009-03-13 09:27:44koweysetstatus: wont-fix -> resolved
nosy: kowey, simon, thorkilnaur, dmitry.kurochkin, Sassan_M1
messages: + msg7446
title: The knowledge of the patch may have to include knowledge of its context or it will fail to have an inverse -> do we need patch contexts to get inverses? no
2009-03-13 09:35:07koweysetstatus: resolved -> wont-fix
nosy: kowey, simon, thorkilnaur, dmitry.kurochkin, Sassan_M1
messages: + msg7447
2009-04-22 02:40:49twbsetpriority: wishlist
nosy: kowey, simon, thorkilnaur, dmitry.kurochkin, Sassan_M1
2009-08-25 17:38:20adminsetnosy: + darcs-devel, - simon
2009-08-27 14:17:21adminsetnosy: kowey, darcs-devel, thorkilnaur, dmitry.kurochkin, Sassan_M1