about summary refs log tree commit diff stats
path: root/arc/.traces/scheduler-helper-sleeping
blob: 3c288dafa4da4051f12ce9503852e7df21ecec73 (plain) (blame)
1
schedule: just helpers left; stopping everything
#ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
# This file is part of ranger, the console file manager.
# License: GNU GPL version 3, see the file "AUTHORS" for details.

"""Subversion module"""

from __future__ import with_statement
import os
import re
import logging
from datetime import datetime

from .vcs import Vcs, VcsError

class SVN(Vcs):
    """VCS implementation for Subversion"""
    HEAD = 'HEAD'

    # Generic
    #---------------------------

    def _svn(self, path, args, silent=True, catchout=False, retbytes=False):
        return self._vcs(path, 'svn', args, silent=silent, catchout=catchout, retbytes=retbytes)

    def _has_head(self):
        """Checks whether repo has head"""
        return True

    def _sanitize_rev(self, rev):
        if rev == None: return None
        rev = rev.strip()
        if len(rev) == 0: return None
        if rev[-1] == '+': rev = rev[:-1]

        try:
            if int(rev) == 0: return None
        except:
            pass

        return rev

    def _log(self, refspec=None, maxres=None, filelist=None):
        """ Retrieves log message and parses it.
        """
        args = ['log']

        if refspec:  args = args + ['--limit', '1', '-r', refspec]
        elif maxres: args = args + ['--limit', str(maxres)]

        if filelist: args = args + filelist
        logging.debug('Running svn log')
        logging.debug(args)

        raw = self._svn(self.path, args, catchout=True)
        logging.debug(raw)
        L = re.findall(r"""^[-]*\s*            # Dash line
                       r([0-9]*)\s\|\s         # Revision          [0]
                       (.*)\s\|\s              # Author            [1]
                       (.*?)\s                 # Date              [2]
                       (.*?)\s                 # Time              [3]
                       .*?\|\s*?               # Dump rest of date string
                       ([0-9])+\sline(?:s)?\s* # Number of line(s) [4]
                       (.*)\s                  # Log Message       [5]
                       [-]+\s*                 # Dash line
                       $""", raw, re.MULTILINE | re.VERBOSE)

        log = []
        for t in L:
            logging.debug(t)
            dt = {}
            dt['short'] = t[0].strip()
            dt['revid'] = t[0].strip()
            dt['author'] = t[1].strip()
            dt['date'] = datetime.strptime(t[2]+'T'+t[3], "%Y-%m-%dT%H:%M:%S")
            dt['summary'] = t[5].strip()
            log.append(dt)
            logging.debug(log)
        return log

    def _svn_file_status(self, st):
        if len(st) != 1: raise VcsError("Wrong hg file status string: %s" % st)
        if   st in "A":  return 'staged'
        elif st in "D":  return 'deleted'
        elif st in "I":  return 'ignored'
        elif st in "?":  return 'untracked'
        elif st in "C":  return 'conflict'
        else:            return 'unknown'

    # Action Interface
    #---------------------------

    def action_add(self, filelist=None):
        """Adds files to the index, preparing for commit"""
        if filelist != None: self._svn(self.path, ['add'] + filelist)
        else:                self._svn(self.path, ['add'])

    def action_reset(self, filelist=None):
        """Equivalent to svn revert"""
        if filelist == None: filelist = self.data_status_subpaths().keys()
        self._svn(self.path, ['revert'] + filelist)

    # Data Interface
    #---------------------------

    def data_status_subpaths(self):
        """Returns a dict indexed by files not in sync their status as values.
           Paths are given relative to the root. Strips trailing '/' from dirs."""
        raw = self._svn(self.path, ['status'], catchout=True, retbytes=True)
#        logging.debug(raw)
        L = re.findall(r'^(.)\s*(.*?)\s*$', raw.decode('utf-8'), re.MULTILINE)
        ret = {}
        for st, p in L:
            # Detect conflict by the existence of .orig files
            if st == '?' and re.match(r'^.*\.orig\s*$', p): st = 'X'
            sta = self._svn_file_status(st)
            ret[os.path.normpath(p.strip())] = sta
        return ret

    def data_status_remote(self):
        """Checks the status of the repo regarding sync state with remote branch.

        I'm not sure this make sense for SVN so we're just going to return 'sync'"""
        return 'sync'

    def data_branch(self):
        """Returns the current named branch, if this makes sense for the backend. None otherwise"""
        return None
        branch = self._svn(self.path, ['branch'], catchout=True)
        return branch or None

    def data_info(self, rev=None):
        """Gets info about the given revision rev"""
        if rev == None: rev = self.HEAD
        rev = self._sanitize_rev(rev)
        if rev == self.HEAD and not self._has_head(): return None
        logging.debug('refspec is ' + str(rev))
        L = self._log(refspec=rev)
        logging.debug(len(L))
        if len(L) == 0:
            raise VcsError("Revision %s does not exist" % rev)
        elif len(L) > 1:
            raise VcsError("More than one instance of revision %s ?!?" % rev)
        else:
            return L[0]