]> arthur.barton.de Git - bup.git/log
bup.git
5 years agovfs: flatten resolution cache key
Rob Browning [Sat, 7 Jul 2018 17:20:47 +0000 (12:20 -0500)]
vfs: flatten resolution cache key

This will require more storage if there are a lot of lookups with the
same parent and differing paths, but otherwise, without more
intentional structure sharing among paths, this should be better, and
we can always revisit the arrangement later.

Serializing the parent path segments should also make sure the same
parent (semantically-speaking) contributes the same hash to the key.
Previously, Metadata objects could prevent that, given their trivial,
pointer-based hashes.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
5 years agolib/xstat: use // not / for int division for py3
Julien Goodwin [Thu, 30 Aug 2018 11:21:36 +0000 (21:21 +1000)]
lib/xstat: use // not / for int division for py3

Adjust nsecs_to_timespec() and nsecs_to_timeval() to use // for
integer division for py3.

Signed-off-by: Julien Goodwin <jgoodwin@studio442.com.au>
[rlb@defaultvalue.org: adjust commit message]
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
5 years agovfs: remove unused izip import
Julien Goodwin [Thu, 30 Aug 2018 10:53:09 +0000 (20:53 +1000)]
vfs: remove unused izip import

izip isn't available in python3 (standard zip now handles its case),
but it's not actually being used anyway.

Signed-off-by: Julien Goodwin <jgoodwin@studio442.com.au>
[rlb@defaultvalue.org: adjust commit summary and wrap body]
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
5 years agoUpdate file() calls to open() for py3
Julien Goodwin [Thu, 30 Aug 2018 10:35:32 +0000 (20:35 +1000)]
Update file() calls to open() for py3

Signed-off-by: Julien Goodwin <jgoodwin@studio442.com.au>
[rlb@defaultvalue.org: adjust commit message]
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
5 years agolib/gc: update lambda syntax for py3
Julien Goodwin [Thu, 30 Aug 2018 10:16:57 +0000 (20:16 +1000)]
lib/gc: update lambda syntax for py3

Signed-off-by: Julien Goodwin <jgoodwin@studio442.com.au>
[rlb@defaultvalue.org: adjust commit summary]
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
5 years agoRefuse to run by default if python version is not 2
Rob Browning [Sun, 2 Sep 2018 17:29:01 +0000 (12:29 -0500)]
Refuse to run by default if python version is not 2

Exit with an error if the python major version isn't 2, since we're
working on support for py3, and we'll probably reach a point before
we're finished where bup doesn't immediately crash with py3, but might
well do very bad things to the repository.

Allow overriding the check by setting
BUP_ALLOW_UNEXPECTED_PYTHON_VERSION=true so people can still test py3
if they like.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
5 years agofuse-cmd: update exception raising for py3
Julien Goodwin [Thu, 30 Aug 2018 09:58:48 +0000 (19:58 +1000)]
fuse-cmd: update exception raising for py3

Signed-off-by: Julien Goodwin <jgoodwin@studio442.com.au>
[rlb@defaultvalue.org: adjust commit message]
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
5 years agotindex: add 0o to current octal literal
Julien Goodwin [Thu, 30 Aug 2018 09:57:18 +0000 (19:57 +1000)]
tindex: add 0o to current octal literal

Needed for python3.

This preserves current behaviour, but since I get no test failures if I
just chop of the leading 0 and make it a normal int there's a good
chance there's underlying breakage.

Signed-off-by: Julien Goodwin <jgoodwin@studio442.com.au>
[rlb@defaultvalue.org: adjust commit message summary]
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
5 years agoMigrate all xrange calls to range in bup.compat
Julien Goodwin [Thu, 30 Aug 2018 08:38:48 +0000 (18:38 +1000)]
Migrate all xrange calls to range in bup.compat

Signed-off-by: Julien Goodwin <jgoodwin@studio442.com.au>
[rlb@defaultvalue.org: adjust commit message summary]
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
5 years agoReplace remaining print statements with print function
Julien Goodwin [Thu, 30 Aug 2018 08:25:25 +0000 (18:25 +1000)]
Replace remaining print statements with print function

Also add the appropriate __future__ import statement.

Signed-off-by: Julien Goodwin <jgoodwin@studio442.com.au>
[rlb@defaultvalue.org: memtest-cmd.py: remove a few preexisting
 trailing spaces that were carried over; adjust commit summary]
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
5 years agovfs: include unique repo id in resolution cache key
Rob Browning [Fri, 6 Jul 2018 17:01:55 +0000 (12:01 -0500)]
vfs: include unique repo id in resolution cache key

