[issue3246] fetch can silently overwrite a file

Mark Saaltink bugs at mercurial.selenic.com
Sat Feb 4 04:01:53 UTC 2012


New submission from Mark Saaltink <mark.saaltink at gmail.com>:

The fetch command can silently overwrite a file, if your working directory
contains an untracked file and the incoming changes add a file of the same
name.  I've observed this in versions 1.9.1 and 1.9.2.

If instead of fetch you try pull then update, the attempt to update is
aborted with a message about the untracked file.  This seems like a safer
thing to do.

Example:

$ mkdir hg1
$ cd hg1/
$ hg init
$ echo "test" > file.txt
$ hg add
adding file.txt
$ hg commit -m "initial file"
$ cd ..
$ hg clone hg1 hg2
Updating to branch default
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ echo "good" > hg2/foo.txt
$ cd hg1
$ echo "bad" > foo.txt
$ hg add
adding foo.txt
$ hg commit -m "second file"
$ cd ../hg2
$ cat foo.txt 
good
$ hg fetch
pulling from /home/mark/hg-tmp/hg1
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cat foo.txt 
bad

----------
messages: 18963
nosy: mark.saaltink
priority: bug
status: unread
title: fetch can silently overwrite a file

____________________________________________________
Mercurial issue tracker <bugs at mercurial.selenic.com>
<http://mercurial.selenic.com/bts/issue3246>
____________________________________________________



More information about the Mercurial-devel mailing list