Local vs. Remote Diff

Advertisement

Dennis Bell
Guest

Local vs. Remote Diff

Having the ability to view the difference between a local and a remote version of a file would be very handy. If a merge facility was also included, this would definitely facilitate multiple users being able to work on the same files.

The diff could simply copy the remote file over to a temp directory, then run something like tkdiff (https://sourceforge.net/projects/tkdiff/) to display a graphical difference. This is what I do now, but it would be a lot better if this could be done with a single button or context menu action.

Reply with quote

Advertisement

ow1n
Guest

Seconded

I agree...it's just what I was coming to the forums today to find out about. TortoiseCVS has a preference where you can specify your Diff application. It's just what WinSCP needs.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,442
Location:
Prague, Czechia

Re: Seconded

WinSCP can do that via custom commands. There is an built-in example provided that uses simple command-line fc diff. Replace it with your favourite one.

Reply with quote

ow1n
Guest

Anyone got this working?

Has anyone tried @martin's suggestion? @martin, are you saying that it would be possible to have a custom command launch a local program (like WinMerge) to diff a local and remote program?

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,442
Location:
Prague, Czechia

Re: Anyone got this working?

ow1n wrote:

@martin, are you saying that it would be possible to have a custom command launch a local program (like WinMerge) to diff a local and remote program?
Yes. Please see built-in example command labeled "File Compare". Basically the command should look like:
executable "!" "!^!"
And it should be a "local command".

Reply with quote

Advertisement

guest
Guest

Keyboard Shortcuts

First off, nice work. I've been enjoying WinSCP for, oh, at least 2 years now. Now, then, how about user-definable keyboard shortcuts for those handy custom commands? Right now it's Alt, F, C, C, {Right Arrow}, {My Command}.

Reply with quote

pip
Guest

Re: Seconded

martin wrote:

WinSCP can do that via custom commands. There is an built-in example provided that uses simple command-line fc diff. Replace it with your favourite one.
I just upgraded from v368 to 407 and as if by magic - file compare! No more downloading into temp, renaming, diffing, deleting etc... aah my RSI.

Martin you are a legend.

Reply with quote

pip
Guest

Re: Anyone got this working?

I've just got it working with CS Diff. Simply add a new local custom command and enter:
"C:\Program Files\ComponentSoftware\CSDiff\CSDiff.exe" /n /t=2 /q ! !^!
brilliant.

Reply with quote

Advertisement

Guest

Re: Anyone got this working?

And for folders (recursive!): e.g.
"C:\Program Files\ComponentSoftware\CSDiff\CSDiff.exe" /q /X*.svn /d ! !^!
tick "Apply to directories" and "local command".

This even allows the click-through (in CSDiff) into modified files to diff them individually.

wondrous!

Reply with quote

PIP
Guest

Re: Keyboard Shortcuts

guest wrote:

First off, nice work. I've been enjoying WinSCP for, oh, at least 2 years now. Now, then, how about user-definable keyboard shortcuts for those handy custom commands? Right now it's Alt, F, C, C, {Right Arrow}, {My Command}.
You can turn on the toolbar buttons?
Tick File > Custom Commands > Custom Command Buttons

Reply with quote

sven
Guest

Uploading local files when changed using 'Custom Commands'

Would it be possible to see a 'request to upload/synchronize' a file back to the remote server when it was locally modified using 'Custom Commands'?

e.g. after a merge of a local and a remote version of a file...

Reply with quote

Advertisement

delazee
Joined:
Posts:
3
Location:
Manchester, England

Re: Anyone got this working?

@ow1n

Yes, I got WinMerge working no problem :P

Just a straight copy of the code that pip put in for csdiff
"C:\Program Files\WinMerge\WinMerge.exe" /n /t=2 /q ! !^!
And also for the directory compare, (although both commands show for files and directories).
"C:\Program Files\WinMerge\WinMerge.exe" /q /X*.svn /d ! !^!
Note on the directory compare: You have to select the matching local directory before right clicking the corresponding remote directory.

But this is absolutely awesome, I was looking for a Dreamweaver like FTP Client (i.e. synchronised browsing), but this feature (directory comparison via WinMerge) just blasts Dreamweaver right out of the water. Kudos to the WinSCP Team!

Reply with quote

Freitag
Freitag avatar
Joined:
Posts:
75

Re: Anyone got this working?

delazee wrote:

Kudos to the WinSCP Team!
Team =

I am trying a variation where both files/folders are remote and although I could get the file compare working, I could not get the folder compare working in WinDiff

For file compare I have this
"C:\Program Files\WinMerge\WinMergeU.exe" !&
(WinMerge does not have the /q, /n, or /t flags that CSDiff does.)

But for the directory compare I got the two directories downloaded (WinSCP works great) but WinMerge opened on a blank screen and not on a compare screen.

Reply with quote

delazee
Joined:
Posts:
3
Location:
Manchester, England

Tip

If you're integrating WinMerge then you only need one command for both single file comparison and directory comparison.
"C:\Program Files\WinMerge\WinMerge.exe" /q /X*.svn /d ! !^!"
Click "Apply to directories", and set as a local command in the custom command set up wizard.

Reply with quote

Advertisement

Freitag
Freitag avatar
Joined:
Posts:
75

Re: Tip

delazee wrote:

If you're integrating WinMerge then you only need one command for both single file comparison and directory comparison.
"C:\Program Files\WinMerge\WinMerge.exe" /q /X*.svn /d ! !^!"
WinMerge does not understand the /q or /X or /d commands - those belong to that other compare tool.

Also, !^! expands to a selection in the local system and is only meaningful if you are using the Norton style interface. The Explorer interface does not have a selection for that.

Did you read anything at all or just reply with the same post that was made previously?

The WinMerge command line accepts several parameters in addition to the paths to compare. Most of these parameters are intended for using WinMerge as an external compare application or starting a compare operation from a batch file.

Use one of these formats for the WinMerge command:

WinMerge[ U ] [/?]

WinMerge[ U ] [/r] [/e] [/f filter] [/x] [/s] [/ul] [/ur] [/u] [/wl] [/wr] [/minimize] [/maximize] [/dl leftdesc] [/dr rightdesc] leftpath rightpath [outputpath]

WinMerge[U] conflictfile

The command has two forms:

WinMergeU
Use WinMergeU if you are running the Unicode version of WinMerge, typically installed on recent Windows systems.

WinMerge
Use WinMerge only if you are running the ANSI version of WinMerge, typically installed only on Windows 9x and WME systems.

Entering the command with no parameters or pathnames simply opens the WinMerge window. Parameters are prefixed with either a forward slash ( / ) or dash ( - ) character. Pathnames have no prefix character.

/? opens WinMerge Help at this topic.

/r compares all files in all subfolders (recursive compare). Unique folders (occurring only on one side) are listed in the compare result as separate items. Note that including subfolders can increase compare time significantly. Without this parameter, WinMerge lists only files and subfolders at the top level of the two target folders. It does not compare the subfolders.

/e enables you to close WinMerge with a single Esc key press. This is useful when you use WinMerge as an external compare application: you can close WinMerge quickly, like a dialog. Without this parameter, you might have to press Esc multiple times to close all its windows.

/f applies a specified filter to restrict the comparison. The filter can be a filemask like *.h *.cpp, or the name of a file filter like XML/HTML Devel. Add quotation marks around a filter mask or name that contains spaces.

/x closes WinMerge (after displaying an information dialog) when you start a comparison of identical files. The parameter has no effect after the comparison, for example if the files become identical as a result of merging or editing. This parameter is useful when you use WinMerge as an external compare application, or when you want to eliminate unnecessary steps by ignoring files that don't have any differences.

/s limits WinMerge windows to a single instance. For example, if WinMerge is already running, a new compare opens in the same instance. Without this parameter, multiple windows are allowed: depending on other settings, a new compare might open in the existing window or in a new window.

/ul prevents WinMerge from adding the left path to the Most Recently Used (MRU) list. External applications should not add paths to the MRU list in the Select Files or Folders dialog.

/ur prevents WinMerge from adding the right path to the Most Recently Used (MRU) list. External applications should not add paths to the MRU list in the Select Files or Folders dialog.

/u prevents WinMerge from adding either path (left or right) to the Most Recently Used (MRU) list. External applications should not add paths to the MRU list in the Select Files or Folders dialog.

/wl opens the left side as read-only. Use this when you don't want to change left side items in the compare.

/wr opens the right side as read-only. Use this when you don't want to change right side items in the compare.

/minimize starts WinMerge as a minimized window. This option can be useful during lengthy compares.

/maximize starts WinMerge as a maximized window.

/dl specifies a description in the left side title bar, overriding the default folder or filename text. For example: /dl "Version 1.0" or /dl WorkingCopy. Use quotation marks around descriptions that contain spaces.

/dr specifies a description in the right side title bar, just like /dl.

leftpath specifies the folder, file, or project file to open on the left side.

rightpath specifies the folder, file, or project file to open on the right side.
That is the command line help from WinMerge - if it interprets /X at all, it will simple exit without showing you a thing.

Reply with quote

delazee
Joined:
Posts:
3
Location:
Manchester, England

OK, I'll take that on board

@Freitag

If you create the custom command as described in my post above it works just beautifully for WinMerge and WinSCP. So although I hadn't read anything other than your previous post on how to make it work, I had tested the code.

I'm just trying to help people that I've never met. I think I might also need to point out that my previous post was not a reply to your post on comparing two remote folders.

Anyhow, I've read your post and I've got a new simpler version of the code that works for both individual files and for directory comparison. Having looked at the list of switches, none of them seem appropriate for the default comparison that I want to do, except for the switch that stops adding the files to the recently compared list, which is not useful as the remote files are deleted from the temp directory after you close winmerge.

So this is the custom command required to compare files with WinMerge:
"C:\Program Files\WinMerge\WinMerge.exe" /u ! !^!
Set as a Local Command and check Apply to Directories.

Reply with quote

Freitag
Freitag avatar
Joined:
Posts:
75

!^! still expands to the list of file names in the local panel.

I am trying to compare two directories from the remote panel with each other and not with anything local.

If you put !^! in the command string, then the option to execute this command is greyed out and unavailable in the remote panel.

The expansion to use is !&

This may be an issue with WinMerge just not liking something about the call parameters

I set up an editor (TextPad) using the remote command function and instead of getting one function call with two arguments, I got two calls with one argument each when selecting two files and six function calls with one argument each when selecting six files.

For editing that is OK, but WinMerge wants both arguments on one command line.

I guess that depends on what does WinSCP do with !& when it is two directory names selected? It does copy the two directories over to local PC, but does !& expand to all file names in both directories or just the directory names selected (and that in the location on the local disk)

Hmm, well I wrote a diagnostic batch file to see what parameters were passed and in getting that to work I found how to make WinMerge work.

I do not know WHY the hoops must be jumped through, but here is the command that works for WinMerge to compare two remote directories
cmd /C "C:\Program Files\WinMerge\WinMergeU.exe" /r /u !&
If you do not use cmd, then WinMerge just sits there as if you started it without a parameter list.

Reply with quote

stmulligan
Guest

Spaces in Filenames

I had to wrapper the local file name for WinMerge in quotes to get it to recognize paths with space (like "My Documents"). Here's my File Compare command:
"C:\Program Files\WinMerge\WinMergeU.exe" /u ! "!^!"

Reply with quote

Advertisement

Terabyte
Guest

Compare and DIFF with winmerge and winscp

just wanted to say thanks to all who contributed here. i am still striking at it, in trying to get my winmerge to fire when i run file compare.

will report back directly. i would like to know if there is a method for excluding file types --> .png .gif .jpg

in running diff on the file set, not really necessary to know if an image has changed.

Reply with quote

martin
Site Admin
martin avatar

Re: Compare and DIFF with winmerge and winscp

Terabyte wrote:

i would like to know if there is a method for excluding file types --> .png .gif .jpg
WinSCP compares the file you select, so just avoid selecting the images. You can use excluding mask, when selecting files for comparison.

Reply with quote

Advertisement

Guest

Re: Compare and DIFF with winmerge and winscp

I am trying to integrate Compare It 4 https://www.grigsoft.com/index.htm and am able to have both the local and remote file to open and compare. My problem is when I edit the remote file, save it and exit Compare It, it is not transferred to the remote host. The local copy of the remote file is update by Compare It, but the catalog/file is deleted (by winscp?) and no file uploaded to the remote host.
I am on a Win7 64 computer, latest version of winscp and compare it. Command string used:
"C:\temp\comp\wincmp3.exe" "!^!" "!"
(had to move compare it to new folder because it installs with a path containing a !)

Any suggestions?

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,442
Location:
Prague, Czechia

Re: Compare and DIFF with winmerge and winscp

Anonymous wrote:

I am trying to integrate Compare It 4 https://www.grigsoft.com/index.htm and am able to have both the local and remote file to open and compare. My problem is when I edit the remote file, save it and exit Compare It, it is not transferred to the remote host. The local copy of the remote file is update by Compare It, but the catalog/file is deleted (by winscp?) and no file uploaded to the remote host.
This is not implemented yet.
https://winscp.net/tracker/169

Reply with quote

Guest

Re: Compare and DIFF with winmerge and winscp

Thanks, I am waiting, please raise priority. Winscp is awesome, but this is the only issue stopping me from totally migrating from Total Commander (with SFTP plugin).

Vidar

Reply with quote

mlplus
Guest

Can't get winmerge to show the matches

I am having a problem using winmerge.
I am trying to find all the matching files in these two directories(and sub directories). On the left it's a folder with many files; on the right it's a folder that contains many sub folders that contain files. There is are many file matches but they wont show as matches.. HELP! Can winmerge do this? If not can anyone tell me what software can? Thanks in advance.

Right - H:\media\music ( note there many sub directories in this folder that contain matching files in the left folder)

Left - Z:\music

Thanks Again
Marty

Reply with quote

Advertisement

Freitag
Freitag avatar
Joined:
Posts:
75

Re: Can't get winmerge to show the matches

Not a WinSCP problem, but here are some rough ideas on how to approach.

mlplus wrote:

I am having a problem using winmerge.
I am trying to find all the matching files in these two directories(and sub directories). On the left it's a folder with many files; on the right it's a folder that contains many sub folders that contain files. There is are many file matches but they wont show as matches.. HELP! Can winmerge do this? If not can anyone tell me what software can? Thanks in advance.

Right - H:\media\music ( note there many sub directories in this folder that contain matching files in the left folder)

Left - Z:\music

Thanks Again
Marty
As far as I know WinMerge expects the files in both directory trees to be at the same branch level so Z:\music\song1.XXX will not match to H:\media\music\artist_name\song1.XXX (because on one side the file is in the top level directory and in the other side there is artist_name directory between them) Had to use XXX instead of the typical expected suffix because of the banned word list in the posting filter

What you may be able to do (sounds like Windows to me) is this
DIR /S Z:\music > C:\z_list.txt
DIR /S H:\media\music > C:\h_list.txt
/S forces DIR to recurse sub directories

When you have the two lists you can put them in a spreadsheet and parse the file name from the path and then sort by the column that contains the filename

You'll still have two lists that you have to eyeball to compare. A conditional format to change the background color when the two names do not match will help.

Try exporting a CSV of just the file names and then load those two files into WinMerge and it will show you where the two lists match and don't match

Good luck.

Reply with quote

mcfc4heatons
Joined:
Posts:
9
Location:
UK

Meld Anyone ??

Well, I like Meld ... have been using for years, a simple command like this works just fine:
"C:\Program Files (x86)\Meld\Meld.exe" !&

Reply with quote

Advertisement

You can post new topics in this forum