]> arthur.barton.de Git - bup.git/log
bup.git
13 years agoRename _faster.so to _helpers.so. bup-0.17
Avery Pennarun [Mon, 23 Aug 2010 03:27:03 +0000 (20:27 -0700)]
Rename _faster.so to _helpers.so.

Okay, _faster.so wasn't a good choice of names.  Partly because not
everything in there is just to make stuff faster, and partly because some
*proposed* changes to it don't just make stuff faster.  So let's rename it
one more time.  Hopefully the last time for a while!

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agolib/bup/ssh: Add docstrings
Gabriel Filion [Mon, 16 Aug 2010 01:29:34 +0000 (21:29 -0400)]
lib/bup/ssh: Add docstrings

Document the code with doctrings.

Also add an "import sys" line since it is used by sys.argv[0] on line 6.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
13 years agolib/bup/options: Add docstrings
Gabriel Filion [Mon, 16 Aug 2010 01:29:33 +0000 (21:29 -0400)]
lib/bup/options: Add docstrings

Document the code with docstrings.

Use one line per imported module as recommended by PEP 8 to make it
easier to spot unused modules.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
13 years agoimport cleanup
Gabriel Filion [Mon, 16 Aug 2010 01:29:29 +0000 (21:29 -0400)]
import cleanup

Remove unused imported modules.

I started using the pyflakes.vim plugin and it automagically shows a
bunch of problems/uncleanliness in the code. It helped me pull this out
in 15mins.

This change shouldn't have any impact on performance or functionality
but it makes the code cleaner.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
13 years agocmd/ftp: don't die if we can't import the ctypes module.
Avery Pennarun [Sun, 22 Aug 2010 06:44:49 +0000 (23:44 -0700)]
cmd/ftp: don't die if we can't import the ctypes module.

It's only needed on some rare broken versions of readline anyway.  If we
can't find the module, chances are the system doesn't have that broken
version of readline.

Based on suggestions by Gabriel Filion and Aaron Ucko.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agolib/bup/vfs: bring back Python 2.4 support
Gabriel Filion [Fri, 20 Aug 2010 06:24:57 +0000 (02:24 -0400)]
lib/bup/vfs: bring back Python 2.4 support

There is currently one test failure when running tests against Python
2.4: a try..except..finally block that's interpreted as a syntax error.
The commit introducing this incompatibility with 2.4 is f77a0829

This is a well known python 2.4 limitation and the workaround, although
ugly, is easy.

With this test passing, Python 2.4 support is back.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
13 years agolib/bup/vfs: Add docstrings
Gabriel Filion [Mon, 2 Aug 2010 06:20:06 +0000 (02:20 -0400)]
lib/bup/vfs: Add docstrings

Since the vfs module uses the function git._treeparse, it should not be
named as if it was a private function. Rename git._treeparse to
git.treeparse and document it (add a docstring to it).

Also, transform _ChunkReader, _FileReader and Node into new-style
classes.

Finally, remove trailing spaces from lib/bup/vfs.py .

13 years agoDESIGN: update mentions of stupidsum to reflect new rollsum algorithm.
Avery Pennarun [Mon, 2 Aug 2010 03:01:56 +0000 (23:01 -0400)]
DESIGN: update mentions of stupidsum to reflect new rollsum algorithm.

Pointed out by Gabriel Filion.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agoREADME: typo.
Avery Pennarun [Sun, 1 Aug 2010 15:18:23 +0000 (11:18 -0400)]
README: typo.

Noticed by Zoran Zaric.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agocmd/save: update the progress meter less often.
Avery Pennarun [Sat, 31 Jul 2010 06:33:38 +0000 (02:33 -0400)]
cmd/save: update the progress meter less often.

If you ran 'bup save' in an ssh sessio, you could end up sending huge
amounts of data back over ssh *just* to update the progress meter after
every single block!  Oops.  Limit the updates to only about 5 per second,
which is much better.

13 years agoRename _hashsplit.so to _faster.so, and move bupsplit into its own source file.
Avery Pennarun [Sat, 31 Jul 2010 00:23:08 +0000 (20:23 -0400)]
Rename _hashsplit.so to _faster.so, and move bupsplit into its own source file.

A lot of stuff in _hashsplit.c wasn't actually about hashsplitting; it was
just a catch-all for all our C accelerator functions.  Now the module name
reflects that.

Also move the bupsplit functions into their own non-python-dependent C
source file so they can be used as part of other projects.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agotest.sh: check the return code of 'bup random'
Avery Pennarun [Sat, 31 Jul 2010 00:17:15 +0000 (20:17 -0400)]
test.sh: check the return code of 'bup random'

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agocmd/{random,memtest}: use the new options.py default value support.
Avery Pennarun [Wed, 28 Jul 2010 06:37:38 +0000 (02:37 -0400)]
cmd/{random,memtest}: use the new options.py default value support.

13 years agooptions.py: support for putting default values in [square brackets].
Avery Pennarun [Fri, 16 Jul 2010 06:45:33 +0000 (02:45 -0400)]
options.py: support for putting default values in [square brackets].

