Gedare-Csphd

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Sunday, 14 March 2010

Versioning my work

Posted on 14:07 by Unknown
I've found it helpful to keep around clean and working versions of projects that I edit, especially when I am changing someone else's work.  This is suggested behavior for generating patches for open source projects, but I find it useful for both programming and document editing.

Of course, version control (CVS or subversion) helps, but I don't always want to commit my changes back to the repository. Someday I should also investigate a distributed version control system that lets other users "check out" your branches.  However, most of the projects I work on use cvs and svn. I also like to extract the changes that I've made, in order to keep track of my versions by hand.  This is useful when I reach milestones in projects, and I want to make off-line backups.



My preferred method is to use diff and patch. When I'm planning to create my own patches, I first copy the original project's directory tree. For example, if the project I'm working on is in a directory called "foo", then from the parent directory of foo I will:
>$ cp -lpr foo foo-new
This generates a copy of foo, with hard links instead of copying the files, reducing the storage space overhead.  My editor is configured to break hard links when it saves files, which is done in vim by adding the following to my .vimrc file:
>$ echo "set backupcopy=auto,breakhardlink" >> ~/.vimrc
Now I will leave the foo directory untouched, and do my development work in foo-new.  When I get to some point that I want to make a version patch, just go to the parent of foo-new and:
>$ diff -uprN foo foo-new > foo-new-1.00.patch
>$ ls -la foo-new-1.00.patch
I check the ls output to make sure my patch is a reasonable size. I will also usually open it and make sure it looks right. Then, I can send my patch to someone, or apply it to a copy of foo. I will often test my patch first, for example:
>$ cp -lpr foo foo-test
>$ cd foo-test
>$ patch -p1 < ../foo-new-1.00.patch
This works great for code, but isn't always the best for less well-structured documents. It also can create fairly large .patch text files that can be cumbersome to apply.

If I am creating a lot of new files, or replacing entire files, I will also just generate tar balls of my entire project.  But these can get rather large, and when I really just want the diff, I recently found a way that I can do better.

With tar, I can also just archive the files that have been changed. Then when you untar, only those files are overwritten. The first thing I do is create a "staging area" for the new files in the same parent directory as the foo project:
>$ mkdir foo-stage
Next I copy the directory structure (only the directories!) into the staging area, so that I can put new files in the appropriate directories:
>$ cd foo-stage
>$ (cd ../foo; find -type d ! -name .) | xargs mkdir
 Finally, I will put the new files that I changed in to their appropriate locations in the staging area, and finally I will create a compressed tar (from within foo-stage directory):
>$ tar -zcf ../foo-1.00.tgz .
Finally, to apply the tar to a copy,
>$ cp -lpr foo foo-test
>$ cd foo-test
>$ tar -zxmf ../foo-1.00.tgz
The -m option keeps tar from updating the modified timestamps for directories that are unchanged. This will replace files in foo only with the files that I added to foo-stage.  This method can also be used in conjunction with diff/patch, in which case I would not use the -N option to diff.
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Posted in hacking, linux, VC, work | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • Generating interrupts with a gem5 device
    Today I extended my work of adding a device to gem5 by causing the device to generate an interrupt. Interrupts seem to be architecture-spec...
  • RTEMS Modular Task Scheduler
    As I mentioned in my last post , this past summer I participated in the Google Summer of Code by working on the RTEMS project. I have hopef...
  • Gambler's fallacy
    I was listening to ESPN First Take on Monday ( podcast [mp3] ) and the hosts were debating whether the Falcons should have punted or not on ...
  • Extensible Data Structures in C
    A lot of systems programming code is done in C, primarily because of the exposure of explicit memory addresses, but for other reasons too. ...
  • Red-Black Trees Redux: Left-Right Symmetry
    I previously compared top-down versus bottom-up red-black trees and concluded that bottom-up is faster and therefore preferred. Recently I ...
  • Properly attired yogurt is delicious
    In the grocery store today I impulsively bought some plain yogurt and a box of granola (oats & honey) with the idea—surely not original—...
  • Post 0
    I've been thinking about starting a blog for awhile, but unlike some of my compulsions, I actually followed through this time.  Although...
  • Versioning my work
    I've found it helpful to keep around clean and working versions of projects that I edit, especially when I am changing someone else'...
  • Using partitions as a free list
    Yesterday I discussed my search for some help with implementing a free list in RTEMS . Today I'm glad to say I was able to use partition...
  • Adding a simple io device to gem5
    Last time, I added custom pseudo-instructions in gem5. Today, I add a device in gem5 and then use the device from within a simulated (linux...

Categories

  • cerification
  • computer architecture
  • computer security
  • COO
  • cooking
  • gem5
  • git
  • government
  • GSoC
  • hacking
  • LaTeX
  • life
  • linux
  • lolcat
  • Lua
  • mentorsummit
  • OOP
  • open source software
  • rant
  • research
  • RTEMS
  • science
  • sisu
  • space
  • thesis
  • VC
  • visualization
  • work

Blog Archive

  • ►  2013 (12)
    • ►  October (1)
    • ►  May (3)
    • ►  April (1)
    • ►  February (4)
    • ►  January (3)
  • ►  2012 (12)
    • ►  November (1)
    • ►  October (6)
    • ►  August (1)
    • ►  May (2)
    • ►  April (2)
  • ►  2011 (29)
    • ►  December (5)
    • ►  November (3)
    • ►  October (2)
    • ►  September (2)
    • ►  August (2)
    • ►  July (5)
    • ►  June (2)
    • ►  May (2)
    • ►  April (2)
    • ►  March (2)
    • ►  February (1)
    • ►  January (1)
  • ▼  2010 (19)
    • ►  December (2)
    • ►  November (2)
    • ►  July (3)
    • ►  June (2)
    • ►  May (3)
    • ►  April (2)
    • ▼  March (5)
      • Running your code!
      • Extensible Data Structures in C
      • Introduction to RTEMS
      • Versioning my work
      • Post 0
Powered by Blogger.

About Me

Unknown
View my complete profile