sparse: fix temporary includes that are not in working copy

Summary:
There was a bug where rebasing a commit that contained a file that was not
currently in the working copy would cause an exception. This is because the
'temporarily include a file' logic tries to bring the file back to life
immediately, regardless of if the file actually exists yet or not (it may be an
incoming file from the upcoming merge, so it doesn't exist yet).

Test Plan: Added a test

Reviewers: sid0, rmcelroy, pyd, lcharignon

Reviewed By: lcharignon

Differential Revision: https://phabricator.fb.com/D2083802

Signature: t1:2083802:1432075849:7a90c94a97322ca619d481477fcc8812e7a26e93
This commit is contained in:
Durham Goode 2015-05-19 10:18:50 -07:00
parent f9db07b833
commit 72e331f593
2 changed files with 20 additions and 3 deletions

View File

@ -129,16 +129,18 @@ def _setupupdates(ui):
# Add the new files to the working copy so they can be merged, etc
actions = []
message = 'temporarily adding to sparse checkout'
wctxmanifest = repo[None].manifest()
for file in temporaryfiles:
fctx = repo[None][file]
actions.append((file, (fctx.flags(),), message))
if file in wctxmanifest:
fctx = repo[None][file]
actions.append((file, (fctx.flags(),), message))
typeactions = collections.defaultdict(list)
typeactions['g'] = actions
mergemod.applyupdates(repo, typeactions, repo[None], repo['.'], False)
dirstate = repo.dirstate
for file in temporaryfiles:
for file, flags, msg in actions:
dirstate.normal(file)
profiles = repo.getactiveprofiles()

View File

@ -45,3 +45,18 @@ Verify bar disappears automatically when the working copy becomes clean
$ hg cat -r . bar
bar
bar2
Test merging things outside of the sparse checkout that are not in the working
copy
$ hg strip -q -r . --config extensions.strip=
$ hg up -q feature
$ touch branchonly
$ hg ci -Aqm 'add branchonly'
$ hg up -q default
$ hg sparse -X branchonly
$ hg merge feature
temporarily included 2 file(s) in the sparse checkout for merging
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)