]> arthur.barton.de Git - bup.git/log
bup.git
13 years agocmd/join: add a new -o (output filename) option.
Avery Pennarun [Sun, 13 Feb 2011 06:53:50 +0000 (22:53 -0800)]
cmd/join: add a new -o (output filename) option.

This is a helpful way to have it open and write to the given output file.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agocmd/ls: fix a typo causing 'bup ls foo/latest' to not work.
Avery Pennarun [Sun, 13 Feb 2011 06:50:34 +0000 (22:50 -0800)]
cmd/ls: fix a typo causing 'bup ls foo/latest' to not work.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agocmd/server: add a new 'help' command.
Avery Pennarun [Sun, 13 Feb 2011 05:56:29 +0000 (21:56 -0800)]
cmd/server: add a new 'help' command.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agomidx4: Fix the other side of my previous nasty bug
Brandon Low [Thu, 10 Feb 2011 21:23:36 +0000 (13:23 -0800)]
midx4: Fix the other side of my previous nasty bug

The previous one was a problem with midx4s generated from idx files,
this one is similar but when they are generated from other .midx4 files.

Many thanks to Aneurin Price for putting up with the awful behavior and
prodding at bup and whatnot while I was trying to make this one
disappear under a rug.

Once again, midx4 files generated prior to this patch will want to be
regenerated.  Once again, only smart servers which have objects not on
the client's index cache will be effected, but they sure as hell well be
effected.

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agomidx4: Fix name offsets when generated from idx
Brandon Low [Tue, 8 Feb 2011 18:43:22 +0000 (10:43 -0800)]
midx4: Fix name offsets when generated from idx

This was a nasty bug, glad it got found before release.  Only effected
the server's ability to suggest .idxs so far, but would have effected
any attempt to have bup retrieve objects directly too.

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agoFix a couple of python 2.4 incompatibilities.
Avery Pennarun [Tue, 8 Feb 2011 12:59:54 +0000 (04:59 -0800)]
Fix a couple of python 2.4 incompatibilities.

Thanks to Jimmy Tang for his help testing these since I don't have python
2.4 easily available.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agoRemove incorrect comment
Brandon Low [Tue, 8 Feb 2011 06:14:45 +0000 (22:14 -0800)]
Remove incorrect comment

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agoMerge branch 'bloom'
Avery Pennarun [Tue, 8 Feb 2011 06:16:08 +0000 (22:16 -0800)]
Merge branch 'bloom'

* bloom:
  bloom: avoid kernel disk flushes when we dirty a lot of pages.
  midx4: Properly decide whether to do progress in C
  midx4: Don't use Py_ssize_t, it's not in python2.4
  cmd/bloom: map only one .idx file at a time.
  bloom: Use truncate not writing zeros in create
  bloom: Don't use function pointers in tight loops
  Fix updating of bloom with additional files
  ShaBloom.init(): initialize members before the assert().
  cmd/bloom: actually, always use the same temp filename.
  cmd/bloom: use mkstemp() instead of NamedTemporaryFile().
  midx: Write midx4 in C rather than python
  midx4: midx2 with idx backreferences
  ShaBloom: Add k=4 support for large repositories
  ShaBloom prefilter to detect nonexistant objects
  mmap: Make closing source file optional

13 years agobloom: avoid kernel disk flushes when we dirty a lot of pages.
Avery Pennarun [Tue, 8 Feb 2011 03:09:06 +0000 (19:09 -0800)]
bloom: avoid kernel disk flushes when we dirty a lot of pages.

Based on the number of objects we'll add to the bloom, decide if we want to
mmap() the pages as shared-writable ('immediate' write) or else map them
private-writable for later manual writing back to the file ('delayed'
write).

A bloom table's write access pattern is such that we dirty almost all the
pages after adding very few entries; essentially, we can expect to dirty
about n*k/4096 pages if we add n objects to the bloom with k hashes. But the
table is so big that dirtying *all* the pages often exceeds Linux's default
/proc/sys/vm/dirty_ratio or /proc/sys/vm/dirty_background_ratio,
thus causing it to start flushing the table before we're
finished... even though there's more than enough space to
store the bloom table in RAM.

To work around that behaviour, if we calculate that we'll probably end up
touching the whole table anyway (at least one bit flipped per memory page),
let's use a "private" mmap, which defeats Linux's ability to flush it to
disk.  Then we'll flush it as one big lump during close(), which doesn't
lose any time since we would have had to flush all the pages anyway.

While we're here, let's remove the readwrite=True option to
ShaBloom.create(); nobody's going to create a bloom file that isn't
writable.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agomidx4: Properly decide whether to do progress in C
Brandon Low [Tue, 8 Feb 2011 02:30:04 +0000 (18:30 -0800)]
midx4: Properly decide whether to do progress in C

