From a kdiff3 file comparison, can I generate a diff in unified diff format? - diff

I have a kdiff3 comparison in Windows, and I would like to save the comparison as a text file in unified diff format.
I realize this is kind of a strange question. Usually, people already have the text diff in hand, and want to see it graphically in kdiff3.
I'm using an ... unusual ... version control tool in Windows, and it can compare versions and display the comparison in kdiff3. However, it is decidedly unfriendly in generating Unix-friendly output, at least for non-ClearCase-ninjas like me.
What I would really, truly, love is to get the output of the comparison in a unified diff format, so I can use tools like patch or similar. I do not particularly love ClearCase, and I would be happy to leave it alone as much as possible.
Can kdiff3 take an existing comparison and export it to a unified diff format?

kdiff3 in Windows tends to come with the standard command-line diff utils as well -- look in your C:\Program Files*\KDiff3\bin folder; if diff.exe is there, you can use that (the standard diff -u file1 file2). (If it's not there, re-run the kdiff3 installer and select the "Utilities" option.)
If you're looking at some files in a running kdiff3 that was auto-launched from ClearCase, open a command prompt in the kdiff3 bin directory (or copy the contents of the bin directory into C:\Windows to make these commands work from anywhere) and do:
diff -u "<copy-pasted path of file A>" "<copy-pasted path of file B>"
where the paths for file A and file B come from your kdiff3 window (doesn't matter if they're temporary files; they'll exist as long as the kdiff3 window is open).

Don't bother with kdiff3. The command you're looking for is
cleartool diff --diff-format
Answered by John here: From a kdiff3 file comparison, can I generate a diff in unified diff format?

Related

How to install vim which is cloned from github.com?

I've cloned it but I didn't find any .exe file, Nor do i see it in programs list in Control Panel of windows. I'am a bit confused as to what cloning means. I know that there is direct download .exe file on vim.org website. Its for sure that I'am beginner for all these. Please help. Thanks for the help in advance.
reading the "installation" section found in the README.md of the vim repo, you can see the filenames containing the instructions that will help you with the installation, depending on your OS.
README_ami.txt Amiga
README_unix.txt Unix
README_dos.txt MS-DOS and MS-Windows
README_mac.txt Macintosh
README_haiku.txt Haiku
README_vms.txt VMS
So, for the full information I suggest you go to those files, or go to the vim website where there is also good information about the installation.
Anyway, I will briefly explain below the information that those files and the vim website say for most common operating systems
If you're on Unix:
git clone https://github.com/vim/vim.git
cd vim/src
make
If you're on Mac
The Macintosh binaries are not on the Vim ftp site. They are produced by a few Macintosh lovers. Often they lag behind a few versions.
MacVim has more a Mac look and feel, is developed actively and most people prefer this version. Most of MacVim was made by Björn Winckler.
MacVim can be downloaded here: link
Or if you prefer, here is the MacVim homepage.
If you're on Windows:
The next instructions were copied from here.
Option A: Using the self-installing .exe
Go to vim.org/download.php and click on self-installing executable (or just click here) and follow the prompts.
Watch out for:
When an existing installation is detected, you are offered to first remove
this. The uninstall program is then started while the install program waits
for it to complete. Sometimes the windows overlap each other, which can be
confusing. Be sure the complete the uninstalling before continuing the
installation. Watch the taskbar for uninstall windows.
When selecting a directory to install Vim, use the same place where other
versions are located. This makes it easier to find your _vimrc file. For
example "C:\Program Files\vim" or "D:\vim". A name ending in "vim" is
preferred.
After selecting the directory where to install Vim, clicking on "Next" will
start the installation.
Option B: Using .zip files
Go to the directory where you want to put the Vim files. Examples:
cd C:\
cd D:\editors
If you already have a "vim" directory, go to the directory in which it is
located. Check the $VIM setting to see where it points to:
set VIM
For example, if you have
C:\vim\vim82
do
cd C:\
Binary and runtime Vim archives are normally unpacked in the same location,
on top of each other.
Unpack the zip archives. This will create a new directory "vim\vim82",
in which all the distributed Vim files are placed. Since the directory
name includes the version number, it is unlikely that you overwrite
existing files.
Examples:
pkunzip -d gvim82.zip
unzip vim82w32.zip
You need to unpack the runtime archive and at least one of the binary
archives. When using more than one binary version, be careful not to
overwrite one version with the other, the names of the executables
"vim.exe" and "gvim.exe" are the same.
After you unpacked the files, you can still move the whole directory tree
to another location. That is where they will stay, the install program
won't move or copy the runtime files.
Change to the new directory:
cd vim\vim82
Run the "install.exe" program. It will ask you a number of questions about
how you would like to have your Vim setup. Among these are:
You can tell it to write a "_vimrc" file with your preferences in the
parent directory.
It can also install an "Edit with Vim" entry in the Windows Explorer
popup menu.
You can have it create batch files, so that you can run Vim from the
console or in a shell. You can select one of the directories in your
$PATH. If you skip this, you can add Vim to the search path manually:
The simplest is to add a line to your autoexec.bat. Examples:
set path=%path%;C:\vim\vim82
set path=%path%;D:\editors\vim\vim82
Create entries for Vim on the desktop and in the Start menu.
That's it!
Vim is open source software, and its source code, i.e. all the technical files that make up Vim is (nowadays) hosted at GitHub.
Cloning that repository means you'll download all of those files to your computer (and with Git as the underlying revision control system, you'll even get the full history of all changes ever done). As Vim supports a very big set of very diverse platforms (Windows, Linux, Mac, ...), the repository itself does not (and should not) contain pre-built binaries, nor a full installer that most users expect to run. So, unless you have the intention to actively contribute to Vim by submitting bug fixes or enhancements, you don't need to clone or do anything with GitHub. If you do want to get technical, src/INSTALLpc.txt contains the instructions for building Vim on Windows. This includes choosing a compiler, installing it and the required dependencies, configuring the build, building, and then finally copying the files to a permanent location on your PC, either manually or by building and then running an installer.
For plain passive consumption of Vim (which is rewarding in itself, but may even lead you to eventually also programming it), the Downloading Vim page on vim.org has all the information that you need, with links to the most popular installers right at the top.
a word on versions
For a casual user, using the latest stable version is recommended; this is 8.2 right now; gvim82.exe is a corresponding installer for Windows. This offers the best compromise between stability and latest features. In the case of Vim, expect a new release roughly every year.
You'll also find development builds (something like 8.2.0740); these usually function as well and have the very latest features under development, but often are less stable. I would use these only if you really need a leading-edge feature, or want to report a bug. You should then probably update very frequently, and from there it's only a small step to actually cloning the repository and building everything on your own!

Refactor java classes on windows file system using cygwin

I'm trying to refactor classes from my local working copy due to an urgent refactor needed after a bug fix.
So what i am doing is, using cygwin, move to the dir where my exlipse workspace is located and run this query
find . -name "*.java" -exec sed -i 's/bug/big fix/' {} \;
I simply need to replace 1 line of code,
The issue is, that this affects also classes that does not contain tat bug, i see that by looking at the java files in svn, right after running my command on the java files icons in eclipse it appears the brows asterisk appears, and if i run a diff, i see that all lines differs, even though i thought not even one line should be modified.
My local working copy is on a windows file system, any advise?
#Aurand is probably right, it sounds like a line-ending issue. Reset the repo, then add the -b option to sed to preserve line endings.

Eclipse project.properties backslash paths considered harmful

I am working in a team that is developing Android software. Some team members use Windows, some use Macs, and I have been known to use Linux. Everyone uses Eclipse.
Eclipse writes a file called project.properties; here's an example. The important part is the last three lines, the android library reference paths.
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-17
android.library.reference.1=../private-code/lib/SomeLibrary
android.library.reference.2=../google-play-services_lib
android.library.reference.3=../FacebookSDK
The above is what the file looks like when Eclipse on Mac or Linux writes it. When Eclipse on Windows writes it, the library reference lines are written with backslashes.
Of course on Windows, backslashes are acceptable path separators. But on Mac and Linux such paths do not work. The thing is, on Windows, forward slashes work perfectly well. So, our policy now is always to commit the file with forward slashes, so that it will work for everyone.
But this is a pain for our Windows users, and it's a pain for the rest of us when the Windows users make a mistake, so I'm looking for a technical solution. I have two ideas:
Find a setting somewhere in Eclipse on Windows, telling it to use forward slashes when saving paths in files like project.properties. (Why the heck isn't that the default?!?)
We use Mercurial, so: install some sort of "hooks" that will solve the problem.
Install a commit hook on the Windows computers, so that the file is committed into the repository with the backslashes replaced by forward slashes.
Install a pull hook on the Mac and Linux computers; so if the file gets committed with backslashes, they get fixed up by the time the files are written.
The commit hook seems cleaner, so if both are available I'd take a commit hook over a pull hook.
I found a Mercurial extension that edits tabs to spaces, which is at least sort of similar to what I want. It's complex enough that I'm a bit leery of trying to modify it into what I need.
https://www.mercurial-scm.org/wiki/CheckFilesExtension
The other strategy is to add a hook that detects backslashes in the paths, and simply aborts the commit, forcing the Windows user to fix the file by hand before committing. That would be better than nothing.
I would keep both versions in the project (as project.properties.windows and project.properties.linux) and create a symbolic link pointing to the right file depending on the OS. Call this symbolic link project.properties and let it be ignored by the version control.
Obviously the disadvantage of this setup is that when windows users update their project.properties file (which points to project.properties.windows), the linux version must be updated manually, and vice-versa, but it doesn't sound like a big deal tho, I presume you don't update this file very often.
- To create the links -
Create a file make_link.sh to setup Linux environments, with the following command:
ln -s $(readlink -m project.properties.linux) $(readlink . -m)/project.properties
Create a file make_link.bat to setup Windows environments, with the following command:
mklink project.properties project.properties.windows
You can commit those scripts as well.
We faced the similar situation due to the path of the local library varies, so after searching a while we found that the best practice to use centralized repository tools (Git for us), "Remove all eclipse dependent/Specific settings files from Repository". And that works fine for us. This way, the change to eclipse settings file will not be effecting the central repository or get committed.

how to parse files using ebrowse

I have a folder tree which contains my C++ files. After reading this document,
http://www.gnu.org/software/emacs/manual/html_node/ebrowse/Generating-browser-files.html#Generating-browser-files
still don't know how to parse all my c++ files in folder tree easily.
I can execute the command below in each folder manually, but looks stupid. I can write some scripts to do it recursively, but want to know any better idea here.
ebrowse *.h
I use ebrowse at work. I don't have my bash alias at hand, but from memory it looks like that:
ebrowse $(find . -name "*.[hc]pp")
Don't hesitate to replace the . with the path to the root of your project.
How about open it in dired buffer, then M-xfind-name-diredRETRET*.ht!ebrowse * ?
In other words: use dired to locate all files you need, then run shell command on them, shell command being ebrowse?
How'bout ebrowse **/*.h **/*.cpp? Don't know which shells support ** nowadays, but at least Zsh has supported it for a decade or two.

Is there a way to replace the diff utility, with another, non-Tcl/Tk diff utility?

I'm using TkCVS as the GUI front-end for a CYGWIN CVS client, on a Windows XP machine.
It's a good compromise, since on my Linux machine I'm also running TkCVS (the same machine running the CVS server, BTW...).
I'm interested in replacing the diff utility (which has a tkdiff.tcl GUI front-end, for TkCVS) with a commercial product (like BeyondCompare or ExamDiff...)
Does anyone have a way to do this?
Thanks!
From a tkcvs faq:
Q4. Can I use a diff tool other than
tkdiff with tkcvs?
A. Yes, by changing cvscfg(tkdiff).
You usually have to write a wrapper
for your diff tool to get it to
check out the versions, and and deal
with its particular command-line
options, which are probably different
from tkdiff's.
In the contrib directory, there is
a gvim-wrapper called "cvsdiff" which
can be used as-is or as a model for
wrapping your favorite diff tool.
what about just using the cvs diff command?
Or download the cvscommand plugin module for vim.