...since resolve() currently requires a full parent path and the root
refs are only applicable to a particular repository.

Use differing integers to identify repositories that may be
independent (with respect to refs, tags, etc.), and use (typically
small) integers rather than the repo path/address so that they'll be
short if we want to embed them directly in cache keys later.

Use realpath() for local repositories in order to detect when the same
repository is reachable by multiple paths.  (Something similar could
eventually be done for remotes.)

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
5 years agoHACKING: delete hyphen; actual file is CODINGSTYLE, not CODING-STYLE
Julien Goodwin [Sat, 18 Aug 2018 01:38:57 +0000 (18:38 -0700)]
HACKING: delete hyphen; actual file is CODINGSTYLE, not CODING-STYLE

Signed-off-by: Julien Goodwin <jgoodwin@studio442.com.au>
[rlb@defaultvalue.org: adjust commit message]
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
5 years agoREADME: mention BUP_DIR config more clearly
Rob Browning [Sat, 18 Aug 2018 19:54:36 +0000 (14:54 -0500)]
README: mention BUP_DIR config more clearly

Thanks to Mateusz Konieczny for the suggestion.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
5 years agoREADME: replace du code example's tab prefix with spaces
Mateusz Konieczny [Mon, 30 Jul 2018 06:04:49 +0000 (08:04 +0200)]
README: replace du code example's tab prefix with spaces

The command wasn't rendered as code before this change.

Signed-off-by: Mateusz Konieczny <matkoniecz@gmail.com>
[rlb@defaultvalue.org: adjust commit message]
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
5 years agotest-xdev: use different filesystem images for each mount point
Rob Browning [Sat, 11 Aug 2018 20:30:18 +0000 (15:30 -0500)]
test-xdev: use different filesystem images for each mount point

Previously we were mounting the same image twice, which was
unintended, and may produce the same device number.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
5 years agotest-index-check-device: use separate files for loopback mounts
Rob Browning [Sat, 11 Aug 2018 17:24:07 +0000 (12:24 -0500)]
test-index-check-device: use separate files for loopback mounts

Previously we were mounting the same image twice, which may produce
the same device number.

Thanks to Mateusz Pavlic for reporting the problem.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
5 years agoFix attributes misspelling in bup-index.md
Artem Leshchev [Sun, 29 Jul 2018 08:33:59 +0000 (11:33 +0300)]
Fix attributes misspelling in bup-index.md

Fix small typo that lintian shows me every time I compile deb package.

Signed-off-by: Artem Leshchev <matshch@gmail.com>
[rlb@defaultvalue.org: adjust commit message]
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
5 years agoREADME: fix outdated comments about LWN and about reliability
Rob Browning [Sun, 29 Jul 2018 18:44:44 +0000 (13:44 -0500)]
README: fix outdated comments about LWN and about reliability

Thanks to matkoniecz for bringing them up.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
5 years agoREADME: update minimum git version to 1.5.6
Rob Browning [Sun, 29 Jul 2018 18:39:43 +0000 (13:39 -0500)]
README: update minimum git version to 1.5.6

Given the changes in db8a2b95e2cc44f7070ae6ac0bbc086e51696c72

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
5 years agovfs.contents: remove unreachable code to handle commit blobs
Rob Browning [Fri, 6 Jul 2018 20:11:19 +0000 (15:11 -0500)]
vfs.contents: remove unreachable code to handle commit blobs

It shouldn't be possible to encounter an Item referring to a commit
blob because they're all (supposed to be) wrapped by a Commit.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
5 years agosplit: use // not / for division
Rob Browning [Sun, 21 Jan 2018 22:26:24 +0000 (16:26 -0600)]
split: use // not / for division

Without this, columnate can go off into the weeds because Python 3
changed / to floating point.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
5 years agohelpers: use compat.range everywhere for py3
Rob Browning [Sun, 24 Jun 2018 20:57:03 +0000 (15:57 -0500)]
helpers: use compat.range everywhere for py3

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
5 years agohelpers: use // not / for division
Rob Browning [Sun, 21 Jan 2018 22:26:24 +0000 (16:26 -0600)]
helpers: use // not / for division

...because Python 3 changed / to floating point.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
5 years agotimespec_to_nsecs(): don't destructure arguments
Rob Browning [Sun, 24 Jun 2018 20:44:48 +0000 (15:44 -0500)]
timespec_to_nsecs(): don't destructure arguments

