def checkout (self):
        self.repo = create_repository ('git', 'git://git.kernel.org/pub/scm/')
        self.repo.checkout ('utils/kernel/cpufreq/cpufrequtils.git', '/tmp/', newdir = 'cpufrequtils')
        if not os.path.exists ('/tmp/cpufrequtils/.git'):
            print "Git checkout: FAILED"
            return

        self.repo.checkout ('utils/pciutils/pciutils.git', '/tmp/', newdir = 'pciutils', branch = 'network')
        if not os.path.exists ('/tmp/pciutils/.git'):
            print "Git checkout: FAILED"
            return

        # Test module = '.'
        repo2 = create_repository ('git', 'git://anongit.freedesktop.org/libspectre')
        repo2.checkout ('.', '/tmp')
        if not os.path.exists ('/tmp/libspectre/.git'):
            print "Git checkout (module = '.'): FAILED"
            return
        
        try:
            repo2 = create_repository_from_path ('/tmp/cpufrequtils')
        except:
            print "Git create_repository_from_path: FAILED"
            return
        try:
            repo2 = create_repository_from_path ('/tmp/')
        except RepositoryUnknownError:
            print "Git create_repository_from_path: PASSED"
        except:
            print "Git create_repository_from_path: FAILED"
            return
            
        print "Git checkout: PASSED"
Ejemplo n.º 2
0
 def checkout (self):
     # checkout
     self.repo = create_repository ('cvs', ':pserver:[email protected]:/cvs/poppler')
     self.repo.add_watch (CHECKOUT, output, "check out")
     self.repo.checkout ('poppler', '/tmp/')
     if not os.path.exists ('/tmp/poppler/CVS'):
         print "CVS checkout: FAILED"
         return
     
     self.repo.checkout ('poppler', '/tmp/', newdir = 'poppler-0.5', rev = 'POPPLER_0_5_X')
     if os.path.exists ('/tmp/poppler-0.5/CVS'):
         print "CVS checkout module: PASSED"
         try:
             repo2 = create_repository_from_path ('/tmp/poppler-0.5/')
         except:
             print "CVS create_repository_from_path: FAILED"
             return
         try:
             repo2 = create_repository_from_path ('/tmp/')
         except RepositoryUnknownError:
             print "CVS create_repository_from_path: PASSED"
         except:
             print "CVS create_repository_from_path: FAILED"
     else:
         print "CVS checkout: FAILED"
     
     # checkout of all modules module
     print "CVS checkout of all modules"
     self.repo.checkout ('.', '/tmp/', newdir = 'poppler_modules-0.5', rev = 'POPPLER_0_5_X')
     if not os.path.exists ('/tmp/poppler_modules-0.5/CVS'):
          print "CVS checkout: FAILED"
          return
     print "CVS checkout: PASSED"
Ejemplo n.º 3
0
    def checkout(self):
        # checkout
        self.repo = create_repository('svn',
                                      'http://svn.gnome.org/svn/gnome-common')
        self.repo.checkout('gnome-common', '/tmp/', branch="trunk", rev="3910")
        if not os.path.exists('/tmp/gnome-common/.svn') or \
                self.repo.get_last_revision('/tmp/gnome-common') != "3910":
            print "SVN checkout: FAILED"
            return

        self.repo.checkout('gnome-common',
                           '/tmp/',
                           newdir='gnome-common-2.16',
                           branch='gnome-2-16')
        if os.path.exists('/tmp/gnome-common-2.16/.svn'):
            print "SVN checkout: PASSED"
            try:
                repo2 = create_repository_from_path('/tmp/gnome-common-2.16')
            except:
                print "SVN create_repository_from_path: FAILED"
                return
            try:
                repo2 = create_repository_from_path('/tmp/')
            except RepositoryUnknownError:
                print "SVN create_repository_from_path: PASSED"
            except:
                print "SVN create_repository_from_path: FAILED"
        else:
            print "SVN checkout: FAILED"
            return

        try:
            # Repository without trunk dir
            repo2 = create_repository(
                'svn',
                'https://svn.forge.morfeo-project.org/svn/libresoft-tools')

            repo2.checkout('octopus/trunk', '/tmp/', newdir='octopus')
            if not os.path.exists('/tmp/octopus/.svn'):
                print "SVN checkout repo without /trunk: FAILED"
                return
        except:
            print "SVN checkout repo without /trunk: FAILED"
            return

        print "SVN checkout repo without /trunk: PASSED"

        try:
            # Download unconditionally the whole repo
            repo3 = create_repository('svn',
                                      'http://svn.gnome.org/svn/asyncworker')
            repo3.checkout('.', '/tmp/')
            if not os.path.exists('/tmp/asyncworker/.svn'):
                print "SVN checkout the whole repo: FAILED"
                return
        except:
            print "SVN checkout the whole repo: FAILED"
            return

        print "SVN checkout the whole repo: PASSED"
