Ronny Pfannschmidt avatar Ronny Pfannschmidt committed 6dba968

add pep8/pyflakes checks, fix all issues

Comments (0)

Files changed (46)

anyvc/__init__.py

         'clone': 'anyvc._workdir:clone',
         'checkout': 'anyvc._workdir:checkout',
         'open': 'anyvc._workdir:open',
-        },
-    })
+    },
+})

anyvc/_workdir.py

 def _disallowd_workdirs():
     return set(
         local(os.path.expanduser(x))
-        for x in os.environ.get('ANYVC_IGNORED_WORKDIRS',
-                                '/').split(os.pathsep))
+        for x in os.environ.get(
+            'ANYVC_IGNORED_WORKDIRS', '').split(os.pathsep))
+
 
 def open(path):
     """
             continue
 
         applying = [backend for backend in get_backends()
-                    if backend.is_workdir(part) ]
+                    if backend.is_workdir(part)]
 
         if applying:
             if len(applying) > 1:
 import py
 from anyvc.util import cachedproperty
 
+
 class Backend(object):
     def __init__(self, name, module_name):
         self.name = name
         return self.module.required_tools
 
     def missing_tools(self):
-        return [ tool
+        return [
+            tool
             for tool in self.required_tools
             if not py.path.local.sysfind(tool)
         ]
             except ImportError:
                 pass
 
-        return [ module
+        return [
+            module
             for module in self.required_modules
             if not tryimport(module)
         ]
 """
 
 
