예제 #1
0
 def open(self, mode='r'):
     """ return an opened file with the given mode. """
     assert 'w' not in mode and 'a' not in mode, "XXX not implemented for svn cmdline"
     assert self.check(file=1) # svn cat returns an empty file otherwise
     def popen(cmd):
         return os.popen(cmd)
     if self.rev is None:
         return popen(svncommon.fixlocale() +
                         'svn cat "%s"' % (self._escape(self.strpath), ))
     else:
         return popen(svncommon.fixlocale() +
                         'svn cat -r %s "%s"' % (self.rev, self._escape(self.strpath)))
예제 #2
0
 def _svn(self, cmd, *args):
     l = ['svn %s' % cmd]
     args = [self._escape(item) for item in args]
     l.extend(args)
     l.append('"%s"' % self._escape(self.strpath))
     # try fixing the locale because we can't otherwise parse
     string = svncommon.fixlocale() + " ".join(l)
     if DEBUG:
         print "execing", string
     try:
         try:
             key = 'LC_MESSAGES'
             hold = os.environ.get(key)
             os.environ[key] = 'C'
             out = py.process.cmdexec(string)
         finally:
             if hold:
                 os.environ[key] = hold
             else:
                 del os.environ[key]
     except py.process.cmdexec.Error, e:
         strerr = e.err.lower()
         if strerr.find('file not found') != -1: 
             raise py.error.ENOENT(self) 
         if (strerr.find('file exists') != -1 or 
             strerr.find('file already exists') != -1 or
             strerr.find("can't create directory") != -1):
             raise py.error.EEXIST(self)
         raise
예제 #3
0
    def log(self, rev_start=None, rev_end=1, verbose=False):
        """ return a list of LogEntry instances for this path.
rev_start is the starting revision (defaulting to the first one).
rev_end is the last revision (defaulting to HEAD).
if verbose is True, then the LogEntry instances also know which files changed.
"""
        from py.__.path.svn.urlcommand import _Head, LogEntry
        assert self.check()   # make it simpler for the pipe
        rev_start = rev_start is None and _Head or rev_start
        rev_end = rev_end is None and _Head or rev_end

        if rev_start is _Head and rev_end == 1:
                rev_opt = ""
        else:
            rev_opt = "-r %s:%s" % (rev_start, rev_end)
        verbose_opt = verbose and "-v" or ""
        locale_env = svncommon.fixlocale()
        # some blather on stderr
        auth_opt = self._makeauthoptions()
        stdin, stdout, stderr  = os.popen3(locale_env +
                                           'svn log --xml %s %s %s "%s"' % (
                                            rev_opt, verbose_opt, auth_opt,
                                            self.strpath))
        minidom,ExpatError = importxml()
        try:
            tree = minidom.parse(stdout)
        except ExpatError:
            raise ValueError('no such revision')
        result = []
        for logentry in filter(None, tree.firstChild.childNodes):
            if logentry.nodeType == logentry.ELEMENT_NODE:
                result.append(LogEntry(logentry))
        return result
예제 #4
0
 def _svn(self, cmd, *args):
     l = ['svn %s' % cmd]
     args = [self._escape(item) for item in args]
     l.extend(args)
     l.append('"%s"' % self._escape(self.strpath))
     # try fixing the locale because we can't otherwise parse
     string = svncommon.fixlocale() + " ".join(l)
     if DEBUG:
         print "execing", string
     try:
         try:
             key = 'LC_MESSAGES'
             hold = os.environ.get(key)
             os.environ[key] = 'C'
             out = py.process.cmdexec(string)
         finally:
             if hold:
                 os.environ[key] = hold
             else:
                 del os.environ[key]
     except py.process.cmdexec.Error, e:
         strerr = e.err.lower()
         if strerr.find('file not found') != -1:
             raise py.error.ENOENT(self)
         if (strerr.find('file exists') != -1
                 or strerr.find('file already exists') != -1
                 or strerr.find("can't create directory") != -1):
             raise py.error.EEXIST(self)
         raise