Basically just gives us a _helpers.istty to go along with helpers.istty
and uses it to decide whether or not to write progress messages from
midx4 generation.

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agomidx4: Don't use Py_ssize_t, it's not in python2.4
Brandon Low [Tue, 8 Feb 2011 02:25:44 +0000 (18:25 -0800)]
midx4: Don't use Py_ssize_t, it's not in python2.4

This also uses a slightly more error-checked conversion of input values
to appropriate C structures.

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agocmd/bloom: map only one .idx file at a time.
Avery Pennarun [Tue, 8 Feb 2011 01:41:00 +0000 (17:41 -0800)]
cmd/bloom: map only one .idx file at a time.

This massively decreases virtual memory allocation since we only ever need
to look at a single idx at once.

In theory, VM doesn't cost us anything, but on 32-bit systems we can
actually run out of address space if we try to map all the idx files at
once on a very large repo.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agobloom: Use truncate not writing zeros in create
Brandon Low [Mon, 7 Feb 2011 17:08:00 +0000 (09:08 -0800)]
bloom: Use truncate not writing zeros in create

This lets us test more of bloom's code without writing gigabyte(s) of
zeros to disk.  As noted in the NOTE: this works on all of the common
modern unixes that I checked, but may need special handling on other
systems.

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agobloom: Don't use function pointers in tight loops
Brandon Low [Mon, 7 Feb 2011 17:07:59 +0000 (09:07 -0800)]
bloom: Don't use function pointers in tight loops

They really just confused the code at this point and may have prevented
GCC from doing some optimization.

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agoFix updating of bloom with additional files
Brandon Low [Mon, 7 Feb 2011 16:19:04 +0000 (08:19 -0800)]
Fix updating of bloom with additional files

Make bloom add additional .idx files when it's run on a repo with an
existing bloom filter file rather than just regenerating all the time.

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agoShaBloom.init(): initialize members before the assert().
Avery Pennarun [Mon, 7 Feb 2011 09:25:32 +0000 (01:25 -0800)]
ShaBloom.init(): initialize members before the assert().

Otherwise __del__() throws an exception if the assert triggers, thus hiding
the original problem.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agocmd/bloom: actually, always use the same temp filename.
Avery Pennarun [Mon, 7 Feb 2011 09:28:06 +0000 (01:28 -0800)]
cmd/bloom: actually, always use the same temp filename.

There's no reason to use a different temp filename every time, since we're
going to just be overwriting the same output file anyhow.  And if we got
interrupted, we left the temp file lying around.  Let's just always use the
same temp filename, which means if we get interrupted, we'll clean it up
next time.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agocmd/bloom: use mkstemp() instead of NamedTemporaryFile().
Avery Pennarun [Mon, 7 Feb 2011 08:55:10 +0000 (00:55 -0800)]
cmd/bloom: use mkstemp() instead of NamedTemporaryFile().

Older versions of python (I tested python 2.5) don't support the
delete=False parameter to NamedTemporaryFile().  In any case, it's not
actually a temporary file since we're not planning to delete it.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agomidx: Write midx4 in C rather than python
Brandon Low [Mon, 7 Feb 2011 06:06:09 +0000 (22:06 -0800)]
midx: Write midx4 in C rather than python

Obviously this is dramatically faster.

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agomidx4: midx2 with idx backreferences
Brandon Low [Mon, 7 Feb 2011 06:06:08 +0000 (22:06 -0800)]
midx4: midx2 with idx backreferences

Like midx3, this adds a lookup table of 4 bytes per entry to
reference an entry in the idxnames list.  2 bytes should be plenty, but
disk is cheap and the table will only be referenced when bup server gets
an object that's already in the midx.

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agoShaBloom: Add k=4 support for large repositories
Brandon Low [Mon, 7 Feb 2011 06:06:07 +0000 (22:06 -0800)]
ShaBloom: Add k=4 support for large repositories

Comments pretty much tell the story, as 3TiB is really not large enough
for a backup system to support, this adds k=4 support to ShaBloom which
lets it hold 100s of TiB without too many negative tradeoffs.  Still
better to use k=5 for smaller repositories, so it switches when the
repository exceeds 3TiB.

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agoShaBloom prefilter to detect nonexistant objects
Brandon Low [Mon, 7 Feb 2011 06:06:06 +0000 (22:06 -0800)]
ShaBloom prefilter to detect nonexistant objects

This inserts a bloom prefilter ahead of midx for efficient checking of
objects most of which do not exist.  As long as you have enough RAM for
the bloom filter to stay in memory, this saves a lot of time compared to
midx files.  Bloom filter is between 1/5th and 1/20th the size of midx
given the parameters I'm using so far.

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agommap: Make closing source file optional
Brandon Low [Mon, 7 Feb 2011 06:06:05 +0000 (22:06 -0800)]
mmap: Make closing source file optional

