##// END OF EJS Templates
scripts: update i18n dev script to modern hg...
Mads Kiilerich -
r8784:419329d4 stable
parent child Browse files
Show More
@@ -20,6 +20,7 b' import sys'
20
20
21 import click
21 import click
22 import i18n_utils
22 import i18n_utils
23 from mercurial import util
23
24
24
25
25 """
26 """
@@ -90,28 +91,25 b' def normalized_merge(local, base, other,'
90 and then invoke merge/rebase/graft with the additional argument '--tool i18n'.
91 and then invoke merge/rebase/graft with the additional argument '--tool i18n'.
91 """
92 """
92 from mercurial import context, simplemerge
93 from mercurial import context, simplemerge
93 from mercurial import ui as uimod
94
94
95 print('i18n normalized-merge: normalizing and merging %s' % output)
95 print('i18n normalized-merge: normalizing and merging %s' % output)
96
96
97 i18n_utils._normalize_po_file(local, merge_pot_file=merge_pot_file, strip=strip)
97 i18n_utils._normalize_po_file(local, merge_pot_file=merge_pot_file, strip=strip)
98 i18n_utils._normalize_po_file(base, merge_pot_file=merge_pot_file, strip=strip)
98 i18n_utils._normalize_po_file(base, merge_pot_file=merge_pot_file, strip=strip)
99 i18n_utils._normalize_po_file(other, merge_pot_file=merge_pot_file, strip=strip)
99 i18n_utils._normalize_po_file(other, merge_pot_file=merge_pot_file, strip=strip)
100 i18n_utils._normalize_po_file(output, merge_pot_file=merge_pot_file, strip=strip)
101
100
102 # simplemerge will write markers to 'local' if it fails, keep a copy without markers
101 # simplemerge will write markers to 'local' if it fails, keep a copy without markers
103 localkeep = local + '.keep'
102 localkeep = local + '.keep'
104 shutil.copyfile(local, localkeep)
103 shutil.copyfile(local, localkeep)
105
104
106 ret = simplemerge.simplemerge(uimod.ui.load(),
105 merged_text, conflicts = simplemerge.simplemerge(
107 context.arbitraryfilectx(local.encode('utf-8')),
106 simplemerge.MergeInput(context.arbitraryfilectx(local.encode('utf-8'), b'local')),
108 context.arbitraryfilectx(base.encode('utf-8')),
107 simplemerge.MergeInput(context.arbitraryfilectx(base.encode('utf-8'), b'base')),
109 context.arbitraryfilectx(other.encode('utf-8')),
108 simplemerge.MergeInput(context.arbitraryfilectx(other.encode('utf-8'), b'other')),
110 label=[b'local', b'other', b'base'],
111 mode='merge',
109 mode='merge',
112 )
110 )
113 shutil.copyfile(local, output) # simplemerge wrote to local - either resolved or with conflict markers
111 util.writefile(output, merged_text) # either resolved or with conflict markers
114 if ret:
112 if conflicts:
115 shutil.copyfile(localkeep, local)
113 shutil.copyfile(localkeep, local)
116 basekeep = base + '.keep'
114 basekeep = base + '.keep'
117 otherkeep = other + '.keep'
115 otherkeep = other + '.keep'
@@ -119,7 +117,7 b' def normalized_merge(local, base, other,'
119 shutil.copyfile(other, otherkeep)
117 shutil.copyfile(other, otherkeep)
120 sys.stderr.write("Error: simple merge failed and %s is left with conflict markers. Resolve the conflicts, then use 'hg resolve -m'.\n" % output)
118 sys.stderr.write("Error: simple merge failed and %s is left with conflict markers. Resolve the conflicts, then use 'hg resolve -m'.\n" % output)
121 sys.stderr.write('Resolve with e.g.: kdiff3 %s %s %s -o %s\n' % (basekeep, localkeep, otherkeep, output))
119 sys.stderr.write('Resolve with e.g.: kdiff3 %s %s %s -o %s\n' % (basekeep, localkeep, otherkeep, output))
122 sys.exit(ret)
120 sys.exit(1)
123
121
124 os.remove(localkeep)
122 os.remove(localkeep)
125
123
General Comments 0
You need to be logged in to leave comments. Login now