Showing posts with label Software Development. Show all posts
Showing posts with label Software Development. Show all posts

Thursday, May 28, 2020

Writing useful commit comments

Some thoughts on writing useful [concise, descriptive, contextual] commit comments. Applies to all SCM systems (Git, Subversion, etc.)

A properly formed Git commit subject line should always be able to complete the following sentence:

  • If applied, this commit will your subject line here
For example:
  • If applied, this commit will refactor subsystem X for readability
  • If applied, this commit will update getting started documentation
  • If applied, this commit will remove deprecated methods
  • If applied, this commit will release version 1.0.0
  • If applied, this commit will merge pull request #123 from user/branch
Chris Beam

Wednesday, April 3, 2019

How to Roll Back (revert) an SVN commit

Crap. My last commit in Subversion broke Jenkins. How do I undo it?

Sometimes TortoiseSVN gives us too much of a good thing. There are several options with similar names for "reverting" and "updating" files in Subversion, and I can never keep them straight, thus another post that tries to sum up the options and their effects.

First, just a simple "undo":

Revert a single file:
  1. Right-Click -> TortoiseSVN -> Show log
  2. Find the revision/changeset you want to rollback to (i.e. the revision just before the change you want to remove)
  3. Right-click on the single file in the list of files -> Revert to this Revision
Revert the entire changeset:
  1. Right-Click -> TortoiseSVN -> Show log. 
  2. Find the revision/changeset you want to rollback to
  3. Right-click on that revision -> Revert to this Revision