New index file formats require this behavior (bloom, midx3, etc.)

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agoMerge branch 'daemon_msg' of git://github.com/leto/bup bup-0.22a
Avery Pennarun [Mon, 7 Feb 2011 08:47:00 +0000 (00:47 -0800)]
Merge branch 'daemon_msg' of git://github.com/leto/bup

* 'daemon_msg' of git://github.com/leto/bup:
  Make 'bup daemon' print a message at startup regardless of debug level

13 years agooptions.py: update docstrings and detail optspec
Gabriel Filion [Sat, 5 Feb 2011 22:17:47 +0000 (17:17 -0500)]
options.py: update docstrings and detail optspec

The docstring on the Options class currently refers to a man page which
does not exist, and still talks about the now-removed 'exe' parameter.
Update this to be more accurate.

Add a docstring to OptDict.

Finally, the options.py file brings a concept of option spec string. Its
construction should be documented. Since we'd like the options.py file
to be a one-file drop-in so that it can be easily used in other
projects, let's document the option specs in the module's docstring.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
13 years agocmd/memtest: don't die if /proc/self/status is the wrong format.
Avery Pennarun [Sat, 5 Feb 2011 01:30:11 +0000 (17:30 -0800)]
cmd/memtest: don't die if /proc/self/status is the wrong format.

Apparently Solaris has /proc/self/status, but it's binary and so our
Linux-centric parser couldn't handle it.  The data we're getting from it is
non-critical, so just ignore the parse error and let the high-level code in
report() deal with it.

Reported by henning mueller, diagnosed by Gabriel Filion.  Thanks guys!

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agoMake 'bup daemon' print a message at startup regardless of debug level
Jonathan "Duke" Leto [Sat, 5 Feb 2011 00:43:40 +0000 (16:43 -0800)]
Make 'bup daemon' print a message at startup regardless of debug level

13 years agoclient.py: replace a never-used GitError with a ClientError.
Avery Pennarun [Fri, 4 Feb 2011 11:01:33 +0000 (03:01 -0800)]
client.py: replace a never-used GitError with a ClientError.

Nobody ever tried calling that function, so it's really just an assertion
that never triggered.  Which is good, because it was trying to throw an
exception that wasn't available in the current namespace.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agoDemuxConn.__init__: you can't assume the *last* 6 bytes are BUPMUX.
Avery Pennarun [Thu, 3 Feb 2011 23:12:52 +0000 (15:12 -0800)]
DemuxConn.__init__: you can't assume the *last* 6 bytes are BUPMUX.

The actual muxed data might arrive immediately after it, and since we're not
buffering that, we have to read one byte at a time.

