Hello,
while testing mercurial I noticed that the diff commands in the Mercurial Bundle behave differently than what I'm used to from the svn bundle.
When I select a folder in the drawer and issue any diff command using the subversion bundle, I get a diff for all files under that selected folder.
The mercurial diff commands always use the currently active file in the diff commands.
Changing the hg_diff.rb file enables me to select a folder and get a diff for everything under it:
@@ -6,7 +6,7 @@ module Mercurial def Mercurial.diff_active_file( revision, command ) hg = ENV['TM_HG'] || 'hg' - target_path = ENV['TM_FILEPATH'] + target_path = ENV['TM_SELECTED_FILE'] || ENV['TM_FILEPATH'] work_path = ENV['WorkPath'] path = target_path.sub(/^#{work_path}//, '') output_path = File.basename(target_path) + ".diff"
(patch is attached)
While I'm here .. I had to change all diff commands do something like
( "${TM_RUBY:=ruby}" -I "$TM_BUNDLE_SUPPORT/" <<END require 'hg_diff' Mercurial::diff_active_file("-r$rev2 -r$rev1", "Diff Revisions…") END ) | iconv -t UTF-8 -c
since without the iconv call I'd get empty diff windows (probably because of incorrectly encoded german special chars inside the generated diff) -- but I'm not shure if this is just a local problem.
Bye, Eike
Index: /Library/Application Support/TextMate/Bundles/Mercurial.tmbundle/Support/hg_diff.rb =================================================================== --- /Library/Application Support/TextMate/Bundles/Mercurial.tmbundle/Support/hg_diff.rb (revision 7253) +++ /Library/Application Support/TextMate/Bundles/Mercurial.tmbundle/Support/hg_diff.rb (working copy) @@ -6,7 +6,7 @@ module Mercurial def Mercurial.diff_active_file( revision, command ) hg = ENV['TM_HG'] || 'hg' - target_path = ENV['TM_FILEPATH'] + target_path = ENV['TM_SELECTED_FILE'] || ENV['TM_FILEPATH'] work_path = ENV['WorkPath'] path = target_path.sub(/^#{work_path}//, '') output_path = File.basename(target_path) + ".diff"
On 5/16/07, Eike Bernhardt eike+textmate@unorganized.net wrote:
Hello,
The mercurial diff commands always use the currently active file in the diff commands.
Changing the hg_diff.rb file enables me to select a folder and get a diff for everything under it:
Thanks for the patch, I just committed it.
While I'm here .. I had to change all diff commands do something like (...) since without the iconv call I'd get empty diff windows (probably because of incorrectly encoded german special chars inside the generated diff) -- but I'm not shure if this is just a local problem.
I never had a problem like that (although I use accented chars). Anyway, changes applied too.
Thanks for the feedback. I you have any ideas/improvements you want to discuss, feel free to contact me off-list.
-- FredB
On 16. May 2007, at 09:29, Eike Bernhardt wrote:
[...] since without the iconv call I'd get empty diff windows (probably because of incorrectly encoded german special chars inside the generated diff) -- but I'm not shure if this is just a local problem.
What encoding do you use for your source files?
The official party line is that all TM commands which work with files “on disk” expect these to be in UTF-8.
This includes stuff like diff’ing (via the SCM system), finding TODO tags in your project, etc.
It also includes output from programs you run in TextMate, e.g. the various ScriptMate derivatives (PerlMate, RubyMate, PyMate, etc.), the Xcode target runner, etc.
Having all these commands handle encoding is quite a lot of complexity (and non-trivial, since encodings (other than the various UTF-n variants) can’t be determined safely by just looking at the file).
On 5/16/07, Allan Odgaard throw-away-1@macromates.com wrote:
On 16. May 2007, at 09:29, Eike Bernhardt wrote:
[...] since without the iconv call I'd get empty diff windows (probably because of incorrectly encoded german special chars inside the generated diff) -- but I'm not shure if this is just a local problem.
What encoding do you use for your source files?
The official party line is that all TM commands which work with files "on disk" expect these to be in UTF-8.
Ok. Removed the iconv stuff. Use UTF-8 or die is fine for me. ;)
On 16.05.2007 23:33 Uhr, Allan Odgaard wrote:
On 16. May 2007, at 09:29, Eike Bernhardt wrote:
[...] since without the iconv call I'd get empty diff windows (probably because of incorrectly encoded german special chars inside the generated diff) -- but I'm not shure if this is just a local problem.
What encoding do you use for your source files?
ISO-8859-1
It's an old project, not started in TextMate.
The official party line is that all TM commands which work with files “on disk” expect these to be in UTF-8.
I will recode the source files, then.