Mercurial > hg
changeset 5245:a1efa71f3ece
Improve extdiff configuration.
In addition to the old cmd.foo, opts.foo hgrc entries, allow a more simple
alias = command [opts]... form. For example:
[extdiff]
cdiff = colordiff -uprN
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Sat, 25 Aug 2007 12:25:53 -0700 |
parents | 79279b5583c6 |
children | 7d3dcdd92a1a |
files | hgext/extdiff.py |
diffstat | 1 files changed, 52 insertions(+), 47 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/extdiff.py Sat Aug 25 16:31:37 2007 +0200 +++ b/hgext/extdiff.py Sat Aug 25 12:25:53 2007 -0700 @@ -4,55 +4,51 @@ # # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -# -# The `extdiff' Mercurial extension allows you to use external programs -# to compare revisions, or revision with working dir. The external diff -# programs are called with a configurable set of options and two -# non-option arguments: paths to directories containing snapshots of -# files to compare. -# -# To enable this extension: -# -# [extensions] -# hgext.extdiff = -# -# The `extdiff' extension also allows to configure new diff commands, so -# you do not need to type "hg extdiff -p kdiff3" always. -# -# [extdiff] -# # add new command that runs GNU diff(1) in 'context diff' mode -# cmd.cdiff = gdiff -# opts.cdiff = -Nprc5 + +''' +The `extdiff' Mercurial extension allows you to use external programs +to compare revisions, or revision with working dir. The external diff +programs are called with a configurable set of options and two +non-option arguments: paths to directories containing snapshots of +files to compare. + +To enable this extension: + + [extensions] + hgext.extdiff = + +The `extdiff' extension also allows to configure new diff commands, so +you do not need to type "hg extdiff -p kdiff3" always. -# # add new command called vdiff, runs kdiff3 -# cmd.vdiff = kdiff3 + [extdiff] + # add new command that runs GNU diff(1) in 'context diff' mode + cdiff = gdiff -Nprc5 + ## or the old way: + #cmd.cdiff = gdiff + #opts.cdiff = -Nprc5 -# # add new command called meld, runs meld (no need to name twice) -# cmd.meld = + # add new command called vdiff, runs kdiff3 + vdiff = kdiff3 -# # add new command called vimdiff, runs gvimdiff with DirDiff plugin -# #(see http://www.vim.org/scripts/script.php?script_id=102) -# # Non english user, be sure to put "let g:DirDiffDynamicDiffText = 1" in -# # your .vimrc -# cmd.vimdiff = gvim -# opts.vimdiff = -f '+next' '+execute "DirDiff" argv(0) argv(1)' -# -# Each custom diff commands can have two parts: a `cmd' and an `opts' -# part. The cmd.xxx option defines the name of an executable program -# that will be run, and opts.xxx defines a set of command-line options -# which will be inserted to the command between the program name and -# the files/directories to diff (i.e. the cdiff example above). -# -# You can use -I/-X and list of file or directory names like normal -# "hg diff" command. The `extdiff' extension makes snapshots of only -# needed files, so running the external diff program will actually be -# pretty fast (at least faster than having to compare the entire tree). + # add new command called meld, runs meld (no need to name twice) + meld = + + # add new command called vimdiff, runs gvimdiff with DirDiff plugin + #(see http://www.vim.org/scripts/script.php?script_id=102) + # Non english user, be sure to put "let g:DirDiffDynamicDiffText = 1" in + # your .vimrc + vimdiff = gvim -f '+next' '+execute "DirDiff" argv(0) argv(1)' + +You can use -I/-X and list of file or directory names like normal +"hg diff" command. The `extdiff' extension makes snapshots of only +needed files, so running the external diff program will actually be +pretty fast (at least faster than having to compare the entire tree). +''' from mercurial.i18n import _ from mercurial.node import * from mercurial import cmdutil, util, commands -import os, shutil, tempfile - +import os, shlex, shutil, tempfile def snapshot_node(ui, repo, files, node, tmproot): '''snapshot files as of some revision''' @@ -187,11 +183,20 @@ def uisetup(ui): for cmd, path in ui.configitems('extdiff'): - if not cmd.startswith('cmd.'): continue - cmd = cmd[4:] - if not path: path = cmd - diffopts = ui.config('extdiff', 'opts.' + cmd, '') - diffopts = diffopts and [diffopts] or [] + if cmd.startswith('cmd.'): + cmd = cmd[4:] + if not path: path = cmd + diffopts = ui.config('extdiff', 'opts.' + cmd, '') + diffopts = diffopts and [diffopts] or [] + elif cmd.startswith('opts.'): + continue + else: + # command = path opts + if path: + diffopts = shlex.split(path) + path = diffopts.pop(0) + else: + path, diffopts = cmd, [] def save(cmd, path, diffopts): '''use closure to save diff command to use''' def mydiff(ui, repo, *pats, **opts):