Python 3 doesn't allow it.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
5 years agosplit: switch to print_function
Rob Browning [Thu, 18 Jan 2018 01:57:47 +0000 (19:57 -0600)]
split: switch to print_function

Python 3 requires it.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
5 years agosplit: don't require a repo unless we need it
Rob Browning [Sat, 7 Apr 2018 20:04:44 +0000 (15:04 -0500)]
split: don't require a repo unless we need it

This can be handy if you just want to test split performance, e.g.

  time ./bup split --noop whatever

etc.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
5 years agovfs: cache resolve() calls to improve (fuse) performance
Rob Browning [Sun, 6 May 2018 16:46:45 +0000 (11:46 -0500)]
vfs: cache resolve() calls to improve (fuse) performance

Include resolve() results in the vfs cache.  This substantially
improves fuse "cat somefile" performance.  (Observed a ~2x rate
improvement with a 500MB urandom file).

This appears to be due to the fact that fuse read(path, offset, len)
is called many times for the file, resulting in many corresponding,
redundant resolve(path) calls.

The previous fuse implementation, based on the previous vfs had its
own cache, but moving the caching to the vfs should be more generally
helpful.

Now bup fuse will again ignore repository changes that affect paths it
has already examined.  This matches its behavior in the current stable
release (0.29.1).

Thanks to voldial for reporting the problem.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
5 years agobup-split.md: indicate --noop doesn't require -t and -n
Rob Browning [Sun, 24 Jun 2018 16:52:26 +0000 (11:52 -0500)]
bup-split.md: indicate --noop doesn't require -t and -n

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
5 years agotest-split-join: test that split --noop produces no output
Rob Browning [Sun, 24 Jun 2018 16:32:42 +0000 (11:32 -0500)]
test-split-join: test that split --noop produces no output

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
5 years agoAdd bup split --noop <--blobs|--tree>
Robert Evans [Sun, 29 Apr 2018 10:47:30 +0000 (06:47 -0400)]
Add bup split --noop <--blobs|--tree>

This prints the resulting id without storing in the repo.

Signed-off-by: Robert Evans <evansr@google.com>
[rlb@defaultvalue.org: remove trailing period from commit summary]
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
5 years agovfs.copy_item: don't try to copy an integer mode
Rob Browning [Sun, 6 May 2018 17:19:18 +0000 (12:19 -0500)]
vfs.copy_item: don't try to copy an integer mode

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
5 years agocache_notice: import randrange; use del not pop(); add tests
Rob Browning [Sun, 6 May 2018 15:56:50 +0000 (10:56 -0500)]
cache_notice: import randrange; use del not pop(); add tests

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
5 years agoprint_clean_line: don't print final sep when None
Rob Browning [Sun, 6 May 2018 15:20:03 +0000 (10:20 -0500)]
print_clean_line: don't print final sep when None

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agofix t/root-status for CygWin
Patrick Rouleau [Mon, 23 Apr 2018 01:47:37 +0000 (21:47 -0400)]
fix t/root-status for CygWin

Signed-off-by: Patrick Rouleau <prouleau72@gmail.com>
Tested-by: Patrick Rouleau <prouleau72@gmail.com>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
6 years agoAdd missing space in bup split --bench output.
Robert Evans' via bup-list [Tue, 24 Apr 2018 02:12:35 +0000 (22:12 -0400)]
Add missing space in bup split --bench output.

Signed-off-by: Robert Evans <evansr@google.com>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
6 years agois_superuser: test for group 544 or 0 on cygwin
Rob Browning [Sat, 31 Mar 2018 16:53:24 +0000 (11:53 -0500)]
is_superuser: test for group 544 or 0 on cygwin

This appears to be the appropriate way to check for admin status in
cygwin right now: https://cygwin.com/ml/cygwin/2015-02/msg00057.html

