flush pending transaction data in eden_dirstate_map.setparents()

Summary:
Previously we flushed the pending transaction data in
eden_dirstate.setparents().  However, some dirstate code paths (particularly
dirstate.rebuild()) can directly call eden_dirstate_map.setparents().

We need to make sure the transaction data is flushed in this case.

Reviewed By: bolinfest

Differential Revision: D6175410

fbshipit-source-id: 256cb07f57ada02d6c1f118ec5075fb8ac93506c
This commit is contained in:
Adam Simpkins 2017-10-27 14:08:50 -07:00 committed by Facebook Github Bot
parent 0f4ba60602
commit 74c1027bba
2 changed files with 111 additions and 0 deletions

View File

@ -0,0 +1,110 @@
#!/usr/bin/env python3
#
# Copyright (c) 2004-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
import logging
from .lib.hg_extension_test_base import hg_test
log = logging.getLogger('eden.test.absorb')
@hg_test
class AbsorbTest:
def populate_backing_repo(self, repo):
repo.write_file('readme.txt', 'readme\n')
repo.write_file('src/test.c', '''\
start of the file
line 1
line 2
line 3
end of the file
''')
self.commit1 = repo.commit('Initial commit.')
repo.hg('phase', '--public', self.commit1)
log.debug('commit1: %s', self.commit1)
def test_absorb(self):
self.assert_status_empty()
# Update src/test.c in our first draft commit
self.write_file('src/test.c', '''\
start of the file
line 1
new line a
line 2
new line b
line 3
end of the file
''')
self.assert_status({'src/test.c': 'M'})
commit2 = self.repo.commit('new lines in test.c\n')
self.assert_status_empty()
log.debug('commit2: %s', commit2)
# Update src/new.c in our second draft commit
self.write_file('src/new.c', '''\
this is a brand new file
with some new contents
last line
''')
self.hg('add', 'src/new.c')
self.assert_status({'src/new.c': 'A'})
commit3 = self.repo.commit('add new.c\n')
self.assert_status_empty()
log.debug('commit2: %s', commit3)
# Now modify test.c and new.c in the working copy
self.write_file('src/test.c', '''\
start of the file
line 1
new line abc
testing
line 2
new line b
line 3
end of the file
''')
self.write_file('src/new.c', '''\
this is a brand new file
with some enhanced new contents
last line
''')
self.assert_status({'src/new.c': 'M', 'src/test.c': 'M'})
old_commits = self.repo.log()
# Run "hg absorb" to fold these changes into their respective commits
out = self.hg('absorb', '-p')
log.debug('absorb output:\n%s' % (out,))
self.assert_status_empty()
# Verify the results are what we expect
new_commits = self.repo.log()
files_changed = self.repo.log(template='{files}')
self.assertEqual(len(old_commits), len(new_commits))
self.assertEqual(old_commits[0], new_commits[0])
self.assertNotEqual(old_commits[1], new_commits[1])
self.assertNotEqual(old_commits[2], new_commits[2])
self.assertEqual(files_changed[0], 'readme.txt src/test.c')
self.assertEqual(files_changed[1], 'src/test.c')
self.assertEqual(files_changed[2], 'src/new.c')
self.assertEqual(self.read_file('src/test.c'), '''\
start of the file
line 1
new line abc
testing
line 2
new line b
line 3
end of the file
''')
self.assertEqual(self.read_file('src/new.c'), '''\
this is a brand new file
with some enhanced new contents
last line
''')

View File

@ -77,6 +77,7 @@ class HgExtensionTestBase(testcase.EdenTestCase):
'evolutioncommands': 'prev next split fold obsolete metaedit', 'evolutioncommands': 'prev next split fold obsolete metaedit',
} }
hgrc['extensions'] = { hgrc['extensions'] = {
'absorb': '',
'directaccess': '', 'directaccess': '',
'fbamend': '', 'fbamend': '',
'fbhistedit': '', 'fbhistedit': '',