This looks good in the usage message, and is a better place to hardcode such
things than in the code itself.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years ago_hashsplit.c: get rid of some warnings indicated by a C++ compiler.
Avery Pennarun [Tue, 27 Jul 2010 07:05:55 +0000 (03:05 -0400)]
_hashsplit.c: get rid of some warnings indicated by a C++ compiler.

Not hugely important, but might as well fix them.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years ago_hashsplit.c: replace the stupidsum algorithm with rsync's adler32-based one.
Avery Pennarun [Tue, 27 Jul 2010 05:27:54 +0000 (01:27 -0400)]
_hashsplit.c: replace the stupidsum algorithm with rsync's adler32-based one.

I've been meaning to do this for a while, but a particular test dataset that
really caused problems with stupidsum() (ie. it split things into way more
chunks than it should have) finally screwed me over.  Let's change over to a
"real" checksum algorithm.

Non-annoying datasets shouldn't be noticeably affected, but bad ones (such
as my test case from EQL Data) can be 10x more sensible.  Typical backup
sets now have about 20% fewer chunks, although this has little affect on the
overall repository size.

WARNING: After this patch, all your chunk boundaries will be different from
before!  That means your incremental backups won't be terribly incremental
and your backup repositories will jump in size.  This should only happen
once.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years ago_hashsplit.c: switch rollsum_roll() to a macro instead of an inline function.
Avery Pennarun [Tue, 27 Jul 2010 07:06:26 +0000 (03:06 -0400)]
_hashsplit.c: switch rollsum_roll() to a macro instead of an inline function.

gcc 4.3's optimizer manages to fail at optimizing the inline, but works okay
with the macro.

Mysteriously, if find_ofs() is *not* static (and therefore presumably
*harder* to optimize), the optimizer works either way.  But removing the
static is just wrong, so use the macro instead.

The difference in speed is about 53 megs/sec vs 80 megs/sec on my machine
for this command:

bup random 100M 2>/dev/null | bup split -N --bench

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years ago_hashsplit.c: refactor a bit, and add a self-test.
Avery Pennarun [Tue, 27 Jul 2010 04:49:20 +0000 (00:49 -0400)]
_hashsplit.c: refactor a bit, and add a self-test.

In preparation for replacing the stupidsum algorithm with the rsync
adler32-based one.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agomake clean: remove some leftover files.
Avery Pennarun [Wed, 28 Jul 2010 04:43:11 +0000 (00:43 -0400)]
make clean: remove some leftover files.

Stuff has moved around a bit recently, and we weren't cleaning up everything
like we should.

13 years agocmd/web: hide .dotfiles by default
Gabriel Filion [Tue, 27 Jul 2010 18:02:36 +0000 (14:02 -0400)]
cmd/web: hide .dotfiles by default

Make all files begining with a dot be hidden by default. The hidden
files can be shown by giving the argument "hidden" with a vlue of 1 in
the URL.

Also, in _compute_dir_contents, remove the line "contents = []" since it
is never used.

Finally add a "Show/Hide hidden files" link on the pages where content
is hidden.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
13 years agocmd/ftp: exit cleanly on Ctrl-C
Gabriel Filion [Tue, 27 Jul 2010 17:28:49 +0000 (13:28 -0400)]
cmd/ftp: exit cleanly on Ctrl-C

bup ftp currently does not handle KeyboardInterrupt exceptions.

Simply call handle_ctrl_c() at the beginning of the file to make the
command exit without a stacktrace.

13 years agocmd/ftp: Hide .dotfiles by default (-a shows them)
Gabriel Filion [Tue, 27 Jul 2010 03:52:34 +0000 (23:52 -0400)]
cmd/ftp: Hide .dotfiles by default (-a shows them)

Normally in FTP sites, files beginning with a dot are hidden from a list
(ls) command by default. Also, using the argument '-a' makes the list
show hidden files.

The current 'bup ftp' implementation does not behave so. Make it hide
hidden files by default, as expected, and show hidden files when '-a' or
'--all' is specified to the 'ls' command.

All unknown switches will make bup ftp show the ls command usage.

Users can also give 'ls --help' to obtain the usage string.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
13 years agolib/options: Add an onabort argument to Options()
Gabriel Filion [Tue, 27 Jul 2010 03:52:33 +0000 (23:52 -0400)]
lib/options: Add an onabort argument to Options()

Some times, we may want to parse a list of arguments and not have the
call to Options.parse() exit the program when it finds an unknown
argument.

Add an argument to the class' __init__ method that can be either a
function or a class (must be an exception class). If calling the
function or class constructor returns an object, this object will be
raised on abort.

Also add a convenience exception class named Fatal that can be
passed to Options() to exclusively catch situations in which
Options.parse() would have caused the program to exit.

Finally, set the default value to the onabort argument to call
sys.exit(97) as was previously the case.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
13 years agocmd/ftp: if completion fails due to FileNotFound, just eat it.
Gabriel Filion [Tue, 27 Jul 2010 07:24:23 +0000 (03:24 -0400)]
cmd/ftp: if completion fails due to FileNotFound, just eat it.