Thanks to at least Andrew Skretvedt, Ruvim Pinka, renpj, and Iar De
for reporting the problem, Ruvim Pinka, Paul Kronenwetter, and renpj
for proposing earlier solutions, and Ben Kelly and Johannes Berg for
helping test this approach.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
6 years agoCatPipe.get: fix error message construction (wrong var)
Rob Browning [Sun, 1 Apr 2018 17:05:17 +0000 (12:05 -0500)]
CatPipe.get: fix error message construction (wrong var)

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agorepo: make repository classes closeable and close client for remotes
Rob Browning [Sat, 31 Mar 2018 20:10:45 +0000 (15:10 -0500)]
repo: make repository classes closeable and close client for remotes

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoMake PackWriter a "with" context manager
Rob Browning [Sat, 31 Mar 2018 20:30:02 +0000 (15:30 -0500)]
Make PackWriter a "with" context manager

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
6 years agoPackWriter: allow specification of a repo_dir
Rob Browning [Sat, 31 Mar 2018 20:25:55 +0000 (15:25 -0500)]
PackWriter: allow specification of a repo_dir

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agobuptest: base testing subproc funcs ex() and exo() on run()
Rob Browning [Sat, 31 Mar 2018 18:24:48 +0000 (13:24 -0500)]
buptest: base testing subproc funcs ex() and exo() on run()

Rework the subprocess functions, providing ex() and exo() as concise
test functions that print the commands they're executing.  Base them
on a common, lower-level run() function.

Drop exc() since ex() and exo() both check the exit status by default.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agotclient: invoke bup via absolute path
Rob Browning [Sat, 22 Mar 2014 19:07:09 +0000 (14:07 -0500)]
tclient: invoke bup via absolute path

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agobuptest: don't depend on helpers.mkdirp
Rob Browning [Wed, 28 Mar 2018 05:30:33 +0000 (00:30 -0500)]
buptest: don't depend on helpers.mkdirp

Better to keep the test harness independent when the relevant code is
this simple.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agocompat: add range and use it in the vfs
Rob Browning [Sat, 31 Mar 2018 21:42:53 +0000 (16:42 -0500)]
compat: add range and use it in the vfs

Define range as range for py3 and xrange for py2, so that we'll have
the same semantics both places.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agovfs: limit root_items branches to refs/heads
Rob Browning [Sat, 31 Mar 2018 19:48:16 +0000 (14:48 -0500)]
vfs: limit root_items branches to refs/heads

...since the top-level VFS names (without a dot prefix) should only
resolve to branches.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoSIGNED-OFF-BY: defer to ./LICENSE
Rob Browning [Tue, 27 Mar 2018 04:17:42 +0000 (23:17 -0500)]
SIGNED-OFF-BY: defer to ./LICENSE

Previously, the SIGNED-OFF-BY only referred to the LGPL-2, even though
several files are covered under a different license (described in
LICENSE).

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
6 years agoAdd "AND CONTRIBUTORS" to options.py license
Rob Browning [Tue, 27 Mar 2018 04:09:38 +0000 (23:09 -0500)]
Add "AND CONTRIBUTORS" to options.py license

From https://groups.google.com/d/msg/bup-list/8lcxXuXilTE/JC9rm69oAQAJ

  From: Avery Pennarun <apenwarr@gmail.com>
  Date: Sun, 25 Mar 2018 21:35:58 -0400
  Message-ID: <CAHqTa-2LB2mqscnzZmmixeTbR86BPh=FTk3UyGQKjPwaQPrZ3g@mail.gmail.com>
  Subject: Re: bupsplit.c copyright and patching
  To: Rob Browning <rlb@defaultvalue.org>
Cc: Robert Evans <evansr@google.com>, bup-list <bup-list@googlegroups.com>
  On Sun, Mar 25, 2018 at 1:48 PM, Rob Browning <rlb@defaultvalue.org> wrote:
  > Avery Pennarun <apenwarr@gmail.com> writes:
  >> On Sun, Mar 18, 2018 at 11:52 AM, Rob Browning <rlb@defaultvalue.org> wrote:
  >>> Avery Pennarun <apenwarr@gmail.com> writes:
  >>> So for the record, it sounds like you approve of changing the relevant
  >>> bupsplit.h and bupsplit.c phrase to this?
  >>>
  >>>   THIS SOFTWARE IS PROVIDED BY AVERY PENNARUN AND CONTRIBUTORS``AS IS'' AND ANY
  >>
  >> Yes, that's fine.
  >
  > And perhaps you'd approve of making the same change to options.py as
  > well?

  Good idea.  Let's do that :)

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
6 years agoAdd "AND CONTRIBUTORS" to bupsplit.h and bupsplit.c licenses
Rob Browning [Sun, 25 Mar 2018 17:19:53 +0000 (12:19 -0500)]
Add "AND CONTRIBUTORS" to bupsplit.h and bupsplit.c licenses

