33
33
from opengrok_tools .utils .command import Command
34
34
35
35
36
- def add_commit_file (file_path , repo_path , comment ):
37
- """
38
- :param file_path: path to the file to be created
39
- :param repo_path: Mercurial repository path
40
- :param comment: content and commit comment
41
- """
42
- with open (file_path , "w" ) as fp :
43
- fp .write (comment )
44
- assert os .path .exists (file_path )
45
-
46
- cmd = Command (["hg" , "add" , file_path ], work_dir = repo_path )
47
- cmd .execute ()
48
- assert cmd .getretcode () == 0
49
-
36
+ def hg_commit_file (file_path , repo_path , comment ):
50
37
cmd = Command (
51
38
[
52
39
"hg" ,
@@ -63,6 +50,23 @@ def add_commit_file(file_path, repo_path, comment):
63
50
assert cmd .getretcode () == 0
64
51
65
52
53
+ def hg_add_commit_file (file_path , repo_path , comment ):
54
+ """
55
+ :param file_path: path to the file to be created
56
+ :param repo_path: Mercurial repository path
57
+ :param comment: content and commit comment
58
+ """
59
+ with open (file_path , "w" , encoding = "ascii" ) as fp :
60
+ fp .write (comment )
61
+ assert os .path .exists (file_path )
62
+
63
+ cmd = Command (["hg" , "add" , file_path ], work_dir = repo_path )
64
+ cmd .execute ()
65
+ assert cmd .getretcode () == 0
66
+
67
+ hg_commit_file (file_path , repo_path , comment )
68
+
69
+
66
70
@pytest .mark .parametrize ("create_file_in_parent" , [True , False ])
67
71
@pytest .mark .skipif (shutil .which ("hg" ) is None , reason = "need hg" )
68
72
def test_strip_outgoing (create_file_in_parent ):
@@ -82,7 +86,7 @@ def test_strip_outgoing(create_file_in_parent):
82
86
#
83
87
if create_file_in_parent :
84
88
file_path = os .path .join (repo_parent_path , file_name )
85
- add_commit_file (file_path , repo_parent_path , "parent" )
89
+ hg_add_commit_file (file_path , repo_parent_path , "parent" )
86
90
87
91
# Clone the repository and create couple of new changesets.
88
92
repo_clone_path = os .path .join (test_root , "clone" )
@@ -93,13 +97,11 @@ def test_strip_outgoing(create_file_in_parent):
93
97
assert cmd .getretcode () == 0
94
98
95
99
file_path = os .path .join (repo_clone_path , file_name )
96
- add_commit_file (file_path , repo_clone_path , "first" )
100
+ hg_add_commit_file (file_path , repo_clone_path , "first" )
97
101
98
- with open (file_path , "a" ) as fp :
102
+ with open (file_path , "a" , encoding = "ascii" ) as fp :
99
103
fp .write ("bar" )
100
- cmd = Command (["hg" , "commit" , "-m" , "second" ], work_dir = repo_clone_path )
101
- cmd .execute ()
102
- assert cmd .getretcode () == 0
104
+ hg_commit_file (file_path , repo_clone_path , "second" )
103
105
104
106
# Strip the changesets.
105
107
repository = MercurialRepository (
0 commit comments