##// END OF EJS Templates
filemerge: create detail of internal merge tools from documentation string...
FUJIWARA Katsunori -
r16126:0c4bec95 default
parent child Browse files
Show More
@@ -91,8 +91,10 b' update-pot: i18n/hg.pot'
91
91
92 i18n/hg.pot: $(PYFILES) $(DOCFILES)
92 i18n/hg.pot: $(PYFILES) $(DOCFILES)
93 $(PYTHON) i18n/hggettext mercurial/commands.py \
93 $(PYTHON) i18n/hggettext mercurial/commands.py \
94 hgext/*.py hgext/*/__init__.py mercurial/fileset.py mercurial/revset.py \
94 hgext/*.py hgext/*/__init__.py \
95 mercurial/fileset.py mercurial/revset.py \
95 mercurial/templatefilters.py mercurial/templatekw.py \
96 mercurial/templatefilters.py mercurial/templatekw.py \
97 mercurial/filemerge.py \
96 $(DOCFILES) > i18n/hg.pot
98 $(DOCFILES) > i18n/hg.pot
97 # All strings marked for translation in Mercurial contain
99 # All strings marked for translation in Mercurial contain
98 # ASCII characters only. But some files contain string
100 # ASCII characters only. But some files contain string
@@ -19,19 +19,19 b' def _toolbool(ui, tool, part, default=Fa'
19 def _toollist(ui, tool, part, default=[]):
19 def _toollist(ui, tool, part, default=[]):
20 return ui.configlist("merge-tools", tool + "." + part, default)
20 return ui.configlist("merge-tools", tool + "." + part, default)
21
21
22 _internal = {}
22 internals = {}
23
23
24 def internaltool(name, trymerge, onfailure=None):
24 def internaltool(name, trymerge, onfailure=None):
25 '''return a decorator for populating internal merge tool table'''
25 '''return a decorator for populating internal merge tool table'''
26 def decorator(func):
26 def decorator(func):
27 _internal[name] = func
27 internals[name] = func
28 func.trymerge = trymerge
28 func.trymerge = trymerge
29 func.onfailure = onfailure
29 func.onfailure = onfailure
30 return func
30 return func
31 return decorator
31 return decorator
32
32
33 def _findtool(ui, tool):
33 def _findtool(ui, tool):
34 if tool in _internal:
34 if tool in internals:
35 return tool
35 return tool
36 for kn in ("regkey", "regkeyalt"):
36 for kn in ("regkey", "regkeyalt"):
37 k = _toolstr(ui, tool, kn)
37 k = _toolstr(ui, tool, kn)
@@ -133,6 +133,9 b' def _matcheol(file, origfile):'
133
133
134 @internaltool('internal:prompt', False)
134 @internaltool('internal:prompt', False)
135 def _iprompt(repo, mynode, orig, fcd, fco, fca, toolconf):
135 def _iprompt(repo, mynode, orig, fcd, fco, fca, toolconf):
136 """``internal:prompt``
137 Asks the user which of the local or the other version to keep as
138 the merged version."""
136 ui = repo.ui
139 ui = repo.ui
137 fd = fcd.path()
140 fd = fcd.path()
138
141
@@ -145,15 +148,23 b' def _iprompt(repo, mynode, orig, fcd, fc'
145
148
146 @internaltool('internal:local', False)
149 @internaltool('internal:local', False)
147 def _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf):
150 def _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf):
151 """``internal:local``
152 Uses the local version of files as the merged version."""
148 return 0
153 return 0
149
154
150 @internaltool('internal:other', False)
155 @internaltool('internal:other', False)
151 def _iother(repo, mynode, orig, fcd, fco, fca, toolconf):
156 def _iother(repo, mynode, orig, fcd, fco, fca, toolconf):
157 """``internal:other``
158 Uses the other version of files as the merged version."""
152 repo.wwrite(fcd.path(), fco.data(), fco.flags())
159 repo.wwrite(fcd.path(), fco.data(), fco.flags())
153 return 0
160 return 0
154
161
155 @internaltool('internal:fail', False)
162 @internaltool('internal:fail', False)
156 def _ifail(repo, mynode, orig, fcd, fco, fca, toolconf):
163 def _ifail(repo, mynode, orig, fcd, fco, fca, toolconf):
164 """``internal:fail``
165 Rather than attempting to merge files that were modified on both
166 branches, it marks them as unresolved. The resolve command must be
167 used to resolve these conflicts."""
157 return 1
168 return 1
158
169
159 def _premerge(repo, toolconf, files):
170 def _premerge(repo, toolconf, files):
@@ -187,6 +198,10 b' def _premerge(repo, toolconf, files):'
187 _("merging %s incomplete! "
198 _("merging %s incomplete! "
188 "(edit conflicts, then use 'hg resolve --mark')\n"))
199 "(edit conflicts, then use 'hg resolve --mark')\n"))
189 def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files):
200 def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files):
201 """``internal:merge``
202 Uses the internal non-interactive simple merge algorithm for merging
203 files. It will fail if there are any conflicts and leave markers in
204 the partially merged file."""
190 r = _premerge(repo, toolconf, files)
205 r = _premerge(repo, toolconf, files)
191 if r:
206 if r:
192 a, b, c, back = files
207 a, b, c, back = files
@@ -199,6 +214,13 b' def _imerge(repo, mynode, orig, fcd, fco'
199
214
200 @internaltool('internal:dump', True)
215 @internaltool('internal:dump', True)
201 def _idump(repo, mynode, orig, fcd, fco, fca, toolconf, files):
216 def _idump(repo, mynode, orig, fcd, fco, fca, toolconf, files):
217 """``internal:dump``
218 Creates three versions of the files to merge, containing the
219 contents of local, other and base. These files can then be used to
220 perform a merge manually. If the file to be merged is named
221 ``a.txt``, these files will accordingly be named ``a.txt.local``,
222 ``a.txt.other`` and ``a.txt.base`` and they will be placed in the
223 same directory as ``a.txt``."""
202 r = _premerge(repo, toolconf, files)
224 r = _premerge(repo, toolconf, files)
203 if r:
225 if r:
204 a, b, c, back = files
226 a, b, c, back = files
@@ -267,8 +289,8 b' def filemerge(repo, mynode, orig, fcd, f'
267 ui.debug("picked tool '%s' for %s (binary %s symlink %s)\n" %
289 ui.debug("picked tool '%s' for %s (binary %s symlink %s)\n" %
268 (tool, fd, binary, symlink))
290 (tool, fd, binary, symlink))
269
291
270 if tool in _internal:
292 if tool in internals:
271 func = _internal[tool]
293 func = internals[tool]
272 trymerge = func.trymerge
294 trymerge = func.trymerge
273 onfailure = func.onfailure
295 onfailure = func.onfailure
274 else:
296 else:
@@ -340,3 +362,6 b' def filemerge(repo, mynode, orig, fcd, f'
340 os.unlink(b)
362 os.unlink(b)
341 os.unlink(c)
363 os.unlink(c)
342 return r
364 return r
365
366 # tell hggettext to extract docstrings from these functions:
367 i18nfunctions = internals.values()
@@ -7,7 +7,7 b''
7
7
8 from i18n import gettext, _
8 from i18n import gettext, _
9 import sys, os
9 import sys, os
10 import extensions, revset, fileset, templatekw, templatefilters
10 import extensions, revset, fileset, templatekw, templatefilters, filemerge
11 import util
11 import util
12
12
13 def listexts(header, exts, indent=1):
13 def listexts(header, exts, indent=1):
@@ -105,6 +105,7 b' def addtopicsymbols(topic, marker, symbo'
105 addtopichook(topic, add)
105 addtopichook(topic, add)
106
106
107 addtopicsymbols('filesets', '.. predicatesmarker', fileset.symbols)
107 addtopicsymbols('filesets', '.. predicatesmarker', fileset.symbols)
108 addtopicsymbols('merge-tools', '.. internaltoolsmarker', filemerge.internals)
108 addtopicsymbols('revsets', '.. predicatesmarker', revset.symbols)
109 addtopicsymbols('revsets', '.. predicatesmarker', revset.symbols)
109 addtopicsymbols('templates', '.. keywordsmarker', templatekw.keywords)
110 addtopicsymbols('templates', '.. keywordsmarker', templatekw.keywords)
110 addtopicsymbols('templates', '.. filtersmarker', templatefilters.filters)
111 addtopicsymbols('templates', '.. filtersmarker', templatefilters.filters)
@@ -34,33 +34,7 b' GUI is available if the tool requires a '
34 There are some internal merge tools which can be used. The internal
34 There are some internal merge tools which can be used. The internal
35 merge tools are:
35 merge tools are:
36
36
37 ``internal:merge``
37 .. internaltoolsmarker
38 Uses the internal non-interactive simple merge algorithm for merging
39 files. It will fail if there are any conflicts and leave markers in
40 the partially merged file.
41
42 ``internal:fail``
43 Rather than attempting to merge files that were modified on both
44 branches, it marks them as unresolved. The resolve command must be
45 used to resolve these conflicts.
46
47 ``internal:local``
48 Uses the local version of files as the merged version.
49
50 ``internal:other``
51 Uses the other version of files as the merged version.
52
53 ``internal:prompt``
54 Asks the user which of the local or the other version to keep as
55 the merged version.
56
57 ``internal:dump``
58 Creates three versions of the files to merge, containing the
59 contents of local, other and base. These files can then be used to
60 perform a merge manually. If the file to be merged is named
61 ``a.txt``, these files will accordingly be named ``a.txt.local``,
62 ``a.txt.other`` and ``a.txt.base`` and they will be placed in the
63 same directory as ``a.txt``.
64
38
65 Internal tools are always available and do not require a GUI but will by default
39 Internal tools are always available and do not require a GUI but will by default
66 not handle symlinks or binary files.
40 not handle symlinks or binary files.
General Comments 0
You need to be logged in to leave comments. Login now