Ejemplo n.º 4
0
    def checkout(self):
        # checkout
        self.repo = create_repository('svn',
                                      'http://svn.gnome.org/svn/gnome-common')
        self.repo.checkout('gnome-common', '/tmp/', branch="trunk", rev="3910")
        if not os.path.exists('/tmp/gnome-common/.svn') or \
                self.repo.get_last_revision('/tmp/gnome-common') != "3910":
            print "SVN checkout: FAILED"
            return

        self.repo.checkout('gnome-common', '/tmp/', newdir='gnome-common-2.16',
                           branch='gnome-2-16')
        if os.path.exists('/tmp/gnome-common-2.16/.svn'):
            print "SVN checkout: PASSED"
            try:
                repo2 = create_repository_from_path('/tmp/gnome-common-2.16')
            except:
                print "SVN create_repository_from_path: FAILED"
                return
            try:
                repo2 = create_repository_from_path('/tmp/')
            except RepositoryUnknownError:
                print "SVN create_repository_from_path: PASSED"
            except:
                print "SVN create_repository_from_path: FAILED"
        else:
            print "SVN checkout: FAILED"
            return

        try:
            # Repository without trunk dir
            repo2 = create_repository(
                'svn',
                'https://svn.forge.morfeo-project.org/svn/libresoft-tools')

            repo2.checkout('octopus/trunk', '/tmp/', newdir='octopus')
            if not os.path.exists('/tmp/octopus/.svn'):
                print "SVN checkout repo without /trunk: FAILED"
                return
        except:
            print "SVN checkout repo without /trunk: FAILED"
            return

        print "SVN checkout repo without /trunk: PASSED"

        try:
            # Download unconditionally the whole repo
            repo3 = create_repository('svn',
                                      'http://svn.gnome.org/svn/asyncworker')
            repo3.checkout('.', '/tmp/')
            if not os.path.exists('/tmp/asyncworker/.svn'):
                print "SVN checkout the whole repo: FAILED"
                return
        except:
            print "SVN checkout the whole repo: FAILED"
            return

        print "SVN checkout the whole repo: PASSED"
Ejemplo n.º 5
0
def _get_uri_and_repo(path):
    """ Get a URI and repositoryhandler object for a path.

    This function returns a URI as a string, and the repositoryhandler
    object that represents that URI. They are returned together as a tuple.

    Args:
      path: The path to the repository
    """
    # Create repository
    if path is not None:
        try:
            printdbg("Creating repositoryhandler instance")
            repo = create_repository_from_path(path)
            repo.timeout = 120
        except RepositoryUnknownError:
            printerr("Path %s doesn't seem to point to a repository " + \
                     "supported by cvsanaly", (path,))
            sys.exit(1)
        except Exception, e:
            printerr("Unknown error creating repository for path %s (%s)",
                     (path, str(e)))
            sys.exit(1)
        uri = repo.get_uri_for_path(path)
        return (uri, repo)
Ejemplo n.º 6
0
def _get_uri_and_repo(path):
    """ Get a URI and repositoryhandler object for a path.

    This function returns a URI as a string, and the repositoryhandler
    object that represents that URI. They are returned together as a tuple.

    Args:
      path: The path to the repository
    """
    # Create repository
    if path is not None:
        try:
            printdbg("Creating repositoryhandler instance")
            repo = create_repository_from_path(path)
            repo.timeout = 120
        except RepositoryUnknownError:
            printerr("Path %s doesn't seem to point to a repository " + \
                     "supported by cvsanaly", (path,))
            sys.exit(1)
        except Exception, e:
            printerr("Unknown error creating repository for path %s (%s)",
                     (path, str(e)))
            sys.exit(1)
        uri = repo.get_uri_for_path(path)
        return (uri, repo)
