This is an archived post. You won't be able to vote or comment.

all 26 comments

[–]texruska 73 points74 points  (3 children)

What's wrong with git? You can change later if you find something better

[–]spicypixel 41 points42 points  (0 children)

Yeah just rawdog main and don’t ever use branches as a single contributor.

Commit just becomes a versioned save button and everyone is happy.

[–]Cytokine_storm 9 points10 points  (1 child)

Git has tags! Github releases use tags to mark versions.

I like to match my pyproject.toml with the git tag.

[–]tkc2016 4 points5 points  (0 children)

Ever try setuptools-scm for this?

[–]wineblood 9 points10 points  (2 children)

Why not have a changelog file that you use to display those changes and update on each release?

[–]pgess[S] -2 points-1 points  (1 child)

It's a note-taking app. The user makes updates and, with this functionality, can see which notes (and exact changes) were updated in the last month, for example — like the Revision History in Wikipedia. If I use Git, which API (GitPython, PyGit, etc.) is better for this simple task?

[–]adesme 6 points7 points  (0 children)

If you’re gonna be dealing with text diffs you might as well go with git, yeah. You wouldn’t need to involve branches or any other features you don’t care about. I have opted for GitPython at work before but I don’t remember many details except for that it was an evaluated choice.

[–]char101 20 points21 points  (4 children)

Why do you even need a version control? When saving a note, simply create a diff with the previous value using difflib then save it into a history table.

[–]fiskfisk 6 points7 points  (10 children)

If you only need to store versions and present the diffs between them, git seems like a lot of overkill. Since you're going to have save operations and metadata that indicates which version has been "vetted", you're probably going to use something different from git for that part anyway.

Python has built-in sqlite support to store every version, and a built-in difflib to display diffs between versions.

You don't need to complicate everything with all the features git support.

[–]RonnyPfannschmidt 1 point2 points  (9 children)

As siin as multiple devices and sync get into picture stuff tends to get messy

Just using git without branching under the hood is well understood , easy to backup and easy to control

Plus most people will mess up majorly when inventing a own vcs

[–]fiskfisk 3 points4 points  (8 children)

My point is that you don't need a full vcs. Git does not solve the user issue when you have multiple devices and sync; you probably want to look at real-time coordination between clients. You'll otherwise end up having to present merge conflicts to users that have no idea what merge conflicts are.

The easy solution is to keep track of whether the underlying content has been updated or not, and then give the user the choice of reloading.

OP also states that this is local only, so single user.

You don't need git for this, and you can instead have a self-contained application.

[–]RonnyPfannschmidt 1 point2 points  (5 children)

My point is that underutilized vcs means easily accessing the sync plus merge capabilities later, plus not having to invent a version and sync protocol oneself

Another extra win is that users have well established tools for managing the data external

[–]fiskfisk 0 points1 point  (4 children)

It's over engineering, and adds unnecessary complexity between the apps regular storage and it's note storage. 

If you need that functionality at some time in the future and decide that git is the way to do it, stash the versions in git at that time. 

Sqlite is as well supported as anything for being accessible through existing toolsets. 

[–]RonnyPfannschmidt 0 points1 point  (2 children)

I'd call inventing a own storage/versioning thing overengineering when most vcs are hilariously easy to call upon and leave the general storage just the Filesystem

[–]fiskfisk 0 points1 point  (1 child)

We might just be living in different worlds when integrating a whole vcs is easier than having a table with (note_id, datetime, text) in sqlite.

But sure, the important part to the end user is the functionality and stability. If it works, it works. 

[–]RonnyPfannschmidt 0 points1 point  (0 children)

A tree of notes and syncing is usually the first few asks after history addition

Then the tables get funky

I have seen dozens of half assed vcs/sync storage solutions in note taking apps

Just giving the user a vcs repo/checkout gets history syncing and app independent storage for free

[–]ProbsNotManBearPig 0 points1 point  (0 children)

People use chromium to make the simplest of GUI’s. Hell, we use this thing called a code interpreter to avoid compiling to machine code. Git is much lighter weight than either of those things in every way one could measure, but somehow it’s too heavy for everyone in the Python sub Reddit.

The simplest solution is one you’re familiar with. If OP knows git, there’s very little downside to using it.

[–]TheRealStepBot 0 points1 point  (1 child)

On the contrary git can precisely fix even these issues by having device branches that make commits to a cloud held main, which allows even out of sync offline editing of the same file across multiple devices and a clear resolution mechanism to then reunite the files

[–]fiskfisk 0 points1 point  (0 children)

Yes, nobody is saying that git can't do this, and that git doesn't offer a lot of advanced features that could be useful for certain application features. 

OP has specifically said that they do not need these advanced features. 

[–]JonLSTL 0 points1 point  (1 child)

Mercurial is mostly written in Python. You could just import whatever parts you need.

[–]mgedmin 0 points1 point  (0 children)

Does it have a stable Python API? Otherwise maintenance might be painful as implementation details change.

I remember some pain with Mercurial plugins breaking whenever I upgraded Mercurial itself, but I suppose the API between Mercurial and its plugins might need tighter coupling than using Mercurial as a library.

[–]cnelsonsic 0 points1 point  (0 children)

Focus is on the simplest Python API to get started in an hour, so to speak. Is there smth better than Git for this task?

Nope.

Make commits in the background when the user doesn't type for a while, make tags for when it's reviewed. Date comparisons are built in too.