From https://groups.google.com/d/msg/bup-list/8lcxXuXilTE/UyOe7VGuCQAJ

  From: Avery Pennarun <apenwarr@gmail.com>
  Date: Sun, 18 Mar 2018 18:35:15 -0400
  Message-ID: <CAHqTa-1ghU6+Y0Y2pBOjbS=7CWKMytPvj-c1Z0aE3=PqpPi1OA@mail.gmail.com>
  Subject: Re: bupsplit.c copyright and patching
  To: Rob Browning <rlb@defaultvalue.org>
Cc: Robert Evans <evansr@google.com>, bup-list <bup-list@googlegroups.com>
    ...

  > So for the record, it sounds like you approve of changing the relevant
  > bupsplit.h and bupsplit.c phrase to this?
  >
  >   THIS SOFTWARE IS PROVIDED BY AVERY PENNARUN AND CONTRIBUTORS``AS IS'' AND ANY

  Yes, that's fine.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
6 years agotest-sparse-files: check sparse file size more carefully
Rob Browning [Tue, 27 Mar 2018 04:29:17 +0000 (23:29 -0500)]
test-sparse-files: check sparse file size more carefully

Test the actual sparse file with du, not the parent restore
directory.  Unnecessarily testing the whole tree broke the tests on a
docker system because the directories themselves were large.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years ago_cmp_sha: Replace manual sha comparison with memcmp
Rob Browning [Sun, 25 Feb 2018 18:03:21 +0000 (10:03 -0800)]
_cmp_sha: Replace manual sha comparison with memcmp

...under the assumption that the platform-specific version may be more
efficient.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoREADME.md: recommend the stable release when building from source
Rob Browning [Tue, 13 Mar 2018 01:09:45 +0000 (20:09 -0500)]
README.md: recommend the stable release when building from source

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
6 years agoRevert "lib/__init__.py: remove, since lib is not a package"
Rob Browning [Tue, 13 Mar 2018 01:05:21 +0000 (20:05 -0500)]
Revert "lib/__init__.py: remove, since lib is not a package"

...because at the moment this breaks wvtest.py.

This reverts commit 90ffb64f57bd754a7c562171c5a11c441f97bbfa.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agolib/__init__.py: remove, since lib is not a package
Rob Browning [Sat, 10 Mar 2018 19:16:02 +0000 (13:16 -0600)]
lib/__init__.py: remove, since lib is not a package

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoSwitch mincore to Py_buffer for py3
Rob Browning [Sun, 25 Feb 2018 17:50:05 +0000 (09:50 -0800)]
Switch mincore to Py_buffer for py3

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
6 years agoMakefile: Don't use printf '\c'; not needed, and not portable
Rob Browning [Sat, 10 Feb 2018 16:18:08 +0000 (10:18 -0600)]
Makefile: Don't use printf '\c'; not needed, and not portable

Remove the printf '\c' introduced in
3306a802a11b8d945af081cb835bb7fe208dc84c.

Thanks to Alexander Barton for reporting the problem (seen on macOS)
and proposing an alternate solution.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agomain: don't set stdio to nonblocking
Rob Browning [Sat, 27 Jan 2018 21:19:24 +0000 (15:19 -0600)]
main: don't set stdio to nonblocking

This was left in the newliner replacement patch, and I can't remember
a justification for it.  Having it in there affects other processes,
so take it out.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agogit.repo: don't unintentionally set global repodir
Rob Browning [Wed, 31 Jan 2018 07:26:27 +0000 (01:26 -0600)]
git.repo: don't unintentionally set global repodir

Stop setting the global repodir when probing for and finding a .git/
subdirectory.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoLocalRepo.__init__: use correct dir everywhere
Rob Browning [Wed, 31 Jan 2018 06:32:36 +0000 (00:32 -0600)]
LocalRepo.__init__: use correct dir everywhere

Don't set self.repo_dir to the correct value and then ignore that when
setting _cp and rev_list.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoUse absolute_import from the __future__ everywhere
Rob Browning [Sat, 27 Jan 2018 17:40:02 +0000 (11:40 -0600)]
Use absolute_import from the __future__ everywhere

Without this, among other things, we can end up with conflicts with
new upstream modules.  For example, given lib/bup/io.py:

  Traceback (most recent call last):
    File "/home/rlb/src/bup/main-4/cmd/bup-index", line 10, in <module>
      from bup import metadata, options, git, index, drecurse, hlinkdb
    File "/home/rlb/src/bup/main-4/lib/bup/metadata.py", line 10, in <module>
      from io import BytesIO
  ImportError: cannot import name BytesIO