(Paraphrased from eduncan911's lucid instructions in this post on Stack Overflow)

Wait a minute. The context menu in TortoiseSVN (1.9.7.x) shows three similar commands when selecting a revision in the list:
  1. Update item to revision
  2. Revert to this revision
  3. Revert changes from this revision
and just the last one, "Revert changes from this revision," when selecting an item in the list of files.

What???

Here's what each "Revert" option does, according to JB Nizet again on Stack Overflow:
Let's say you have these N successive commits: 1, 2, 3 and 4.
If you select the commit 2 and choose "Revert to this revision", your working copy will contain the changes brought by commits 1 and 2. Commits 3 and 4 will be "canceled".
If you select the commit 2 and choose "Revert changes from this revision", your working copy will contain the changes brought by commits 1, 3 and 4. Commit 2 will be "canceled", or rather, played in reverse on the top of commit 4: if a line was added, it will be removed. If a line was removed, it will be re-added.
(Emphasis and spelling corrections are mine)

So it would follow that either option has the same effect when undoing just the last commit on a file.

How about "Update item to revision" vs "Revert to this revision"? Here's Peter Parker's explanation on Stack Overflow:
Update to revision will only update files of your working copy to your chosen revision. But you cannot continue to work on this revision, as SVN will complain that your working copy is out of date.
revert to this revision will undo all changes in your working copy which were made after the selected revision (in your example rev. 96,97,98,99,100) Your working copy is now in modified state.
The file content of both scenarios is same, however in first case, you have an unmodified working copy and you cannot commit your changes (as your working copy is not pointing to HEAD rev 100), in second case you have a modified working copy pointing to head and you can continue to work and commit
(spelling and punctuation corrections are mine)

Monday, February 2, 2009

jEdit delete duplicate lines

In jEdit's Search and Replace dialog, select "Regular Expressions",  then Search for:
^(.\*)$\n\1

replace with:
$1

This tells jEdit to

  • start at the beginning of a line ^

  • find any characters, spaces, etc .*

  • up to the end of the line $

  • including a carriage return \n

  • that matches the text on the following line \1

  • then replace it with just the first matched line $1


The result is any lines that are duplicated will be replaced with just a single copy of the line.

Thursday, September 4, 2008

TLDs for TLC

Thanks to "Jon", who pointed out that the Top Level Domain (TLD) example.org is reserved for those times when you need a bogus domain for testing or documentation. Go ahead, click it!

Even better, under RFC 2606 four TLDs are reserved for your testing and documentation pleasure. To quote the RFC:






















TLDPurpose
.testtesting of current or new DNS related code
.exampledocumentation or examples
.invalidonline construction of domain names that are sure
to be invalid and which it is obvious at a glance are invalid
.localhostloop back

Sunday, May 11, 2008

Deleting the .ncb file fixes Intellisense Crash in VS 2008 Express

Argh! Visual Studio 2008 Express was crashing every time I right-clicked on any code belonging to the C++ template class declaration I was writing for my C++ course assignment. Googling "2008 intellisense crash" turned up a link to an MSDN forum discussion about VS crash when updating intellisense, wherein one of the posters suggested deleting the .ncb file. Before launching my project for the nth time, I deleted the .ncb file. Voila! Intellisense works again.

Thursday, May 1, 2008

What did I just edit?

I checked out some code files from Razor (don't ask, we use an old CM system), created a couple of new ones, now I want to quickly double-check which of the thousands of files in our source tree are the ones I checked out or created (don't ask, we use an old CM system), so I can check the changes back in and introduce the new files (if I forget, guess who gets the wooden spoon for breaking the build):



So fire up a DOS prompt and type in:


C:\path to my code\>dir *.cpp *.h *.vcproj
/b /s /a:-r > \usafipd\updated_files.txt



This says "list all of the code files and Visual Studio project files from here on down that are writeable (i.e. not locked by Razor), then dump the results to a file in case there are hundreds of filenames to review.


This gives me a file, updated_files.txt, containing a nice list of all the .cpp, .h and .vcproj (Visual Studio project) files I checked out (i.e. made writeable).

Friday, April 11, 2008

Another evaluation of Google AppEngine

Todd Hoff explains how distributed web apps can leverage the much-maligned CGI interface in Google AppEngine - A First Look

Web app hosting as a service?

Kevin Yank opins on the effect services like Google's App Engine may have on web hosting choices. By abstracting away the details of configuring and deploying web apps for a particular host system, services like App Engine and Heroku may give developers more time to concentrate on providing business value (creating applications instead of fighting with servers). The greatest benefit may accrue to independent developers, students and hobby developers, who haven't the time, money or server-fu to set up and administer their own dedicated server, virtual or otherwise.

Monday, March 10, 2008

Your loops got game?

Koen deWitters published an article on game loop design that should be of interest to anyone who designs software. He explains not only how to design a game loop, but why one technique is better than another, with simple, clear examples.

Monday, February 4, 2008

Small C++ Project, huge .ncb file?

I'm taking COMP 2617 C++ for Object Oriented Software Development at BCIT, and using Microsoft Visual C++ 2008 Express Edition to do my homework. Pretty sweet little IDE, lots of Pro VS 2005 goodness for free!

But - why does the .ncb file (Intellisense parser database) for my dinky little C++ program, all of 160 lines in one 5Kb .cpp file, weigh in at over 2Mb?! According to Li Shao in this thread on the MSDN forum, "In VS2005, we have made change to remove this prebuilt ncb and dynamically parsed the files including the system headers into project ncb.", in response to the original poster, who complained that "... an NCB file of 50KB under VS 2003 now has 500-600 KB, a 200 KB NCB under VS 2003 now has about 2 MB. And NCB files that used to have a size of 2-3MB now have 25-30 MB." Sheesh! This is progress?

Thursday, January 10, 2008

Diffing where I want, and diffing the same file

I use WinMerge a lot for general interactive file diff/merge/munging. It's great, free, etc. But what I'd really like is a diff tool that a) lets *me* decide which bits in each buffer match up as the starting point, and b) let me compare two sections of the same file. Does this exist? Please let me know. Please.

Thursday, June 21, 2007

Config files

On a recent project at work, developing a test automation system on top of TestComplete, we tried two ways to store machine-specific configuration data:

  1. One file, shared by all installations, containing a section per machine

  2. One file per machine


At first I had set up a single config file specific to my development PC. When my team mate Alan picked up on the idea, to put some machine-specific data on his system, he created a global config file containing a section per machine. His reasoned that one file, with some common and some machine-specific sections, was more efficient than a collection of files with high redundancy.

The config files contained data specific to each developer or test instance, such as usernames and passwords on the system under test. We needed this data in first place to prevent clashes between developers as we exercised the system.

What we ultimately settled on was separating the single global config file back into one-per-machine. Even though we were following good development practice by using a svn repository, so no-one's edits would get lost or forgotten, we realized that once the project ramped up to 3 or 4 development machines, plus a couple of production servers, that config file would become a pumpkin.