Just as bash would do, if you're trying to complete a filename that doesn't
exist, just don't offer any completions.  In this case, it only happens if
you try to complete through a broken symlink.

Now that we've fixed this case, enable the printing of exception tracebacks
in case of *other* kinds of completion errors, since we don't expect there
to be any.

[Committed by apenwarr based on an unofficial patch from Gabriel]

13 years agoAdd a mode argument to mkdirp. bup-0.16
Rob Browning [Mon, 26 Jul 2010 03:11:36 +0000 (22:11 -0500)]
Add a mode argument to mkdirp.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
13 years agoDon't specify a user or group during "make install".
Rob Browning [Mon, 26 Jul 2010 03:11:35 +0000 (22:11 -0500)]
Don't specify a user or group during "make install".

This makes it possible to install bup as a normal user.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
13 years agoRemove Makefile lines that only contain a tab.
Rob Browning [Mon, 26 Jul 2010 03:11:34 +0000 (22:11 -0500)]
Remove Makefile lines that only contain a tab.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
13 years agocmd/ftp: don't let people cd into a non-directory.
Avery Pennarun [Mon, 26 Jul 2010 04:52:41 +0000 (00:52 -0400)]
cmd/ftp: don't let people cd into a non-directory.

This bug was relatively harmless (since you could also cd back out again)
but kind of weird.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agovfs: resolve absolute symlinks inside their particular backup set.
Avery Pennarun [Mon, 26 Jul 2010 04:50:59 +0000 (00:50 -0400)]
vfs: resolve absolute symlinks inside their particular backup set.

Let's say you back up a file "/etc/motd" that's a symlink to
"/var/run/motd".  The file inside the backup repo is actually
/whatever/latest/etc/motd, so the symlink should *actually* point to
/whatever/latest/var/run/motd.  Let's resolve it that way automatically in
Symlink.dereference().

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agovfs: try_lresolve() was a bad idea. Create try_resolve() instead.
Avery Pennarun [Mon, 26 Jul 2010 04:30:29 +0000 (00:30 -0400)]
vfs: try_lresolve() was a bad idea.  Create try_resolve() instead.

Also add some comments to describe the actual differences between resolve()
and lresolve(), and clean things up a bit so that they actually work as
they're supposed to.

Basically, all of lresolve(), resolve(), and try_resolve() depend on
*intermediate* paths being resolvable; all of them will throw an exception
if not.  They only differ in the very last node in the path, when that node
is a symlink:

  resolve() will dereference it or throw an exception if it can't;
  try_resolve() will try to dereference it, but return self if it can't;
  lresolve() will not dereference it at all, like lstat() doesn't.

With that in mind, we can fix up cmd/ftp and cmd/web to use the right calls,
thus fixing an unexpected error in ftp's tab completion reported by Gabriel
Filion, which would happen if you tried to tab complete inside a directory
that contained a broken symlink.  We only care what the symlink points to so
we can decide whether or not to append '/' to the tab completion, so we want
it to fail silently if it's going to fail.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agofix helpers.columnate bug when list is empty
Gabriel Filion [Sun, 25 Jul 2010 17:34:13 +0000 (13:34 -0400)]
fix helpers.columnate bug when list is empty

When the list given to the columnate function is empty, the function
raises an exception when determining the max(len of all elements), since
the list given to max is empty.

One indirect example of when this bug is apparent is in the 'bup ftp'
command when listing an empty directory:

    bup> ls backupname/latest/etc/keys
    error: max() arg is an empty sequence

Add a special condition at the beginning of the columnate function that
returns an empty string if the list of elements is empty.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
13 years agoIgnore vim's .sw? files.
Peter McCurdy [Fri, 23 Jul 2010 22:07:12 +0000 (18:07 -0400)]
Ignore vim's .sw? files.

Vim names its temp files .filename.sw?.  Let's ignore them.

Signed-off-by: Peter McCurdy <petermccurdy@alumni.uwaterloo.ca>
13 years agocmd/web: don't die if lresolve() fails.
Avery Pennarun [Fri, 23 Jul 2010 07:24:34 +0000 (03:24 -0400)]
cmd/web: don't die if lresolve() fails.

Some symlinks end up pointing to nonexistent names, which is maybe not
"normal", but certainly is allowed.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agoConvert 'bup web' directory listing to use tornado templates.
Joe Beda [Fri, 23 Jul 2010 07:10:36 +0000 (00:10 -0700)]
Convert 'bup web' directory listing to use tornado templates.

This includes creating a new idea of a "resource path" that currently sits
under the lib dir. Getting resources is supported with a new helper
(resource_path).

Signed-off-by: Joe Beda <joe@bedafamily.com>
13 years agoDefault 'bup web' to serving on localhost only.
Joe Beda [Thu, 22 Jul 2010 07:14:45 +0000 (00:14 -0700)]
Default 'bup web' to serving on localhost only.

Also make command output match man page.

Signed-off-by: Joe Beda <joe@bedafamily.com>
13 years agoInstall our copy of tornado into /usr/lib/bup/tornado.
Joe Beda [Thu, 22 Jul 2010 07:14:44 +0000 (00:14 -0700)]
Install our copy of tornado into /usr/lib/bup/tornado.

