Class: VimMate::Subversion

Inherits:
Object
  • Object
show all
Includes:
NiceSingleton
Defined in:
lib/vim_mate/plugins/subversion/lib/subversion.rb

Overview

This class helps the integration of the Subversion version control system

Constant Summary collapse

UNKNOWN =
-1
NONE =
1
UNVERSIONED =
2
NORMAL =
3
ADDED =
4
MISSING =
5
DELETED =
6
REPLACED =
7
MODIFIED =
8
MERGED =
9
CONFLICTED =
10
IGNORED =
11
OBSTRUCTED =
12
EXTERNAL =
13
INCOMPLETE =
14
STATUS_TEXT =
{
  UNKNOWN => "",
  NONE => "None",
  UNVERSIONED => "Unversioned",
  NORMAL => "Normal",
  ADDED => "Added",
  MISSING => "Missing",
  DELETED => "Deleted",
  REPLACED => "Replaced",
  MODIFIED => "Modified",
  MERGED => "Merged",
  CONFLICTED => "Conflicted",
  IGNORED => "Ignored",
  OBSTRUCTED => "Obstructed",
  EXTERNAL => "External",
  INCOMPLETE => "Incomplete",
}.freeze

Instance Method Summary collapse

Methods included from NiceSingleton

included

Constructor Details

#initializeSubversion

Create the Subversion class. Cannot be called directly



77
78
# File 'lib/vim_mate/plugins/subversion/lib/subversion.rb', line 77

def initialize
end

Instance Method Details

#add(path) ⇒ Object

Add the specified file (full path) to Subversion



100
101
102
103
104
105
106
107
# File 'lib/vim_mate/plugins/subversion/lib/subversion.rb', line 100

def add(path)
  cleanup(path)
  new_client.add(path)
rescue
  false
else
  true
end

#cleanup(path) ⇒ Object

Cleanup the subversion path when something is locked



141
142
143
144
145
146
147
# File 'lib/vim_mate/plugins/subversion/lib/subversion.rb', line 141

def cleanup(path)
  new_client.cleanup(File.directory?(path) ? path : File.dirname(path))
rescue
  false
else
  true
end

#move(path, new_path) ⇒ Object

Move the specified file (full path) to a new file name



131
132
133
134
135
136
137
138
# File 'lib/vim_mate/plugins/subversion/lib/subversion.rb', line 131

def move(path, new_path)
  cleanup(path)
  new_client.move(path, new_path)
rescue
  false
else
  true
end

#remove(path) ⇒ Object

Remove the specified file (full path) from Subversion’s control



110
111
112
113
114
115
116
117
# File 'lib/vim_mate/plugins/subversion/lib/subversion.rb', line 110

def remove(path)
  cleanup(path)
  new_client.remove(path)
rescue
  false
else
  true
end

#revert(path) ⇒ Object

Revert the specified file (full path) to what it was before the local modifications



121
122
123
124
125
126
127
128
# File 'lib/vim_mate/plugins/subversion/lib/subversion.rb', line 121

def revert(path)
  cleanup(path)
  new_client.revert(path)
rescue
  false
else
  true
end

#status(path) ⇒ Object

Get the status of the specified file. The file must be a full path.



81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/vim_mate/plugins/subversion/lib/subversion.rb', line 81

def status(path)
  ret_status = UNKNOWN
  begin
  # Arguments: File, Revision, Recursive, Any files, Update
  new_client.status(path, "HEAD", true, true, false) do |path, status|
    ret_status = status.text_status if status.text_status > ret_status
  end
  rescue Svn::Error::WC_NOT_DIRECTORY
  rescue Svn::Error::WC_NOT_LOCKED
  end
  ret_status
end

#status_text(path) ⇒ Object

Get the text that represents the status of the file



95
96
97
# File 'lib/vim_mate/plugins/subversion/lib/subversion.rb', line 95

def status_text(path)
  STATUS_TEXT[status(path)]
end