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>
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>
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>
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>
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>
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:
$ 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>
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>
Ben Kelly [Tue, 21 Jan 2014 15:42:15 +0000 (10:42 -0500)]
bloom: end progress message with \r, not \n
This avoids leaving spurious output lines behind at exit.
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>
Saveguard against deleting new pack-file (f.e. with threshold=0)
Signed-off-by: Tim Riemenschneider <git@tim-riemenschneider.de>
[rlb@defaultvalue.org: wrap comment line in test-gc.sh; adjust comment
whitespace in gc.py] Reviewed-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Sun, 25 Dec 2016 17:44:56 +0000 (11:44 -0600)]
index: only collect metadata for stale paths
Stop collecting all of the metadata for every path, even if the path
hasn't changed since the last save. Further, rework the code to
short-circuit some other unnecessary work.
To support this, split Entry.from_stat() into two parts, stale(), which
tests to see if an entry has "materially" changed, and
update_from_stat() which updates the entry to match the stat information
provided.
This should substantially decrease the indexing cost for paths that
haven't changed since the last save.
While we're here, rename hashgen to fake_hash so it's clearer that's its
only purpose.
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Sat, 17 Dec 2016 20:40:02 +0000 (14:40 -0600)]
git.cp(): don't repeatedly recompute default repo
Before, bup would end up calling repo() for every invocation of cp().
Given that constructions like cp().get(id) are common, this could cause
a lot of unecessary calls, given that we already have git.repodir, which
will have the relevant value once initialized.
Discovered after noticing "bup restore" was hammering
"$BUP_DIR"/.git (which didn't exist).
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Sat, 10 Dec 2016 17:57:05 +0000 (11:57 -0600)]
gc: restart catpipe after each new pack
Without this, the space taken by the stale packfiles that gc removes
won't be available to the filesystem until the entire gc run ends (or
the catpipe is otherwise reset).
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Thu, 15 Dec 2016 18:45:19 +0000 (12:45 -0600)]
test-prune-older: avoid duplicate save times
When creating the list of random save times make sure to avoid any
duplicates since the timestamp is also the trivial commit content.
Otherwise the git commit for the second save dies with "nothing to
commit, working tree clean".
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Sun, 30 Oct 2016 18:31:43 +0000 (13:31 -0500)]
Add bup prune-older command
prune-older removes (permanently deletes) all saves except those
preserved by various temporal keep arguments. It is equivalent to a
suitable "bup rm" invocation followed by "bup gc".
For example, this invocation keeps all saves on the BRANCH for the past
month, and any older monthlies for the past year, and deletes the
remainder:
Ben Kelly [Thu, 10 Nov 2016 15:01:08 +0000 (10:01 -0500)]
walk_object: ignore blob content if not requested
Previously, walk_object would read the contents of each object it
encountered, even if it subsequently threw away those contents.
With this change, it will skip reading the contents of blobs unless
the caller explicitly asked for blob contents. In particular, this
means operations that traverse the object graph without caring
about object contents, such as `bup gc`, now only need to read the
contents of tree and commit objects.
Tested: `make test`; local run against copy of production repo. Signed-off-by: Ben Kelly <btk@google.com>
[rlb@defaultvalue.org: shorten commit summary; adjust indentation;
adjust docstring and comment; test "not include_data" first; change to
type='blob']
Reviewed-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Sat, 5 Nov 2016 19:36:20 +0000 (14:36 -0500)]
test-gc: sort ls output defensively before comm
Explicitly sort the output of ls before passing it to comm in order to
accommodate some systems that apparently used to change the default sort
order. The order must match LC_COLLATE for comm to work.
While we're here, improve error checking around the comm invocations.
Thanks to Nick Alcock for reporting the original problem, and proposing
an initial fix.
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Sat, 10 Sep 2016 17:52:59 +0000 (12:52 -0500)]
Report unknown root status if getwindowsversion > 5
Apparently the situation is much more complicated in newer versions, so
until someone more knowledgable can help, don't try to determine
superuser status there.
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Wed, 7 Sep 2016 04:34:24 +0000 (23:34 -0500)]
Handle ntfs-3g EINVAL for attr save/restore
It appears that ntfs-3g now returns EINVAL for unsupported ioctls
including FS_IOC_GET_FLAGS and FS_IOC_SET_FLAGS.
Treat EINVAL like the existing expected errors for these calls, but
since there's evidence to suggest that other devices/filesystems use
EINVAL to indicate more serious trouble and use ENOTTY to indicate
unsupported ioctls, include a request to report any occurrences of
EINVAL when ntfs-3g is not involved.
Thanks to Mark J Hewitt for reporting the problem.
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Sun, 12 Jun 2016 20:50:46 +0000 (15:50 -0500)]
gc: explicitly handle missing objects
Instead of just dying with a KeyError backtrace, detect missing objects
and print a friendlier message about the problem. Having the new
MissingObject exception derive from KeyError should avoid affecting
existing code.
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Jonathan Wright [Tue, 28 Jun 2016 23:22:41 +0000 (16:22 -0700)]
Fix fsyncing on OSX on SMB file-systems
Fixes the error:
Traceback (most recent call last):
File "/usr/local/Cellar/bup/0.28.1/lib/bup/cmd/bup-server", line 209, in <module>
cmd(conn, rest)
File "/usr/local/Cellar/bup/0.28.1/lib/bup/cmd/bup-server", line 91, in receive_objects_v2
fullpath = w.close(run_midx=not dumb_server_mode)
File "/usr/local/Cellar/bup/0.28.1/lib/bup/bup/git.py", line 790, in close
return self._end(run_midx=run_midx)
File "/usr/local/Cellar/bup/0.28.1/lib/bup/bup/git.py", line 764, in _end
fdatasync(f.fileno())
File "/usr/local/Cellar/bup/0.28.1/lib/bup/bup/helpers.py", line 47, in <lambda>
fdatasync = lambda fd : fcntl.fcntl(fd, fcntl.F_FULLFSYNC)
IOError: [Errno 45] Operation not supported
Traceback (most recent call last):
File "/usr/local/Cellar/bup/0.28.1/lib/bup/cmd/bup-save", line 460, in <module>
w.close() # must close before we can update the ref
File "/usr/local/Cellar/bup/0.28.1/lib/bup/bup/client.py", line 317, in close
id = self._end()
File "/usr/local/Cellar/bup/0.28.1/lib/bup/bup/client.py", line 314, in _end
return self.suggest_packs() # Returns last idx received
File "/usr/local/Cellar/bup/0.28.1/lib/bup/bup/client.py", line 229, in _suggest_packs
self.check_ok()
File "/usr/local/Cellar/bup/0.28.1/lib/bup/bup/client.py", line 134, in check_ok
% rv)
Signed-off-by: Jonathan Wright <quaggy@gmail.com> Reviewed-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Sun, 22 May 2016 18:49:17 +0000 (13:49 -0500)]
Check save/split names early via valid_save_name
Previously, split and save would just wait to see if the final
update_ref failed. Instead, check the validity of the name early,
before doing any significant work.
Thanks to vi0oss for reporting the problem.
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Sat, 11 Jun 2016 17:59:38 +0000 (12:59 -0500)]
test-web: use path with unique unicode sequence
Change the test path from "éxcitement" to "¡excitement!" since the
former has multiple valid unicode encodings (e.g. given combining
characters, etc.).
With the previous string, the test might fail if something along the way
normalized it (which was the case on at least some versions of OS X).
Thanks to ilovezfs for reporting the problem and helping with the fix.
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Fri, 27 May 2016 00:30:40 +0000 (19:30 -0500)]
Fix release archives and add tests
Previously, an archive created by "git archive" would fail to build,
because the versioning code was broken (in part by 03d35993b87f49753542e705e37949a46964be17) for any build outside a git
clone. Although "bup version" may not really have been quite right
since the switch from "bup-VERSION" to "VERSION release tags.
Fix the problem by reintroducing the content of the older
_version.py.pre as a permanent _release.py file, which (as with the
previous incarnation) is a template that's expanded during "git archive"
via export-subst (cf. gitattributes(5)).
Add a version module as the public interface to versioning, and have it
sort out whether or not the current tree is an official release. Adjust
configure-version to manage _checkout.py instead of _version.py (drop
_version.py), so that the version module is effectively just
disambiguating between _release.py and _checkout.py.
Adjust "bup version" to use the new version module and to handle
unprefixed VERSION tags.
Finally, add test-release-archive.sh, invoked via "make distcheck", so
we (hopefully) don't unknowingly break this again.
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Sat, 28 May 2016 14:37:09 +0000 (09:37 -0500)]
Add config.vars.sh for bup_make and bup_python
During configure create a config/config.vars.sh file including (for now)
properly shell escaped bup_make and bup_python definitions so that we
can use them in other schell scripts.
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>