-import os, sys, logging
+import os
+import sys
+import logging
 
 from optparse import OptionParser
 
     parser.add_option('-a', '--list-all', dest='list_all',
                       action='store_true', help='List all files.')
     parser.add_option('-m', '--message', dest='commit_message',
-                     action='store', help='The commit message')
+                      action='store', help='The commit message')
     parser.add_option('-U', '--hide-unknown', dest='hide_unknown',
                       action='store_true', help='Hide unknown files')
     parser.add_option('-u', '--list-unchanged', dest='list_unchanged',
                       action='store_true',
                       help='Only list files in the current working directory.')
     parser.add_option('-c', '--no-color', dest='no_color',
-                       action='store_true',
-                       help='Uncoloured terminal list output')
+                      action='store_true',
+                      help='Uncoloured terminal list output')
 
     # Miscellaneous options
     parser.add_option('-v', '--verbose', action="store_true", dest="verbose",
         level = logging.DEBUG
     else:
         level = logging.INFO
-    logging.basicConfig(level=level, stream=sys.stderr, format='%(levelname)s: %(message)s')
+    logging.basicConfig(
+        level=level,
+        stream=sys.stderr,
+        format='%(levelname)s: %(message)s')
 
 
 list_letters = {
 def output_state(tw, st):
     output = list_letters.get(st.state, '*').ljust(2)
     color = list_colors.get(st.state)
-    kw = {color:True} if color else {}
+    kw = {color: True} if color else {}
     tw.write(output, bold=True, **kw)
     tw.line(st.relpath)
 
+
 def do_status(vc, opts, args):
     tw = TerminalWriter()
 
     paths = tuple(args)
     diff = vc.diff(paths=paths).strip()
     for line in diff.splitlines():
-        kw=dict(
+        kw = dict(
             red=line[0] == '-',
             green=line[0] == '+',
-            bold=line.split(' ', 1)[0] in ('diff','+++', '---'),
+            bold=line.split(' ', 1)[0] in ('diff', '+++', '---'),
         )
         tw.line(line, **kw)
 
     sys.stdout.write(out)
     sys.stdout.flush()
 
+
 def do_add(vc, opts, args):
     out = vc.add(paths=args)
     sys.stdout.write(out)
 
     if not repo.local:
         #XXX: better handling
-        print >> sys.stderr, "can't push from a non-local", repo.__class__.__name__
+        name = type(repo).__name__
+        print >> sys.stderr, "can't push from a non-local", name
         exit(1)
     location = args[0] if args else None
     print repo.push(location, opts.revision)
 
     logging.debug('Found VC: %s' % vc)
 
-    pargs = args[:]
-    called = pargs.pop(0)
+    pargs = args[1:]
 
     try:
         command = pargs.pop(0)
     except IndexError:
         logging.error(_('You must provide a command.'))
-        logging.info(_('The available commands are: %(commands)s' %
-                        {'commands': '%s' % ', '.join(commands.keys())}))
+        logging.info(_('The available commands are: %(commands)s' % {
+            'commands': '%s' % ', '.join(commands.keys())}))
         parser.print_usage()
         return -1
 
     try:
         action = commands[command]
     except KeyError:
-        logging.error(_('The command "%(command)s" is not available.' %
-                        {'command': command}))
-        logging.info(_('The available commands are: %(commands)s' %
-                        {'commands': ', '.join(sorted(commands.keys()))}))
+        logging.error(_('The command "%(command)s" is not available.' % {
+            'command': command}))
+        logging.info(_('The available commands are: %(commands)s' % {
+            'commands': ', '.join(sorted(commands.keys()))}))
         return -1
 
     logging.debug('Calling %s' % command)
 
     return action(vc, opts, pargs)
-

anyvc/common/commit_builder.py

 
 from anyvc.common.repository import MemoryFile
 
+
 class CommitBuilder(object):
     #XXX: ugly and inflexible
-    def __init__(self, repo, base_commit, time=None, local_time=True, author=None, **extra):
+    def __init__(self, repo, base_commit,
+                 time=None, local_time=True,
+                 author=None, **extra):
         self.repo = repo
         self.base_commit = base_commit
         self.extra = extra
 
         if time is None:
             time = datetime.now()
-        self.author = author.strip() # normalize whitespace
+        self.author = author.strip()  # normalize whitespace
         self.time = time
         self.time_local = local_time
 
             return self.contens[path]
         for source, dest in sorted(self.renames, reverse=True):
             if path.startswith(dest):
-                path = path.replace(dest, source) #XXX: incorrect, 
+                path = path.replace(dest, source)  # XXX: incorrect
         return self.base_commit.file_content(path)
 
-
     def remove(self, path):
         pass
 
     def rename(self, source, dest):
         self.renames.append((source, dest))
         for name, content in self.contents.items():
-            if name.startswith(source): #XXX: incorrect
+            if name.startswith(source):  # XXX: incorrect
                 self.contents[name.replace(source, dest)] = content
                 del self.contents[name]
 
-
     def commit(self):
         raise NotImplementedError
 
-    def __enter__(self): 
+    def __enter__(self):
         return RevisionBuilderPath(self.base_commit, "/", self)
 
     def __exit__(self, etype,  eval, tb):
-        if etype is None: 
+        if etype is None:
             self.commit()
 
 
-class RevisionBuilderPath( object):
-    def __init__( self, commit, path, builder):
+class RevisionBuilderPath(object):
+    def __init__(self, commit, path, builder):
         self.commit = commit
         self.path = path
         self.builder = builder
 
-
     def mkdir(self):
         self.builder.mkdir(self.path)
 
-    def rename(self , new_name):
+    def rename(self, new_name):
         new = self.parent().join(new_name)
         assert self.path != '/' and new_name != '/'
         self.builder.rename(self.path, new.path)
         #XXX: shoould self.path change?
 
     def parent(self):
-        return RevisionBuilderPath(self.commit, dirname(self.path), self.builder)
+        return RevisionBuilderPath(
+            self.commit,
+            dirname(self.path),
+            self.builder)
 
     def join(self,  path):
-        return RevisionBuilderPath(self.commit, join(self.path, path), self.builder)
+        return RevisionBuilderPath(
+            self.commit,
+            join(self.path, path),
+            self.builder)
 
     def open(self,  mode='r'):
         #implement in terms of read/write
-        if mode ==  'r':
+        if mode == 'r':
             raise NotImplementedError
         elif mode == 'w':
             #XXX: test and implement all flavors of reopening
 
     def check(self):
         try:
-            self.read() #XXX: less expensive?
+            self.read()  # XXX: less expensive?
             return True
         except IOError:
             return False

anyvc/common/repository.py

         the repo apis are unstable and incomplete
 
 """
-from collections import defaultdict
-from os.path import join, dirname
-try:
-    from io import BytesIO as StringIO #XXX: epic mess
-except ImportError:
-    from StringIO import StringIO
+from os.path import join
+from py.io import BytesIO
 
 
-class MemoryFile(StringIO):
+class MemoryFile(BytesIO):
     def __init__(self, data='', path=None):
-        StringIO.__init__(self, data)
+        BytesIO.__init__(self, data)
         self.path = path
 
     def __enter__(self):
     def __exit__(self, et, ev, tb):
         pass
 
+
 class Revision(object):
 
-    def get_parent_diff(self): 
+    def get_parent_diff(self):
         from anyvc.diff import diff_for_commit
         return diff_for_commit(self)
 
-    def __enter__(self): 
-       return RevisionView(self, '/')
+    def __enter__(self):
+        return RevisionView(self, '/')
 
-    def __exit__(self, et, ev , tb):
+    def __exit__(self, et, ev, tb):
         pass
 
 
         return self.revision.exists(self.path)
 
 
-
 class Repository(object):
     """
     represents a repository
 
     local = True
 
-    def __init__(self,**extra):
+    def __init__(self, path, **extra):
         self.path = path
         self.extra = extra
 
         :param dest: the destination
         :param rev: the maximum revision to push, may be none for latest
         """
-        raise NotImplementedError("%r doesnt implement push"%self.__class__)
+        raise NotImplementedError(
+            "%r doesnt implement push" % self.__class__)
 
     def pull(self, source=None, rev=None):
         """
         counterpart to push
         """
-        raise NotImplementedError("%r doesnt implement pull"%self.__class__)
-
+        raise NotImplementedError(
+            "%r doesnt implement pull" % self.__class__)
 
     def transaction(self, **extra):
         # will be set by subclasses
         return self.CommitBuilder(self, self.get_default_head(), **extra)
-
-

anyvc/common/workdir.py

     :license: LGPL2 or later
 """
 from py.path import local
-from os.path import join
 
-from os.path import dirname, basename, join, normpath
+from os.path import dirname, basename, normpath
+
 
 class StatedPath(object):
     """
             self.abspath = None
 
     def __repr__(self):
-        return '<%s %r>'%(
-                self.state,
-                self.relpath,
-                )
+        return '<%s %r>' % (
+            self.state,
+            self.relpath,
+        )
 
     def __str__(self):
         return self.relpath
         if check(part):
             return part
 
+
 class WorkDir(object):
     """
     Basic Workdir API
 
     :param path: base path
-    :param create: 
+    :param create:
     """
 
     def __init__(self, path, create=False, source=None):
             else:
                 self.create()
         else:
-            pass #XXX
-
+            pass  # XXX
 
     def process_paths(self, paths):
         """
     parsing needs
     """
 
-
     def parse_status_items(self, items, cache):
         """
         default implementation
                 else:
                     yield StatedPath(name, state, self.path)
 
-
     def parse_status_item(self, item, cache):
         """
         parse a single status item
         return a mapping of name to cached states
         only necessary for messed up vcs's
         """
-        return dict(
-                self.parse_cache_items(
-                self.cache_impl(
-                    paths = paths,
-                    recursive=recursive
-                    )))
+        to_parse = self.cache_impl(
+            paths=paths,
+            recursive=recursive
+        )
+        return dict(self.parse_cache_items(to_parse))
 
     def status(self, paths=(), recursive=True):
         """
         yield a list of Path instances tagged with status informations
         """
-        cache = self.cache(paths = paths,recursive=recursive)
-        return self.parse_status_items(
-                self.status_impl(
-                    paths = paths,
-                    recursive=recursive,
-                    ), cache)
+        cache = self.cache(paths=paths, recursive=recursive)
+        to_parse = self.status_impl(
+            paths=paths,
+            recursive=recursive,
+        )
+        return self.parse_status_items(to_parse, cache)
 
 
-import re
-
-from subprocess import Popen, PIPE, STDOUT, call
-import os, os.path
+from subprocess import Popen, PIPE, STDOUT
+import os
 
 
 def relative_to(base_path):
         other paths will be unchanged
     """
     base_path = local(base_path)
+
     def process_path(child_path):
         child_path = local(child_path)
         if child_path.relto(base_path):
     """
     #TODO: set up the missing actions
 
-
-
-
-
     def execute_command(self, args, result_type=str, **kw):
         if not args:
             raise ValueError('need a valid command')
         ret = Popen(
-                [self.cmd] + [str(x) for x in args], # str is for py.path
-                stdout=PIPE,
-                stderr=STDOUT,
-                cwd=self.path.strpath,
-                close_fds=True,
-                env=dict(os.environ, LANG='C',LANGUAGE='C', LC_All='C'),
-                )
+            [self.cmd] + [str(x) for x in args],
+            stdout=PIPE,
+            stderr=STDOUT,
+            cwd=self.path.strpath,
+            close_fds=True,
+            env=dict(os.environ, LANG='C', LANGUAGE='C', LC_All='C'),
+        )
         if result_type is str:
             return ret.communicate()[0]
         elif result_type is iter:
         :param message: the commit message
         :param paths: the paths to commit
         """
-        return ['commit','-m', message] + self.process_paths(paths)
+        return ['commit', '-m', message] + self.process_paths(paths)
 
     def get_diff_args(self, paths=(), **kw):
         return ['diff'] + self.process_paths(paths)
         return ['add'] + self.process_paths(paths)
 
     def get_remove_args(self, paths=(), recursive=False, execute=False, **kw):
-        return ['remove'] +  self.process_paths(paths)
+        return ['remove'] + self.process_paths(paths)
 
     def get_revert_args(self, paths=(), recursive=False, **kw):
         return ['revert'] + self.process_paths(paths)
 
-    def get_status_args(self,**kw):
-        raise NotImplementedError("%s doesn't implement status"%self.__class__.__name__)
+    def get_status_args(self, **kw):
+        raise NotImplementedError
 
     def commit(self, **kw):
         args = self.get_commit_args(**kw)
 
     def get_cache_args(self, **kw):
         return None
-
-
-
-
-
 
     :license: LGPL2 or later
 """
-import itertools
 import difflib
 
 #XXX: those are a pile of hacks
 
+
 def diff_for_file(commit, file):
     #XXX: propperly handle add/remove
     try:
         new = commit.file_content(file).splitlines(True)
-    except: #XXX: ERRORS?!?!
+    except:  # XXX: ERRORS?!?!
         new = []
 
     if commit.parents:
         parent = commit.parents[0]
         try:
             old = parent.file_content(file).splitlines(True)
-        except: #XXX: ERRORS?!?!
+        except:  # XXX: ERRORS?!?!
             old = []
 
     else:
     #XXX: binaries ?!
     return difflib.unified_diff(old, new, file, file)
 
+
 def diff_for_commit(commit):
     changed_files = commit.get_changed_files()
 
     return ''.join(
-                item
-                for file in changed_files
-                for item in diff_for_file(commit, file)
-            )
+        item
+        for file in changed_files
+        for item in diff_for_file(commit, file)
+    )
+class NotFoundError(LookupError, ValueError):
+    #XXX: ValueError for backward compat, figure how to phase out later
+    """raised if a repo/workdir cant be found"""
 
-#XXX: ValueError for backward compat, figure how to phase out later
-class NotFoundError(LookupError, ValueError):
-    """raised if a repo/workdir cant be found"""
     def __init__(self, vc, path):
         Exception.__init__(self, vc, path)
         self.vc = vc
         self.path = path
 
     def __str__(self):
-        return "%(vc)s repo not found for %(path)r"%vars(self)
+        return "%(vc)s repo not found for %(path)r" % vars(self)

anyvc/git/__init__.py

     'info',
 ]
 
