[issue1318] hg commit (and others?) should warn about untracked files

Jesse Glick mercurial-bugs at selenic.com
Tue Sep 30 11:02:47 CDT 2008


New submission from Jesse Glick <jesse.glick at sun.com>:

I have noticed that it is very common for people using Hg to create new files,
forget to 'hg add' them, commit, fetch, and push changes - often breaking a
build as a result. Hg should by default do better at reminding you about unadded
files (or, more rarely and usually less seriously, deleted files without 'hg
remove').

I am provisionally marking this as a bug because CVS and SVN will at least show
a '?' status during the update phase, while Hg will show no warning at all.


You can always use

[defaults]
commit = --addremove

but this has the potential to cause other accidents: there may well be a stray
core dump or whatever lying around your working dir and you would probably not
want to have your commits pick it up without asking you first. It is better for
the user to decide whether the file should be marked as added; deleted from
disk; or added to the ignore list.


[hooks]
precommit.warnuntracked = ! hg st | egrep '^[?!]'

seems to work, though (1) it is Unix-specific; (2) you have to figure this out
for yourself, which most Hg users will never get around to doing.


I would suggest that Hg by default issue a warning if there are any untracked
adds or removes when you run 'hg commit' - and perhaps also 'hg fetch', or any
other commands which normally expect an unmodified working copy. It might be
nice to have an option to make this an error rather than just a warning; it
would definitely be necessary to have an option to disable this warning, for
people who do not wish to maintain .hgignore files.

----------
messages: 7261
nosy: jglick
priority: bug
status: unread
title: hg commit (and others?) should warn about untracked files
topic: surprise, ui

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



More information about the Mercurial-devel mailing list