Skip to content
Snippets Groups Projects
Commit 17c03001 authored by Simon Heimberg's avatar Simon Heimberg
Browse files

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.
parent afa7e6fa
No related branches found
No related tags found
No related merge requests found
......@@ -459,5 +459,13 @@
repo.ui.status(_("%d files updated, %d files merged, "
"%d files removed, %d files unresolved\n") % stats)
def updaterepo(repo, node, overwrite):
"""Update the working directory to node.
When overwrite is set, changes are clobbered, merged else
returns stats (see pydoc mercurial.merge.applyupdates)"""
return mergemod.update(repo, node, False, overwrite, None)
def update(repo, node):
"""update the working directory to node, merging linear changes"""
......@@ -462,6 +470,6 @@
def update(repo, node):
"""update the working directory to node, merging linear changes"""
stats = mergemod.update(repo, node, False, False, None)
stats = updaterepo(repo, node, False)
_showstats(repo, stats)
if stats[3]:
repo.ui.status(_("use 'hg resolve' to retry unresolved file merges\n"))
......@@ -472,7 +480,7 @@
def clean(repo, node, show_stats=True):
"""forcibly switch the working directory to node, clobbering changes"""
stats = mergemod.update(repo, node, False, True, None)
stats = updaterepo(repo, node, True)
if show_stats:
_showstats(repo, stats)
return stats[3] > 0
......
......@@ -523,7 +523,7 @@
self._get(state)
source, revision, kind = state
self._repo.ui.debug("getting subrepo %s\n" % self._path)
hg.clean(self._repo, revision, False)
hg.updaterepo(self._repo, revision, overwrite)
def merge(self, state):
self._get(state)
......
......@@ -210,4 +210,5 @@
subrepo merge f0d2028bf86d+ 1831e14459c4 1f14a2e2d3ec
subrepo t: other changed, get t:6747d179aa9a688023c4b0cad32e4c92bb7f34ad:hg
getting subrepo t
searching for copies back to rev 1
resolving manifests
......@@ -213,6 +214,6 @@
resolving manifests
overwrite: True, partial: False
ancestor: 60ca1237c194+, local: 60ca1237c194+, remote: 6747d179aa9a
overwrite: False, partial: False
ancestor: 60ca1237c194, local: 60ca1237c194+, remote: 6747d179aa9a
t: remote is newer -> g
updating: t 1/1 files (100.00%)
getting t
......@@ -580,8 +581,9 @@
$ hg -q -R repo2/s push
$ hg -R repo2/s up -C 0
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ echo 2 > repo2/s/a
$ hg -R repo2/s ci -m3
$ echo 2 > repo2/s/b
$ hg -R repo2/s ci -m3 -A
adding b
created new head
$ hg -R repo2 ci -m3
$ hg -q -R repo2 push
......@@ -585,8 +587,8 @@
created new head
$ hg -R repo2 ci -m3
$ hg -q -R repo2 push
abort: push creates new remote head 9d66565e64e1!
abort: push creates new remote head cc505f09a8b2!
(did you forget to merge? use push -f to force)
[255]
$ hg -R repo update
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
......@@ -589,7 +591,27 @@
(did you forget to merge? use push -f to force)
[255]
$ hg -R repo update
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
test if untracked file is not overwritten
$ echo issue3276_ok > repo/s/b
$ hg -R repo2 push -f -q
$ hg -R repo update
b: untracked file differs
abort: untracked files in working directory differ from files in requested revision
[255]
$ cat repo/s/b
issue3276_ok
$ rm repo/s/b
$ hg -R repo revert --all
reverting repo/.hgsubstate
reverting subrepo s
$ hg -R repo update
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cat repo/s/b
2
$ rm -rf repo2 repo
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment