1) You have a repository with a subrepository 2) You create a file in the subrepository but don't add it yet (the file is left untracked) 3) Someone else creates the file with the same name, commits it to the subrepository and commits the root repository (linking it to the new revision of the subrepository) 4) You pull the changesets 5) You update the root repository Bug: the untracked file you've just created is silently replaced without even backup. Correct behavior would be to abort update (as if an untracked file is in the root repository), or make a backup, or ask the user See the attachment Windows batch-file that reproduces the bug.
bug.bat rewritten as mercurial test: $ hg init ACentral $ hg init BCentral $ hg clone ACentral A updating to branch default 0 files updated, 0 files merged, 0 files removed, 0 files unresolved $ echo B=../BCentral >A/.hgsub $ hg -R A add A/.hgsub $ hg init A/B $ echo something > A/B/some.txt $ hg -R A/B add A/B/some.txt $ hg -R A commit --message "step 1" -S committing subrepository B $ hg -R A push pushing to $TESTTMP/ACentral pushing subrepo B to $TESTTMP/BCentral searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files searching for changes adding changesets adding manifests adding file changes added 1 changesets with 2 changes to 2 files created untracked A/B/test.txt with: $ echo foo > A/B/test.txt $ cat A/B/test.txt foo $ hg clone ACentral ACopy updating to branch default cloning subrepo B from $TESTTMP/BCentral 2 files updated, 0 files merged, 0 files removed, 0 files unresolved $ echo bar > ACopy/B/test.txt $ hg -R ACopy/B add ACopy/B/test.txt $ hg -R ACopy commit --message "step 2" -S committing subrepository B $ hg -R ACopy push pushing to $TESTTMP/ACentral pushing subrepo B to $TESTTMP/BCentral searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files $ hg -R A pull -u pulling from $TESTTMP/ACentral searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files pulling subrepo B from $TESTTMP/BCentral 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 untracked A/B/test.txt was silently replaced with: $ cat A/B/test.txt bar
--- Bug imported by bugzilla@serpentine.com 2012-05-12 09:28 EDT --- This bug was previously known as _bug_ 3275 at http://mercurial.selenic.com/bts/issue3275 Imported an attachment (id=1639)
Fixed by http://selenic.com/repo/hg/rev/17c030014ddf Simon Heimberg <simohe@besonet.ch> subrepo: only do clean update when overwrite is set (issue3276) Files in a subrepo were overwritten on update. But this should only happen on a clean update (example: -C is specified). Use the overwrite parameter introduced for svn subrepos in c19b9282d3a7 to decide whether to merge changes (as update) or remove them (as clean). The new function hg.updaterepo is intruduced to keep all update calls in hg. test-subrepo.t is extended to test if an untracked file is overwritten (issue3276). (Update -C is already tested in many places.) The first two chunks are debugging output which has changed. (Because overwrite is not always true anymore for subrepos) All other tests still pass without any change. (please test the fix)
Fixed by http://selenic.com/repo/hg/rev/ce2c709a8e90 Adrian Buehlmann <adrian@cadifra.com> test-subrepo: adapt for Windows after 17c030014ddf Fixes @@ -606,7 +606,7 @@ issue3276_ok $ rm repo/s/b $ hg -R repo revert --all - reverting repo/.hgsubstate + reverting repo\.hgsubstate reverting subrepo s $ hg -R repo update 1 files updated, 0 files merged, 0 files removed, 0 files unresolved on Windows (please test the fix)