[MESSAGES CONTROL]
disable=all
-enable=unused-import,unused-wildcard-import
+enable=
+ trailing-whitespace,
+ unused-import,
+ unused-wildcard-import
return self._init_failed()
ver = struct.unpack('!I', self.map[4:8])[0]
if ver < BLOOM_VERSION:
- log('Warning: ignoring old-style (v%d) bloom %r\n'
+ log('Warning: ignoring old-style (v%d) bloom %r\n'
% (ver, filename))
return self._init_failed()
if ver > BLOOM_VERSION:
def check_busy(self):
if self._busy:
raise ClientError('already busy with command %r' % self._busy)
-
+
def ensure_busy(self):
if not self._busy:
raise ClientError('expected to be busy, but not busy?!')
-
+
def _not_busy(self):
self._busy = None
icount = 0
for name in add:
ix = git.open_idx(name)
- qprogress('bloom: writing %.2f%% (%d/%d objects)\r'
+ qprogress('bloom: writing %.2f%% (%d/%d objects)\r'
% (icount*100.0/add_count, icount, add_count))
b.add_idx(ix)
count += 1
if sum.digest() != wantsum:
raise ValueError('expected %r, got %r' % (hexlify(wantsum),
sum.hexdigest()))
-
+
def git_verify(base):
if opt.quick:
return 0
else:
return run([b'git', b'verify-pack', b'--', base])
-
-
+
+
def do_pack(base, last, par2_exists, out):
code = 0
if par2_ok and par2_exists and (opt.repair or not opt.generate):
self.repo = repo
self.verbose = verbose
self.fake_metadata = fake_metadata
-
+
def getattr(self, path):
path = argv_bytes(path)
if self.verbose > 0:
sub = git.open_idx(os.path.join(os.path.dirname(name), subname))
for ecount,e in enumerate(sub):
if not (ecount % 1234):
- qprogress(' %d/%d: %s %d/%d\r'
+ qprogress(' %d/%d: %s %d/%d\r'
% (count, len(ix.idxnames),
git.shorten_hash(subname).decode('ascii'),
ecount, len(sub)))
assert(outdir)
sum = hexlify(Sha1(b'\0'.join(infilenames)).digest())
outfilename = b'%s/midx-%s.midx' % (outdir, sum)
-
+
inp = []
total = 0
allfilenames = []
m = git.open_idx(mname)
contents[mname] = [(b'%s/%s' % (path,i)) for i in m.idxnames]
sizes[mname] = len(m)
-
+
# sort the biggest+newest midxes first, so that we can eliminate
# smaller (or older) redundant ones that come later in the list
midxs.sort(key=lambda ix: (-sizes[ix], -xstat.stat(ix).st_mtime))
-
+
for mname in midxs:
any = 0
for iname in contents[mname]:
sizes[iname] = len(i)
all = [(sizes[n],n) for n in (midxs + idxs)]
-
+
# FIXME: what are the optimal values? Does this make sense?
DESIRED_HWM = force and 1 or 5
DESIRED_LWM = force and 1 or 2
existed = dict((name,1) for sz,name in all)
- debug1('midx: %d indexes; want no more than %d.\n'
+ debug1('midx: %d indexes; want no more than %d.\n'
% (len(all), DESIRED_HWM))
if len(all) <= DESIRED_HWM:
debug1('midx: nothing to do.\n')
m.uid = owner_map['uid'].get(m.uid, m.uid)
m.gid = owner_map['gid'].get(m.gid, m.gid)
m.apply_to_path(name, restore_numeric_ids = restore_numeric_ids)
-
+
def hardlink_compatible(prev_path, prev_item, new_item, top):
prev_candidate = top + prev_path
if not os.path.exists(prev_candidate):
# FIXME: we can probably replace the target_vfs_path with the
# relevant vfs item
-
+
# hardlinks tracks a list of (restore_path, vfs_path, meta)
# triples for each path we've written for a given hardlink_target.
# This allows us to handle the case where we restore a set of
os.ftruncate(outfd, pos)
finally:
os.close(outfd)
-
+
def restore(repo, parent_path, name, item, top, sparse, numeric_ids, owner_map,
exclude_rxs, verbosity, hardlinks):
global total_restored
opt.remote = argv_bytes(opt.remote)
if opt.outdir:
opt.outdir = argv_bytes(opt.outdir)
-
+
git.check_repo_or_die()
if not extra:
def _set_mode():
global dumb_server_mode
dumb_server_mode = os.path.exists(git.repo(b'bup-dumb-server'))
- debug1('bup server: serving in %s mode\n'
+ debug1('bup server: serving in %s mode\n'
% (dumb_server_mode and 'dumb' or 'smart'))
_init_session(arg)
conn.ok()
-
+
def list_indexes(conn, junk):
_init_session()
suffix = b''
n = struct.unpack('!I', ns)[0]
#debug2('expecting %d bytes\n' % n)
if not n:
- debug1('bup server: received %d object%s.\n'
+ debug1('bup server: received %d object%s.\n'
% (w.count, w.count!=1 and "s" or ''))
fullpath = w.close(run_midx=not dumb_server_mode)
if fullpath:
suspended_w = w
conn.ok()
return
-
+
shar = conn.read(20)
crcr = struct.unpack('!I', conn.read(4))[0]
n -= 20 + 4
nw, crc = w._raw_write((buf,), sha=shar)
_check(w, crcr, crc, 'object read: expected crc %d, got %d\n')
# NOTREACHED
-
+
def _check(w, expected, actual, msg):
if expected != actual:
return display_name, link + url_query, display_size
- dir_item = resolution[-1][1]
+ dir_item = resolution[-1][1]
for name, item in vfs.contents(repo, dir_item):
if not show_hidden:
if (name not in (b'.', b'..')) and name.startswith(b'.'):
def head(self, path):
return self._process_request(path)
-
+
def _process_request(self, path):
print('Handling request for %s' % path)
sys.stdout.flush()
ctype = self._guess_type(path)
self.set_header("Last-Modified", http_date_from_utc_ns(meta.mtime))
self.set_header("Content-Type", ctype)
-
+
self.set_header("Content-Length", str(meta.size))
assert len(file_item.oid) == 20
self.set_header("Etag", hexlify(file_item.oid))
def __init__(self, path):
self.fd = None
self.fd = os.open(path, os.O_RDONLY|O_LARGEFILE|O_NOFOLLOW|os.O_NDELAY)
-
+
def __del__(self):
if self.fd:
fd = self.fd
self.data = cat_bytes(self.data, self.start, remaining,
s, 0, len(s))
self.start = 0
-
+
def peek(self, count):
if count <= 256:
return self.data[self.start : self.start + count]
return buffer(self.data, self.start, count)
-
+
def eat(self, count):
self.start += count
def qprogress(s):
"""Calls progress() only if we haven't printed progress in a while.
-
+
This avoids overloading the stderr buffer with excess junk.
"""
global _last_prog
(ofs,n) = (f.tell(), len(self.list))
if self.list:
count = len(self.list)
- #log('popping %r with %d entries\n'
+ #log('popping %r with %d entries\n'
# % (''.join(self.ename), count))
for e in self.list:
e.write(f)
def __iter__(self):
return self.iter()
-
+
class Reader:
def __init__(self, filename):
def _add(self, ename, entry):
if self.lastfile and self.lastfile <= ename:
- raise Error('%r must come before %r'
+ raise Error('%r must come before %r'
% (''.join(ename), ''.join(self.lastfile)))
self.lastfile = ename
self.level = _golevel(self.level, self.f, ename, entry,
paths = []
prev = None
for (rp, p) in xpaths:
- if prev and (prev == rp
+ if prev and (prev == rp
or (prev.endswith(b'/') and rp.startswith(prev))):
continue # already superceded by previous path
paths.append((rp, p))
for cmd,synopsis in sorted(common.items()):
log(' %-10s %s\n' % (cmd, synopsis))
log('\n')
-
+
log('Other available commands:\n')
cmds = set()
for c in sorted(os.listdir(cmdpath)):
log(columnate(sorted(cmds), ' '))
log('\n')
-
+
log("See 'bup help COMMAND' for more information on " +
"a specific command.\n")
if msg:
return self._init_failed()
ver = struct.unpack('!I', self.map[4:8])[0]
if ver < MIDX_VERSION:
- log('Warning: ignoring old-style (v%d) midx %r\n'
+ log('Warning: ignoring old-style (v%d) midx %r\n'
% (ver, path_msg(filename)))
- self.force_keep = False # old stuff is boring
+ self.force_keep = False # old stuff is boring
return self._init_failed()
if ver > MIDX_VERSION:
log('Warning: ignoring too-new (v%d) midx %r\n'
if not self._size:
self._size = _normal_or_chunked_file_size(self._repo, self.oid)
return self._size
-
+
def seek(self, ofs):
if ofs < 0 or ofs > self._compute_size():
raise IOError(EINVAL, 'Invalid seek offset: %d' % ofs)
if not parts:
must_be_dir = True # e.g. path was effectively '.' or '/', etc.
return is_absolute, must_be_dir, parts
-
+
Item = namedtuple('Item', ('meta', 'oid'))
Chunky = namedtuple('Chunky', ('meta', 'oid'))
"""Return (tree_bytes, bupm_oid) where bupm_oid will be None if the
tree has no metadata (i.e. older bup save, or non-bup tree).
- """
+ """
assert len(oid) == 20
it = repo.cat(hexlify(oid))
_, item_t, size = next(it)
tree_ents = sorted(tree_ents, key=lambda x: x[0])
for ent in tree_ents:
yield ent
-
+
def tree_items(oid, tree_data, names=frozenset(), bupm=None):
def tree_item(ent_oid, kind, gitmode):
yield item
_save_name_rx = re.compile(br'^\d\d\d\d-\d\d-\d\d-\d{6}(-\d+)?$')
-
+
def _reverse_suffix_duplicates(strs):
"""Yields the elements of strs, with any runs of duplicate values
suffixed with -N suffixes, where the zero padded integer N
else:
future.extend(target_future)
hops += 1
-
+
def resolve(repo, path, parent=None, want_meta=True, follow=True):
"""Follow the path in the virtual filesystem and return a tuple
representing the location, if any, denoted by the path. Each