]> arthur.barton.de Git - bup.git/log
bup.git
6 years agoFix build error on macOS: "printf: missing format character" fix-macos-printf-format-character
Alexander Barton [Sat, 10 Feb 2018 14:46:49 +0000 (15:46 +0100)]
Fix build error on macOS: "printf: missing format character"

Commit 3306a802a11b8d "_helpers: fix module init, and get it at least
building with py3" breaks building bup on macOS:

  $ make
  [...]
  running build_ext
  find lib/bup/build/* -maxdepth 1 -name '_helpers*.so' \
            -exec printf 'x\c' '{}' \; | wc -c | xargs test 1 -eq
  printf: missing format character
  make: *** [lib/bup/_helpers.so] Error 1

So don't count characters printed for each file found, but count the
filenames found ("lines") itself.

Tested on Debian Linux 9 and macOS 10.13.3.

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>
6 years agovfs2._tree_data_and_bupm: make public
Rob Browning [Sat, 9 Dec 2017 19:35:20 +0000 (13:35 -0600)]
vfs2._tree_data_and_bupm: make public

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agovfs2.resolve: verify result is not a symlink
Rob Browning [Sun, 3 Dec 2017 17:24:28 +0000 (11:24 -0600)]
vfs2.resolve: verify result is not a symlink

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agovfs2._resolve_path: require parent to be a path sequence
Rob Browning [Sat, 25 Nov 2017 17:10:03 +0000 (11:10 -0600)]
vfs2._resolve_path: require parent to be a path sequence

Require an actual path sequence for the parent since it provides the
context for the resolution of the path (with respect to relative
paths, symlinks containing .., etc.).

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agovfs2._resolve_path: replace + with append() for result lists
Rob Browning [Sat, 25 Nov 2017 17:09:18 +0000 (11:09 -0600)]
vfs2._resolve_path: replace + with append() for result lists

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agovfs2: suffix duplicate save names (e.g. 1970-01-01-214640-07)
Rob Browning [Sun, 15 Oct 2017 19:40:15 +0000 (14:40 -0500)]
vfs2: suffix duplicate save names (e.g. 1970-01-01-214640-07)

From now on, append zero-padded integers to the names of saves that
have the same commit time in order to avoid duplicates.  The sequence
number currently represents the save's reversed position in default
rev-list order, so that given:

  /foo/1970-01-01-214640-09
  /foo/1970-01-01-214640-10

In the normal case, the -10 save would indicate the next save made
after -09 (and the -09 save would be the single parent commit for
-10).

Thanks to Ben Kelley for helping me sort out some of the details.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agotest-ls: strip the test tempdir from the test save
Rob Browning [Sat, 16 Dec 2017 19:57:24 +0000 (13:57 -0600)]
test-ls: strip the test tempdir from the test save

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years ago_git_wait: pass cmd to GitError through shstr
Rob Browning [Sat, 4 Nov 2017 18:52:28 +0000 (13:52 -0500)]
_git_wait: pass cmd to GitError through shstr

Tested-by: Rob Browning <rlb@defaultvalue.org>
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
6 years agovfs2: contents - remove superfluous commit blob fetch
Rob Browning [Sat, 2 Dec 2017 19:40:22 +0000 (13:40 -0600)]
vfs2: contents - remove superfluous commit blob fetch

Tested-by: Rob Browning <rlb@defaultvalue.org>
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
6 years agovfs2: tree-items - fix incorrect sort-order based short-circuit
Rob Browning [Sat, 2 Dec 2017 19:39:22 +0000 (13:39 -0600)]
vfs2: tree-items - fix incorrect sort-order based short-circuit

Tested-by: Rob Browning <rlb@defaultvalue.org>
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
6 years agovfs2: remove redundant tuple() from tree_items arg
Rob Browning [Sat, 2 Dec 2017 19:38:02 +0000 (13:38 -0600)]
vfs2: remove redundant tuple() from tree_items arg

Tested-by: Rob Browning <rlb@defaultvalue.org>
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
6 years agotest-rm: fix regexes to handle newer *and* older git
Rob Browning [Sat, 11 Nov 2017 17:53:56 +0000 (11:53 -0600)]
test-rm: fix regexes to handle newer *and* older git

To accommodate optional lines, we need to use a construct like this:

  foo(
  bar)?

instead of this:

  foo
  (bar)?

The problem became apparent when people tested against older git after
the introduction of the patch to work with newer git:
292361d86d1cf0cc555681ae43371d66c8ebb366

Thanks to Greg Troxel and Basil Mohamed Gohar for reporting the
problem.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoftp: fix trivial typo
Rob Browning [Sat, 14 Oct 2017 16:28:45 +0000 (11:28 -0500)]
ftp: fix trivial typo

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
6 years ago_resolve_path: ensure vfs content() iterator is exhausted
Rob Browning [Sun, 5 Nov 2017 18:35:36 +0000 (12:35 -0600)]
_resolve_path: ensure vfs content() iterator is exhausted

Otherwise we leave git rev-list zombies lying around (spawned by
contents() (revlist_items)).

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agotest-rm: accommodate packed-refs creation by newer git
Rob Browning [Sat, 21 Oct 2017 16:27:15 +0000 (11:27 -0500)]
test-rm: accommodate packed-refs creation by newer git

It looks like newer versions of git (as of at least 2.150 rc1) are
automatically creating packed-refs.  Adjust test-rm.sh to accommodate
that possibility.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agotest-rm: ensure entire string matches in wv_matches_rx
Rob Browning [Sat, 21 Oct 2017 16:14:55 +0000 (11:14 -0500)]
test-rm: ensure entire string matches in wv_matches_rx

Previously trailing garbage (for example) would have been ignored.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoimport-duplicity: remove unused vfs reference
Rob Browning [Sun, 8 Oct 2017 20:13:06 +0000 (15:13 -0500)]
import-duplicity: remove unused vfs reference

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
6 years agorevlist_items: fix ordering in early exit detection
Rob Browning [Wed, 11 Oct 2017 05:14:48 +0000 (00:14 -0500)]
revlist_items: fix ordering in early exit detection

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoclient.rev_list: strip() returned commit
Rob Browning [Wed, 11 Oct 2017 05:05:30 +0000 (00:05 -0500)]
client.rev_list: strip() returned commit

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agobup-restore.md: document -r
Rob Browning [Tue, 10 Oct 2017 00:35:14 +0000 (19:35 -0500)]
bup-restore.md: document -r

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoPrint the metadata mode in octal, not hex
Rob Browning [Sun, 8 Oct 2017 15:13:06 +0000 (10:13 -0500)]
Print the metadata mode in octal, not hex

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoAdd trivial t/perf-glance for sanity checking
Rob Browning [Sun, 8 Oct 2017 16:32:31 +0000 (11:32 -0500)]
Add trivial t/perf-glance for sanity checking

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years ago_compute_size: add missing self argument
Rob Browning [Sun, 8 Oct 2017 20:09:13 +0000 (15:09 -0500)]
_compute_size: add missing self argument

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
6 years agoAdd restore from remote: "bup restore -r host:path ..."
Rob Browning [Sun, 24 Sep 2017 16:26:29 +0000 (11:26 -0500)]
Add restore from remote: "bup restore -r host:path ..."

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoAdd vfs2 and rewrite restore to use it
Rob Browning [Sun, 2 Jul 2017 14:47:01 +0000 (09:47 -0500)]
Add vfs2 and rewrite restore to use it

Thanks to Greg Troxel for reminding me that timezones are a thing when
you're testing.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoAdd repo abstraction and use it in join
Rob Browning [Tue, 13 Jun 2017 06:44:45 +0000 (01:44 -0500)]
Add repo abstraction and use it in join

Operations that can be --remote currently rely on code like this:

  if opt.remote:
      cli = client.Client(opt.remote)
      cat = cli.cat
  else:
      cp = git.CatPipe()
      cat = cp.join

Instead, add LocalRepo and RemoteRepo classes with matching methods so
that we can say:

  repo = RemoteRepo(opt.remote) if opt.remote else LocalRepo()

and then use repo methods to handle the work.

Rework "bup join" accordingly.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agorev_list: allow multiple refs
Rob Browning [Sun, 2 Jul 2017 16:38:57 +0000 (11:38 -0500)]
rev_list: allow multiple refs

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
6 years agorev_list: support custom formats
Rob Browning [Sun, 2 Jul 2017 16:14:17 +0000 (11:14 -0500)]
rev_list: support custom formats

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
6 years agoclient: ensure server provides requested command
Rob Browning [Sun, 24 Sep 2017 17:08:44 +0000 (12:08 -0500)]
client: ensure server provides requested command

Gather the list of available commands from the server during client
initialization and use that to throw a suitable ClientError whenever
the server doesn't support a requested command.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoChange WalkItem hex id to binary oid
Rob Browning [Mon, 4 Sep 2017 00:23:41 +0000 (19:23 -0500)]
Change WalkItem hex id to binary oid

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoChange walk_object id arg to oidx
Rob Browning [Mon, 4 Sep 2017 00:20:58 +0000 (19:20 -0500)]
Change walk_object id arg to oidx

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoChange name of MissingObject id to oid
Rob Browning [Sun, 3 Sep 2017 23:44:37 +0000 (18:44 -0500)]
Change name of MissingObject id to oid

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoCatPipe.get: always return (oidx, type, size) for obj info
Rob Browning [Sun, 3 Sep 2017 23:28:19 +0000 (18:28 -0500)]
CatPipe.get: always return (oidx, type, size) for obj info

Return the size unconditionally, and add the oidx, which can be useful
if the get id argument was a ref rather than a hash.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoCatPipe.get: don't throw MissingObject; return None
Rob Browning [Sun, 3 Sep 2017 22:11:52 +0000 (17:11 -0500)]
CatPipe.get: don't throw MissingObject; return None

This will be more heavily used later and exceptions are notably more
expensive.  Further, a missing object isn't necessarily an error.
It's perfectly reasonable to attempt to check an object's existence
via get().

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agorev_list: check count type more carefully
Rob Browning [Sun, 2 Jul 2017 16:20:18 +0000 (11:20 -0500)]
rev_list: check count type more carefully

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoSkip unset values in metadata repr
Rob Browning [Mon, 4 Sep 2017 04:17:37 +0000 (23:17 -0500)]
Skip unset values in metadata repr

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoUse next(it), not it.next() and drop the helpers fallback
Rob Browning [Sun, 10 Sep 2017 20:08:33 +0000 (15:08 -0500)]
Use next(it), not it.next() and drop the helpers fallback

Change all it.next() invocations to next(it) for compatibility with
newer versions of python that do not support the next() method.  Drop
the next() fallback helper since we depend on python 2.6 now.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agotest-meta: don't try to chattr +T a file
Rob Browning [Tue, 11 Jul 2017 20:53:33 +0000 (15:53 -0500)]
test-meta: don't try to chattr +T a file

...since 'T' only works for directories, and newer kernels actually
reject the attempt (as of at least 4.12, and maybe 4.10).  Thanks to
Mateusz Pavlic for reporting the problem and verifying the fix.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
6 years agogit.list_refs: change arg from refnames to patterns
Rob Browning [Sat, 17 Jun 2017 17:36:22 +0000 (12:36 -0500)]
git.list_refs: change arg from refnames to patterns

...to make it clearer how they're going to be interpreted, since we
pass them straight to git show-ref.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoActually run test__git_date_str()
Rob Browning [Sun, 18 Jun 2017 20:41:36 +0000 (15:41 -0500)]
Actually run test__git_date_str()

We'd forgotten the @wvtest annotation.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoSupport catpipe get(...,size=True); require git >= 1.5.6
Rob Browning [Sun, 18 Jun 2017 20:40:41 +0000 (15:40 -0500)]
Support catpipe get(...,size=True); require git >= 1.5.6

Add a new size argument to get() that requests the object size in
addition to the type.  To support this, require git 1.5.6 (circa 2008)
or newer so that we'll have cat-file --batch.

Remove the _slow_get() fallback since it's no longer needed.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoMove test.sh save/restore tests to test-save-restore
Rob Browning [Mon, 12 Jun 2017 05:21:23 +0000 (00:21 -0500)]
Move test.sh save/restore tests to test-save-restore

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agometadata: set size when loading symlink info
Rob Browning [Sat, 17 Jun 2017 16:50:56 +0000 (11:50 -0500)]
metadata: set size when loading symlink info

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agotest-prune-older: report cmd, not argv in exception
Rob Browning [Tue, 13 Jun 2017 07:18:02 +0000 (02:18 -0500)]
test-prune-older: report cmd, not argv in exception

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoSwitch to py2/3 compatible octal notation
Rob Browning [Tue, 13 Jun 2017 05:57:49 +0000 (00:57 -0500)]
Switch to py2/3 compatible octal notation

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agobup-restore.md: improve --quiet doc
Rob Browning [Sun, 11 Jun 2017 15:16:35 +0000 (10:16 -0500)]
bup-restore.md: improve --quiet doc

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
6 years agoSupport exception chaining and tracebacks
Rob Browning [Fri, 7 Apr 2017 00:32:50 +0000 (19:32 -0500)]
Support exception chaining and tracebacks

Python 3 has added support for exception chaining
https://www.python.org/dev/peps/pep-3134/

Which makes it possible to avoid losing information when an exception
is thrown from within an exception handler:

  try:
      ...
      raise lp0_on_fire()
  except Exception as ex:
    # Imagine the disk is also full and close() throws too
    some_output_file.close()

In this situation, you'll never find out the printer's on fire.  With
chaining, the first exception will be attached to the second as its
__context__.  (Note that "finally" blocks suffer from the same issue.)

The PEP also describes adding a __traceback__ attribute to exceptions
so that they're more self-contained.

Python 3 handles all of this automatically, and includes any chained
exceptions in its tracebacks.  For this:

  def inner():
      raise Exception('first')

  def outer():
      try:
          inner()
      except Exception as ex:
          raise chain_ex(Exception('second'), ex)

  wrap_main(outer)

Python 3 produces:

  $ python3 lib/bup/compat.py
  Traceback (most recent call last):
    File "lib/bup/compat.py", line 74, in outer
      inner()
    File "lib/bup/compat.py", line 70, in inner
      raise Exception('first')
  Exception: first

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "lib/bup/compat.py", line 78, in <module>
      wrap_main(outer)
    File "lib/bup/compat.py", line 50, in wrap_main
      sys.exit(main())
    File "lib/bup/compat.py", line 76, in outer
      raise chain_ex(Exception('second'), ex)
  Exception: second

Add a compat.py supporting something similar for Python 2, and use it
in main.py.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoHonor git config pack.packSizeLimit when set
Rob Browning [Mon, 15 May 2017 06:19:37 +0000 (01:19 -0500)]
Honor git config pack.packSizeLimit when set

Thanks to Ross Patterson for suggesting the improvement and proposing
an earlier implementation.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoRemove max_pack_size and max_pack_objects globals
Rob Browning [Mon, 15 May 2017 04:16:55 +0000 (23:16 -0500)]
Remove max_pack_size and max_pack_objects globals

Instead, have the packwriters take optional arguments with the same
names and purposes.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoMove _git_wait and _git_capture before use
Rob Browning [Sun, 14 May 2017 19:17:28 +0000 (14:17 -0500)]
Move _git_wait and _git_capture before use

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoPackWriter_Remote: don't ignore compression_level
Rob Browning [Mon, 15 May 2017 06:11:17 +0000 (01:11 -0500)]
PackWriter_Remote: don't ignore compression_level

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoprune-older(1): doc keeping newest save in period groups
Rob Browning [Sun, 23 Apr 2017 20:16:39 +0000 (15:16 -0500)]
prune-older(1): doc keeping newest save in period groups

Update the manpage to reflect the change to keep the newest save in
each period group rather than the oldest.

cf. 669256ddc5b65c65bc908c6f740f93a18e936231

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
6 years agoprune-older: enhance classify_saves comments
Rob Browning [Sun, 23 Apr 2017 20:13:31 +0000 (15:13 -0500)]
prune-older: enhance classify_saves comments

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
6 years agoprune-older: keep most recent save in each period group
Ben Kelly [Tue, 14 Mar 2017 16:29:04 +0000 (12:29 -0400)]
prune-older: keep most recent save in each period group

Keep the most recent save in each period group (day, week, month, ...)
rather than the oldest.

Signed-off-by: Ben Kelly <btk@google.com>
[rlb@defaultvalue.org: adjust commit message]
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
7 years agotty_width: only import fcntl and termios once
Rob Browning [Thu, 6 Apr 2017 06:34:39 +0000 (01:34 -0500)]
tty_width: only import fcntl and termios once

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