svnx 1.0.1 → 2.0.6
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.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.glarkrc +1 -0
- data/Features.txt +7 -0
- data/Gemfile +4 -0
- data/History.txt +4 -0
- data/LICENSE +20 -0
- data/Manifest.txt +0 -0
- data/README.md +12 -0
- data/Rakefile +12 -0
- data/lib/svnx/base/action.rb +57 -52
- data/lib/svnx/base/cmdline.rb +58 -0
- data/lib/svnx/base/command.rb +49 -41
- data/lib/svnx/base/entries.rb +46 -45
- data/lib/svnx/base/entry.rb +51 -38
- data/lib/svnx/base/env.rb +26 -0
- data/lib/svnx/base/options.rb +25 -0
- data/lib/svnx/cat/command.rb +3 -64
- data/lib/svnx/cat/options.rb +28 -0
- data/lib/svnx/commit/command.rb +9 -0
- data/lib/svnx/commit/options.rb +29 -0
- data/lib/svnx/diff/command.rb +17 -0
- data/lib/svnx/diff/elements.rb +84 -0
- data/lib/svnx/diff/options.rb +35 -0
- data/lib/svnx/diff/parser.rb +105 -0
- data/lib/svnx/info/command.rb +4 -47
- data/lib/svnx/info/entries.rb +6 -8
- data/lib/svnx/info/entry.rb +21 -23
- data/lib/svnx/info/options.rb +28 -0
- data/lib/svnx/io/directory.rb +9 -5
- data/lib/svnx/io/element.rb +93 -95
- data/lib/svnx/log/command.rb +7 -3
- data/lib/svnx/log/entries.rb +17 -14
- data/lib/svnx/log/entry.rb +61 -49
- data/lib/svnx/log/options.rb +31 -0
- data/lib/svnx/merge/command.rb +9 -0
- data/lib/svnx/merge/options.rb +34 -0
- data/lib/svnx/project.rb +74 -0
- data/lib/svnx/propget/command.rb +9 -0
- data/lib/svnx/propget/entries.rb +15 -0
- data/lib/svnx/propget/entry.rb +23 -0
- data/lib/svnx/propget/options.rb +31 -0
- data/lib/svnx/propset/command.rb +9 -0
- data/lib/svnx/propset/options.rb +33 -0
- data/lib/svnx/revision/argfactory.rb +2 -2
- data/lib/svnx/revision/argument.rb +7 -3
- data/lib/svnx/revision/date.rb +27 -0
- data/lib/svnx/revision/error.rb +2 -2
- data/lib/svnx/revision/range.rb +5 -2
- data/lib/svnx/status/command.rb +4 -42
- data/lib/svnx/status/entries.rb +11 -12
- data/lib/svnx/status/entry.rb +43 -41
- data/lib/svnx/status/options.rb +28 -0
- data/lib/svnx/update/command.rb +9 -0
- data/lib/svnx/update/options.rb +25 -0
- data/lib/svnx/util/dateutil.rb +35 -0
- data/lib/svnx/util/objutil.rb +14 -0
- data/lib/{svnx.rb → svnx/version.rb} +2 -2
- data/lib/system/command/arg.rb +6 -5
- data/lib/system/command/cachefile.rb +29 -21
- data/lib/system/command/caching.rb +12 -25
- data/lib/system/command/line.rb +41 -30
- data/svnx.gemspec +34 -0
- metadata +85 -61
- data/lib/svnx/base/args.rb +0 -24
- data/lib/svnx/log/args.rb +0 -57
- data/lib/svnx/log/exec.rb +0 -27
- data/lib/svnx/log/line.rb +0 -42
- data/test/integration/info/info_test.rb +0 -21
- data/test/integration/log/log_test.rb +0 -74
- data/test/integration/status/status_test.rb +0 -35
- data/test/integration/svnx/io/element_test.rb +0 -235
- data/test/unit/svnx/base/action_test.rb +0 -49
- data/test/unit/svnx/cat/command_test.rb +0 -55
- data/test/unit/svnx/info/entries_test.rb +0 -22
- data/test/unit/svnx/log/args_test.rb +0 -15
- data/test/unit/svnx/log/entries_test.rb +0 -87
- data/test/unit/svnx/log/entry_test.rb +0 -15
- data/test/unit/svnx/log/exec_test.rb +0 -15
- data/test/unit/svnx/log/line_test.rb +0 -14
- data/test/unit/svnx/revision/argfactory_test.rb +0 -50
- data/test/unit/svnx/revision/argument_test.rb +0 -167
- data/test/unit/svnx/revision/range_test.rb +0 -48
- data/test/unit/svnx/status/entries_test.rb +0 -20
- data/test/unit/system/command/cachefile_test.rb +0 -52
- data/test/unit/system/command/caching_test.rb +0 -92
- data/test/unit/system/command/line_test.rb +0 -63
@@ -6,11 +6,11 @@ require 'svnx/revision/error'
|
|
6
6
|
require 'logue/loggable'
|
7
7
|
require 'svnx/revision/argfactory'
|
8
8
|
|
9
|
-
module
|
9
|
+
module Svnx; module Revision; end; end
|
10
10
|
|
11
11
|
# We represent what svn calls a revision (-r134:{2010-1-1}) as a Range,
|
12
12
|
# consisting of a from and to (optional) Argument.
|
13
|
-
module
|
13
|
+
module Svnx::Revision
|
14
14
|
RELATIVE_REVISION_RE = Regexp.new '^([\+\-])(\d+)$'
|
15
15
|
|
16
16
|
# Returns the Nth revision from the given logging output.
|
@@ -42,7 +42,11 @@ module SVNx::Revision
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def <=> other
|
45
|
-
|
45
|
+
if other.kind_of? Argument
|
46
|
+
@value <=> other.value
|
47
|
+
else
|
48
|
+
@value <=> other
|
49
|
+
end
|
46
50
|
end
|
47
51
|
end
|
48
52
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'pathname'
|
5
|
+
|
6
|
+
module Svnx
|
7
|
+
module Revision
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class Svnx::Revision::DateToDate
|
12
|
+
attr_reader :from
|
13
|
+
attr_reader :to
|
14
|
+
|
15
|
+
def initialize from, to
|
16
|
+
@from = from
|
17
|
+
@to = to
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_svn_str
|
21
|
+
[ @from, @to ].collect { |dt| "{" + to_svn_date(dt) + "}" }.join(":")
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_svn_date date
|
25
|
+
date.strftime "%Y-%m-%d"
|
26
|
+
end
|
27
|
+
end
|
data/lib/svnx/revision/error.rb
CHANGED
data/lib/svnx/revision/range.rb
CHANGED
@@ -5,9 +5,12 @@ require 'svnx/log/entries'
|
|
5
5
|
require 'svnx/revision/argument'
|
6
6
|
require 'logue/loggable'
|
7
7
|
|
8
|
-
module
|
8
|
+
module Svnx
|
9
|
+
module Revision
|
10
|
+
end
|
11
|
+
end
|
9
12
|
|
10
|
-
module
|
13
|
+
module Svnx::Revision
|
11
14
|
# this is of the form: -r123:456
|
12
15
|
class Range
|
13
16
|
include Logue::Loggable
|
data/lib/svnx/status/command.rb
CHANGED
@@ -2,47 +2,9 @@
|
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
4
|
require 'svnx/base/command'
|
5
|
-
require 'svnx/
|
5
|
+
require 'svnx/status/options'
|
6
|
+
require 'svnx/status/entries'
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
def initialize args
|
10
|
-
super "status", args.to_a
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class StatusCommandArgs < CommandArgs
|
15
|
-
def to_a
|
16
|
-
[ @path ].compact
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
class StatusCommand < Command
|
21
|
-
def command_line
|
22
|
-
StatusCommandLine.new @args
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
class StatusExec
|
27
|
-
attr_reader :entries
|
28
|
-
|
29
|
-
def initialize args
|
30
|
-
path = args[:path]
|
31
|
-
rootpath = nil
|
32
|
-
|
33
|
-
while true
|
34
|
-
begin
|
35
|
-
inf = InfoExec.new(path: path).entry
|
36
|
-
rootpath = inf.wc_root
|
37
|
-
break
|
38
|
-
rescue
|
39
|
-
path = Pathname.new(path).dirname.to_s
|
40
|
-
break if path == '/'
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
cmd = StatusCommand.new StatusCommandArgs.new(args)
|
45
|
-
@entries = SVNx::Status::Entries.new(xmllines: cmd.execute, rootpath: rootpath)
|
46
|
-
end
|
47
|
-
end
|
8
|
+
class Svnx::Status::Command < Svnx::Base::EntriesCommand
|
9
|
+
noncaching
|
48
10
|
end
|
data/lib/svnx/status/entries.rb
CHANGED
@@ -4,19 +4,18 @@
|
|
4
4
|
require 'svnx/status/entry'
|
5
5
|
require 'svnx/base/entries'
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
7
|
+
class Svnx::Status::Entries < Svnx::Base::Entries
|
8
|
+
def initialize args = Hash.new
|
9
|
+
@rootpath = args[:rootpath]
|
10
|
+
super
|
11
|
+
end
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
def get_elements doc
|
14
|
+
# status/target
|
15
|
+
doc.elements['status'].elements['target'].elements
|
16
|
+
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
end
|
18
|
+
def create_entry xmlelement
|
19
|
+
Svnx::Status::Entry.new xmlelement: xmlelement, rootpath: @rootpath
|
21
20
|
end
|
22
21
|
end
|
data/lib/svnx/status/entry.rb
CHANGED
@@ -4,52 +4,54 @@
|
|
4
4
|
require 'svnx/base/entry'
|
5
5
|
require 'svnx/base/action'
|
6
6
|
|
7
|
-
module
|
7
|
+
module Svnx
|
8
|
+
module Status
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class Svnx::Status::Entry < Svnx::Base::Entry
|
13
|
+
include Comparable, Logue::Loggable
|
14
|
+
|
15
|
+
attr_reader :status
|
16
|
+
attr_reader :path
|
17
|
+
attr_reader :status_revision
|
18
|
+
attr_reader :action
|
19
|
+
attr_reader :commit_revision
|
20
|
+
attr_reader :name
|
21
|
+
|
22
|
+
def initialize xmlelement: nil, rootpath: nil
|
23
|
+
@rootpath = rootpath
|
24
|
+
super xmlelement: xmlelement
|
25
|
+
# @status is an Svnx::Action
|
26
|
+
@action = @status
|
27
|
+
end
|
28
|
+
|
29
|
+
def set_from_element elmt
|
30
|
+
set_attr_var elmt, 'path'
|
8
31
|
|
9
|
-
|
10
|
-
|
11
|
-
|
32
|
+
wcstatus = elmt.elements['wc-status']
|
33
|
+
@status = Svnx::Action.new(wcstatus.attributes['item'])
|
34
|
+
@status_revision = wcstatus.attributes['revision']
|
12
35
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
attr_reader :action
|
17
|
-
attr_reader :commit_revision
|
18
|
-
attr_reader :name
|
19
|
-
|
20
|
-
def initialize args
|
21
|
-
@rootpath = args[:rootpath]
|
22
|
-
super
|
23
|
-
@action = SVNx::Action.new @status
|
24
|
-
end
|
36
|
+
commit = wcstatus.elements['commit']
|
37
|
+
@commit_revision = commit && commit.attributes['revision']
|
38
|
+
@name = @path.dup
|
25
39
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
wcstatus = elmt.elements['wc-status']
|
30
|
-
@status = SVNx::Action.new(wcstatus.attributes['item'])
|
31
|
-
@status_revision = wcstatus.attributes['revision']
|
32
|
-
|
33
|
-
commit = wcstatus.elements['commit']
|
34
|
-
@commit_revision = commit && commit.attributes['revision']
|
35
|
-
@name = @path.dup
|
36
|
-
|
37
|
-
info "@name: #{@name}"
|
38
|
-
info "@path: #{@path}"
|
39
|
-
info "@rootpath: #{@rootpath}"
|
40
|
-
|
41
|
-
if @rootpath
|
42
|
-
# name is prefixed with directory unless '.' is used as the argument
|
43
|
-
@name.sub! Regexp.new('^' + @rootpath), ''
|
44
|
-
end
|
45
|
-
end
|
40
|
+
info "@name: #{@name}"
|
41
|
+
info "@path: #{@path}"
|
42
|
+
info "@rootpath: #{@rootpath}"
|
46
43
|
|
47
|
-
|
48
|
-
|
44
|
+
if @rootpath
|
45
|
+
# name is prefixed with directory unless '.' is used as the argument
|
46
|
+
@name.sub! Regexp.new('^' + @rootpath), ''
|
49
47
|
end
|
48
|
+
end
|
50
49
|
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
def to_s
|
51
|
+
"path: #{@path}; status: #{@status}"
|
52
|
+
end
|
53
|
+
|
54
|
+
def <=> other
|
55
|
+
path <=> other.path
|
54
56
|
end
|
55
57
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'svnx/util/objutil'
|
5
|
+
require 'svnx/base/options'
|
6
|
+
|
7
|
+
module Svnx
|
8
|
+
module Status
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class Svnx::Status::Options < Svnx::Base::Options
|
13
|
+
attr_reader :revision
|
14
|
+
attr_reader :url
|
15
|
+
attr_reader :paths
|
16
|
+
|
17
|
+
def initialize args
|
18
|
+
assign args, :revision, :url, :paths
|
19
|
+
end
|
20
|
+
|
21
|
+
def options_to_args
|
22
|
+
Array.new.tap do |optargs|
|
23
|
+
optargs << [ :revision, [ "-r", @revision ] ]
|
24
|
+
optargs << [ :url, @url ]
|
25
|
+
optargs << [ :paths, @paths ]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'svnx/base/options'
|
5
|
+
|
6
|
+
module Svnx
|
7
|
+
module Update
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class Svnx::Update::Options < Svnx::Base::Options
|
12
|
+
attr_reader :revision
|
13
|
+
attr_reader :paths
|
14
|
+
|
15
|
+
def initialize args = Hash.new
|
16
|
+
assign args, :revision, :paths
|
17
|
+
end
|
18
|
+
|
19
|
+
def options_to_args
|
20
|
+
Array.new.tap do |optargs|
|
21
|
+
optargs << [ :revision, [ "-r", revision ] ]
|
22
|
+
optargs << [ :paths, paths ]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'time'
|
5
|
+
|
6
|
+
class DateUtil
|
7
|
+
class << self
|
8
|
+
def relative_full datetime, reltime = Time.now
|
9
|
+
secs = (reltime - datetime).to_i
|
10
|
+
if ago = to_time_units(secs)
|
11
|
+
ago + " ago (" + fmt_mmdd_hhmm(datetime) + ")"
|
12
|
+
else
|
13
|
+
datetime.strftime "%Y/%m/%d %H:%M"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_time_units seconds
|
18
|
+
secs = seconds.to_i
|
19
|
+
|
20
|
+
if secs < 120
|
21
|
+
"#{secs} seconds"
|
22
|
+
elsif (min = secs / 60) < 120
|
23
|
+
"#{min} minutes"
|
24
|
+
elsif (hour = min / 60) < 72
|
25
|
+
"#{hour} hours"
|
26
|
+
elsif (day = hour / 24) < 7
|
27
|
+
"#{day} days"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def fmt_mmdd_hhmm date
|
32
|
+
date.strftime "%m/%d %H:%M"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
module Svnx
|
5
|
+
end
|
6
|
+
|
7
|
+
module Svnx::ObjectUtil
|
8
|
+
# shortcut for "@var = args[:var]", for multiple variable names, which are symbols.
|
9
|
+
def assign args, *symbols
|
10
|
+
symbols.each do |symbol|
|
11
|
+
instance_variable_set "@" + symbol.to_s, args[symbol]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/system/command/arg.rb
CHANGED
@@ -2,11 +2,12 @@
|
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
4
|
module System
|
5
|
-
|
6
|
-
|
5
|
+
end
|
6
|
+
|
7
|
+
class System::Argument < String
|
8
|
+
# just a string, but quotes itself
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
end
|
10
|
+
def to_s
|
11
|
+
'"' + super + '"'
|
11
12
|
end
|
12
13
|
end
|
@@ -6,45 +6,53 @@ require 'zlib'
|
|
6
6
|
require 'logue/loggable'
|
7
7
|
|
8
8
|
module System
|
9
|
-
class
|
9
|
+
class GzipPathname < Pathname
|
10
10
|
include Logue::Loggable
|
11
|
-
|
12
|
-
attr_reader :output
|
13
11
|
|
14
|
-
def
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
def save_file
|
21
|
-
@pn.parent.mkpath unless @pn.parent.exist?
|
22
|
-
@pn.unlink if @pn.exist?
|
23
|
-
Zlib::GzipWriter.open(@pn.to_s) do |gz|
|
24
|
-
gz.puts @output
|
12
|
+
def save_file content
|
13
|
+
parent.mkpath unless parent.exist?
|
14
|
+
unlink if exist?
|
15
|
+
Zlib::GzipWriter.open(to_s) do |gz|
|
16
|
+
gz.puts content
|
25
17
|
end
|
26
18
|
end
|
27
19
|
|
28
20
|
def read_file
|
29
|
-
|
30
|
-
|
21
|
+
Array.new.tap do |content|
|
22
|
+
Zlib::GzipReader.open(to_s) do |gz|
|
23
|
+
content.concat gz.readlines
|
24
|
+
end
|
31
25
|
end
|
32
|
-
@output
|
33
26
|
end
|
27
|
+
end
|
34
28
|
|
29
|
+
class CacheFile
|
30
|
+
include Logue::Loggable
|
31
|
+
|
32
|
+
attr_reader :output
|
33
|
+
attr_reader :pathname
|
34
|
+
|
35
|
+
def initialize cache_dir, args
|
36
|
+
@args = args
|
37
|
+
basename = args.join('-').gsub('/', '_slash_') + '.gz'
|
38
|
+
fullname = Pathname(cache_dir) + basename
|
39
|
+
@pathname = GzipPathname.new fullname
|
40
|
+
@output = nil
|
41
|
+
end
|
42
|
+
|
35
43
|
def readlines
|
36
|
-
if @
|
37
|
-
read_file
|
44
|
+
if @pathname.exist?
|
45
|
+
@output = @pathname.read_file
|
38
46
|
else
|
39
47
|
cl = CommandLine.new @args
|
40
48
|
@output = cl.execute
|
41
|
-
save_file
|
49
|
+
@pathname.save_file @output
|
42
50
|
@output
|
43
51
|
end
|
44
52
|
end
|
45
53
|
|
46
54
|
def to_s
|
47
|
-
@
|
55
|
+
@pathname.to_s
|
48
56
|
end
|
49
57
|
end
|
50
58
|
end
|