Signed-off-by: Joe Beda <joe@bedafamily.com>
13 years agoweb: Make output follow html4 standard
Gabriel Filion [Wed, 21 Jul 2010 02:45:36 +0000 (22:45 -0400)]
web: Make output follow html4 standard

Add a doctype to specify which HTML version to use, in our case use the
HTML4.01 transitional doctype.

Close the second <th> tag so that it doesn't appear as 3 columns.

Add a charset definition in the head of the document.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
13 years agoweb: Lowercase tags in output
Gabriel Filion [Wed, 21 Jul 2010 02:45:35 +0000 (22:45 -0400)]
web: Lowercase tags in output

For stylistic preference, lowercase all tags in the output sent from bup
web.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
13 years agoUpdate tornado to revision ad104ffb41
Gabriel Filion [Tue, 20 Jul 2010 22:42:26 +0000 (18:42 -0400)]
Update tornado to revision ad104ffb41

The file lib/tornado/escape.py was forcing users to install a json
library even though "bup web" doesn't use any json functionality.

An issue was opened upstream:

http://github.com/facebook/tornado/issues/closed#issue/114

and the day after it was opened, a fix was committed for it.

Update to the latest revision of tornado so that we can remove a
dependency on json/simplejson.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
13 years agoConvert web-cmd to use Tornado.
Peter McCurdy [Sat, 17 Jul 2010 04:16:09 +0000 (00:16 -0400)]
Convert web-cmd to use Tornado.

Pleasantly, this mostly just involved deleting code, with a few tweaks.

Signed-off-by: Peter McCurdy <petermccurdy@alumni.uwaterloo.ca>
13 years agoAdd Tornado framework from git, commit 7a30f9f6
Peter McCurdy [Sat, 17 Jul 2010 04:14:48 +0000 (00:14 -0400)]
Add Tornado framework from git, commit 7a30f9f6

I just took the tornado/tornado directory, along with the README.

I'm using tornado's git commit 7a30f9f6eac9aa0cf295b078695156776fd050ce,
since recent versions of Tornado have support for specifying which
address you want to listen to.

Signed-off-by: Peter McCurdy <petermccurdy@alumni.uwaterloo.ca>
13 years agoAdded breadcrumb navigation to bup-web.
Zoran Zaric [Fri, 16 Jul 2010 18:37:58 +0000 (20:37 +0200)]
Added breadcrumb navigation to bup-web.

Signed-off-by: Zoran Zaric <zz@zoranzaric.de>
13 years agogit.py: use close_fds=True when starting git cat-file.
Avery Pennarun [Thu, 15 Jul 2010 23:15:06 +0000 (19:15 -0400)]
git.py: use close_fds=True when starting git cat-file.

Otherwise git could inherit some other file descriptors we're using.  This
is particularly relevant in cmd/web, and particularly when applying
pmccurdy's patches to use Tornado.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agoAdd docstrings to lib/bup/helpers.py
Gabriel Filion [Thu, 15 Jul 2010 00:06:17 +0000 (20:06 -0400)]
Add docstrings to lib/bup/helpers.py

Since the split_path function was only used in one place, also move the
function inside this file (lib/bup/index.py).

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
13 years agoAll HTML attribute values should be enclosed by doublequotes.
Zoran Zaric [Wed, 14 Jul 2010 08:02:37 +0000 (10:02 +0200)]
All HTML attribute values should be enclosed by doublequotes.

Signed-off-by: Zoran Zaric <zz@zoranzaric.de>
13 years agoClosing a UL-tag doesn't make sense here, the TABLE-tag has to be closed.
Zoran Zaric [Wed, 14 Jul 2010 08:02:36 +0000 (10:02 +0200)]
Closing a UL-tag doesn't make sense here, the TABLE-tag has to be closed.

