Move the VFS's cp() to git.py and reset the cp() CatPipe whenever the
global repodir changes.
Previously, if two different lib/bup/t/ tests (for example) needed to
use two different repositories, and both happened to indirectly call
cp(), the second test would end up with a CatPipe() connected to the
wrong repository.
In the longer run, we may want to consider further cleanup here, but
this should fix the immediate problem without too much risk.
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
except StopIteration:
log('booger!\n')
+
+_cp = (None, None)
+
+def cp():
+ """Create a CatPipe object or reuse an already existing one."""
+ global _cp
+ cp_dir, cp = _cp
+ cur_dir = os.path.realpath(repo())
+ if cur_dir != cp_dir:
+ cp = CatPipe()
+ _cp = (cur_dir, cp)
+ return cp
+
+
def tags():
"""Return a dictionary of all tags in the form {hash: [tag_names, ...]}."""
tags = {}
import os, re, stat, time
from bup import git, metadata
from helpers import *
-from bup.git import BUP_NORMAL, BUP_CHUNKED
+from bup.git import BUP_NORMAL, BUP_CHUNKED, cp
from bup.hashsplit import GIT_MODE_TREE, GIT_MODE_FILE
EMPTY_SHA='\0'*20
-_cp = None
-def cp():
- """Create a git.CatPipe object or reuse the already existing one."""
- global _cp
- if not _cp:
- _cp = git.CatPipe()
- return _cp
class NodeError(Exception):
"""VFS base exception."""