예제 #5
0
    def log(self, rev_start=None, rev_end=1, verbose=False):
        """ return a list of LogEntry instances for this path.
rev_start is the starting revision (defaulting to the first one).
rev_end is the last revision (defaulting to HEAD).
if verbose is True, then the LogEntry instances also know which files changed.
"""
        from py.__.path.svn.urlcommand import _Head, LogEntry
        assert self.check()  # make it simpler for the pipe
        rev_start = rev_start is None and _Head or rev_start
        rev_end = rev_end is None and _Head or rev_end

        if rev_start is _Head and rev_end == 1:
            rev_opt = ""
        else:
            rev_opt = "-r %s:%s" % (rev_start, rev_end)
        verbose_opt = verbose and "-v" or ""
        locale_env = svncommon.fixlocale()
        # some blather on stderr
        auth_opt = self._makeauthoptions()
        stdin, stdout, stderr = os.popen3(
            locale_env + 'svn log --xml %s %s %s "%s"' %
            (rev_opt, verbose_opt, auth_opt, self.strpath))
        minidom, ExpatError = importxml()
        try:
            tree = minidom.parse(stdout)
        except ExpatError:
            raise ValueError('no such revision')
        result = []
        for logentry in filter(None, tree.firstChild.childNodes):
            if logentry.nodeType == logentry.ELEMENT_NODE:
                result.append(LogEntry(logentry))
        return result
예제 #6
0
    def log(self, rev_start=None, rev_end=1, verbose=False):
        """ return a list of LogEntry instances for this path.
rev_start is the starting revision (defaulting to the first one).
rev_end is the last revision (defaulting to HEAD).
if verbose is True, then the LogEntry instances also know which files changed.
"""
        assert self.check() #make it simpler for the pipe
        rev_start = rev_start is None and _Head or rev_start
        rev_end = rev_end is None and _Head or rev_end

        if rev_start is _Head and rev_end == 1:
            rev_opt = ""
        else:
            rev_opt = "-r %s:%s" % (rev_start, rev_end)
        verbose_opt = verbose and "-v" or ""
        xmlpipe =  os.popen(svncommon.fixlocale() +
                      'svn log --xml %s %s "%s"' %
                      (rev_opt, verbose_opt, self.strpath))
        from xml.dom import minidom
        tree = minidom.parse(xmlpipe)
        result = []
        for logentry in filter(None, tree.firstChild.childNodes):
            if logentry.nodeType == logentry.ELEMENT_NODE:
                result.append(LogEntry(logentry))
        return result
예제 #7
0
 def _svnwrite(self, cmd, *args):
     l = ['svn %s' % cmd]
     args = ['"%s"' % self._escape(item) for item in args]
     l.extend(args)
     l.append('"%s"' % self._encodedurl())
     # fixing the locale because we can't otherwise parse
     string = svncommon.fixlocale() + " ".join(l)
     if DEBUG:
         print "execing", string
     try:
         out = process.cmdexec(string)
     except py.process.cmdexec.Error, e:
         if (e.err.find('File Exists') != -1 or
                         e.err.find('File already exists') != -1):
             raise py.error.EEXIST(self)
         raise
예제 #8
0
파일: urlcommand.py 프로젝트: enyst/plexnet
 def _svnpopenauth(self, cmd):
     """ execute an svn command, return a pipe for reading stdin """
     cmd = svncommon.fixlocale() + cmd
     if self.auth is not None:
         cmd += ' ' + self.auth.makecmdoptions()
     return self._popen(cmd)
예제 #9
0
파일: urlcommand.py 프로젝트: enyst/plexnet
 def _svncmdexecauth(self, cmd):
     """ execute an svn command 'as is' """
     cmd = svncommon.fixlocale() + cmd
     if self.auth is not None:
         cmd += ' ' + self.auth.makecmdoptions()
     return self._cmdexec(cmd)
예제 #10
0
 def _svnpopenauth(self, cmd):
     """ execute an svn command, return a pipe for reading stdin """
     cmd = svncommon.fixlocale() + cmd
     if self.auth is not None:
         cmd += ' ' + self.auth.makecmdoptions()
     return self._popen(cmd)
예제 #11
0
 def _svncmdexecauth(self, cmd):
     """ execute an svn command 'as is' """
     cmd = svncommon.fixlocale() + cmd
     if self.auth is not None:
         cmd += ' ' + self.auth.makecmdoptions()
     return self._cmdexec(cmd)