+
 def has_git_base_dirs(path):
     return all(path.join(x).check(dir=1) for x in base_dirs)
 
+
 def is_workdir(path):
     #XXX better check
     git = path.join('.git')
     return git.check(dir=1) and has_git_base_dirs(git)
 
+
 def is_repository(path):
     if not isinstance(path, py.path.local):
         if path.startswith('git://'):
             #XXX more trouble probably
             return True
         path = py.path.local(path)
-    return has_git_base_dirs(path) or has_git_base_dirs(path/'.git')
+    return has_git_base_dirs(path) or is_workdir(path)

anyvc/git/repo.py

 import subprocess
 import stat
 import os
-from py.path import local
 from datetime import datetime
 from collections import defaultdict
 from dulwich.repo import Repo
 from dulwich.objects import Blob, Tree, Commit
 from dulwich.errors import NotGitRepository
 
+
 class GitRevision(Revision):
 
     def __init__(self, repo, commit):
     def message(self):
         return self.commit.message.rstrip()
 
-
     def resolve(self, path):
         repo = self.repo.repo
         tree = repo.get_object(self.commit.tree)
             assert blob.__class__ is Blob
             return blob.data
         except KeyError:
-            raise IOError('%r not found'%path)
+            raise IOError('%r not found' % path)
 
     def exists(self, path):
         try:
         added, removed, changed = diff_tree(self.repo.repo, old, new)
         return sorted(added | removed | changed)
 
+
 class GitCommitBuilder(CommitBuilder):
 
     def commit(self):
-        #XXX: evidence for the rest of 
+        #XXX: evidence for the rest of
         # this functions is supposed not to exist
-        # yes, its that 
-
-        #XXX: generate all objects at once and 
+        # yes, its that
+        #XXX: generate all objects at once and
         #     add them as pack instead of legacy objects
-
         r = self.repo.repo
         store = r.object_store
         new_objects = []
             tree[dest] = tree[src]
             del tree[src]
 
-
         for name in names:
             blob = Blob()
             blob.data = self.contents[name]
             new_objects.append((blob, name))
             tree.add(0555, os.path.basename(name), blob.id)
+
         new_objects.append((tree, ''))
         commit = Commit()
         if self.base_commit:
         store.add_objects(new_objects)
         self.repo.repo.refs['HEAD'] = commit.id
 
+
 class GitRepository(Repository):
     CommitBuilder = GitCommitBuilder
 
         return GitRevision(self, self.repo.get_object(id))
 
 
-
-
 def walk_tree_object(repo, tree, path=''):
     for mode, name, sha in tree.entries():
         if stat.S_IFDIR & mode:
         else:
             yield os.path.join(path, name), sha
 
+
 def walk_tree(repo, tree_id, path=''):
     if tree_id is None:
         return ()
     added = new_set - old_set
     removed = old_set - new_set
 
-    changed = set(name
-            for name, sha in new_sha.items()
-            if name not in added
-            and name not in removed
-            and old_sha[name] != sha)
+    changed = set(
+        name for name, sha in new_sha.items()
+        if (name not in added and
+            name not in removed and
+            old_sha[name] != sha)
+    )
     return added, removed, changed
-
-
-
-
-

anyvc/git/workdir.py

     :copyright: 2007-2008 Ronny Pfannschmidt
     :license: LGPL2 or later
 """
+from anyvc.common.workdir import CommandBased
+from subprocess import call
 
 
-
-from anyvc.common.workdir import CommandBased, relative_to
-import re
-from subprocess import call
-
 class Git(CommandBased):
     """
     fooked liek hell
         from .repo import GitRepository
         return GitRepository(workdir=self)
 
-    def setup(self):
-        pass #XXX: actually unneded?
-
     def create_from(self, source):
         call(['git', 'clone', str(source), self.path.strpath])
 
 
     def get_commit_args(self, message, paths=(), **kw):
         if paths:
+            paths = list(self.process_paths(paths))
             # commit only for the supplied paths
-            return ['commit', '-m', message, '--'] + list(self.process_paths(paths))
+            return ['commit', '-m', message, '--'] + paths
         else:
             # commit all found changes
             # this also adds all files not tracked and not in gitignore
             return ['commit', '-a', '-m', message]
 
     def get_revert_args(self, paths=(), recursive=False, **kw):
-        return ['checkout','HEAD'] + self.process_paths(paths)
+        return ['checkout', 'HEAD'] + self.process_paths(paths)
 
     def get_remove_args(self, paths=(), recursive=False, execute=False, **kw):
-        return ['rm'] +  self.process_paths(paths)
+        return ['rm'] + self.process_paths(paths)
 
     def get_rename_args(self, source, target):
         return ['mv', source, target]
     def status_impl(self, *k, **kw):
         #XXX: OMG HELLISH FRAGILE SHIT
         if self.execute_command(['branch']).strip():
