OSDev.org

The Place to Start for Operating System Developers
It is currently Mon Mar 18, 2024 8:47 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Versioning control system
PostPosted: Fri Mar 13, 2020 3:54 pm 
Offline
Member
Member

Joined: Fri Nov 22, 2019 5:46 am
Posts: 590
I've read the Osdev.org wiki about code managment and the Wikipedia article about Revision Control System. Three questions about VCS remain for me:

1.) Is there a simple versioning control system for very small code projects? This is NOT about the best IDE (which is highly subjective and was already discussed in this forum) but about simplicity in its usage.

2.) Is there an easy way to produce a commit/update (or whatever it is called) when I remove a block of code? Maybe even automatically and/or done by the editor/IDE?

3.) Is there a way to upload code blocks when they are removed? I mean there is the old repo and the new repo but can I explicitely collect code blocks which I removed into a repo?

I hope these questions aren't nonsense.

Happy hacking
Peter


Top
 Profile  
 
 Post subject: Re: Versioning control system
PostPosted: Fri Mar 13, 2020 5:29 pm 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 1584
Hi,
PeterX wrote:
I've read the Osdev.org wiki about code managment and the Wikipedia article about Revision Control System. Three questions about VCS remain for me:

1.) Is there a simple versioning control system for very small code projects? This is NOT about the best IDE (which is highly subjective and was already discussed in this forum) but about simplicity in its usage.
I've used cvs, svn, bazaar and git (not familiar with mercurial). I must say git is the best so far, scales pretty well from small codebase to large ones. There's a catch though, it does not handle long history well, so from time to time it is recommended to merge old commits to keep your repo effective (called squash rebase). Cloning even a small repository could be extremely slow if it has many commits. (This also depends on you computer and your network connection of course, but let's say a repo with 10Mb worth of source and over 50000 commits will probably grant you a coffee-break.) For a local repo the number of commits only matters if you switch branches frequently.

PeterX wrote:
2.) Is there an easy way to produce a commit/update (or whatever it is called) when I remove a block of code? Maybe even automatically and/or done by the editor/IDE?
The good thing about git is that you are not forced to use all of its features. You can work on a single master branch if you want to keep it simple. If you're not adding new files just modifying existing ones then a simple 'git commit -a -m "comment"' enough (followed by a 'git push' if you also want to save it remotely). Since git is extremely popular, many editor/IDE has a plugin to make your life even easier. Some supports automatic commits, but I would recommend against those. I think it's better if you create a commit after a particular step is done (which might spread across multiple files), and giving a descriptive comment what the modification is about pays out on the long run (an automatic commit will never give you informative comments).

PeterX wrote:
3.) Is there a way to upload code blocks when they are removed? I mean there is the old repo and the new repo but can I explicitely collect code blocks which I removed into a repo?
The easiest way with git is 'git diff (file)'. This will create a list of removed blocks in a format that the 'patch' command can understand. Not sure about repos (in theory it can compare two repos, but frankly I've never used that feature), but comparing two branches or two particular time in the same branch is a piece of cake. Has a funky command line though, for example you use "HEAD" to refer to the current state, and "HEAD^" to refer to the state before the last commit, "HEAD^^" or "HEAD~2" to the state before the last two commits etc. Other oddities include deletion is ":". That's right, a colon. Thankfully you only need to learn the commands once, and there are only a few you'll need. Also if you prefer there are awesome GUI applications to help you, like gitk, and some of the aforementioned editor/IDE plugins are pretty neat too.

PeterX wrote:
I hope these questions aren't nonsense.

Happy hacking
Peter
Sure they make sense, hope I could help.

Cheers,
bzt


Top
 Profile  
 
 Post subject: Re: Versioning control system
PostPosted: Sun Mar 15, 2020 4:16 pm 
Offline
Member
Member
User avatar

Joined: Mon May 22, 2017 5:56 am
Posts: 811
Location: Hyperspace
I suffer from severe fatigue issues so I can't reliably commit at the point where I have to walk away from the computer. To work around that, I'm planning a versioning file system (actually blocks) as the first part of my OS, to run in Forth interpreters before my OS can even boot. I don't know about finding deleted blocks specifically, but I know I want to be able to look at and search the entire previous state of the filesystem like you can with Plan 9's versioning filesystems. I'm not entirely sure how I'd find deleted code blocks, but given that my files will actually be 1-4KB blocks, I'd be more likely to just not load a blocks I don't want, leaving a little note in the block itself, and write replacement code in other blocks. When I later reuse the block, I'll be able to search history for the note. Or perhaps I could write a little routine to search for points when >50% of the text of a block was changed, or whatever.

_________________
Kaph — a modular OS intended to be easy and fun to administer and code for.
"May wisdom, fun, and the greater good shine forth in all your work." — Leo Brodie


Top
 Profile  
 
 Post subject: Re: Versioning control system
PostPosted: Sun Mar 15, 2020 4:51 pm 
Offline
Member
Member

Joined: Fri Nov 22, 2019 5:46 am
Posts: 590
I had a backup and cvs procedere. I copied all my files on an USB stick. Including snippets I removed from my code which provided certain functionality. I was very satisfied with it...until I trashed my USB stick!

So I, too, decided to implement an own CVS. But that brought me to the idea of some deeper software solutions that could be used as a base for several tasks, one task being CVS.
So I currently have my Asm bootloader and the mentioned software solution as projects. I think that's not too big a distraction. If I ever should feel overwhelmed or disturbed by these two project I will stick to the bootloader.

Greetings
Peter


Top
 Profile  
 
 Post subject: Re: Versioning control system
PostPosted: Sun Mar 15, 2020 5:52 pm 
Offline
Member
Member
User avatar

Joined: Mon May 22, 2017 5:56 am
Posts: 811
Location: Hyperspace
PeterX wrote:
I had a backup and cvs procedere. I copied all my files on an USB stick. Including snippets I removed from my code which provided certain functionality. I was very satisfied with it...until I trashed my USB stick!

Ouch! :mrgreen: I don't keep stuff on USB sticks for that very reason. One of git's best features (in a way) is github, because it's free offsite backup. There are other services, of course. Even Fossil has a free code hosting service. You might like Fossil, it's simpler than Git or Hg and is designed to have a single authoritative source like CVS & SVN. Lack of free offsite backup is my biggest concern with my scheme, but I can push the blocks to multiple machines easily enough. I suppose I could auto-commit & push to some SCM host from one of the machines I push to.

_________________
Kaph — a modular OS intended to be easy and fun to administer and code for.
"May wisdom, fun, and the greater good shine forth in all your work." — Leo Brodie


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: DotBot [Bot] and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group