Class: BuildTool::VCS::SVN

Inherits:
Base show all
Defined in:
lib/kde-build/vcs/svn.rb

Overview

Implementation for the subversion version control system (subversion.tigris.org).

Instance Attribute Summary

Attributes inherited from Base

#configuration, #path, #repository

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#info

Constructor Details

#initialize(repository, path = nil) ⇒ SVN

Returns a new instance of SVN.



21
22
23
# File 'lib/kde-build/vcs/svn.rb', line 21

def initialize( repository, path = nil )
    super
end

Class Method Details

.configObject



37
38
39
# File 'lib/kde-build/vcs/svn.rb', line 37

def self.config
    SvnConfiguration
end

.svn(command, wd, &block) ⇒ Object



29
30
31
# File 'lib/kde-build/vcs/svn.rb', line 29

def self.svn( command, wd, &block )
    self.execute( "svn #{command}", wd, &block )
end

Instance Method Details

#checkedout?Boolean

Check if the local checkout exists.

calls VCS::Base::checkedout? and checks if there is a ‘.git’ directory at path

Returns:

  • (Boolean)


45
46
47
48
49
50
51
52
# File 'lib/kde-build/vcs/svn.rb', line 45

def checkedout?
    return false if !super
    if !File.exists? "#{path}/.svn"
        $log.debug("Checkout path #{path} is not a svn repo")
        return false
    end
    return true
end

#fetchObject

Fetch from repository

Initializes the local clone if it does not exist.



71
72
73
74
75
76
# File 'lib/kde-build/vcs/svn.rb', line 71

def fetch()
    if !checkedout?
       init
    end
    return true
end

#initObject

Initialize the local repository



80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/kde-build/vcs/svn.rb', line 80

def init
    # Check if path exists
    if File.exists? path
        raise SvnError, "Failed to create repository at '#{path}': Path exists"
    end

    # Create the directories parent dir.
    FileUtils.mkdir_p( File.dirname( path ) ) if !$noop

    # Init the repository
    if !svn "checkout --depth=infinity #{repository}", File.dirname(path)
        raise SvnError, "Error during 'svn checkout #{repository}'`: #{$?}"
    end
end

#last_changed_revObject

Returns the last changed revision on the remote repository. Return 0 if the last changed revision could not be determined.



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/kde-build/vcs/svn.rb', line 56

def last_changed_rev
    info = Hash.new
    return 777777 if $noop
    svn( "info #{repository}", nil ) {
        |line|
        key, value = line.chomp.split( ':', 2 )
        info[key] = value
    }
    version = info["Last Changed Rev"];
    return version
end

#nameObject



25
26
27
# File 'lib/kde-build/vcs/svn.rb', line 25

def name
    "Subversion"
end

#rebaseObject



95
96
97
# File 'lib/kde-build/vcs/svn.rb', line 95

def rebase
    return svn "update"
end

#svn(command, wd = path, &block) ⇒ Object



33
34
35
# File 'lib/kde-build/vcs/svn.rb', line 33

def svn( command, wd = path, &block )
    self.class.svn command, wd, &block
end