Show More
@@ -324,6 +324,32 b' def extdiff(ui, repo, *pats, **opts):' | |||||
324 | cmdline = ' '.join(map(util.shellquote, [program] + option)) |
|
324 | cmdline = ' '.join(map(util.shellquote, [program] + option)) | |
325 | return dodiff(ui, repo, cmdline, pats, opts) |
|
325 | return dodiff(ui, repo, cmdline, pats, opts) | |
326 |
|
326 | |||
|
327 | class savedcmd(object): | |||
|
328 | """use %(path)s to diff repository (or selected files) | |||
|
329 | ||||
|
330 | Show differences between revisions for the specified files, using | |||
|
331 | the %(path)s program. | |||
|
332 | ||||
|
333 | When two revision arguments are given, then changes are shown | |||
|
334 | between those revisions. If only one revision is specified then | |||
|
335 | that revision is compared to the working directory, and, when no | |||
|
336 | revisions are specified, the working directory files are compared | |||
|
337 | to its parent. | |||
|
338 | """ | |||
|
339 | ||||
|
340 | def __init__(self, path, cmdline): | |||
|
341 | # We can't pass non-ASCII through docstrings (and path is | |||
|
342 | # in an unknown encoding anyway) | |||
|
343 | docpath = path.encode("string-escape") | |||
|
344 | self.__doc__ = self.__doc__ % {'path': util.uirepr(docpath)} | |||
|
345 | self._cmdline = cmdline | |||
|
346 | ||||
|
347 | def __call__(self, ui, repo, *pats, **opts): | |||
|
348 | options = ' '.join(map(util.shellquote, opts['option'])) | |||
|
349 | if options: | |||
|
350 | options = ' ' + options | |||
|
351 | return dodiff(ui, repo, self._cmdline + options, pats, opts) | |||
|
352 | ||||
327 | def uisetup(ui): |
|
353 | def uisetup(ui): | |
328 | for cmd, path in ui.configitems('extdiff'): |
|
354 | for cmd, path in ui.configitems('extdiff'): | |
329 | path = util.expandpath(path) |
|
355 | path = util.expandpath(path) | |
@@ -357,28 +383,5 b' def uisetup(ui):' | |||||
357 | ui.config('merge-tools', cmd+'.diffargs') |
|
383 | ui.config('merge-tools', cmd+'.diffargs') | |
358 | if args: |
|
384 | if args: | |
359 | cmdline += ' ' + args |
|
385 | cmdline += ' ' + args | |
360 | def save(cmdline): |
|
|||
361 | '''use closure to save diff command to use''' |
|
|||
362 | def mydiff(ui, repo, *pats, **opts): |
|
|||
363 | options = ' '.join(map(util.shellquote, opts['option'])) |
|
|||
364 | if options: |
|
|||
365 | options = ' ' + options |
|
|||
366 | return dodiff(ui, repo, cmdline + options, pats, opts) |
|
|||
367 | # We can't pass non-ASCII through docstrings (and path is |
|
|||
368 | # in an unknown encoding anyway) |
|
|||
369 | docpath = path.encode("string-escape") |
|
|||
370 | mydiff.__doc__ = '''\ |
|
|||
371 | use %(path)s to diff repository (or selected files) |
|
|||
372 |
|
||||
373 | Show differences between revisions for the specified files, using |
|
|||
374 | the %(path)s program. |
|
|||
375 |
|
||||
376 | When two revision arguments are given, then changes are shown |
|
|||
377 | between those revisions. If only one revision is specified then |
|
|||
378 | that revision is compared to the working directory, and, when no |
|
|||
379 | revisions are specified, the working directory files are compared |
|
|||
380 | to its parent.\ |
|
|||
381 | ''' % {'path': util.uirepr(docpath)} |
|
|||
382 | return mydiff |
|
|||
383 | command(cmd, extdiffopts[:], _('hg %s [OPTION]... [FILE]...') % cmd, |
|
386 | command(cmd, extdiffopts[:], _('hg %s [OPTION]... [FILE]...') % cmd, | |
384 | inferrepo=True)(save(cmdline)) |
|
387 | inferrepo=True)(savedcmd(path, cmdline)) |
General Comments 0
You need to be logged in to leave comments.
Login now