Ejemplo n.º 7
0
    def test_branching_file_paths(self):
        # This part should be moved to set up, but in case no one from MetricsGrimoire
        # is interested in this pull request (which is the case for all my pull requests
        # so far), it is easier to keep compatible with the main repository this way
        opened, temp_file_name = tempfile.mkstemp('.db', 'cvsanaly-test')
        os.close(opened)
        command_line_options = [
            "--db-driver=sqlite", "-d", temp_file_name,
            self.TEST_REPOSITORY_PATH
        ]
        pycvsanaly2.main.main(command_line_options)

        connection = db.connect(temp_file_name)
        cursor = connection.cursor()
        cursor.execute('SELECT id FROM repositories')
        database = create_database('sqlite', temp_file_name)
        fr = FileRevs(database, connection, cursor, cursor.fetchone()[0])
        repo = create_repository_from_path(self.TEST_REPOSITORY_PATH)
        for revision, commit_id, file_id, action_type, composed in fr:
            if revision == '51a3b654f252210572297f47597b31527c475fb8':
                # Getting the latest file_links record
                actual = fr.get_path()
                self.assertEqual(u'aaa/otherthing.renamed', actual)
                # Using git merge-base
                actual = fr.get_path(repo, self.TEST_REPOSITORY_PATH)
                self.assertEqual(u'aaa/otherthing', actual)

        cursor.close()
        connection.close()
        os.remove(temp_file_name)
Ejemplo n.º 8
0
    def test_branching_file_paths(self):
        # This part should be moved to set up, but in case no one from MetricsGrimoire
        # is interested in this pull request (which is the case for all my pull requests
        # so far), it is easier to keep compatible with the main repository this way
        opened, temp_file_name = tempfile.mkstemp('.db', 'cvsanaly-test')
        os.close(opened)
        command_line_options = ["--db-driver=sqlite", "-d", temp_file_name, self.TEST_REPOSITORY_PATH]
        pycvsanaly2.main.main(command_line_options)

        connection = db.connect(temp_file_name)
        cursor = connection.cursor()
        cursor.execute('SELECT id FROM repositories')
        database = create_database('sqlite', temp_file_name)
        fr = FileRevs(database, connection, cursor, cursor.fetchone()[0])
        repo = create_repository_from_path(self.TEST_REPOSITORY_PATH)
        for revision, commit_id, file_id, action_type, composed in fr:
            if revision == '51a3b654f252210572297f47597b31527c475fb8':
                # Getting the latest file_links record
                actual = fr.get_path()
                self.assertEqual(u'aaa/otherthing.renamed', actual)
                # Using git merge-base
                actual = fr.get_path(repo, self.TEST_REPOSITORY_PATH)
                self.assertEqual(u'aaa/otherthing', actual)


        cursor.close()
        connection.close()
        os.remove(temp_file_name)
Ejemplo n.º 9
0
    def checkout(self):
        self.repo = create_repository('git', 'git://git.kernel.org/pub/scm/')
        self.repo.checkout('utils/kernel/cpufreq/cpufrequtils.git',
                           '/tmp/',
                           newdir='cpufrequtils')
        if not os.path.exists('/tmp/cpufrequtils/.git'):
            print "Git checkout: FAILED"
            return

        self.repo.checkout('utils/pciutils/pciutils.git',
                           '/tmp/',
                           newdir='pciutils',
                           branch='network')
        if not os.path.exists('/tmp/pciutils/.git'):
            print "Git checkout: FAILED"
            return

        # Test module='.'
        repo2 = create_repository('git',
                                  'git://anongit.freedesktop.org/libspectre')
        repo2.checkout('.', '/tmp')
        if not os.path.exists('/tmp/libspectre/.git'):
            print "Git checkout(module='.'): FAILED"
            return

        try:
            repo2 = create_repository_from_path('/tmp/cpufrequtils')
        except:
            print "Git create_repository_from_path: FAILED"
            return
        try:
            repo2 = create_repository_from_path('/tmp/')
        except RepositoryUnknownError:
            print "Git create_repository_from_path: PASSED"
        except:
            print "Git create_repository_from_path: FAILED"
            return

        print "Git checkout: PASSED"
    def checkout (self):
        self.repo = create_repository ('bzr', 'http://pkg-config.freedesktop.org/bzr/')
        self.repo.checkout ('pkg-config', '/tmp/', newdir = 'pkg-config')
        if not os.path.exists ('/tmp/pkg-config/.bzr'):
            print "Bzr checkout: FAILED"
            return

        try:
            repo2 = create_repository_from_path ('/tmp/pkg-config')
        except:
            print "Bzr create_repository_from_path: FAILED"
            return

        print "Bzr checkout: PASSED"
