Add integration test for hg move.

Summary:
Fortunately, this passed on the first try: it did not require any bug fixes in
Eden! Though admittedly, most of the relevant fixes were presumably done in
D5686114.

(Note: this ignores all push blocking failures!)

Reviewed By: simpkins

Differential Revision: D5696055

fbshipit-source-id: 0099db501ae1a5d72528d222dee0176fc1fc4332
This commit is contained in:
Michael Bolin 2017-08-24 14:14:56 -07:00 committed by Facebook Github Bot
parent 227d851a9b
commit 442feff98f
3 changed files with 88 additions and 7 deletions

View File

@ -7,7 +7,6 @@
# 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 json
from textwrap import dedent
from .lib.hg_extension_test_base import hg_test
@ -47,9 +46,3 @@ class CopyTest:
self.assertEqual(dedent('''\
A goodbye.txt
'''), extended_status)
def assert_copy_map(self, expected):
stdout = self.eden.run_cmd('debug', 'hg_copy_map_get_all',
cwd=self.mount)
copy_map = json.loads(stdout)
self.assertEqual(expected, copy_map)

View File

@ -9,6 +9,7 @@
from ...lib import find_executables, hgrepo, testcase
import configparser
import json
import os
@ -168,6 +169,12 @@ class HgExtensionTestBase(testcase.EdenTestCase):
'''Ensures that `hg status` reports no modifications.'''
self.assert_status({}, msg=msg, check_ignored=check_ignored)
def assert_copy_map(self, expected):
stdout = self.eden.run_cmd('debug', 'hg_copy_map_get_all',
cwd=self.mount)
copy_map = json.loads(stdout)
self.assertEqual(expected, copy_map)
def _apply_flatmanifest_config(test, config):
# flatmanifest is the default mercurial behavior

View File

@ -0,0 +1,81 @@
#!/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 os
from textwrap import dedent
from .lib.hg_extension_test_base import hg_test
@hg_test
class MoveTest:
def populate_backing_repo(self, repo):
repo.write_file('hello.txt', 'hola')
repo.commit('Initial commit.\n')
def test_move_file_without_modification(self):
self.hg('move', 'hello.txt', 'goodbye.txt')
self.assert_status({'goodbye.txt': 'A', 'hello.txt': 'R'})
extended_status = self.hg('status', '--copies')
self.assertEqual(dedent('''\
A goodbye.txt
hello.txt
R hello.txt
'''), extended_status)
self.assert_copy_map({'goodbye.txt': 'hello.txt'})
self.assertFalse(os.path.exists(self.get_path('hello.txt')))
self.assertTrue(os.path.exists(self.get_path('goodbye.txt')))
self.repo.commit('Commit copied file.\n')
self.assert_status_empty()
self.assert_copy_map({})
def test_move_file_then_revert_it(self):
self.hg('move', 'hello.txt', 'goodbye.txt')
self.assert_status({'goodbye.txt': 'A', 'hello.txt': 'R'})
self.assert_copy_map({'goodbye.txt': 'hello.txt'})
self.assertFalse(os.path.exists(self.get_path('hello.txt')))
self.assertTrue(os.path.exists(self.get_path('goodbye.txt')))
self.hg('revert', '--no-backup', '--all')
self.assert_status({'goodbye.txt': '?'})
self.assert_copy_map({})
self.assertTrue(os.path.exists(self.get_path('hello.txt')))
self.assertTrue(os.path.exists(self.get_path('goodbye.txt')))
self.hg('add', 'goodbye.txt')
extended_status = self.hg('status', '--copies')
self.assertEqual(dedent('''\
A goodbye.txt
'''), extended_status)
def test_replace_after_move_file_then_revert_it(self):
self.hg('move', 'hello.txt', 'goodbye.txt')
self.assert_status({'goodbye.txt': 'A', 'hello.txt': 'R'})
self.assert_copy_map({'goodbye.txt': 'hello.txt'})
self.assertFalse(os.path.exists(self.get_path('hello.txt')))
self.assertTrue(os.path.exists(self.get_path('goodbye.txt')))
self.write_file('hello.txt', 'different contents')
self.assert_status({'goodbye.txt': 'A', 'hello.txt': 'R'})
self.hg('add', 'hello.txt')
self.assert_status({'goodbye.txt': 'A', 'hello.txt': 'M'})
self.assert_copy_map({'goodbye.txt': 'hello.txt'})
extended_status = self.hg('status', '--copies')
self.assertEqual(dedent('''\
M hello.txt
A goodbye.txt
hello.txt
'''), extended_status)
self.hg('revert', '--no-backup', '--all')
self.assert_status({'goodbye.txt': '?'})
self.assert_copy_map({})
self.assertTrue(os.path.exists(self.get_path('hello.txt')))
self.assertTrue(os.path.exists(self.get_path('goodbye.txt')))