-            tree = set(self.execute_command([
-            'ls-tree', '-r', '--name-only', 'HEAD'
-            ]).splitlines())
+            tree = set(self.execute_command(
+                ['ls-tree', '-r', '--name-only', 'HEAD']
+            ).splitlines())
         else:
             tree = set()
 
         def ls_files(args):
-            files = self.execute_command([
-                    'ls-files' ] + [
-                    '-%s' % c for c in args
-                ]).splitlines()
+            files = self.execute_command(
+                ['ls-files'] +
+                ['-%s' % c for c in args]
+            ).splitlines()
 
             d = dict()
             for item in files:
                 yield 'missing', name
             elif 'C' in w and 'H' in i:
                 yield 'modified', name
-
-

anyvc/mercurial/__init__.py

 required_tools = []
 required_modules = ['mercurial']
 
+
 def is_hg(path):
-    return path.join('.hg/store').check(dir=1) \
-       and path.join('.hg/requires').check()
+    return (path.join('.hg/store').check(dir=1) and
+            path.join('.hg/requires').check())
 
 
 is_workdir = is_hg
 
+
 def is_repository(path):
     if isinstance(path, py.path.local) \
         or ('://' not in path and
         return is_hg(path)
     else:
         if path[:4] == 'http':
-            code, content = http_code_content(path+'?cmd=capabilities')
+            code, content = http_code_content(path + '?cmd=capabilities')
             if code == 200:
                 return 'unbundle=' in content
         elif path[:4] == 'ssh':
         else:
             return False
             raise RuntimeError('unknown kind of path ' + str(path))
-

anyvc/mercurial/repo.py

         * 2008 by Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
 """
 
-from anyvc.common.repository import Repository, Revision, join
+from anyvc.common.repository import Repository, Revision
 from anyvc.common.commit_builder import CommitBuilder
 from .workdir import grab_output
 from datetime import datetime
 class MercurialRevision(Revision):
     def __init__(self, repo, rev):
         self.repo, self.rev = repo, rev
-    
+
     @property
     def id(self):
         return self.rev.hex()
 
     @property
     def parents(self):
-        return [MercurialRevision(self.repo, rev) for rev in self.rev.parents() if rev]
-
+        return [MercurialRevision(self.repo, rev)
+                for rev in self.rev.parents() if rev]
 
     @property
     def message(self):
         try:
             return self.rev[path].data()
         except LookupError:
-            raise IOError('%r not found'%path)
+            raise IOError('%r not found' % path)
 
     def get_changed_files(self):
         return self.rev.files()
     def isdir(self, path):
         entries = list(self.rev)
         if not path.endswith('/'):
-            path+='/'
+            path += '/'
 
         from bisect import bisect_right
         point = bisect_right(entries, path)
         if point >= len(entries):
             return False
         entry = entries[point]
-        return path!=entry and entry.startswith(path)
+        return path != entry and entry.startswith(path)
 
     def isfile(self, path):
         return path in self.rev
     def exists(self, path):
         return self.isfile(path) or self.isdir(path)
 
+
 class MercurialCommitBuilder(CommitBuilder):
     def commit(self):
         repo = self.repo.repo
+
         def get_file(repo, ctx, path):
             #XXX: copy sources
             #XXX: renames
             else:
                 data = self.contents[path]
                 copyed = False
+            #XXX: real flags
+            islink = False
+            isexec = False
 
-            islink = False #XXX
-            isexec = False #XXX
+            return context.memfilectx(path, data, islink,
+                                      isexec, copyed)
 
-
-            return context.memfilectx(path, data, islink, isexec, copyed)
-
-        rn = dict((k, v) for k, v in self.renames if self.base_commit.exists(k))
+        rn = dict((k, v) for k, v in self.renames
+                  if self.base_commit.exists(k))
         rrn = dict(reversed(x) for x in self.renames)
         #XXX: directory renames
 
         else:
             base = None
         ctx = context.memctx(
-                repo,
-                [base, None],
-                self.extra['message'],
-                sorted(files),
-                get_file,
-                user=self.author,
-                date="%(time_unix)d %(time_offset)s"%self.__dict__,
-                )
+            repo,
+            [base, None],
+            self.extra['message'],
+            sorted(files),
+            get_file,
+            user=self.author,
+            date="%(time_unix)d %(time_offset)s" % self.__dict__,
+        )
         repo.commitctx(ctx)
 
 
 
         elif path is not None:
             try:
-                repo = localrepo.localrepository(ui.ui(), str(path), create=create)
+                repo = localrepo.localrepository(ui.ui(), str(path),
+                                                 create=create)
             except error.RepoError:
                 raise NotFoundError('mercurial', path)
 

anyvc/mercurial/workdir.py

 from functools import wraps
 
 from anyvc.common.workdir import WorkDir, StatedPath
-from ..exc import NotFoundError
+
+version_error = ImportError('HG version too old, '
+                            'please update to a release >= 1.3')
 
 try:
     import mercurial.util
     hgversion = mercurial.util.version()
     from mercurial.__version__ import version as hgversion
     if hgversion < '1.3':
-        raise ImportError('HG version too old, please update to a release >= 1.3')
+        raise version_error
 except AttributeError:
-    raise ImportError('HG version too old, please update to a release >= 1.3')
+    raise version_error
 
-from mercurial import ui as hgui, hg, commands, util, cmdutil
+from mercurial import ui as hgui, hg, commands, cmdutil
 from mercurial.match import match, always
 try:
     remoteui = cmdutil.remoteui
 __all__ = 'Mercurial',
 
 
-
 #XXX: this shouldn't work if used by the vc client
 #     console output should be responsive
 def grab_output(func):
         """
         try:
             self.ui = hgui.ui(interactive=False, verbose=True, debug=True)
-        except TypeError: # hg >= 1.3 ui
+        except TypeError:  # hg >= 1.3 ui
             self.ui = hgui.ui()
             self.ui.setconfig('ui', 'interactive', 'off')
 
     def create(self):
         hg.repository(self.ui, self.path.strpath, create=True)
 
-    def setup(self):
-        pass #XXX unneded
-
     def create_from(self, source):
         if hasattr(hg, 'peer'):
-            hg.clone(remoteui(self.ui, {}), {},
-                    str(source), self.path.strpath)
+            hg.clone(
+                remoteui(self.ui, {}), {},
+                str(source), self.path.strpath)
         else:
-            hg.clone(remoteui(self.ui, {}),
-                    str(source), self.path.strpath)
+            hg.clone(
+                remoteui(self.ui, {}),
+                str(source), self.path.strpath)
 
     def status(self, paths=(), *k, **kw):
-        glob = '**' if kw.get('recursive') else '*'
+        #XXX: regursive kwargs
         #XXX: merce conflicts ?!
         names = (
-                'modified', 'added', 'removed',
-                'missing', 'unknown', 'ignored', 'clean',
-                )
+            'modified', 'added', 'removed',
+            'missing', 'unknown', 'ignored', 'clean',
+        )
 
         if paths:
         #XXX: investigate cwd arg