Ejemplo n.º 11
0
    def checkout(self):
        self.repo = create_repository(
            'bzr', 'http://pkg-config.freedesktop.org/bzr/')
        self.repo.checkout('pkg-config', '/tmp/', newdir='pkg-config')
        if not os.path.exists('/tmp/pkg-config/.bzr'):
            print "Bzr checkout: FAILED"
            return

        try:
            repo2 = create_repository_from_path('/tmp/pkg-config')
        except:
            print "Bzr create_repository_from_path: FAILED"
            return

        print "Bzr checkout: PASSED"
Ejemplo n.º 12
0
            printerr("Cannot create cache directory in %s. Error: %s",
                     (config.writable_path, repr(e)))
            return 1

        try:
            set_writable_path_from_config('dot', config.writable_path)
        except OSError, e:
            printerr("Cannot create .cvsanaly2 directory in %s. Error: %s",
                     (config.writable_path, repr(e)))
            return 1

    # Create repository
    path = uri_to_filename(uri)
    if path is not None:
        try:
            repo = create_repository_from_path(path)
        except RepositoryUnknownError:
            printerr(
                "Path %s doesn't seem to point to a repository supported by cvsanaly",
                (path, ))
            return 1
        except Exception, e:
            printerr("Unknown error creating repository for path %s (%s)",
                     (path, str(e)))
            return 1
        uri = repo.get_uri_for_path(path)
    else:
        uri = uri.strip('/')
        # Get an object of the backends class for managing the repository
        repo = create_repository('svn', uri)
        # Check uri actually points to a valid svn repo
Ejemplo n.º 13
0

if __name__ == '__main__':
    import sys
    import os
    from utils import uri_to_filename
    from repositoryhandler.backends import create_repository, create_repository_from_path

    def new_line(line, user_data=None):
        print line.strip('\n')
        if user_data is not None:
            user_data.add_line(line)

    path = uri_to_filename(sys.argv[1])
    if path is not None:
        repo = create_repository_from_path(path)
    else:
        repo = create_repository('svn', sys.argv[1])
        path = sys.argv[1]

    reader = LogReader()
    reader.set_repo(repo, path)

    writer = None

    if len(sys.argv) > 2:
        if os.path.isfile(sys.argv[2]):
            reader.set_logfile(sys.argv[2])
        else:
            writer = LogWriter(sys.argv[2])
Ejemplo n.º 14
0
def main(args):
    parser = OptionParser(usage='%prog [ options ... ] URI [ FILES ]',
                          description='Analyze repository modifications',
                          version=VERSION)
    parser.disable_interspersed_args()
    parser.add_option('-g',
                      '--debug',
                      dest='debug',
                      action="store_true",
                      default=False,
                      help="Run in debug mode")
    parser.add_option('-c',
                      '--config-file',
                      dest='config_file',
                      metavar='FILE',
                      help="Use a custom configuration file")
    parser.add_option('-r',
                      '--revision',
                      dest='revision',
                      metavar='REV',
                      help='Revision to analyze (HEAD)')
    parser.add_option('-f',
                      '--fast',
                      dest='fast',
                      action="store_true",
                      default=False,
                      help="Run faster but moves and copies are not detected")
    parser.add_option('-o',
                      '--output',
                      dest='output',
                      default='text',
                      help='Output type [text|db|xml|csv] (%default)')
    add_outputs_options(parser)

    # Save default values and pass an emtpy Values object to
    # parser_args, so that default values are not set. We need it
    # to know whether a value has been provided by the user or not
    # After parsing the command line we complete the config options
    # with the default values for the options that have not been set
    # by the parser or by a config file
    defaults = parser.get_default_values()
    options, args = parser.parse_args(args, values=Values())

    try:
        config = Config(options.config_file)
    except AttributeError:
        config = Config()

    config.update(options.__dict__)
    config.add(defaults.__dict__)

    if not args:
        parser.error("missing required repository URI")
        return 1

    parser.destroy()

    if config.debug:
        import repositoryhandler.backends
        repositoryhandler.backends.DEBUG = True

    uri = args[0]
    files = args[1:]
    files_from_stdin = (files and files[0] == '-')

    # Create repository
    path = uri_to_filename(uri)
    if path is not None:
        try:
            repo = create_repository_from_path(path)
        except RepositoryUnknownError:
            printerr(
                "Path %s doesn't seem to point to a repository supported by guilty",
                (path, ))
            return 1
        except Exception, e:
            printerr("Unknown error creating repository for path %s (%s)",
                     (path, str(e)))
            return 1
        uri = repo.get_uri_for_path(path)
