##// END OF EJS Templates
filemerge: remove some redundancy in decorators/docstrings
Matt Mackall -
r16127:14dc2bbb default
parent child Browse files
Show More
@@ -24,7 +24,9 b' internals = {}'
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 internals[name] = func
27 fullname = 'internal:' + name
28 func.__doc__ = "``%s``\n" % fullname + func.__doc__.strip()
29 internals[fullname] = func
28 func.trymerge = trymerge
30 func.trymerge = trymerge
29 func.onfailure = onfailure
31 func.onfailure = onfailure
30 return func
32 return func
@@ -131,10 +133,9 b' def _matcheol(file, origfile):'
131 if newdata != data:
133 if newdata != data:
132 util.writefile(file, newdata)
134 util.writefile(file, newdata)
133
135
134 @internaltool('internal:prompt', False)
136 @internaltool('prompt', False)
135 def _iprompt(repo, mynode, orig, fcd, fco, fca, toolconf):
137 def _iprompt(repo, mynode, orig, fcd, fco, fca, toolconf):
136 """``internal:prompt``
138 """Asks the user which of the local or the other version to keep as
137 Asks the user which of the local or the other version to keep as
138 the merged version."""
139 the merged version."""
139 ui = repo.ui
140 ui = repo.ui
140 fd = fcd.path()
141 fd = fcd.path()
@@ -146,22 +147,20 b' def _iprompt(repo, mynode, orig, fcd, fc'
146 else:
147 else:
147 return _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf)
148 return _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf)
148
149
149 @internaltool('internal:local', False)
150 @internaltool('local', False)
150 def _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf):
151 def _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf):
151 """``internal:local``
152 """Uses the local version of files as the merged version."""
152 Uses the local version of files as the merged version."""
153 return 0
153 return 0
154
154
155 @internaltool('internal:other', False)
155 @internaltool('other', False)
156 def _iother(repo, mynode, orig, fcd, fco, fca, toolconf):
156 def _iother(repo, mynode, orig, fcd, fco, fca, toolconf):
157 """``internal:other``
157 """Uses the other version of files as the merged version."""
158 Uses the other version of files as the merged version."""
159 repo.wwrite(fcd.path(), fco.data(), fco.flags())
158 repo.wwrite(fcd.path(), fco.data(), fco.flags())
160 return 0
159 return 0
161
160
162 @internaltool('internal:fail', False)
161 @internaltool('fail', False)
163 def _ifail(repo, mynode, orig, fcd, fco, fca, toolconf):
162 def _ifail(repo, mynode, orig, fcd, fco, fca, toolconf):
164 """``internal:fail``
163 """
165 Rather than attempting to merge files that were modified on both
164 Rather than attempting to merge files that were modified on both
166 branches, it marks them as unresolved. The resolve command must be
165 branches, it marks them as unresolved. The resolve command must be
167 used to resolve these conflicts."""
166 used to resolve these conflicts."""
@@ -194,11 +193,11 b' def _premerge(repo, toolconf, files):'
194 util.copyfile(back, a) # restore from backup and try again
193 util.copyfile(back, a) # restore from backup and try again
195 return 1 # continue merging
194 return 1 # continue merging
196
195
197 @internaltool('internal:merge', True,
196 @internaltool('merge', True,
198 _("merging %s incomplete! "
197 _("merging %s incomplete! "
199 "(edit conflicts, then use 'hg resolve --mark')\n"))
198 "(edit conflicts, then use 'hg resolve --mark')\n"))
200 def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files):
199 def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files):
201 """``internal:merge``
200 """
202 Uses the internal non-interactive simple merge algorithm for merging
201 Uses the internal non-interactive simple merge algorithm for merging
203 files. It will fail if there are any conflicts and leave markers in
202 files. It will fail if there are any conflicts and leave markers in
204 the partially merged file."""
203 the partially merged file."""
@@ -212,9 +211,9 b' def _imerge(repo, mynode, orig, fcd, fco'
212 return True, r
211 return True, r
213 return False, 0
212 return False, 0
214
213
215 @internaltool('internal:dump', True)
214 @internaltool('dump', True)
216 def _idump(repo, mynode, orig, fcd, fco, fca, toolconf, files):
215 def _idump(repo, mynode, orig, fcd, fco, fca, toolconf, files):
217 """``internal:dump``
216 """
218 Creates three versions of the files to merge, containing the
217 Creates three versions of the files to merge, containing the
219 contents of local, other and base. These files can then be used to
218 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
219 perform a merge manually. If the file to be merged is named
General Comments 0
You need to be logged in to leave comments. Login now