-            matcher = match(self.repo.root, self.repo.root, paths,
-                    default='relpath')
+            matcher = match(
+                self.repo.root, self.repo.root,
+                paths,
+                default='relpath',
+            )
         else:
             matcher = always(self.repo.root, self.repo.root)
 
             for file in files:
                 yield StatedPath(file, state, base=self.path)
 
-
-
     @grab_output
     def add(self, paths=()):
         commands.add(self.ui, self.repo, *self.joined(paths))
 
     @grab_output
     def commit(self, paths=(), message=None, user=None):
-        commands.commit(self.ui, self.repo,
+        commands.commit(
+            self.ui, self.repo,
             user=user,
             message=message,
             logfile=None,
             date=None,
-
             *self.joined(paths)
-            )
+        )
 
     @grab_output
     def remove(self, paths):
         #XXX: support for after ?
-        commands.remove(self.ui, self.repo,
-                after=False, # only hg 0.9.5 needs that explicit
-                force=False,
-                *self.joined(paths)
-                )
+        commands.remove(
+            self.ui, self.repo,
+            after=False,  # only hg 0.9.5 needs that explicit
+            force=False,
+            *self.joined(paths)
+        )
 
     @grab_output
-    def revert(self, paths, rev=None): #XXX: how to pass opts['all']?
+    def revert(self, paths, rev=None):
+        #XXX: how to pass opts['all']?
         if rev is None:
             parents = self.repo.parents()
-            if len(parents)!=1 and rev is None:
+            if len(parents) != 1 and rev is None:
                 #XXX: better exception type?
                 raise Exception(
-                        "can't revert on top of a merge without explicit rev")
+                    "can't revert on top of a merge without explicit rev")
             rev = parents[0].rev()
-        commands.revert(self.ui, self.repo,
-                date=None,
-                rev=rev,
-                no_backup=False,
-                *self.joined(paths))
+        commands.revert(
+            self.ui, self.repo,
+            date=None,
+            rev=rev,
+            no_backup=False,
+            *self.joined(paths))
 
     @grab_output
     def rename(self, source, target):
-        commands.rename(self.ui, self.repo,
-                after=False, # hg 0.9.5
-                *self.joined([source, target])
-                )
+        commands.rename(
+            self.ui, self.repo,
+            after=False,  # hg 0.9.5
+            *self.joined([source, target])
+        )
 
     @grab_output
     def diff(self, paths=(), rev=None):
         commands.diff(
-                self.ui,
-                self.repo,
-                rev=rev,
-                git=True,
-                *self.joined(paths))
-
+            self.ui,
+            self.repo,
+            rev=rev,
+            git=True,
+            *self.joined(paths))
 
     @grab_output
     def update(self, paths=None, revision=None):
         assert paths is None
         commands.update(self.ui, self.repo, rev=revision)
-
-

anyvc/metadata.py

       this module is subject to huge changes
 """
 
+
 def _(str):
-    return str #XXX: gettext
+    #XXX: gettext
+    return str
 
 state_descriptions = dict(
     #XXX: finish, validate
-    unknown = _("not known to the vcs"),
-    ignored = _("ignored by the vcs"),
-    added = _("added"),
-    clean = _("known by the vcs and unchanged"),
-    modified =_("changed in the workdir"),
-    missing = _("removed from the workdir, still recorded"),
-    removed = _("removed by deletion or renaming"),
-    conflicte = _("merge conflict")
+    unknown=_("not known to the vcs"),
+    ignored=_("ignored by the vcs"),
+    added=_("added"),
+    clean=_("known by the vcs and unchanged"),
+    modified=("changed in the workdir"),
+    missing=_("removed from the workdir, still recorded"),
+    removed=_("removed by deletion or renaming"),
+    conflicte=_("merge conflict")
 )
 
 aliases = {
     'subversion': 'anyvc.subversion'
 }
 
-def get_backends(limit_to=None,features=None):
+
+def get_backends(limit_to=None, features=None):
     """
-    :param limit_to: optional list of backends to try, will use all if use is none
+    :param limit_to:
+        optional list of backends to try,
+        will use all if use is none
     :type limit_to: list of string or None
 
     a generator over all known backends

anyvc/remote/__init__.py

     anyvc.remote
     ~~~~~~~~~~~~
 """
+__all__ = ['RemoteBackend']
 
 from .master import RemoteBackend

anyvc/remote/master.py

 
 """
 from execnet import makegateway
-from os.path import join
-
-from anyvc.exc import NotFoundError
 from anyvc.util import cachedproperty
 from .object import RemoteCaller
-from anyvc.common.commit_builder import CommitBuilder, FileBuilder, RevisionBuilderPath
-from anyvc.common.repository import MemoryFile
-from anyvc.metadata import backends
+from anyvc.common.commit_builder import RevisionBuilderPath
 import time
 import datetime
 from py.path import local
 
+
 class RemoteCommit(object):
     def __init__(self, repo, id):
         self.repo = repo
     def file_content(self, path):
         data = self.repo.commit_file_content(self.id, path)
         if data is None:
-            raise IOError('%r not found'%path)
+            raise IOError('%r not found' % path)
         return data
 
     @cachedproperty
 
 
 class RemoteRepository(RemoteCaller):
-    
+
     @cachedproperty
     def path(self):
         return local(self._call_remote('path'))
 
     def transaction(self, *k, **kw):
         t = kw.get('time')
-        if isinstance(t, datetime.datetime): #XXX: fragile
+        if isinstance(t, datetime.datetime):  # XXX: fragile
             t = time.mktime(t.timetuple())
             kw['time'] = t
         channel = self._call_remote('transaction', *k, **kw)
     def __enter__(self):
         #XXX: take remote commit into account
         return RevisionBuilderPath(None, '', self)
+
     def __exit__(self, etype,  eval, tb):
         if etype is None:
             self.commit()
 
     def Workdir(self, path, **kw):
         kw['path'] = str(path)
-        if kw.get('source'): # might be none
+        if kw.get('source'):  # might be none
             kw['source'] = str(kw['source'])
         newchan = self._caller.open_workdir(**kw)
         return RemoteWorkdir(newchan)