(Buffering would be more efficient if we expected this to happen frequently,
but it shouldn't.)

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agoDemuxConn.__init__: abort the loop if read() returns EOF.
Avery Pennarun [Thu, 3 Feb 2011 23:07:48 +0000 (15:07 -0800)]
DemuxConn.__init__: abort the loop if read() returns EOF.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agohelpers.py: always use two blank lines between functions/classes.
Avery Pennarun [Thu, 3 Feb 2011 23:04:47 +0000 (15:04 -0800)]
helpers.py: always use two blank lines between functions/classes.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agoclient.py: avoid an exception when no new remote packs were generated.
Avery Pennarun [Thu, 3 Feb 2011 10:16:54 +0000 (02:16 -0800)]
client.py: avoid an exception when no new remote packs were generated.

This is probably pretty rare, but it can happen if you needed to download a
remote index, and that index had *all* your objects, so we did end up
writing some objects to the remote server, but it didn't end up generating
any packs.  If that happened, we would try to return the contents of a
nonexistent variable.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agoFix documentation for `bup daemon`
Brandon Low [Thu, 3 Feb 2011 03:06:41 +0000 (19:06 -0800)]
Fix documentation for `bup daemon`

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agoruntests: Apparently $(wildcard) in make doesn't always sort its output. bup-0.22
Avery Pennarun [Tue, 1 Feb 2011 10:04:53 +0000 (02:04 -0800)]
runtests: Apparently $(wildcard) in make doesn't always sort its output.

This meant that on Solaris, tests would be run in a different order, so that
BUP_MAIN_EXTRA (set in tclient.py) wouldn't be set the same as on Linux.

In this case, we know the wildcard will always match something anyway, so we
might as well just let the shell expand it out rather than asking make to do
it.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agocmd/help: earlier path.exedir() change made it not find manpages correctly.
Avery Pennarun [Tue, 1 Feb 2011 09:47:09 +0000 (01:47 -0800)]
cmd/help: earlier path.exedir() change made it not find manpages correctly.

...when the binary wasn't actually installed.  Previously, it would use
sys.argv[0], which was the path to bup-help, but now it uses path.exedir(),
which has the path to bup, which is one directory up.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agoMerge branch 'mux'
Avery Pennarun [Tue, 1 Feb 2011 08:22:07 +0000 (00:22 -0800)]
Merge branch 'mux'

* mux:
  If you specified the port number on the command line, convert it to an int.
  Add `bup daemon` command for simple socket server
  Add DemuxConn and `bup mux` for client-server

13 years agoIf you specified the port number on the command line, convert it to an int.
Avery Pennarun [Tue, 1 Feb 2011 06:13:00 +0000 (22:13 -0800)]
If you specified the port number on the command line, convert it to an int.

This gets rid of an exception.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agoAdd `bup daemon` command for simple socket server
Brandon Low [Thu, 27 Jan 2011 02:30:21 +0000 (18:30 -0800)]
Add `bup daemon` command for simple socket server

Nothing special here, just listens on a host:port combination and spawns
`bup mux server` instances.

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agoAdd DemuxConn and `bup mux` for client-server
Brandon Low [Thu, 27 Jan 2011 02:30:20 +0000 (18:30 -0800)]
Add DemuxConn and `bup mux` for client-server

`bup mux` works with any bup command to multiplex its stdout and stderr
streams over a single stdout stream.

DemuxConn works on the client side to demultiplex stderr and data
streams from a single stream, emulating a simple connection.

For now, these are only used in the case of simple socket bup://
client-server connections, because rsh and local connections don't need
them.

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agot/test.sh: Fix a test for 'split' on solaris
Gabriel Filion [Fri, 28 Jan 2011 06:14:08 +0000 (01:14 -0500)]
t/test.sh: Fix a test for 'split' on solaris

When looking at output from a test run on Solaris, one test in the
'split' suite showed up as OK but was actually showing a diff
invocation error.

The -q argument (for quiet) does not exist on the version of diff that
is installed on Solaris. Since wvtest intercepts output from tested
commands, the -q argument is actually not needed. Remove the argument in
order to make the test execute correctly under all operating systems
that were tested thus far.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
13 years agoGive main.py the a --profile option
Brandon Low [Wed, 26 Jan 2011 06:54:23 +0000 (22:54 -0800)]
Give main.py the a --profile option

This is just a convenience for anyone who is interested in seeing where
CPU seconds are going.

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agooptions.py: generate usage string correctly for no-* options.
Avery Pennarun [Wed, 26 Jan 2011 05:14:35 +0000 (21:14 -0800)]
options.py: generate usage string correctly for no-* options.

(copied from the sshuttle project)

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agooptions.py: don't die if tty width is set to 0.
Avery Pennarun [Sun, 23 Jan 2011 00:42:32 +0000 (16:42 -0800)]
options.py: don't die if tty width is set to 0.

This sometimes happens if weird people, such as myself, open a pty without
setting the width field correctly.

(copied from the sshuttle project)

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agoCombine and speed up idx->midx and bupindex merge
Brandon Low [Mon, 24 Jan 2011 03:31:51 +0000 (19:31 -0800)]
Combine and speed up idx->midx and bupindex merge

These two processes used almost identical algorithms, but were
implemented separately.  The main difference was one was ascending and
the other was descending.

This patch reverses the cmp on index.Entry so that both can share an
algorithm.

It also cuts some overhead in the algorithm by using it.next() instead of
the next() wrapper, yielding a ~6% speedup on midx generation and index merging.

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agoMinorly fix outbytes calculation in client
Brandon Low [Sat, 22 Jan 2011 16:28:04 +0000 (08:28 -0800)]
Minorly fix outbytes calculation in client

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agoUse os.path rather than '/' logic in wvtest
Brandon Low [Sat, 22 Jan 2011 19:24:46 +0000 (11:24 -0800)]
Use os.path rather than '/' logic in wvtest

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agoHandle $BUP_MAIN_EXE more carefully.
Avery Pennarun [Wed, 26 Jan 2011 03:35:21 +0000 (19:35 -0800)]
Handle $BUP_MAIN_EXE more carefully.

In some cases, we might have been using sys.argv[0] *after* doing a chdir(),
which doesn't work reliably since argv[0] might be a relative path.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agoauto_midx(): report args when failing to call a subprocess.
Avery Pennarun [Wed, 26 Jan 2011 03:32:27 +0000 (19:32 -0800)]
auto_midx(): report args when failing to call a subprocess.

The exception from subprocess.call() doesn't report the path it tried to use
when it prints the "No such file or directory" error, which isn't helpful
when trying to debug problems.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agoHenning Mueller reports that bup works on Solaris now.
Avery Pennarun [Wed, 26 Jan 2011 03:11:35 +0000 (19:11 -0800)]
Henning Mueller reports that bup works on Solaris now.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agolib/bup/drecurse.py: work even if O_NOFOLLOW is missing.
Avery Pennarun [Wed, 26 Jan 2011 03:04:18 +0000 (19:04 -0800)]
lib/bup/drecurse.py: work even if O_NOFOLLOW is missing.

It's non-critical and appears to be missing on Solaris.  Thanks to Henning
Mueller for reporting the problem.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agooptions: remove unused 'exe' parameter
Gabriel Filion [Mon, 17 Jan 2011 01:38:56 +0000 (20:38 -0500)]
options: remove unused 'exe' parameter

The 'exe' parameter was added in the hope of using it for additional
contextual information in the help text that Options generates. It was
till then abandoned and was judged as superflous information.

Remove the 'exe' parameter from Options' constructor.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
13 years agosave: handle backup write errors properly
Brandon Low [Wed, 12 Jan 2011 01:15:53 +0000 (17:15 -0800)]
save: handle backup write errors properly

bup-save was catching all IOErrors and treating them as data-read
failures, but some of them could be backup-write errors.  Have git.py
and client.py raise distinctive errors when pack write raises IOError.

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agoFix test by forcing order
Brandon Low [Wed, 12 Jan 2011 01:15:52 +0000 (17:15 -0800)]
Fix test by forcing order

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agoRemove seemingly unnecessary abspath() call from the previous patch.
Avery Pennarun [Tue, 18 Jan 2011 20:32:41 +0000 (12:32 -0800)]
Remove seemingly unnecessary abspath() call from the previous patch.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agoFreeBSD + os.mknod => broken, open().close()
Brandon Low [Wed, 12 Jan 2011 01:15:51 +0000 (17:15 -0800)]
FreeBSD + os.mknod => broken, open().close()

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agocmd/init: don't spit out a traceback on init error
Gabriel Filion [Mon, 17 Jan 2011 02:19:25 +0000 (21:19 -0500)]
cmd/init: don't spit out a traceback on init error

When an error occurs during repository creation, 'bup init' currently
lets GitError exceptions leak out, printing a backtrace to unsuspecting
users in the process.

Intercept GitError exceptions that come out of git.init_repo() and print
out the message that it contains in a more friendly manner.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
13 years agogit.py: error when repo's parent dir absent
Gabriel Filion [Mon, 17 Jan 2011 02:19:24 +0000 (21:19 -0500)]
git.py: error when repo's parent dir absent

Currently, when you try to initialize a bup repository inside an
unexistant directory (e.g. BUP_DIR=some_dir/bup_repo, and some_dir does
not exist), bup has to call "git init" to then obtain an error code
which is not very significant to users.

Add a check for the existence of the repository's parent directory and
throw an exception with a more meaningful error message when that
happens.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
13 years agoFix typo in documentation for strip_base_path
Zoran Zaric [Sat, 8 Jan 2011 14:57:03 +0000 (15:57 +0100)]
Fix typo in documentation for strip_base_path

Signed-off-by: Zoran Zaric <zz@zoranzaric.de>
13 years agoAdd some notes on how to install bup on FreeBSD
Gabriel Filion [Sun, 9 Jan 2011 02:19:37 +0000 (21:19 -0500)]
Add some notes on how to install bup on FreeBSD

I've given bup a go on FreeBSD 8.1 and everything seemed to be
functional.

Some package names are not really obvious, and the default 'make'
command doesn't like bup's GNU Make-ish Makefile. Add some notes in the
README so that people can have some pointers on what to do to get bup
fully functional under FreeBSD.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
13 years agoUpdate ls man page for new -a option
Gabriel Filion [Sun, 9 Jan 2011 02:59:48 +0000 (21:59 -0500)]
Update ls man page for new -a option

Commit 74d28e77366dba1eefbfa2beeda34bcaa835dc58, while modifying the
default behaviour for 'bup ls', introduced a new option to obtain the
old default behaviour.

Reflect this change in the bup-ls man page.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
13 years agomove auto_midx calls to callers of sync_index
Brandon Low [Sat, 8 Jan 2011 19:56:01 +0000 (11:56 -0800)]
move auto_midx calls to callers of sync_index

In call cases, sync_index is now called from a loop.  It makes more
sense to have the callers run auto_midx after the loop now.

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agoclient/server:Handle multiple suggestions and misc
Brandon Low [Sat, 8 Jan 2011 19:56:00 +0000 (11:56 -0800)]
client/server:Handle multiple suggestions and misc

There was a fixme in the code, I was doing cleanups and fixed it.  There
are therefor some misc. cleanups in here along with the handling of
multiple suggested packs.

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agoDumb server doesn't need objcache
Brandon Low [Sat, 8 Jan 2011 19:55:59 +0000 (11:55 -0800)]
Dumb server doesn't need objcache

And it's a waste of memory on a low power box.

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agoMerge branch 'next' into 'master'
Avery Pennarun [Sat, 8 Jan 2011 09:59:55 +0000 (01:59 -0800)]
Merge branch 'next' into 'master'

* 'next':
  Change server_mode=='dumb' to just a dumb_server_mode bool.
  Teach bup about URLs and non-ssh remotes
  Don't generate midx files in dumb server mode
  Add optional dumb-server mode
  git.CatPipe: set a buffer size on the subprocess to increase performance.
  Improve test pass condition
  Adds examples for strip, strip-prefix and graft to bup save's documentation
  Adds --graft option to bup save.

Conflicts:
lib/bup/t/thelpers.py

13 years agoMerge branch 'zz/strip_path_fix' bup-0.21
Avery Pennarun [Sat, 8 Jan 2011 09:50:47 +0000 (01:50 -0800)]
Merge branch 'zz/strip_path_fix'

* zz/strip_path_fix:
  Fix a bug in strip_path when prefix is a symlink
  Add a testcase for strip_path

13 years agoFix a bug in strip_path when prefix is a symlink
Zoran Zaric [Fri, 7 Jan 2011 11:16:24 +0000 (12:16 +0100)]
Fix a bug in strip_path when prefix is a symlink

helpers.realpath() wasn't the right choice for path normalization.
The prefix itself can be a symlink, too.  Now we use os.path.realpath(),
which also follows symlinks for the last element.

Signed-off-by: Zoran Zaric <zz@zoranzaric.de>
13 years agoAdd a testcase for strip_path
Zoran Zaric [Fri, 7 Jan 2011 11:16:23 +0000 (12:16 +0100)]
Add a testcase for strip_path

As reported by Aleksandr Milewski strip_path has a bug when the prefix
is a symlink.  This case is addressed with this test.

Signed-off-by: Zoran Zaric <zz@zoranzaric.de>
13 years agoMerge branch 'bl/dumbserver' into next
Avery Pennarun [Thu, 6 Jan 2011 23:27:04 +0000 (15:27 -0800)]
Merge branch 'bl/dumbserver' into next

* bl/dumbserver:
  Change server_mode=='dumb' to just a dumb_server_mode bool.
  Teach bup about URLs and non-ssh remotes
  Don't generate midx files in dumb server mode
  Add optional dumb-server mode

13 years agoChange server_mode=='dumb' to just a dumb_server_mode bool.
Avery Pennarun [Thu, 6 Jan 2011 23:26:18 +0000 (15:26 -0800)]
Change server_mode=='dumb' to just a dumb_server_mode bool.

Marginally faster runtime, shorter code, and less chance of typos.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agoTeach bup about URLs and non-ssh remotes
Brandon Low [Wed, 5 Jan 2011 17:28:25 +0000 (09:28 -0800)]
Teach bup about URLs and non-ssh remotes

Also adds the ability to connect to ports other than default for ssh.

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agoDon't generate midx files in dumb server mode
Brandon Low [Wed, 5 Jan 2011 17:28:24 +0000 (09:28 -0800)]
Don't generate midx files in dumb server mode

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agoAdd optional dumb-server mode
Brandon Low [Wed, 5 Jan 2011 17:28:23 +0000 (09:28 -0800)]
Add optional dumb-server mode

In dumb server mode, the server tells the client to load all .idx files
up front.  Puts the burden of deciding what .idxs a client should work
from more squarely in the server side.  This mode is activated by
putting a bup-dumb-server file in the bup repodir.

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agogit.CatPipe: set a buffer size on the subprocess to increase performance.
Carsten Bormann [Thu, 6 Jan 2011 21:38:10 +0000 (13:38 -0800)]
git.CatPipe: set a buffer size on the subprocess to increase performance.

apenwarr: I modified Carsten's patch slightly, since "line mode" is not
really appropriate.  On my system, this patch (or Carsten's) can read 111
megabytes in 1.7 seconds instead of 2.1 seconds, or 65MB/sec instead of 52
MB/sec.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agoImprove test pass condition
Brandon Low [Tue, 4 Jan 2011 07:07:48 +0000 (23:07 -0800)]
Improve test pass condition

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agoAdds examples for strip, strip-prefix and graft to bup save's documentation
Zoran Zaric [Tue, 4 Jan 2011 02:22:28 +0000 (03:22 +0100)]
Adds examples for strip, strip-prefix and graft to bup save's documentation

Signed-off-by: Zoran Zaric <zz@zoranzaric.de>
13 years agoAdds --graft option to bup save.
Zoran Zaric [Tue, 4 Jan 2011 02:22:27 +0000 (03:22 +0100)]
Adds --graft option to bup save.

This adds the option to rename paths when saving them.

A directory /root/chroot/a/etc saved with "bup save -n chroots
--graft /root/chroot/a/etc=/chroots/a" would be saved as
/chroots/a/etc.

Signed-off-by: Zoran Zaric <zz@zoranzaric.de>
13 years agocmd/import-rsnapshot: eliminate use of readlink and stat commands.
Avery Pennarun [Tue, 4 Jan 2011 08:21:32 +0000 (00:21 -0800)]
cmd/import-rsnapshot: eliminate use of readlink and stat commands.

These aren't portable across operating systems.

While we're here, catch some error cases that were revealed by these
commands failing.

Also reduce indentation by using 'continue' in places where the entire loop
iteration depends on a single conditional.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agocmd/import-rsnapshot: fix some sh stylistic stuff.
Avery Pennarun [Tue, 4 Jan 2011 08:03:17 +0000 (00:03 -0800)]
cmd/import-rsnapshot: fix some sh stylistic stuff.

Should not affect functionality.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agoFix some 'print' to stdout that snuck in somehow.
Avery Pennarun [Tue, 4 Jan 2011 08:09:12 +0000 (00:09 -0800)]
Fix some 'print' to stdout that snuck in somehow.

We should be using debug1() or debug2() instead, most of the time.  print is
only for stuff that callers might actually want to read and parse.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agocmd/import-rsnapshot: fix a bashism (== instead of =).
Avery Pennarun [Mon, 3 Jan 2011 21:12:32 +0000 (13:12 -0800)]
cmd/import-rsnapshot: fix a bashism (== instead of =).

Bug reported by Brandon Low.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agoMerge branches 'gf/ls', 'gf/tag', 'zz/import-rsnapshot' and 'bl/selfindex' bup-0.21-rc1
Avery Pennarun [Mon, 3 Jan 2011 04:58:35 +0000 (20:58 -0800)]
Merge branches 'gf/ls', 'gf/tag', 'zz/import-rsnapshot' and 'bl/selfindex'

* gf/ls:
  ls-cmd: hide files with a leading dot by default

* gf/tag:
  Refuse branch/tag names that start with a dot
  tag-cmd: Some fixups

* zz/import-rsnapshot:
  Adds a testcase for import-rsnapshot.
  Makes import-rsnapshot use save's -f option.
  Adds -f option to save to use a given indexfile.
  Makefile: handle shell commands (cmd/*-cmd.sh)
  Adds documentation for bup-import-rsnapshot
  Adds import-rsnapshot command.
  Adds documentation for save's strip option.
  Adds testcases for --strip and --strip-path.
  Adds a strip and strip-path option to bup save.

* bl/selfindex:
  Rename receive-objects command to receive-objects-v2.
  Write idxs directly rather than using git-index-pack.
  Send SHAs from the client to reduce server load
  Use chunkyreader() instead of manually reading multiple blocks.

13 years agoAdds a testcase for import-rsnapshot.
Zoran Zaric [Mon, 6 Dec 2010 12:00:10 +0000 (13:00 +0100)]
Adds a testcase for import-rsnapshot.

Also makes import-rsnapshot use $BUP_MAIN_EXE if available.

Signed-off-by: Zoran Zaric <zz@zoranzaric.de>
13 years agoMakes import-rsnapshot use save's -f option.
Zoran Zaric [Mon, 6 Dec 2010 12:00:09 +0000 (13:00 +0100)]
Makes import-rsnapshot use save's -f option.

Signed-off-by: Zoran Zaric <zz@zoranzaric.de>
13 years agoAdds -f option to save to use a given indexfile.
Zoran Zaric [Mon, 6 Dec 2010 12:00:08 +0000 (13:00 +0100)]
Adds -f option to save to use a given indexfile.

index supported -f before but save didn't.  Using a specific indexfile
makes it possible to use temporary indexfiles for one-time-backups like
imports.

Signed-off-by: Zoran Zaric <zz@zoranzaric.de>
13 years agoMakefile: handle shell commands (cmd/*-cmd.sh)
Zoran Zaric [Mon, 6 Dec 2010 12:00:07 +0000 (13:00 +0100)]
Makefile: handle shell commands (cmd/*-cmd.sh)

Signed-off-by: Zoran Zaric <zz@zoranzaric.de>
13 years agoAdds documentation for bup-import-rsnapshot
Zoran Zaric [Mon, 6 Dec 2010 12:00:06 +0000 (13:00 +0100)]
Adds documentation for bup-import-rsnapshot

Signed-off-by: Zoran Zaric <zz@zoranzaric.de>
13 years agoAdds import-rsnapshot command.
Zoran Zaric [Mon, 6 Dec 2010 12:00:05 +0000 (13:00 +0100)]
Adds import-rsnapshot command.

Signed-off-by: Zoran Zaric <zz@zoranzaric.de>
13 years agoAdds documentation for save's strip option.
Zoran Zaric [Mon, 6 Dec 2010 12:00:04 +0000 (13:00 +0100)]
Adds documentation for save's strip option.

Signed-off-by: Zoran Zaric <zz@zoranzaric.de>
13 years agoAdds testcases for --strip and --strip-path.
Zoran Zaric [Mon, 6 Dec 2010 12:00:03 +0000 (13:00 +0100)]
Adds testcases for --strip and --strip-path.

Signed-off-by: Zoran Zaric <zz@zoranzaric.de>
13 years agoAdds a strip and strip-path option to bup save.
Zoran Zaric [Mon, 6 Dec 2010 12:00:02 +0000 (13:00 +0100)]
Adds a strip and strip-path option to bup save.

If the strip option is given bup uses all given filenames as base paths
and tries to stripe them from long to short.

If the strip-path option is given bup strip the given prefix from all
paths.

Signed-off-by: Zoran Zaric <zz@zoranzaric.de>
13 years agoRefuse branch/tag names that start with a dot
Gabriel Filion [Thu, 2 Dec 2010 23:01:41 +0000 (18:01 -0500)]
Refuse branch/tag names that start with a dot

In git, branch and tag names are not allowed to start with a dot.

In bup, we also want to enforce this since we want to avoid collision with the
top-level special directories (.commit and .tag).

Also, in save-cmd, there was an unused variable at line 286. 'oldref' is used
and contains the same thing so get rid of 'ref'.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
13 years agotag-cmd: Some fixups
Gabriel Filion [Thu, 2 Dec 2010 23:01:40 +0000 (18:01 -0500)]
tag-cmd: Some fixups

* Make some error messages nicer in telling the tag name that was used.

* Move tag listing code in git.py and use this code in tag-cmd and vfs.py

* Make tag-cmd output the list of tags on stdout instead of stderr

* Don't error out when more than 2 arguments are given. When there are less
  than 2, be nice and show the usage.

* In tag-cmd, catch GitErrors that come out of git.rev_parse()

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
13 years agols-cmd: hide files with a leading dot by default
Gabriel Filion [Thu, 2 Dec 2010 22:58:42 +0000 (17:58 -0500)]
ls-cmd: hide files with a leading dot by default

All of the frontends currently don't show hidden files by default (named with a
leading dot).

Make ls-cmd hide those files by default and add an option, '-a' or '--all', to
make it possible to show hidden files.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
13 years agoRename receive-objects command to receive-objects-v2.
Avery Pennarun [Mon, 3 Jan 2011 04:38:44 +0000 (20:38 -0800)]
Rename receive-objects command to receive-objects-v2.

...since it's incompatible with the old one.  That will make it die more
spectacularly when talking to an old-style server, rather than failing in
more confusing ways.

Theoretically we could do fancy things like making our server support both
variants of receive-objects, but hey, bup is a pre-release, it shouldn't be
acquiring backwards compatibility cruft *already* :)

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agoWrite idxs directly rather than using git-index-pack.
Brandon Low [Mon, 3 Jan 2011 03:40:51 +0000 (19:40 -0800)]
Write idxs directly rather than using git-index-pack.

Also add a test round trip on idx r/w.

(Rearranged by apenwarr mostly due to merge conflicts.)

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agoSend SHAs from the client to reduce server load
Brandon Low [Sun, 2 Jan 2011 08:49:23 +0000 (00:49 -0800)]
Send SHAs from the client to reduce server load

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agoUse chunkyreader() instead of manually reading multiple blocks.
Brandon Low [Sun, 2 Jan 2011 08:49:22 +0000 (00:49 -0800)]
Use chunkyreader() instead of manually reading multiple blocks.

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
13 years agoSkip over invalid .idx files if we find any.
Avery Pennarun [Thu, 23 Dec 2010 02:08:58 +0000 (18:08 -0800)]
Skip over invalid .idx files if we find any.

There's no particular reason to make it fatal; just pretend they're not
there.

Zoran reported a bug where he had (it seems) some zero-length .idx files,
which is weird, but nothing worth aborting a backup over.

Also, fix _mmap_do() to be able to handle mmap'ing a zero-length file
without an error.  It's a trivial and somewhat pointless operation, but it
shouldn't throw an exception.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agocmd/server: find .idx filenames more efficiently when needed.
Avery Pennarun [Wed, 22 Dec 2010 18:49:20 +0000 (10:49 -0800)]
cmd/server: find .idx filenames more efficiently when needed.

Rather than mapping *all* the .idx files into memory at once just to look up
a single object, just open/read/close them sequentially.  This should
significantly increase the total repo size on a 32-bit system.  (Of course,
it's still not very ideal; we really should have some kind of fallback mode
for when our total set of indexes starts getting too big.)

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
13 years agoREADME.md: suggest using apt-get build-dep.
Jon Dowland [Sat, 18 Dec 2010 07:14:15 +0000 (23:14 -0800)]
README.md: suggest using apt-get build-dep.