This switch also revealed a circular dependency between midx and git,
and several places where we weren't qualifying our bup imports
properly, i.e. "import git" rather than "from bup import git".

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoRemove circular dep between git and midx
Rob Browning [Sat, 27 Jan 2018 17:39:30 +0000 (11:39 -0600)]
Remove circular dep between git and midx

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years ago_helpers: fix module init, and get it at least building with py3
Rob Browning [Sat, 20 Jan 2018 20:15:13 +0000 (14:15 -0600)]
_helpers: fix module init, and get it at least building with py3

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoAdd compat.items() and use it
Rob Browning [Thu, 18 Jan 2018 02:00:00 +0000 (20:00 -0600)]
Add compat.items() and use it

Python 3 made items behave like iteritems and dropped iteritems.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoDon't use cmp()
Rob Browning [Mon, 13 Mar 2017 06:08:39 +0000 (01:08 -0500)]
Don't use cmp()

Python 3 dropped it.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agocolumnate: use // not / for division
Rob Browning [Sun, 21 Jan 2018 22:26:24 +0000 (16:26 -0600)]
columnate: use // not / for division

Without this, columnate can go off into the weeds because Python 3
changed / to floating point.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agopath_components: adjust exception raise for py3
Rob Browning [Sat, 20 Jan 2018 20:17:14 +0000 (14:17 -0600)]
path_components: adjust exception raise for py3

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoversion: switch to print_function
Rob Browning [Thu, 18 Jan 2018 01:57:47 +0000 (19:57 -0600)]
version: switch to print_function

Python 3 requires it.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agooptions: use items() instead of iteritems()
Rob Browning [Thu, 18 Jan 2018 01:56:46 +0000 (19:56 -0600)]
options: use items() instead of iteritems()

Python 3 dropped iteritems().

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoroot-status: use print_function
Rob Browning [Wed, 15 Mar 2017 04:05:14 +0000 (23:05 -0500)]
root-status: use print_function

Python 3 requires it.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoIgnore mincore when it returns ENOSYS
Rob Browning [Sat, 13 Jan 2018 16:23:49 +0000 (10:23 -0600)]
Ignore mincore when it returns ENOSYS

Observed on WSL.  Thanks to Levent Dane <leventdane@gmail.com> for
reporting the problem and helping test the fix.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
6 years agoClean subprocess output without newliner
Rob Browning [Sun, 26 Jun 2016 20:49:14 +0000 (15:49 -0500)]
Clean subprocess output without newliner

Instead of launching a newliner subprocess from main.py to clean up the
output from other subprocesses (with respect to \r, shorter lines as
compared to the previous line, etc.), do something similar directly from
main.py via select, and then drop all of the attendant signal
forwarding, subprocess detaching via setsid(), etc. that the newliner
arrangement had accumulated.

Among other things, this should make bup much more responsive to
TERM/QUIT/etc. signals (i.e. C-c).  Previously the
index/save/... subprocess might continue running even after bup
appeared to have quit.

To clean up the output, regularly check tty_width() and always write
"whole" space-padded lines, tracking stdout and stderr independently
(bup-newliner redirected both to stdout).

Related:

  aa6f2c87e6f1292f1fa22f618532b65a5565d604
  b7a524ccb662c9ed3ebd786da0f45f459929ef45
  119f9dd3b3421c31578105954a34fc5e32826ae5
  073b383882e73904ae04179e69a68419d8d57199

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agowvtest: set a very large timeout to disable test time colors
Rob Browning [Sun, 31 Dec 2017 19:29:53 +0000 (13:29 -0600)]
wvtest: set a very large timeout to disable test time colors

I find them distracting and would rather only "see red" for failed
tests.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoCODINGSTYLE: add python exception handling guidelines
Rob Browning [Sun, 31 Dec 2017 18:29:05 +0000 (12:29 -0600)]
CODINGSTYLE: add python exception handling guidelines

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
6 years agochain_ex: don't opportunistically add tracebacks to context_ex
Rob Browning [Sun, 31 Dec 2017 18:23:01 +0000 (12:23 -0600)]
chain_ex: don't opportunistically add tracebacks to context_ex

Don't add a traceback to the context_ex while chaining.  This could be
wrong, depending on the context, and in the common case, the traceback
more likely belonged on the result exception, not the context_ex.,
i.e.

  except ... as ex:
      raise chain_ex(ex, pending_ex)