anyvc/remote/object.py

 
     convience tool make execnet channels remote objects
 """
-import pickle
 from py.path import local
 
+
 class RemoteCaller(object):
     def __init__(self, channel):
         self.channel = channel
         method.__name__ = name
         return method
 
+
 class RemoteHandler(object):
     def __init__(self, channel):
         self.channel = channel
             self.channel.close(errortext)
         except:
             self.channel.close('unknown error')
-
-

anyvc/remote/slave.py

 import time
 import datetime
 
+
 def start_controller(channel):
     vcs = channel.receive()
     backend_module = channel.receive()
     try:
         backend = Backend(vcs, backend_module)
-        backend.module # cause that one is lazy-loaded
+        backend.module  # cause that one is lazy-loaded
     except ImportError:
-        channel.send(None) # magic value for 'i dont have it'
+        channel.send(None)  # magic value for 'i dont have it'
         return
 
     workchan = channel.gateway.newchannel()
         RemoteHandler.__init__(self, channel)
         self.backend = backend
 
-
-    def open_repo(self, *k,**kw):
+    def open_repo(self, *k, **kw):
         repo = self.backend.Repository(*k, **kw)
         channel = self.newchannel()
         RepositoryHandler(channel, repo)
     def features(self):
         return self.backend.features
 
+
 class RepositoryHandler(RemoteHandler):
+
     def __init__(self, channel, repo):
         RemoteHandler.__init__(self, channel)
         self.repo = repo
         self.transaction.__enter__()
 
     def write(self, path, data):
-        fb = self.transaction.write(path, data)
+        self.transaction.write(path, data)
 
     def commit(self):
         self.transaction.__exit__(None, None, None)
 
     def rename(self, source, dest):
         self.transaction.rename(source, dest)
-

anyvc/repository.py

 """
 from py.path import local
 
+
 def open(path, backends=None):
     """
     :param backends: optional list of backends to try
 
     open a repository backend at the given path
     """
+
     from anyvc.metadata import get_backends
     for backend in get_backends(backends):
         if backend.is_repository(path):
             #XXX: add metadata about the worktree base, use it
             return backend.Repository(path)
 
+
 def find(root, backends=None):
     """
     :param root: the search root
 
     find all repositories below `root`
     """
-    start = local(root)
+    root = local(root)
     backend = open(root, backends=backends)
     if backend is not None:
         yield backend
         for subdir in root.listdir(lambda p: p.check(dir=1)):
             for item in find(subdir, backends):
                 yield item
-

anyvc/subversion/__init__.py

 
 def is_workdir(path):
     svn = path.join('.svn')
-    return svn.join('entries').check() \
-       and svn.join('props').check(dir=1) \
-       and svn.join('text-base').check(dir=1)
+    return (svn.join('entries').check() and
+            svn.join('props').check(dir=1) and
+            svn.join('text-base').check(dir=1))
 
 
 def is_repository(path):
 
     path = py.path.local(path)
 
-    return path.join('format').check() \
-       and path.join('hooks').check(dir=1) \
-       and path.join('locks').check(dir=1) \
-       and path.join('format').read().strip().isdigit()
+    return (path.join('format').check() and
+            path.join('hooks').check(dir=1)
+            and path.join('locks').check(dir=1) and
+            path.join('format').read().strip().isdigit())

