hilfer 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,58 @@
1
+ require 'svn/client'
2
+ =begin
3
+ This does a simple svn status (not going to the server)
4
+ and returns colouring for various statuses
5
+ =end
6
+ module SvnColours
7
+ def status_colours
8
+ @status_colours ||= {
9
+ Svn::Wc::STATUS_NONE => '#000',
10
+ Svn::Wc::STATUS_NORMAL => '#000',
11
+ Svn::Wc::STATUS_ADDED => '#080', # green
12
+ Svn::Wc::STATUS_MISSING => '#f00',
13
+ Svn::Wc::STATUS_INCOMPLETE => '#f00',
14
+ Svn::Wc::STATUS_DELETED => '#000',
15
+ Svn::Wc::STATUS_REPLACED => '#000',
16
+ Svn::Wc::STATUS_MODIFIED => '#008',
17
+ Svn::Wc::STATUS_MERGED => '#000',
18
+ Svn::Wc::STATUS_CONFLICTED => '#f00',
19
+ Svn::Wc::STATUS_OBSTRUCTED => '#f00',
20
+ Svn::Wc::STATUS_IGNORED => '#880',
21
+ Svn::Wc::STATUS_EXTERNAL => '#000',
22
+ Svn::Wc::STATUS_UNVERSIONED => '#808',
23
+ }
24
+ end
25
+
26
+ def context
27
+ if @context.nil?
28
+ @context = Svn::Client::Context.new
29
+ @context.add_simple_provider{|x| }
30
+ end
31
+ @context
32
+ end
33
+
34
+ def compute_colours( dir_path )
35
+ path_colours = {}
36
+ begin
37
+ # args are
38
+ # path
39
+ # rev=nil ed 'HEAD'
40
+ # recurse=true
41
+ # get_all=false
42
+ # update=true
43
+ # no_ignore=false
44
+ # ignore_externals=false
45
+
46
+ # don't go to the server
47
+ # status is an instance of Svn_wc_status2_t
48
+ context.status( dir_path, nil, false, true, false ) do
49
+ |path,status|
50
+ path_colours[path] = status_colours[status.text_status]
51
+ end
52
+ rescue
53
+ # mainly to catch exceptions from non-svn directories
54
+ end
55
+ path_colours
56
+ end
57
+
58
+ end