darcs

Issue 319 Pull/apply can overwrite files that are not owned by darcs

Title Pull/apply can overwrite files that are not owned by darcs
Priority bug Status resolved
Milestone Resolved in
Superseder Nosy List darcs-devel, dmitry.kurochkin, kowey, magnus, thorkilnaur, tommy
Assigned To kowey
Topics

Created on 2006-10-19.02:45:21 by magnus, last changed 2009-08-27.14:11:11 by admin.

Messages
msg1136 (view) Author: magnus Date: 2006-10-19.02:45:16
mkdir a && cd a
darcs init
cd ../
mkdir b && cd b
darcs get ../a
cd ../a
echo foo > f
darcs record
cd ../b/a
echo bar > f
darcs pull
cat f

outputs foo! our unrecorded work on f is lost!
msg1137 (view) Author: kowey Date: 2006-10-19.06:46:29
I can confirm that this happens.  Here is a slightly simplified version.

mkdir a && cd a && darcs init && cd ..
darcs get a b

cd a
echo foo > f
darcs record -a -m 'foo > f' --author=moi
cd ..

cd b
echo bar > f
darcs pull -a
cat f

This (luckily) seems to be just a mundane, almost UI issue; file f has
not yet been added, so darcs cannot know it should do something with it.
But it seems like when we're in the working directory, we should detect
addfiles or moves that overwrite some pre-existing file.  Would the
right solution consist of moving the pre-existing file away?
msg1204 (view) Author: tommy Date: 2006-11-11.13:05:07
If the files _is_ managed by darcs, and contains unrecorded changes, darcs
merges these with the pull (or does conflict markup). So perhaps it would be
intuitive to consider an unmanaged file's content as unrecorded changes as soon
as the file is added "in the middle" of the pull, and merge or conflict markup it?
msg1206 (view) Author: magnus Date: 2006-11-11.18:23:16
Tommy's solution sounds like the right thing to do. There is a practical problem
in the source code. 'apply' in PatchApply.lhs is stuck in the WritableDirectory
monad (defined in DarcsIO.lhs), while 'add_to_pending' and similar procedures
need IO.
msg1207 (view) Author: tommy Date: 2006-11-11.22:17:21
A good thing with merging unmanaged files is that the clash is handled in a
way already familiar to a darcs user. A bad thing (besides being hard to
implement) is that it will always be a massive two entire files conflict,
and the unmanaged file part probably has nothing to do with the pulled file
part. When I think about it, the _only_ good thing is that the user
immediately will recognize what the problem is and know how to deal with
it, which might indeed be a rather good thing. But since it's an unrecorded
conflict, there is no easy way to back out. And there's also the problem
with a directory being "in the way".

Another idea is to simply let the pull fail with a complaint about the
blocking unmanaged file (or directory). Or interactively ask the user if to
replace it (or merge it).

Well, the more ideas we have the better gets the chance of the best one
being a truly good one...
msg2235 (view) Author: kowey Date: 2007-11-04.22:53:39
The unstable branch now has a feature for backing up files in the working
directory before clobbering them.  That should solve the problem.

Tue Aug 21 07:19:42 CEST 2007  Eric Kow <eric.kow@loria.fr>
  * [issue319, issue440] Backup unmanged working dir files as needed.
History
Date User Action Args
2006-10-19 02:45:21magnuscreate
2006-10-19 06:46:36koweysetstatus: unread -> unknown
nosy: droundy, tommy, kowey, magnus
messages: + msg1137
2006-11-11 13:05:15tommysetnosy: droundy, tommy, kowey, magnus
messages: + msg1204
2006-11-11 18:23:23magnussetnosy: droundy, tommy, kowey, magnus
messages: + msg1206
2006-11-11 22:17:28tommysetnosy: droundy, tommy, kowey, magnus
messages: + msg1207
2007-08-09 07:21:39koweylinkissue440 superseder
2007-08-20 19:32:49koweysetstatus: unknown -> has-patch
nosy: + beschmi
2007-11-04 22:53:40koweysetstatus: has-patch -> resolved-in-unstable
nosy: kowey, magnus, droundy, tommy, beschmi
messages: + msg2235
2007-11-17 11:14:07koweysetstatus: resolved-in-unstable -> resolved-in-stable
2008-09-16 21:30:31adminsetstatus: resolved-in-stable -> resolved
nosy: + dagit
2009-08-06 17:37:20adminsetnosy: + markstos, jast, Serware, dmitry.kurochkin, darcs-devel, zooko, mornfall, simon, thorkilnaur, - droundy, magnus
2009-08-06 20:34:16adminsetnosy: - beschmi
2009-08-10 21:57:42adminsetnosy: + magnus, - markstos, darcs-devel, zooko, jast, Serware, mornfall
2009-08-10 23:57:19adminsetnosy: - dagit
2009-08-25 17:51:11adminsetnosy: + darcs-devel, - simon
2009-08-27 14:11:11adminsetnosy: tommy, kowey, darcs-devel, magnus, thorkilnaur, dmitry.kurochkin