anyvc/subversion/repo.py

     :license: LGPL 2 or later
     :copyright: 2009 by Ronny Pfannschmidt
 """
-import sys
 
 import subvertpy
 from subvertpy import repos, delta
-from subvertpy.ra import RemoteAccess, Auth, get_username_provider, SubversionException
+from subvertpy.ra import (
+    RemoteAccess, Auth,
+    get_username_provider,
+)
 from anyvc.common.repository import Repository, Revision, join
 from anyvc.common.commit_builder import CommitBuilder
-from subvertpy.properties import time_from_cstring, time_to_cstring
+from subvertpy.properties import time_from_cstring
 from StringIO import StringIO
 
 
 class SubversionRevision(Revision):
     def __init__(self, repo, id):
         #XXX: branch subdirs
-         self.repo, self.id = repo, id
+        self.repo, self.id = repo, id
 
     @property
     def parents(self):
         #XXX: ignore irelevant revisions (no local change)
         #XXX: use mergeinfo to figure additional parents
-        if self.id == 1: # rev 0 is the repo creation
+        if self.id == 1:  # rev 0 is the repo creation
             return []
-        return [SubversionRevision(self.repo, self.id -1)]
+        return [SubversionRevision(self.repo, self.id - 1)]
 
     def file_content(self, path):
         try:
             target = StringIO()
             self.repo.ra.get_file(path.lstrip('/'), target, self.id)
             return target.getvalue()
-        except: #XXX: bad bad
-            raise IOError('%r not found'%path)
-
+        except:  # XXX: bad bad
+            raise IOError('%r not found' % path)
 
     def path_info(self, path):
         return self.repo.ra.check_path(path, self.id)
 
     def get_changed_files(self):
         files = []
+
         def callback(paths, rev, props, childs=None):
             #XXX: take branch path into account?
             files.extend(paths)
+
         self.repo.ra.get_log(
-            start = self.id,
-            end = self.id,
-            callback = callback,
-            paths = None,
+            start=self.id,
+            end=self.id,
+            callback=callback,
+            paths=None,
             discover_changed_paths=True)
         return files
 
         date_str = self.prop('svn:date')
         timestamp = time_from_cstring(date_str)
         #XXX: subertpy uses a magic factor of 1000000
-        return datetime.fromtimestamp(float(timestamp)/1000000)
+        return datetime.fromtimestamp(float(timestamp) / 1000000)
 
 
 class SvnCommitBuilder(CommitBuilder):
         ra = RemoteAccess(self.repo.url,
                           auth=Auth([get_username_provider()]))
         editor = ra.get_commit_editor({
-            'svn:log':self.extra['message'],
-
+            'svn:log': self.extra['message'],
             #XXX: subertpy uses a magic factor of 1000000
             #XXX: subversion cant set a commit date on commit, sucker
             #'svn:date':time_to_cstring(self.time_unix*1000000),
-            })
+        })
 
         root = editor.open_root()
 
         for file in self.contents:
             try:
                 svnfile = root.add_file(file)
-            except Exception as e:
+            except Exception:
                 svnfile = root.open_file(file)
             txhandler = svnfile.apply_textdelta()
             f = StringIO(self.contents[file])
 
     def __getitem__(self, id):
         return SubversionRevision(self, id)
-

anyvc/subversion/workdir.py

-from __future__ import with_statement
-import os
+from anyvc.common.workdir import CommandBased
+from subprocess import call
 
-from anyvc.common.workdir import CommandBased, relative_to, WorkDirWithParser
-from subprocess import call
-#from subvertpy import client, wc, ra, NODE_DIR
-
-#from subvertpy.ra import RemoteAccess, Auth, get_username_provider, SubversionException
 
 class SubVersion(CommandBased):
     #XXX: disabled
     cmd = "svn"
     detect_subdir = ".svn/props"
-    repository = None # no local repo
-
+    # no local repo
+    repository = None
 
     def create(self):
         raise NotImplementedError('no havy workdirs')
             ret.append("--non-recursive")
         return ret + list(paths)
 
-
     def create_from(self, source):
         from urllib import quote
         source = quote(str(source))
         call(['svn', 'co', 'file://%s' % source, self.path.strpath])
 
     state_map = {
-            "?": 'unknown',
-            "A": 'added',
-            " ": 'clean',
-            "!": 'missing',
-            "I": 'ignored',
-            "M": 'modified',
-            "D": 'removed',
-            "C": 'conflict',
-            'X': 'clean',
-            'R': 'modified',
-            '~': 'clean',
-            }
+        "?": 'unknown',
+        "A": 'added',
+        " ": 'clean',
+        "!": 'missing',
+        "I": 'ignored',
+        "M": 'modified',
+        "D": 'removed',
+        "C": 'conflict',
+        'X': 'clean',
+        'R': 'modified',
+        '~': 'clean',
+    }
 
     def get_add_args(self, paths, **kw):
         # svn add doesnt add parent dirs by default
             file = ''
         #TODO: handle paths with whitespace if ppl fall in that one
         return self.state_map[state], file
-
-
-
-
-
-class BrokenSubversion(object):  # workdir with parser
-    detect_subdir= '.svn/entries'
-    repository = None # no local repo
-
-    def create_from(self, source):
-        #XXX: omg what a fucked up mess
-        r = ra.RemoteAccess('file://' + source)
-        rev = r.get_latest_revnum()
-        print rev
-        import os
-        #XXX: wth are we doing here
-        os.mkdir(self.path)
-        c = client.Client(auth=Auth([get_username_provider()]))
-        c.checkout('file://' + source, self.path, rev)
-
-    def add(self, paths=None, recursive=False):
-        #XXX: recursive
-        import os
-        #XXX: hacl
-        print paths
-        w = wc.WorkingCopy(
-                path=self.path,
-                write_lock=True,
-                associated=None)
-        for path in paths:
-            segments = path.split(os.path.sep)
-            p = self.path
-            for segment in segments:
-                p = os.path.join(p, segment)
-                print p, w.add(path=p)
-
-        w.close()
-
-    def commit(self, paths=None, message=None, user=None):
-        if paths:
-            targets = [os.path.join(self.path, path) for path in paths]
-        else:
-            targets = [self.path]
-        c = client.Client(auth=Auth([get_username_provider()]))
-
-        def m(items):
-            print items
-            print message
-            return message #XXX: encoding
-        c.log_msg_func = m
-        c.commit(targets=targets, recurse=True)
-
-    def walk_status(self, parent, basename):
-        basepath = os.path.join(self.path, basename)
-        w = wc.WorkingCopy(parent, basepath)
-        e = w.entries_read(True)
-        print e.keys()
-        for name, entry in e.items():
-            if not name: #ignore root for now
-                continue 
-            yield os.path.join(basename, name), entry
-            if entry.kind == NODE_DIR:
-                for item in self.walk_status(w, os.path.join(basename, name)):
-                    yield item
-        others = os.listdir(basepath)
-
-        for item in others:
-            if item=='.svn' or item in e:
-                continue
-            print item
-            yield os.path.join(basename, item), None #unknown
-
-
-    def status_impl(self,paths=(), recursive=True):
-        return self.walk_status(None, '') #xxx: set limits?
-
-    def parse_status_item(self, item, cache):
-        name, e = item
-        if e is None:
-            return 'unknown', name
-        print e.kind, e.schedule, repr(e.name)
-        map = {
-            wc.SCHEDULE_ADD: 'added',
-            wc.SCHEDULE_DELETE: 'removed',
-            wc.SCHEDULE_NORMAL: 'clean',
-        }
-        state = map[e.schedule]
-        full_path = os.path.join(self.path, name)
-        if not os.path.exists(full_path) and state!='removed':
-            return 'missing', name
-        print state, name
-        if state=='clean':
-            import hashlib
-            with open(os.path.join(self.path, name)) as f:
-                if hashlib.md5(f.read()).hexdigest()!=e.checksum:
-                    return 'modified', name
-
-        return state, name
-
 
 import logging
 
+
 def http_code_content(path):
     try:
         import urllib
         res = urllib.urlopen(path)
         return res.code, res.read()
-    except Exception as e: # diaper
+    except Exception as e:
+        # diaper
         logging.error('no data for path %s, error %s', path, e)
         return -1, ''
 
 
-
 class cachedproperty(object):
     def __init__(self, func):
         self.func = func
             result = self.func(obj)
             setattr(obj, self.__name__, result)
             return result
-
 # -*- coding: utf-8 -*-
-#
-#
-# The contents of this file are pickled, so don't put values in the namespace
-# that aren't pickleable (module imports are okay, they're removed automatically).
-#
-# All configuration values have a default value; values that are commented out
-# serve to show the default value.
-
-import sys, os
-
-# If your extensions are in another directory, add it here. If the directory
-# is relative to the documentation root, use os.path.abspath to make it
-# absolute, like shown here.
+import sys
+import os
 
 cur = os.path.abspath(__file__)
 base = os.path.dirname(os.path.dirname(cur))
 # General configuration
 # ---------------------
 
-# Add any Sphinx extension module names here, as strings. They can be extensions
-# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = [
     'sphinx.ext.autodoc',
     'sphinx.ext.doctest',
     'sphinx.ext.inheritance_diagram',
 ]
 
-# Add any paths that contain templates here, relative to this directory.
 templates_path = ['.templates']
-
-# The suffix of source filenames.
 source_suffix = '.rst'
-
-# The master toctree document.
 master_doc = 'index'
 
 # General substitutions.
 
 # List of documents that shouldn't be included in the build.
 exclude_patterns = [
-    'workdir/cli.rst', #XXX:
-    'readme.rst', #XXX:
+    'workdir/cli.rst',  # XXX:
+    'readme.rst',  # XXX:
 ]
 
-# List of directories, relative to source directories, that shouldn't be searched
-# for source files.
+# List of directories, relative to source directories,
+# that shouldn't be searched for source files.
 exclude_trees = [
     'draco',
 ]
 # dont show the module names for class specs
 add_module_names = False
 
-
-
 # Options for HTML output
 # -----------------------
 
 #latex_font_size = '10pt'
 
 # Grouping the document tree into LaTeX files. List of tuples
-# (source start file, target name, title, author, document class [howto/manual]).
+# (source start file, target, title, author, document class [howto/manual])
 latex_documents = [
-  ('index', 'anyvc.tex', u'anyvc Documentation',
-   u'Pida Team', 'manual'),
+    ('index', 'anyvc.tex', u'anyvc Documentation',
+     u'Pida Team', 'manual'),
 ]
 
 # The name of an image file (relative to this directory) to place at the top of
 #!/usr/bin/python
 from __future__ import with_statement
 from setuptools import setup
+from setuptools.command.test import test
 
 
-
-from setuptools.command.test import test
-
 class pytest(test):
     def finalize_options(self):
         test.finalize_options(self)
         self.test_args = []
         self.test_suite = True
+
     def run_tests(self):
         import pytest
         pytest.main([])
             result.append(f.read())
     return '\n'.join(result)
 
+
 setup(
     name='anyvc',
     packages=[
     classifiers=[
         'Intended Audience :: Developers',
     ],
-    cmdclass = {'test': pytest}
+    cmdclass={'test': pytest}
 )

tests/conftest.py

 import py
 import pytest
-from tests.helpers import  VcsMan
+from tests.helpers import VcsMan
 import os
 
 from anyvc import metadata
 
 pytest_plugins = "doctest"
-
 test_in_interpreters = 'python2', 'python3', 'jython', 'pypy'
 
 
-
 def pytest_addoption(parser):
     g = parser.getgroup('anyvc')
     g.addoption("--local-remoting", action="store_true", default=False,
-               help='test via execnet remoting')
+                help='test via execnet remoting')
     g.addoption("--no-direct-api", action="store_true", default=False,
                 help='don\'t test the direct api')
     g.addoption("--vcs", action='store', default=None)
 
+
 def pytest_configure(config):
     vcs = config.getvalue('vcs')
     if vcs is None:
         else:
             raise KeyError(vcs, '%r not found' % vcs)
 
-
     os.environ['BZR_EMAIL'] = 'Test <test@example.com>'
 
 
 @pytest.fixture(scope='session', params=['direct', 'popen'])
 def spec(request):
-    if request.config.getvalue('no_direct_api') \
-       and request.param == 'direct':
+    direct = request.param == 'direct'
+    if request.config.getvalue('no_direct_api') and direct:
         pytest.skip('no direct api testing')
-    if not request.config.getvalue('local_remoting') \
-       and request.param != 'direct':
+    if not request.config.getvalue('local_remoting') and not direct:
         pytest.skip('no remote testing')
     from execnet.xspec import XSpec
     return XSpec(request.param)
         pytest.skip('%s not wanted for this test run' % request.param)
     return request.param
 
+
 @pytest.fixture(scope='session')
 def backend(vcs, spec):
     """
         spec = None
         return metadata.get_backend(vcs, spec)
 