Instead, just combine chain_ex with add_ex_tb when appropriate:

  except ... as ex:
      raise chain_ex(add_tb_ex(ex), pending_ex)

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoadd_ex_tb: return the exception
Rob Browning [Sun, 31 Dec 2017 18:15:40 +0000 (12:15 -0600)]
add_ex_tb: return the exception

Allows:

  chain_ex(add_ex_tb(ex2), ex)

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoCODINGSTYLE: convert to restructured text
Rob Browning [Sun, 31 Dec 2017 17:53:16 +0000 (11:53 -0600)]
CODINGSTYLE: convert to restructured text

6 years agoDESIGN: remove surplus ``relevant''
bedhanger [Mon, 27 Mar 2017 16:39:58 +0000 (18:39 +0200)]
DESIGN: remove surplus ``relevant''

Signed-off-by: bedhanger <bedhanger@gmx.de>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
6 years agoDESIGN: resolve duplicates: ``to to'' & ``and and''
bedhanger [Mon, 27 Mar 2017 16:37:08 +0000 (18:37 +0200)]
DESIGN: resolve duplicates: ``to to'' & ``and and''

Signed-off-by: bedhanger <bedhanger@gmx.de>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
6 years agosplit: add missing import "parse_date_or_fatal"
Fabian xx4h Melters [Tue, 1 Aug 2017 14:45:11 +0000 (16:45 +0200)]
split: add missing import "parse_date_or_fatal"

Without this "bup split -n NAME -d STAMP FILE" produces an error:

  Traceback (most recent call last):
    File "/usr/lib/bup/cmd/bup-split", line 67, in <module>
      date = parse_date_or_fatal(opt.date, o.fatal)
  NameError: name 'parse_date_or_fatal' is not defined

Signed-off-by: Fabian 'xx4h' Melters <xx4h@xx4h.de>
[rlb@defaultvalue.org: rebase on current master; adjust commit
 message; fix commit author]
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoRemove vfs (replaced by vfs2)
Rob Browning [Wed, 27 Dec 2017 16:35:01 +0000 (10:35 -0600)]
Remove vfs (replaced by vfs2)

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoPort fuse to vfs2
Rob Browning [Sat, 2 Dec 2017 19:31:13 +0000 (13:31 -0600)]
Port fuse to vfs2

The test adjustment was necessary because fuse now notices new saves.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoPort web to vfs2
Rob Browning [Sat, 2 Dec 2017 19:31:29 +0000 (13:31 -0600)]
Port web to vfs2

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoPort ftp to vfs2 and add test-ftp
Rob Browning [Sun, 26 Nov 2017 22:08:19 +0000 (16:08 -0600)]
Port ftp to vfs2 and add test-ftp

Just test for the existing behavior for now.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agols: move opt processing to opts_from_commandline
Rob Browning [Sun, 26 Nov 2017 21:53:20 +0000 (15:53 -0600)]
ls: move opt processing to opts_from_commandline

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoexc: support input arg; return SubprocInfo from exc and exo
Rob Browning [Sun, 26 Nov 2017 19:24:41 +0000 (13:24 -0600)]
exc: support input arg; return SubprocInfo from exc and exo

Change exo to return a namedtuple so that you can refer to bits of the
result by name.

Base exc on exo so that it can support an input arg (even in python2),
and change both exc and exo to be a thinner wrapper around Popen so
that the arguments will behave roughly the same.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoMove exc, exo, and logcmd to buptest.py
Rob Browning [Sun, 26 Nov 2017 20:02:49 +0000 (14:02 -0600)]
Move exc, exo, and logcmd to buptest.py

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoPort tmetadata to vfs2
Rob Browning [Mon, 9 Oct 2017 05:15:58 +0000 (00:15 -0500)]
Port tmetadata to vfs2

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoPort rm and prune-older to vfs2
Rob Browning [Sat, 14 Oct 2017 17:03:31 +0000 (12:03 -0500)]
Port rm and prune-older to vfs2

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agovfs2: add trivial random eviction commit cache
Rob Browning [Mon, 13 Nov 2017 04:44:03 +0000 (22:44 -0600)]
vfs2: add trivial random eviction commit cache

Porting rm and gc to vfs2 has put us at the point where we need at
least some caching so that we're not invoking git an endless number of
times when trying to "bup rm" 1000 saves (i.e. via test-prune-older if
nothing else).  Start with a very primitive, fixed-size commit cache
with random eviction.

