Topic "Local vs. Remote Diff"

Author Message
Dennis Bell

Guest


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.
Advertisements
ow1n

Guest


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.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
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.
_________________
Martin Prikryl
ow1n

Guest


Has anyone tried prikryl's suggestion? prikyrl, 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?
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
ow1n wrote:
prikyrl, 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:
Code:
executable "!" "!^!"

And it should be a "local command".
_________________
Martin Prikryl
guest

Guest


First off, nice work. I've been enjoying WinSCP for, oh, at least 2 years now. Now, then, how about user-definable keyboard shorcuts for those handy custom commands? Right now it's Alt, F, C, C, {Right Arrow}, {My Command}.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
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 shorcuts for those handy custom commands? Right now it's Alt, F, C, C, {Right Arrow}, {My Command}.

It's on TODO list Smile
_________________
Martin Prikryl
pip

Guest


prikryl 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.
pip

Guest


ow1n wrote:
Has anyone tried prikryl's suggestion? prikyrl, 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?


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.
Guest




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!
PIP

Guest


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 shorcuts 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
ram

Guest


Hey, I just became aware of this ability to add a custom command like file compare. Very useful. Magic! Thanks prikryl.
sven

Guest


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...
sven

Guest


sven wrote:
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...


You can ignore this one .. I noticed that this was already requested in Bug# 169
delazee
[View user's profile]

Joined: 2009-02-23
Posts: 3
Location: Manchester, England
@ow1n

Yes, I got WinMerge working no problem Razz

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!
Freitag
[View user's profile]

Joined: 2007-10-25
Posts: 51
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
Code:
"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.
delazee
[View user's profile]

Joined: 2009-02-23
Posts: 3
Location: Manchester, England
Idea Arrow 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.
Freitag
[View user's profile]

Joined: 2007-10-25
Posts: 51
delazee wrote:
Idea Arrow 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.


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 yo uare 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?

Quote:
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.
delazee
[View user's profile]

Joined: 2009-02-23
Posts: 3
Location: Manchester, England
@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.
Freitag
[View user's profile]

Joined: 2007-10-25
Posts: 51
!^! 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.
stmulligan

Guest


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 ! "!^!"
bluescrubbie

Guest


Thanks Freitag! Very Happy
Freitag
[View user's profile]

Joined: 2007-10-25
Posts: 51
bluescrubbie wrote:
Thanks Freitag! Very Happy


Glad my post helped. Very Happy
Terabyte

Guest


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.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
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 exclusing mask, when selecting files for comparison.
_________________
Martin Prikryl
Guest




I am trying to integrate Compare It 4 http://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 transfered 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?
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
Anonymous wrote:
I am trying to integrate Compare It 4 http://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 transfered 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 !)

This is not implemented yet.
https://winscp.net/tracker/show_bug.cgi?id=169
_________________
Martin Prikryl
Guest




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
mlplus

Guest


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 its a folder with many files; on the right its 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
Freitag
[View user's profile]

Joined: 2007-10-25
Posts: 51
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 its a folder with many files; on the right its 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 spreadhseet 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 comapre. A conditional frmat 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.
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License