Bug 3276 - Untracked files in subrepositories are silently replaced with new files during update
Summary: Untracked files in subrepositories are silently replaced with new files durin...
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: Mercurial (show other bugs)
Version: unspecified
Hardware: All All
: normal bug
Assignee: Bugzilla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-17 04:19 UTC by Ihar Bury
Modified: 2012-12-22 18:58 UTC (History)
3 users (show)

See Also:
Python Version: ---


Attachments
(34 bytes, application/octet-stream)
2012-02-17 04:19 UTC, Ihar Bury
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ihar Bury 2012-02-17 04:19 UTC
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.
Comment 1 Patrick Mézard 2012-02-21 10:43 UTC
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
Comment 2 Bugzilla 2012-05-12 09:28 UTC

--- 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)
Comment 3 HG Bot 2012-10-31 17:59 UTC
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)
Comment 4 HG Bot 2012-11-06 19:14 UTC
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)