+
 @pytest.fixture()
 def mgr(spec, backend, tmpdir, request):
     """
     create a preconfigured :class:`tests.helplers.VcsMan` instance
-    pass the currently tested backend 
+    pass the currently tested backend
     and create a tmpdir for the vcs/test combination
 
     auto-check for the vcs features and skip if necessary
         difference = required_features.difference(backend.features)
         print required_features
         if difference:
-            py.test.skip('%s lacks features %r' % (backend, sorted(difference)))
+            py.test.skip('%s lacks features %r' % (
+                backend,
+                sorted(difference)))
 
     return VcsMan(backend.name, tmpdir, spec, backend)
 
+
 @pytest.fixture()
 def repo(mgr):
     """
     """
     return mgr.make_repo('repo')
 
+
 @pytest.fixture()
 def wd(mgr, repo, request):
     #XXX: repo only needed when light backends
         wd = mgr.create_wd('wd')
     return wd
 
+
 @pytest.fixture(autouse=True)
 def prepared_files(request):
     print request, dir(request)
         if  hasattr(fp, 'commit'):
             wd.add(paths=list(files))
             wd.commit(message='initial commit')
-
-
 
 from anyvc.metadata import state_descriptions
 
+
 class WdWrap(object):
     """
     :param wd: the workdir to wrap
     def __getattr__(self, name):
         return getattr(self.__wd, name)
 
-
     def put_files(self, mapping):
         """
         :type mapping: dict of (filename, text content)
         """
         :arg files: a listing of filenames that shsould exist
         """
-        missing = [name for name in map(self.path.join, files) if not name.check()]
-        assert not missing, 'missing %s'%', '.join(missing)
+        missing = [name for name in map(self.path.join, files)
+                   if not name.check()]
+        assert not missing, 'missing %s' % ', '.join(missing)
         return not missing
 
     def delete_files(self, *relpaths):
             assert info.state in state_descriptions
             if info.relpath in mapping:
                 expected = mapping[info.relpath]
-                assert info.state==expected, "%s wanted %s but got %s"%(
-                        info.relpath,
-                        expected,
-                        info.state,
-                        )
+                assert info.state == expected, '%s wanted %s but got %s' % (
+                    info.relpath,
+                    expected,
+                    info.state,
+                )
                 used.add(info.relpath)
 
         untested = set(mapping) - used
         print 'used:', sorted(used)
         print 'missing?:', sorted(all - used)
         print 'untested:', sorted(untested)
-        assert not untested , 'not all excepted stated occured'
+        assert not untested, 'not all excepted stated occured'
 
 
 class VcsMan(object):
         self.xspec = xspec
         self.backend = backend
 
-    def __repr__(self): 
-        return '<VcsMan %(vc)s %(base)r>'%vars(self)
+    def __repr__(self):
+        return '<VcsMan %(vc)s %(base)r>' % vars(self)
 
     def create_wd(self, workdir, source=None):
         """
 
         create a workdir if `source` is given, use it as base
         """
-        path = self.base/workdir
+        path = self.base.join(workdir)
         source_path = getattr(source, 'path', None)
         wd = self.backend.Workdir(path, create=True, source=source_path)
         return WdWrap(wd)
 
         create a repository using the given name
         """
-        return self.backend.Repository(path=self.base/name, create=True)
-
+        return self.backend.Repository(path=self.base.join(name), create=True)

tests/remote/test_remote.py

 from anyvc.remote import RemoteBackend
 from anyvc.metadata import backends
 
+
 def test_end_popen_backend(backend):
     backend = RemoteBackend(backend.name, backends[backend.name], 'popen')
     assert backend.active
     backend.stop()
     assert not backend.active
 
+
 def test_missing_backend_failure(monkeypatch):
     print backends
     py.test.raises(ImportError, RemoteBackend, 'testvc', '_missing_', 'popen')

tests/remote/test_remote_object.py

 from execnet import makegateway
-import pickle
 from anyvc.remote.object import RemoteCaller
 
+
 def test_remote_object():
     gw = makegateway('popen')
     channel = gw.remote_exec("""
     """)
     caller = RemoteCaller(channel.receive())
     result = caller.test(a=1)
-    assert result == {'a':1}
+    assert result == {'a': 1}
 
 
 class TestChannel(object):
 
     def receive(self):
         result = self.next
-        del self.next #XXX: crude hack
+        del self.next  # XXX: crude hack
         return result
 
+
 def test_caller():
 
     test_handler = RemoteCaller(TestChannel())

tests/repository/test_commit_builder.py

-import py
 from os import path
 from anyvc.common.commit_builder import CommitBuilder
 
 class FakeCommit(object):
     def __init__(self, file_tree):
         self.file_tree = file_tree
-    
+
     def file_content(self, name):
         items = name.split(path.sep)
         tree = self.file_tree
         return tree
 
 
-
 def test_rename():
     base_commit = FakeCommit({
-        'test':{
-            'test.py':'#!/usr/bin/python',