alex / pyvcs

A pure python abstraction layer of multiple VCS, very lightweight.
BSD 3-Clause "New" or "Revised" License
127 stars 10 forks source link

multiple issues with git backend #12

Open swilcox opened 14 years ago

swilcox commented 14 years ago

This is a fix for multiple issues (both 9 and 10) related the git backend of pyvcs.

The primary way to see the issue(s) has been to create a new empty git repo and then perform a couple of adds/commits on some new files. I pulled in pbiggar's changes to handle not blowing up upon hitting a commit with no parent and fixing the deprecation warnings. I fixed the long line.

Like issue 11 (with the hg backend), there is also a problem with showing the diff of the first commit because it then defaulted to comparing that commit to the current HEAD instead of to an empty file set of empty files.

I essentially created a new special name for this situation and called it 'NULL'. So when diff'ing a commit that has no parent, it now uses 'NULL' as the "name" for the commit instead of None (which would get the HEAD). So viewing the first commit in history now correctly shows the add of files and their contents... because it's now comparing them to empty filesets.

But None still works correctly in the case of just getting the contents of a file without a commit id/name (i.e. getting the latest and greatest). With this change, both the hg and git backends will now behave identically with regard to commits without parents.

swilcox commented 14 years ago

I've added some test stuff,

tests/simple_git_tests.py
tests/setup_git_test.sh
tests/teardown_git_test.sh

This is obviously not the comprehensive suite everyone would want, but it does (in a posix) environment exercise the git backend in a fairly generic way without referring to someone's specific repo since it actually creates a repo, modifies it, runs the tests and then destroys it. Hate that I had to use shell scripts, but for something quick, this seemed like the only practical thing to do until someone creates something better.