Ejemplo n.º 15
0
def main (args):
    parser = OptionParser (usage='%prog [ options ... ] URI [ FILES ]',
                           description='Analyze repository modifications',
                           version=VERSION)
    parser.disable_interspersed_args()
    parser.add_option ('-g', '--debug', dest='debug',
                       action="store_true", default=False,
                       help="Run in debug mode")
    parser.add_option ('-c', '--config-file', dest='config_file',
                       metavar='FILE',
                       help="Use a custom configuration file")
    parser.add_option ('-r', '--revision', dest='revision',
                       metavar='REV',
                       help='Revision to analyze (HEAD)')
    parser.add_option ('-f', '--fast', dest='fast',
                       action="store_true", default=False,
                       help="Run faster but moves and copies are not detected")
    parser.add_option ('-o', '--output', dest='output',
                       default = 'text',
                       help='Output type [text|db|xml|csv] (%default)')
    add_outputs_options (parser)

    # Save default values and pass an emtpy Values object to
    # parser_args, so that default values are not set. We need it
    # to know whether a value has been provided by the user or not
    # After parsing the command line we complete the config options
    # with the default values for the options that have not been set
    # by the parser or by a config file
    defaults = parser.get_default_values ()
    options, args = parser.parse_args (args, values = Values())

    try:
        config = Config (options.config_file)
    except AttributeError:
        config = Config ()

    config.update (options.__dict__)
    config.add (defaults.__dict__)

    if not args:
        parser.error("missing required repository URI")
        return 1

    parser.destroy ()

    if config.debug:
        import repositoryhandler.backends
        repositoryhandler.backends.DEBUG = True

    uri = args[0]
    files = args[1:]
    files_from_stdin = (files and files[0] == '-')

    # Create repository
    path = uri_to_filename (uri)
    if path is not None:
        try:
            repo = create_repository_from_path (path)
        except RepositoryUnknownError:
            printerr ("Path %s doesn't seem to point to a repository supported by guilty", (path,))
            return 1
        except Exception, e:
            printerr ("Unknown error creating repository for path %s (%s)", (path, str (e)))
            return 1
        uri = repo.get_uri_for_path (path)
Ejemplo n.º 16
0
            return

        match = self.line_pattern.match (line)
        if not match:
            return

        bl = BlameLine ()
        bl.line = int (match.group (5))
        bl.rev = match.group (1)
        bl.author = match.group (3).strip ()
        bl.date = datetime.datetime (* (time.gmtime (int (match.group (4)))[0:6]))
        filename = match.group (2)
        if filename != self.filename:
            bl.file = filename

        self.out.line (bl)

register_parser ('git', GitParser)

if __name__ == '__main__':
    import sys
    from repositoryhandler.backends import create_repository_from_path
    from Guilty.Parser import test_parser

    repo = create_repository_from_path (sys.argv[1])
    filename = sys.argv[1]
    p = GitParser (filename)
    test_parser (p, repo)


Ejemplo n.º 17
0
    def _parse_line(self, line):
        if not line:
            return

        match = self.line_pattern.match(line)
        if not match:
            return

        bl = BlameLine()
        bl.line = self.n_line
        bl.rev = match.group(1)
        bl.author = match.group(2)
        bl.date = datetime.datetime(int(match.group(3)), int(match.group(4)),
                                    int(match.group(5)), int(match.group(6)),
                                    int(match.group(7)), int(match.group(8)))

        self.out.line(bl)


register_parser('svn', SVNParser)

if __name__ == '__main__':
    import sys
    from repositoryhandler.backends import create_repository_from_path
    from Guilty.Parser import test_parser

    repo = create_repository_from_path(sys.argv[1])
    filename = sys.argv[1]
    p = SVNParser(filename)
    test_parser(p, repo)