It's not clear that the cache should always be enabled.  While it may
help commands like rm, prune-older, fuse, web, ftp, etc., it may often
just be extra baggage for for commands like restore, ls, cat-file, ...

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoPort cat-file to vfs2
Rob Browning [Sun, 8 Oct 2017 20:09:53 +0000 (15:09 -0500)]
Port cat-file to vfs2

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agovfs2: add tree_data_reader for use by cat-file
Rob Browning [Sat, 9 Dec 2017 16:51:10 +0000 (10:51 -0600)]
vfs2: add tree_data_reader for use by cat-file

The cat-file command needs to be able to read arbitrary oids (chunked
or not) for --bupm, so add tree_data_reader for that purpose and
adjust fopen() to depend on it.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoSupport remote listings: bup ls -r ...
Rob Browning [Sun, 8 Oct 2017 14:54:39 +0000 (09:54 -0500)]
Support remote listings: bup ls -r ...

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
6 years agols: retrieve all of the available metadata when requested
Rob Browning [Sat, 9 Dec 2017 00:23:53 +0000 (18:23 -0600)]
ls: retrieve all of the available metadata when requested

When a detailed listing is requested, use ensure_item_has_metadata()
to provide all of the available metadata for each
item (e.g. directories).

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agovfs2: add try_resolve() and use it in ls
Rob Browning [Sun, 3 Dec 2017 17:31:18 +0000 (11:31 -0600)]
vfs2: add try_resolve() and use it in ls

Create a vfs2 version of try_resolve and use it in ls to handle bad
symlinks correctly.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agols: add --commit-hash and drop vfs nominal_oid
Rob Browning [Sat, 9 Dec 2017 00:21:21 +0000 (18:21 -0600)]
ls: add --commit-hash and drop vfs nominal_oid

Report the tree hash for commits for ls -s, unless --commit-hash is
also specified, and add some initial tests.  This brings -s in line
with 38a49e9eb930e8a47e9de5a9715fad659a774e8b.

Report 0000000000000000000000000000000000000000 for items without a
hash so that the number of output fields doesn't vary in that case.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agovfs2._resolve_path: improve handling ENOTDIR, absolute paths, etc.
Rob Browning [Sat, 9 Dec 2017 19:46:13 +0000 (13:46 -0600)]
vfs2._resolve_path: improve handling ENOTDIR, absolute paths, etc.

Handle and test various path_resolution(7) cases more carefully.
e.g. ensure a trailing '/' or '/.' forces resolution, ensure a
non-final path element that's not a directory produces ENOTDIR, ...
Add tests for the these, for bad symlink handling, and a for number of
other cases.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agovfs2: drop custom Loop error; just use ELOOP IOError
Rob Browning [Sat, 9 Dec 2017 19:41:36 +0000 (13:41 -0600)]
vfs2: drop custom Loop error; just use ELOOP IOError

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agovfs2: report tree metadata for commits
Rob Browning [Sat, 4 Nov 2017 20:55:23 +0000 (15:55 -0500)]
vfs2: report tree metadata for commits

Don't synthesize metadata for a commit (like /foo, /foo/2017-..., or
/.tag/some-commit) by reporting the author date as the mtime, instead
use the metadata for the underlying commit tree.

Among other things, this avoids an inconsistency between the metadata
for ".../commit" and ".../commit/.".

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agovfs2: add fill_in_metadata_if_dir and ensure_item_has_metadata
Rob Browning [Sat, 4 Nov 2017 20:41:33 +0000 (15:41 -0500)]
vfs2: add fill_in_metadata_if_dir and ensure_item_has_metadata

Add fill_in_metadata_if_dir() as a contents() helper since contents()
does not return metadata for directories (because it's expensive).

This supports:

  (name, fill_in_metadata_if_dir(repo, item)
   for name, item in tuple(contents(...)))

Add ensure_item_has_metadata() to combine fill_in_metadata_if_dir()
and augment_item_meta() for cases like "ls -l" where you want
every item to have all the metadata available, and to have a Metadata
instance (even if faked), not just a mode.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoPort ls to vfs2
Rob Browning [Sat, 7 Oct 2017 21:37:04 +0000 (16:37 -0500)]
Port ls to vfs2

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agovfs2: distinguish commits with a Commit type
Rob Browning [Sat, 14 Oct 2017 16:58:08 +0000 (11:58 -0500)]
vfs2: distinguish commits with a Commit type

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