Signed-off-by: Zoran Zaric <zz@zoranzaric.de>
13 years agoMove t/*.py to lib/bup/t/*.py.
Avery Pennarun [Wed, 14 Jul 2010 06:59:03 +0000 (02:59 -0400)]
Move t/*.py to lib/bup/t/*.py.

Since the tests in that directory are all tests of lib/bup/*.py anyway,
this is a more consistent location for them.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agoclient.py: raising a particular rare exception caused a syntax error.
Avery Pennarun [Wed, 14 Jul 2010 06:31:44 +0000 (02:31 -0400)]
client.py: raising a particular rare exception caused a syntax error.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agoUpdate to latest wvtest.py, wvtest.sh, and wvtestrun from wvtest project.
Avery Pennarun [Wed, 14 Jul 2010 06:28:22 +0000 (02:28 -0400)]
Update to latest wvtest.py, wvtest.sh, and wvtestrun from wvtest project.

Imported from wvtest commit a975b39ddcca5c894e2e2b656b8e28c11af36f47.

Because of changes to wvtest.py's chdir() handling, had to make some slight
changes to filenames used by the bup tests themselves - all changes for the
better.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agocmd/web: print a nicer message if we can't bind the socket.
Avery Pennarun [Tue, 13 Jul 2010 20:24:56 +0000 (16:24 -0400)]
cmd/web: print a nicer message if we can't bind the socket.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agocmd/web: tiny fix to make redirects work with Firefox. bup-0.15b
Gabriel Filion [Mon, 12 Jul 2010 06:23:24 +0000 (02:23 -0400)]
cmd/web: tiny fix to make redirects work with Firefox.

Firefox honours Content-Length even for 301 redirects, so if the field isn't
provided, it assumes there's an unlimited amount of data and just hangs.

Also fixed a typo in the man page.

13 years agoAdd new 'bup web' command.
Joe Beda [Sun, 11 Jul 2010 23:33:36 +0000 (16:33 -0700)]
Add new 'bup web' command.

'bup web' starts a web server that allows one to browse the bup repository
from a web browser.

Also reorganized version-cmd to allow easy access to bup version from other
places.

Signed-off-by: Joe Beda <joe@bedafamily.com>
13 years agooptions.py: differentiate unset and set-to-negative options.
Brandon Low [Sat, 10 Jul 2010 18:21:53 +0000 (11:21 -0700)]
options.py: differentiate unset and set-to-negative options.

Unset options will still be None, but options explicitly set to a negative
will now be 0. This doesn't change semantics for anything currently in bup,
but it could be useful later when applying defaults.

While we're here, clean up the option parsing code to make it
very slightly more efficient.

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agocmd/split: minor correction to an error message.
Brandon Low [Fri, 9 Jul 2010 06:05:32 +0000 (23:05 -0700)]
cmd/split: minor correction to an error message.

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agocmd/ftp: only import readline if necessary.
Avery Pennarun [Fri, 9 Jul 2010 17:47:16 +0000 (13:47 -0400)]
cmd/ftp: only import readline if necessary.

Apparently on some systems (Mandriva and Slackware at least), importing
the readline library can print some escape sequences to stdout, which screws
things up with the unit tests that run 'bup ftp "cat filename"' and expect
it to be the right data.

Thanks to Eduardo Kienetz for noticing and helping to track down the problem
since I couldn't reproduce it.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agovfs: File.open() needs to do a seek(0) on the cached FileReader.
Avery Pennarun [Fri, 9 Jul 2010 04:38:32 +0000 (00:38 -0400)]
vfs: File.open() needs to do a seek(0) on the cached FileReader.

Otherwise if you open a file, read through it, and close it, then do it
again, you'll get zero bytes the second time.

To make this efficient, change seek() to not discard its _chunkiter every
single time; instead, keep the _chunkiter around until trying to read() from
a location that *isn't* the current offset.  Now seeking around in the file
is cheap.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agoUse common env utility rather than hard coded location for bash
Brandon Low [Fri, 9 Jul 2010 03:16:10 +0000 (20:16 -0700)]
Use common env utility rather than hard coded location for bash

13 years agoREADME: one less reason that we suck. bup-0.15a
Avery Pennarun [Wed, 7 Jul 2010 18:09:41 +0000 (14:09 -0400)]
README: one less reason that we suck.

bup fuse and bup ftp can rejoin large files nowadays, so remove that
limitation from the README.

Reported by koo5 @ github.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agoREADME improvement.
koom [Wed, 7 Jul 2010 17:09:01 +0000 (19:09 +0200)]
README improvement.

Be more specific about how to update the remote PATH.

13 years agoInline git.cat() inside server-cmd.py
Gabriel Filion [Fri, 25 Jun 2010 08:07:03 +0000 (04:07 -0400)]
Inline git.cat() inside server-cmd.py

Since the cat() function in git.py is used only inside the server-cmd.py
script, and since it is a discouraged use of CatPipe, inline the code
inside the server-cmd.py script.

At the same time, make the CatPipe object persistent between calls to
the "cat" command to remove unnecessary deletion/creation or resources.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
13 years agoRemove trailing spaces from git.py
Gabriel Filion [Fri, 25 Jun 2010 08:07:02 +0000 (04:07 -0400)]
Remove trailing spaces from git.py

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
13 years agobup-fuse.1: mention how to unmount the filesystem when we're done.
Avery Pennarun [Sat, 26 Jun 2010 03:36:04 +0000 (23:36 -0400)]
bup-fuse.1: mention how to unmount the filesystem when we're done.

Based on a question from the mailing list.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agovfs: correctly handle reading small files.
Avery Pennarun [Fri, 25 Jun 2010 17:13:49 +0000 (13:13 -0400)]
vfs: correctly handle reading small files.

After the recent change to let vfs seek around in files, we broke support
for files that were only one chunk.  Fix it up, then add some unit tests to
detect such mistakes in the future.

Also, 'bup ftp' now returns nonzero if it catches any exceptions during
execution, making it more suitable for use in scripts... such as the unit
tests :)

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agocmd/random: support lengths that aren't a multiple of 1k.
Avery Pennarun [Fri, 25 Jun 2010 17:12:29 +0000 (13:12 -0400)]
cmd/random: support lengths that aren't a multiple of 1k.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agoMakefile: allow PYTHON variable to override python version.
Gabriel Filion [Fri, 25 Jun 2010 01:36:36 +0000 (21:36 -0400)]
Makefile: allow PYTHON variable to override python version.

Currently, the Makefile assumes the python command that should be used
is the default python version -- the "python" executable that is found
in PATH. Compiling and testing with a different python version is not
possible without either having a system with another default version, or
by manually changing the link found in PATH.

Correct this situation by using a variable for the python command name,
that can be overridden on the command line like the following:

    make PYTHON=python2.6 test

Signed-off-by: Gabriel Filion <lelutin@gmail.net>
13 years agoDocstrings for the git.py library
Gabriel Filion [Tue, 8 Jun 2010 05:03:41 +0000 (01:03 -0400)]
Docstrings for the git.py library

Add docstrings to the module and the public classes and functions of the
git library (eg. the ones that do not start with _ ).

Also rename the AbortableIter class to _AbortableIter since it is used
only inside the git.py library and is not intended to be used elsewhere
for now.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
13 years agomake install: don't fail if documentation couldn't be built.
Avery Pennarun [Tue, 8 Jun 2010 04:05:54 +0000 (00:05 -0400)]
make install: don't fail if documentation couldn't be built.

Just silently refuse to install the documentation instead.  Reported by Karl
Kiniger.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agocmd/newliner: if input starts getting too long, print it out.
Avery Pennarun [Tue, 8 Jun 2010 03:59:17 +0000 (23:59 -0400)]
cmd/newliner: if input starts getting too long, print it out.

This prevents output that doesn't have any newlines from being buffered
forever (eg. the output of 'bup split -vv').

Reported by Karl Kiniger.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agocmd/{random,split}: call handle_ctrl_c() for cleaner keyboard interrupts.
Avery Pennarun [Tue, 8 Jun 2010 03:51:54 +0000 (23:51 -0400)]
cmd/{random,split}: call handle_ctrl_c() for cleaner keyboard interrupts.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agocmd/{save,split}: add a --bwlimit option. bup-0.15
Avery Pennarun [Mon, 7 Jun 2010 23:02:23 +0000 (19:02 -0400)]
cmd/{save,split}: add a --bwlimit option.

This allows you to limit how much upstream bandwidth 'bup save' and 'bup
split' will use.  Specify it as a number of bytes/second, or with the 'k' or
'M' or (lucky you!) 'G' suffixes for larger values.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agoWork around extra space added by some readline versions.
Peter McCurdy [Fri, 16 Apr 2010 07:11:13 +0000 (03:11 -0400)]
Work around extra space added by some readline versions.

Apparently some versions of readline (6.0, for me) in some versions of
Python (Ubuntu's python2.6.4-0ubuntu1, for me) have an irritating bug
where they add an extra space to the end of all completions.  This is
particularly annoying for directory completions, as you can't
tab-complete your way into the contents of the directory.  See
http://bugs.python.org/issue5833

This patch, borrowed mostly from Trac, goes in and twiddles the
appropriate variable inside the readline library to make it stop doing
that.  See http://trac.edgewall.org/ticket/8711 for the discussion.

Signed-off-by: Peter McCurdy <petermccurdy@alumni.uwaterloo.ca>
14 years agobup ftp: work even if the 'readline' module isn't available.
Avery Pennarun [Tue, 11 May 2010 17:21:14 +0000 (13:21 -0400)]
bup ftp: work even if the 'readline' module isn't available.

Suggested by Joe Beda.

14 years agoStop using '%s' formatter in strftime.
Joe Beda [Tue, 11 May 2010 08:51:42 +0000 (01:51 -0700)]
Stop using '%s' formatter in strftime.

This isn't supported on all platforms (OpenSolaris specifically).

Signed-off-by: Joe Beda <joe@bedafamily.com>
14 years agocode clarity: one-letter var carried for too long bup-0.14a
Gabriel Filion [Fri, 30 Apr 2010 05:53:13 +0000 (01:53 -0400)]
code clarity: one-letter var carried for too long

In split-cmd.py, the "w" variable is first seen on line 55 and is kept
around until line 96. Variables that are sparsely used in a medium
distance in the code should have a name that carries more sense when
read on its own.

Change "w" into "pack_writer" to better identify the purpose of the
variable.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
14 years agoAvoid len as a variable name
Gabriel Filion [Fri, 30 Apr 2010 05:53:12 +0000 (01:53 -0400)]
Avoid len as a variable name

As discussed earlier on the mailing list, the "len" builtin is used very
often, and using "len" as a variable name can get confusing.

Change all occurrences of "len" as a variable to "sz" to keep it short
and meaningful.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
14 years agoadjust .md files to make lexgrog happy
Jon Dowland [Wed, 28 Apr 2010 14:41:05 +0000 (15:41 +0100)]
adjust .md files to make lexgrog happy

the whatis(1) tool cannot parse the bup manpages, because there
are two words before the '-' separator. This patch joins the words
using another '-', in the same fashion as git, to overcome this
limitation.

Before:

$ whatis bup fuse
bup (1)              - Backup program using rolling checksums and git file fo...
fuse: nothing appropriate.
$ whatis bup-fuse
bup-fuse: nothing appropriate.

After:

$ whatis bup-fuse
bup-fuse (1)         - mount a bup repository as a filesystem

Signed-off-by: Jon Dowland <jmtd@debian.org>
14 years agoDocumentation: some placeholders are lost
Gabriel Filion [Wed, 28 Apr 2010 17:12:05 +0000 (13:12 -0400)]
Documentation: some placeholders are lost

Some pieces of text in the documentation files use the <...> syntax to
mark named placeholders. However, the conversion done by pandoc from
Markdown to makefile makes some of these placeholders disappear.

The affected elements are those that contain only characters that could
be valid for an e-mail address or a URL, but are not supposed to be one
of both. Also, elements inside `...`-style code blocks are unaffected.

Fix this situation by escaping the < and > characters where the tags
disappear.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
14 years agoadd -o/--allow-other to bup-fuse
Jon Dowland [Wed, 28 Apr 2010 13:50:30 +0000 (14:50 +0100)]
add -o/--allow-other to bup-fuse

Setting the fuse option allow_other will fail if user_allow_other
is not set in fuse.conf.  Add toggle -o/--allow-other to bup-fuse
(disabled by default).

Signed-off-by: Jon Dowland <jmtd@debian.org>
14 years agoreplace test files with ones made up of bup code
Jon Dowland [Wed, 28 Apr 2010 12:58:54 +0000 (08:58 -0400)]
replace test files with ones made up of bup code

This is needed to avoid possible questions about licensing in the source
data file.

14 years agogit log --format= isn't in older git, but git log --pretty=format: is.
Avery Pennarun [Tue, 27 Apr 2010 00:11:00 +0000 (20:11 -0400)]
git log --format= isn't in older git, but git log --pretty=format: is.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
14 years agobup-fuse: friendliness when python-fuse not found
Gabriel Filion [Sat, 24 Apr 2010 20:33:31 +0000 (16:33 -0400)]
bup-fuse: friendliness when python-fuse not found

When used with the Python "fuse" module not installed on the system, the
bup-fuse command exits with an error.

To avoid confusing (or frustrating?) users, print a friendlier error
message that better describes what happens.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
14 years agocmd/version, etc: fix version number detection stuff.
Avery Pennarun [Sat, 24 Apr 2010 21:10:02 +0000 (17:10 -0400)]
cmd/version, etc: fix version number detection stuff.

Gabriel Filion pointed out that bup's version number (which we added to the
man pages automatically) was not detected when you used a bup tarball
generated from 'git archive' (or more likely, you let GitHub call 'git
archive' for you).  That makes sense, since our version detection was based
on having a .git directory around, which the tarball doesn't.

Instead, let's create a .gitattributes file and have it auto-substitute some
version information during 'git archive'.  Of course, if we actually *do*
have a .git directory, continue to use that.

While we're here, add a new 'bup version' command and alias "bup --version"
and "bup -V" to call it, since those options are pretty standard.

14 years agovfs: take advantage of bup chunking to make file seeking faster. bup-0.14
Avery Pennarun [Fri, 23 Apr 2010 23:18:10 +0000 (19:18 -0400)]
vfs: take advantage of bup chunking to make file seeking faster.

If you have a huge file, you can now seek around inside it (eg. in 'bup
fuse') without having to read its entire contents.  Calculating the file
size is also really fast now.

This makes a bup fuse-mounted filesystem much more useful for real-time
access.  For example, I was able to connect to an sqlite3 database and have
it work at a reasonable speed.  (Obviously, since 'bup fuse' is written in
python and doesn't currently support threading, the speed could still be
improved, but at least it's no longer godawful.)

14 years agogit.CatPipe: more resilience against weird errors.
Avery Pennarun [Fri, 23 Apr 2010 21:25:39 +0000 (17:25 -0400)]
git.CatPipe: more resilience against weird errors.

Notably, MemoryErrors thrown because the file we're trying to load into
memory is too big to load all at once.  Now the MemoryError gets thrown, but
the main program is potentially able to recover from it because CatPipe at
least doesn't get into an inconsistent state.

Also we can recover nicely if some lamer kills our git-cat-file subprocess.

The AutoFlushIter we were using for this purpose turns out to not have been
good enough, and it's never been used anywhere but in CatPipe, so I've
revised it further and renamed it to git.AbortableIter.

14 years agocmd/ftp: 'ls' command should print filenames in columns.
Avery Pennarun [Fri, 23 Apr 2010 20:33:10 +0000 (16:33 -0400)]
cmd/ftp: 'ls' command should print filenames in columns.

We use the columnate() function from main.py for this, now moved into
helpers.py.

14 years agocmd/ftp: if 'get' command returns an error, print it first.
Avery Pennarun [Fri, 23 Apr 2010 20:32:31 +0000 (16:32 -0400)]
cmd/ftp: if 'get' command returns an error, print it first.

Previously we would print "Saving 'filename'" even if we were about to
report that 'filename' doesn't exist or is the wrong file type.

14 years agovfs: cache file sizes in the Node object.
Avery Pennarun [Fri, 23 Apr 2010 20:21:35 +0000 (16:21 -0400)]
vfs: cache file sizes in the Node object.

Since the filesystem is read only, there's no reason to recalculate the file
size every time someone asks :)

14 years agocmd/fuse: add missing Stat entries to appease older versions of python-fuse.
Avery Pennarun [Fri, 23 Apr 2010 20:19:50 +0000 (16:19 -0400)]
cmd/fuse: add missing Stat entries to appease older versions of python-fuse.

python-fuse 0.2-pre3-4ubuntu1 didn't work, now it does.
python-fuse 0.2-pre3-9 on Debian did work, still does.

14 years agocmd/save: when a file is chunked, mangle its name from * to *.bup
Avery Pennarun [Fri, 23 Apr 2010 19:39:24 +0000 (15:39 -0400)]
cmd/save: when a file is chunked, mangle its name from * to *.bup

Files that are already named *.bup are renamed to *.bup.bupl, so that we can
just always drop either .bup or .bupl from a filename if it's there, and the
result will be the original filename.

Also updated lib/bup/vfs.py to demangle the names appropriately, and treat
git trees named *.bup as real chunked files (ie. by joining them back
together).

14 years agoFirst draft of a DESIGN document.
Avery Pennarun [Wed, 14 Apr 2010 13:48:11 +0000 (09:48 -0400)]
First draft of a DESIGN document.

14 years agoREADME: add some suggestions from the LWN article.
Avery Pennarun [Wed, 7 Apr 2010 02:53:42 +0000 (22:53 -0400)]
README: add some suggestions from the LWN article.

The article itself was here:
https://lwn.net/Articles/380983/

14 years agoREADME: fix some capitalization and whitespace errors.
Avery Pennarun [Wed, 7 Apr 2010 02:53:15 +0000 (22:53 -0400)]
README: fix some capitalization and whitespace errors.

14 years agodoc: bup-split should mention bup-join (not git-join)
Kirill Smelkov [Fri, 2 Apr 2010 06:30:26 +0000 (10:30 +0400)]
doc: bup-split should mention bup-join (not git-join)

14 years agoMerge branch 'master' of /tmp/bup
Avery Pennarun [Thu, 1 Apr 2010 23:36:02 +0000 (19:36 -0400)]
Merge branch 'master' of /tmp/bup

* 'master' of /tmp/bup:
  Add a 'make install' target.

14 years agoAdd a 'make install' target.
Avery Pennarun [Thu, 1 Apr 2010 23:34:03 +0000 (19:34 -0400)]
Add a 'make install' target.

Also change main.py to search around in appropriate places for the installed
library files.  By default, if your bup is in /usr/bin/bup, it'll look in
/usr/lib/bup.  (It drops two words off the end of the filename and adds
/lib/bup to the end.)

This also makes the Debian packager at
http://git.debian.org/collab-maint/bup
actually produce a usable package.

14 years agocmd/fsck: correctly catch nonzero return codes of 'par2 create'. bup-0.13a
Avery Pennarun [Thu, 1 Apr 2010 19:43:05 +0000 (15:43 -0400)]
cmd/fsck: correctly catch nonzero return codes of 'par2 create'.

Oops; we weren't checking the return value like we should.  Reported by
Sitaram Chamarty.

14 years agohelpers.log(): run sys.stdout.flush() first.
Avery Pennarun [Thu, 1 Apr 2010 18:58:00 +0000 (14:58 -0400)]
helpers.log(): run sys.stdout.flush() first.

It's annoying when your log messages come out before stdout messages do.
But it's equally annoying (and inefficient) to have to flush every time you
print something.  This seems like a nice compromise.

14 years agoGet rid of a sha-related DeprecationWarning in python 2.6.
Avery Pennarun [Thu, 1 Apr 2010 18:48:10 +0000 (14:48 -0400)]
Get rid of a sha-related DeprecationWarning in python 2.6.

hashlib is only available in python 2.5 or higher, but the 'sha' module
produces a DeprecationWarning in python 2.6 or higher.  We want to support
python 2.4 and above without any stupid warnings, so let's try using
hashlib.  If it fails, switch to the old sha module.

14 years agoAdd support for a global --bup-dir or -d argument.
Rob Browning [Thu, 25 Mar 2010 07:23:57 +0000 (00:23 -0700)]
Add support for a global --bup-dir or -d argument.

When a "--bup-dir DIR" or "-d DIR" argument is provided, act as if
BUP_DIR=DIR is set in the environment.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
14 years agoAdd support for global command-line options (before any subcmd).
Rob Browning [Thu, 25 Mar 2010 07:23:56 +0000 (00:23 -0700)]
Add support for global command-line options (before any subcmd).

Process global arguments via getopt before handling a subcmd, and add
initial support for a global --help (or -?) option.

Also support --help for subcmds by noticing and translating

  git ... subcmd --help ...

into

  git ... help subcmd ...

Signed-off-by: Rob Browning <rlb@defaultvalue.org>