svnx 2.8.1 → 2.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ee2f457c3e6d933420b413b096eedae95a3decbc
4
- data.tar.gz: bf37347ef5a34295118aad381c99989654f691b8
3
+ metadata.gz: d1e8e4a0e4c8becac18da9d39aaeb0f9db52e683
4
+ data.tar.gz: 247d8f5ba0974ba965066ef6058f073c53020757
5
5
  SHA512:
6
- metadata.gz: 7bb4a5fb1970c4f169b8127980535f15ce625fc197b750cf6b630802c43e3cc8976605f44e56bd645bd0d2ed6c0a9cabcc6c4903fe73f3037d541c5cc54ef2fc
7
- data.tar.gz: 5e5460362594822a2e48a1b59ab1b72523c1de289348568a9b80a42071fa41c59cc100a0416375a5ea9a1f14a968db1930f9fd9a34cdeab801f0ed3a411f1930
6
+ metadata.gz: 79e7e4bfad279b50d113d905cfba6ce0b8faffa1bddf7bfd11b67ac7dd8c841934369de3e2846dbd0ea7e4e31eae128770579e0de5a043cf25790c8f49e560c9
7
+ data.tar.gz: d4ad3cf461a5ff4d26635e452b3c056ad8edbacbcdf652a6a703d115b8025cb8cda70d90b19acd786ff76903ef3b59df84153ef8111a637f32a734990c4028ff
@@ -1,19 +1,11 @@
1
1
  #!/usr/bin/ruby -w
2
2
  # -*- ruby -*-
3
3
 
4
- require 'logue/loggable'
5
4
  require 'command/cacheable/command'
6
5
  require 'svnx/base/env'
7
6
 
8
- module Svnx
9
- module Base
10
- end
11
- end
12
-
13
7
  module Svnx::Base
14
8
  class CommandLine
15
- include Logue::Loggable
16
-
17
9
  attr_reader :output
18
10
  attr_reader :error
19
11
  attr_reader :status
@@ -25,12 +17,19 @@ module Svnx::Base
25
17
  @args = args
26
18
  end
27
19
 
20
+ def command
21
+ Array.new.tap do |a|
22
+ a << 'svn'
23
+ a << @subcommand
24
+ if @xml
25
+ a << '--xml'
26
+ end
27
+ a.concat @args
28
+ end
29
+ end
30
+
28
31
  def execute
29
- cmdargs = [ 'svn', @subcommand ]
30
- cmdargs << '--xml' if @xml
31
- cmdargs.concat @args
32
-
33
- cmdline = command_line cmdargs
32
+ cmdline = ::Command::Cacheable::Command.new command, caching: @caching, cachedir: Svnx::Env.instance.cache_dir
34
33
  cmdline.execute
35
34
 
36
35
  @output = cmdline.output
@@ -39,9 +38,5 @@ module Svnx::Base
39
38
 
40
39
  @output
41
40
  end
42
-
43
- def command_line cmdargs
44
- ::Command::Cacheable::Command.new cmdargs, caching: @caching, cachedir: Svnx::Env.instance.cache_dir
45
- end
46
41
  end
47
42
  end
@@ -3,7 +3,9 @@
3
3
 
4
4
  require 'logue/loggable'
5
5
  require 'svnx/util/classutil'
6
+ require 'svnx/base/options'
6
7
  require 'svnx/base/command_factory'
8
+ require 'svnx/base/command_line_factory'
7
9
 
8
10
  module Svnx::Base
9
11
  class Command
@@ -26,52 +28,40 @@ module Svnx::Base
26
28
  attr_reader :output
27
29
  attr_reader :error
28
30
  attr_reader :status
29
- attr_reader :options
30
31
 
31
- def initialize options, cmdlinecls: nil, optcls: nil, xml: false, caching: caching?
32
- debug "options: #{options}"
33
- factory = CommandFactory.new
32
+ def initialize options, cmdlinecls: nil, caching: caching?
33
+ cmdargs = read_options options
34
34
 
35
- params = factory.create self.class, cmdlinecls: cmdlinecls, optcls: optcls
36
-
37
- optcls ||= params.options
38
- debug "optcls: #{optcls}"
39
-
40
- @options = optcls.new options
41
- cmdargs = @options.to_args
42
- debug "cmdargs: #{cmdargs}"
43
-
44
- subcommand = params.subcommand
45
-
46
- cmdlinecls ||= params.cmdline
47
-
48
- debug "subcommand: #{subcommand}"
49
-
50
- @cmdline = cmdlinecls.new(subcommand: subcommand, xml: xml, caching: caching, args: cmdargs)
51
- debug "@cmdline: #{@cmdline}"
35
+ if cmdlinecls
36
+ @cmdline = cmdlinecls.new subcommand: subcommand, xml: xml?, caching: caching, args: cmdargs
37
+ else
38
+ cmdfactory = CommandFactory.new
39
+ clfactory = cmdfactory.command_line_factory
40
+ @cmdline = clfactory.create subcommand: subcommand, xml: xml?, caching: caching, args: cmdargs
41
+ end
52
42
 
53
43
  @output = @cmdline.execute
54
- debug "@output: #{@output}"
55
-
56
44
  @error = @cmdline.error
57
45
  @status = @cmdline.status
58
46
  end
59
- end
60
47
 
61
- class EntriesCommand < Command
62
- attr_reader :entries
63
-
64
- def initialize options, cmdlinecls: CommandLine, caching: caching?, xml: true, entries_class: nil
65
- super options, cmdlinecls: cmdlinecls, xml: xml, caching: caching
66
-
67
- if not @output.empty?
68
- entries_class ||= begin
69
- modl = ClassUtil.find_module self.class
70
- modl::Entries
71
- end
72
-
73
- @entries = entries_class.new @output
74
- end
48
+ def xml?
49
+ false
50
+ end
51
+
52
+ def read_options args
53
+ opts = options_class.new args
54
+ opts.to_args
55
+ end
56
+
57
+ def options_class
58
+ modl = ClassUtil.find_module self.class
59
+ modl::Options
60
+ end
61
+
62
+ def subcommand
63
+ melements = ClassUtil.module_elements self.class
64
+ melements[-1].downcase
75
65
  end
76
66
  end
77
67
  end
@@ -8,29 +8,33 @@ module Svnx::Base
8
8
  class CommandParams
9
9
  attr_reader :options
10
10
  attr_reader :subcommand
11
- attr_reader :cmdline
12
11
 
13
- def initialize options: nil, subcommand: nil, cmdline: nil
12
+ def initialize options: nil, subcommand: nil
14
13
  @options = options
15
14
  @subcommand = subcommand
16
- @cmdline = cmdline
17
15
  end
18
16
  end
19
17
 
20
18
  class CommandFactory
21
19
  include Logue::Loggable
20
+
21
+ def initialize cmdlinefactory = CommandLineFactory.new
22
+ @cmdlinefactory = cmdlinefactory
23
+ end
22
24
 
23
- def create cmdcls, cmdlinecls: nil, optcls: nil
25
+ def create cmdcls, cmdlinecls: nil
24
26
  melements = ClassUtil.module_elements cmdcls
25
27
 
26
- optcls ||= begin
27
- modl = ClassUtil.find_module cmdcls
28
- modl::Options
29
- end
30
-
31
- cmdlinecls ||= CommandLine
28
+ optcls = begin
29
+ modl = ClassUtil.find_module cmdcls
30
+ modl::Options
31
+ end
32
+
33
+ CommandParams.new options: optcls, subcommand: melements[-1].downcase
34
+ end
32
35
 
33
- CommandParams.new options: optcls, subcommand: melements[-1].downcase, cmdline: cmdlinecls
36
+ def command_line_factory
37
+ @cmdlinefactory
34
38
  end
35
39
  end
36
40
  end
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'logue/loggable'
5
+ require 'svnx/base/command_factory'
6
+
7
+ module Svnx::Base
8
+ class CommandLineFactory
9
+ include Logue::Loggable
10
+
11
+ def create params: nil, subcommand: nil, cls: nil, xml: nil, caching: nil, args: nil
12
+ cls ||= CommandLine
13
+ subcommand ||= params.subcommand
14
+ cls.new subcommand: subcommand, xml: xml, caching: caching, args: args
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'svnx/util/classutil'
5
+ require 'svnx/base/command'
6
+
7
+ module Svnx::Base
8
+ class EntriesCommand < Command
9
+ attr_reader :entries
10
+
11
+ def initialize options, cmdlinecls: nil, caching: caching?
12
+ super options, cmdlinecls: cmdlinecls, caching: caching
13
+
14
+ @entries = if not @output.empty?
15
+ entries_class = begin
16
+ modl = ClassUtil.find_module self.class
17
+ modl::Entries
18
+ end
19
+ entries_class.new @output
20
+ end
21
+ end
22
+
23
+ def xml?
24
+ true
25
+ end
26
+ end
27
+ end
@@ -1,8 +1,10 @@
1
1
  #!/usr/bin/ruby -w
2
2
  # -*- ruby -*-
3
3
 
4
- module Svnx
5
- module ObjectUtil
4
+ require 'svnx/util/strutil'
5
+
6
+ module Svnx::Base
7
+ module Fields
6
8
  # shortcut for "@var = args[:var]", for multiple variable names, which are symbols.
7
9
  def assign args, symbols = Array.new
8
10
  symbols.each do |symbol|
@@ -27,7 +29,8 @@ module Svnx
27
29
  end
28
30
 
29
31
  def fields
30
- self.class.instance_variable_get '@fields'
32
+ varname = '@fields'
33
+ self.class.instance_variable_defined?(varname) && self.class.instance_variable_get(varname)
31
34
  end
32
35
 
33
36
  module ClassMethods
@@ -39,17 +42,14 @@ module Svnx
39
42
  # Creates a reader method for each field, and assigns and validates them from an initialize
40
43
  # method, which is also created.
41
44
  def has_fields fields = Hash.new
42
- @fields ||= Hash.new
43
- @fields.merge! fields
44
-
45
- fields.keys.each do |field|
46
- attr_reader field
45
+ fields.each do |name, arg|
46
+ has_field name, arg
47
47
  end
48
48
  end
49
49
 
50
50
  def has_field name, arg
51
51
  @fields ||= Hash.new
52
- @fields.merge! name => arg
52
+ @fields[name] = arg
53
53
 
54
54
  attr_reader name
55
55
  end
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/ruby -w
2
2
  # -*- ruby -*-
3
3
 
4
- require 'svnx/util/objutil'
5
- require 'svnx/util/strutil'
4
+ require 'svnx/base/fields'
5
+ require 'svnx/base/tags'
6
6
 
7
7
  module Svnx
8
8
  module Base
@@ -11,65 +11,9 @@ end
11
11
 
12
12
  module Svnx::Base
13
13
  class Options
14
- include Svnx::ObjectUtil
15
-
16
- class << self
17
- def mapping field
18
- case field
19
- when :revision
20
- to_args "-r", field
21
- when :ignorewhitespace, :ignore_whitespace
22
- %w{ -x -bw -x --ignore-eol-style }
23
- when :paths
24
- nil
25
- when :path
26
- nil
27
- when :urls
28
- nil
29
- when :url
30
- nil
31
- when :file
32
- to_args "--file", field
33
- else
34
- raise "invalid field '#{field}'"
35
- end
36
- end
37
-
38
- def has(*fields)
39
- fields.each do |field|
40
- arg = mapping field
41
- has_field field, arg
42
- end
43
- end
44
-
45
- def to_args tagname, methname
46
- Proc.new { |obj| [ tagname, obj.send(methname) ] }
47
- end
48
-
49
- def to_tag sym, invoke = nil
50
- tag = "--" + StringUtil.with_dashes(sym)
51
- if invoke
52
- Proc.new { |x| [ tag, x.send(sym) ] }
53
- else
54
- tag
55
- end
56
- end
57
-
58
- def has_tag_field name
59
- has_field name, to_tag(name)
60
- end
61
-
62
- def has_tag_fields(*names)
63
- names.each do |name|
64
- has_tag_field name
65
- end
66
- end
67
-
68
- def has_tag_argument tagname, methname
69
- has_field methname, to_args(tagname, methname)
70
- end
71
- end
72
-
14
+ include Svnx::Base::Tags
15
+ include Svnx::Base::Fields
16
+
73
17
  def initialize args
74
18
  fkeys = fields.keys
75
19
 
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'svnx/util/strutil'
5
+
6
+ module Svnx::Base
7
+ module Tags
8
+ module ClassMethods
9
+ # common options/tags
10
+ def mapping field
11
+ case field
12
+ when :revision
13
+ to_args "-r", field
14
+ when :ignorewhitespace, :ignore_whitespace
15
+ %w{ -x -bw -x --ignore-eol-style }
16
+ when :paths
17
+ nil
18
+ when :path
19
+ nil
20
+ when :urls
21
+ nil
22
+ when :url
23
+ nil
24
+ when :file
25
+ to_args "--file", field
26
+ else
27
+ raise "invalid field '#{field}'"
28
+ end
29
+ end
30
+
31
+ def has(*fields)
32
+ fields.each do |field|
33
+ arg = mapping field
34
+ has_field field, arg
35
+ end
36
+ end
37
+
38
+ def to_args tagname, methname
39
+ Proc.new { |obj| [ tagname, obj.send(methname) ] }
40
+ end
41
+
42
+ def to_tag sym, invoke = nil
43
+ tag = "--" + Svnx::StringUtil.with_dashes(sym)
44
+ if invoke
45
+ Proc.new { |x| [ tag, x.send(sym) ] }
46
+ else
47
+ tag
48
+ end
49
+ end
50
+
51
+ def has_tag_field name
52
+ has_field name, to_tag(name)
53
+ end
54
+
55
+ def has_tag_fields(*names)
56
+ names.each do |name|
57
+ has_tag_field name
58
+ end
59
+ end
60
+
61
+ def has_tag_argument tagname, methname
62
+ has_field methname, to_args(tagname, methname)
63
+ end
64
+ end
65
+
66
+ extend ClassMethods
67
+
68
+ def self.included other
69
+ other.extend ClassMethods
70
+ end
71
+ end
72
+ end
@@ -2,7 +2,7 @@
2
2
  # -*- ruby -*-
3
3
 
4
4
  require 'svnx/blame/options'
5
- require 'svnx/base/command'
5
+ require 'svnx/base/entries_command'
6
6
 
7
7
  module Svnx::Blame
8
8
  class Command < Svnx::Base::EntriesCommand
@@ -10,7 +10,7 @@ module Svnx::Diff
10
10
  attr_reader :entries
11
11
 
12
12
  def initialize cmdopts, cmdlinecls: Svnx::Base::CommandLine
13
- super cmdopts, cmdlinecls: cmdlinecls, xml: false, caching: true
13
+ super cmdopts, cmdlinecls: cmdlinecls, caching: true
14
14
  if @output
15
15
  @entries = Svnx::Diff::Parser.new.parse_all_output @output.dup
16
16
  end
@@ -3,7 +3,7 @@
3
3
 
4
4
  require 'svnx/info/options'
5
5
  require 'svnx/info/entries'
6
- require 'svnx/base/command'
6
+ require 'svnx/base/entries_command'
7
7
 
8
8
  module Svnx::Info
9
9
  class Command < Svnx::Base::EntriesCommand
@@ -3,7 +3,7 @@
3
3
 
4
4
  require 'svnx/log/options'
5
5
  require 'svnx/log/entries'
6
- require 'svnx/base/command'
6
+ require 'svnx/base/entries_command'
7
7
 
8
8
  module Svnx::Log
9
9
  class Command < Svnx::Base::EntriesCommand
@@ -17,8 +17,7 @@ module Svnx::Log
17
17
  def initialize attr: nil, kind: nil, action: nil, name: nil, prop_mods: nil, text_mods: nil
18
18
  if attr
19
19
  @kind = attribute_value attr, 'kind'
20
- act = attribute_value attr, 'action'
21
- @action = Svnx::Action.new act
20
+ @action = Svnx::Action.new(attribute_value attr, 'action')
22
21
  @name = attr.text
23
22
  @prop_mods = "true" == attribute_value(attr, 'prop-mods')
24
23
  @text_mods = "true" == attribute_value(attr, 'text-mods')
@@ -35,6 +34,10 @@ module Svnx::Log
35
34
  @name
36
35
  end
37
36
 
37
+ def inspect
38
+ to_s
39
+ end
40
+
38
41
  def <=> other
39
42
  name <=> other.name
40
43
  end
@@ -65,3 +65,4 @@ class Svnx::Project
65
65
  where.to_s
66
66
  end
67
67
  end
68
+
@@ -2,7 +2,7 @@
2
2
  # -*- ruby -*-
3
3
 
4
4
  require 'svnx/propget/options'
5
- require 'svnx/base/command'
5
+ require 'svnx/base/entries_command'
6
6
 
7
7
  module Svnx::Propget
8
8
  class Command < Svnx::Base::EntriesCommand
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/ruby -w
2
2
  # -*- ruby -*-
3
3
 
4
- require 'svnx/base/command'
5
4
  require 'svnx/status/options'
6
5
  require 'svnx/status/entries'
6
+ require 'svnx/base/entries_command'
7
7
 
8
8
  module Svnx::Status
9
9
  class Command < Svnx::Base::EntriesCommand
@@ -11,9 +11,13 @@ module Svnx::Status
11
11
  super lines
12
12
  end
13
13
 
14
+ def xpath
15
+ '//status/target/entry'
16
+ end
17
+
14
18
  def get_elements doc
15
19
  if $use_nokogiri
16
- doc.xpath '//status/target/entry'
20
+ doc.xpath xpath
17
21
  else
18
22
  # status/target
19
23
  doc.elements['status'].elements['target'].elements
@@ -13,25 +13,22 @@ module Svnx::Status
13
13
  class Entry < Svnx::Base::Entry
14
14
  include Comparable
15
15
 
16
- attr_reader :status
17
- attr_reader :path
18
- attr_reader :status_revision
19
- attr_reader :action
20
16
  attr_reader :commit_revision
21
17
  attr_reader :name
18
+ attr_reader :path
19
+ attr_reader :status
20
+ attr_reader :status_revision
22
21
 
23
22
  def initialize xmlelement, rootpath: nil
24
23
  @rootpath = rootpath
25
24
  super xmlelement
26
- # @status is an Svnx::Action
27
- @action = @status
28
25
  end
29
26
 
30
27
  def set_from_element elmt
31
28
  set_attr_var elmt, 'path'
32
29
 
33
30
  wcstatus = elmt.at_xpath 'wc-status'
34
- @status = Svnx::Action.new(wcstatus['item'])
31
+ @status = Svnx::Action.new wcstatus['item']
35
32
  set_attr_var wcstatus, 'status_revision', 'revision'
36
33
 
37
34
  commit = wcstatus.at_xpath 'commit'
@@ -45,7 +42,7 @@ module Svnx::Status
45
42
  end
46
43
 
47
44
  def to_s
48
- "path: #{@path}; status: #{@status}"
45
+ " #{@path}: #{@status}"
49
46
  end
50
47
 
51
48
  def <=> other
@@ -1,14 +1,20 @@
1
1
  #!/usr/bin/ruby -w
2
2
  # -*- ruby -*-
3
3
 
4
- class StringUtil
5
- class << self
6
- def with_dashes x
7
- x.to_s.gsub "_", "-"
4
+ module Svnx
5
+ class StringUtil
6
+ class << self
7
+ def with_dashes x
8
+ x.to_s.gsub "_", "-"
9
+ end
10
+
11
+ def with_underscores x
12
+ x.to_s.gsub "-", "_"
13
+ end
8
14
  end
9
15
 
10
- def with_underscores x
11
- x.to_s.gsub "-", "_"
16
+ def to_boolean
17
+ downcase == "true"
12
18
  end
13
19
  end
14
20
  end
@@ -3,5 +3,5 @@
3
3
 
4
4
  module Svnx
5
5
  NAME = 'svnx'
6
- VERSION = '2.8.1'
6
+ VERSION = '2.9.0'
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svnx
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.1
4
+ version: 2.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Pace
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-22 00:00:00.000000000 Z
11
+ date: 2019-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: command-cacheable
@@ -145,10 +145,14 @@ files:
145
145
  - lib/svnx/base/cmdline.rb
146
146
  - lib/svnx/base/command.rb
147
147
  - lib/svnx/base/command_factory.rb
148
+ - lib/svnx/base/command_line_factory.rb
148
149
  - lib/svnx/base/entries.rb
150
+ - lib/svnx/base/entries_command.rb
149
151
  - lib/svnx/base/entry.rb
150
152
  - lib/svnx/base/env.rb
153
+ - lib/svnx/base/fields.rb
151
154
  - lib/svnx/base/options.rb
155
+ - lib/svnx/base/tags.rb
152
156
  - lib/svnx/blame/command.rb
153
157
  - lib/svnx/blame/entries.rb
154
158
  - lib/svnx/blame/entry.rb
@@ -181,11 +185,6 @@ files:
181
185
  - lib/svnx/propget/options.rb
182
186
  - lib/svnx/propset/command.rb
183
187
  - lib/svnx/propset/options.rb
184
- - lib/svnx/revision/argfactory.rb
185
- - lib/svnx/revision/argument.rb
186
- - lib/svnx/revision/date.rb
187
- - lib/svnx/revision/error.rb
188
- - lib/svnx/revision/range.rb
189
188
  - lib/svnx/status/command.rb
190
189
  - lib/svnx/status/entries.rb
191
190
  - lib/svnx/status/entry.rb
@@ -195,7 +194,6 @@ files:
195
194
  - lib/svnx/util/classutil.rb
196
195
  - lib/svnx/util/dateutil.rb
197
196
  - lib/svnx/util/englishtime.rb
198
- - lib/svnx/util/objutil.rb
199
197
  - lib/svnx/util/strutil.rb
200
198
  - lib/svnx/util/timeutil.rb
201
199
  - lib/svnx/version.rb
@@ -1,55 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # -*- ruby -*-
3
-
4
- module Svnx
5
- module Revision
6
- RELATIVE_REVISION_RE = Regexp.new '^([\+\-])(\d+)$'
7
- end
8
- end
9
-
10
- module Svnx::Revision
11
- class ArgumentFactory
12
- include Logue::Loggable
13
-
14
- DATE_REGEXP = Regexp.new '^\{(.*?)\}'
15
- SVN_ARGUMENT_WORDS = %w{ HEAD BASE COMMITTED PREV }
16
-
17
- def create value, args = Hash.new
18
- case value
19
- when Fixnum
20
- create_for_fixnum value, args
21
- when String
22
- create_for_string value, args
23
- when Symbol
24
- raise RevisionError.new "symbol not yet handled"
25
- when Date
26
- # $$$ this (and Time) will probably have to be converted to svn's format
27
- raise RevisionError.new "date not yet handled"
28
- when Time
29
- raise RevisionError.new "time not yet handled"
30
- end
31
- end
32
-
33
- def create_for_fixnum value, args
34
- if value < 0
35
- # these are log entries:
36
- RelativeArgument.new value, entries: args[:entries]
37
- else
38
- IndexArgument.new value
39
- end
40
- end
41
-
42
- def create_for_string value, args
43
- case
44
- when SVN_ARGUMENT_WORDS.include?(value)
45
- StringArgument.new value
46
- when md = RELATIVE_REVISION_RE.match(value)
47
- RelativeArgument.new md[0].to_i, entries: args[:entries]
48
- when DATE_REGEXP.match(value)
49
- StringArgument.new value
50
- else
51
- IndexArgument.new value.to_i
52
- end
53
- end
54
- end
55
- end
@@ -1,85 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # -*- ruby -*-
3
-
4
- require 'svnx/log/entries'
5
- require 'svnx/revision/error'
6
- require 'logue/loggable'
7
- require 'svnx/revision/argfactory'
8
-
9
- # We represent what svn calls a revision (-r134:{2010-1-1}) as a Range,
10
- # consisting of a from and to (optional) Argument.
11
-
12
- module Svnx
13
- module Revision
14
- end
15
- end
16
-
17
- module Svnx::Revision
18
- class Argument
19
- include Logue::Loggable, Comparable
20
-
21
- # Returns the Nth revision from the given logging output.
22
-
23
- # -n means to count from the end of the list.
24
- # +n means to count from the beginning of the list.
25
- # n means the literal revision number.
26
-
27
- # these are also valid revisions
28
- # :working_copy
29
- # :head
30
-
31
- attr_reader :value
32
-
33
- class << self
34
- def create value, args = Hash.new
35
- ArgumentFactory.new.create value, args
36
- end
37
- end
38
-
39
- def initialize value
40
- @value = value
41
- end
42
-
43
- def to_s
44
- @value.to_s
45
- end
46
-
47
- def <=> other
48
- @value <=> (other.kind_of?(Argument) ? other.value : other)
49
- end
50
- end
51
- end
52
-
53
- module Svnx::Revision
54
- class IndexArgument < Argument
55
- end
56
- end
57
-
58
- module Svnx::Revision
59
- class StringArgument < Argument
60
- end
61
- end
62
-
63
- # this is of the form -3, which is revision[-3] (second one from the most
64
- # recent; -1 is the most recent).
65
- module Svnx::Revision
66
- class RelativeArgument < IndexArgument
67
- def initialize value, args
68
- unless entries = args[:entries]
69
- raise RevisionError.new "cannot determine relative revision without entries"
70
- end
71
-
72
- nentries = entries.size
73
-
74
- # logentries are in descending order, so the most recent one is index 0
75
-
76
- if value.abs > nentries
77
- raise RevisionError.new "ERROR: no entry for revision: #{value.abs}; number of entries: #{nentries}"
78
- else
79
- idx = value < 0 ? value.abs - 1 : nentries - value
80
- log_entry = entries[idx]
81
- super log_entry.revision.to_i
82
- end
83
- end
84
- end
85
- end
@@ -1,27 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # -*- ruby -*-
3
-
4
- module Svnx
5
- module Revision
6
- end
7
- end
8
-
9
- module Svnx::Revision
10
- class DateToDate
11
- attr_reader :from
12
- attr_reader :to
13
-
14
- def initialize from, to
15
- @from = from
16
- @to = to
17
- end
18
-
19
- def to_svn_str
20
- [ @from, @to ].collect { |dt| "{" + to_svn_date(dt) + "}" }.join(":")
21
- end
22
-
23
- def to_svn_date date
24
- date.strftime "%Y-%m-%d"
25
- end
26
- end
27
- end
@@ -1,12 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # -*- ruby -*-
3
-
4
- module Svnx
5
- module Revision
6
- end
7
- end
8
-
9
- module Svnx::Revision
10
- class RevisionError < RuntimeError
11
- end
12
- end
@@ -1,54 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # -*- ruby -*-
3
-
4
- require 'svnx/log/entries'
5
- require 'svnx/revision/argument'
6
- require 'logue/loggable'
7
-
8
- module Svnx
9
- module Revision
10
- end
11
- end
12
-
13
- module Svnx::Revision
14
- # this is of the form: -r123:456
15
- class Range
16
- include Logue::Loggable
17
-
18
- attr_reader :from
19
- attr_reader :to
20
-
21
- def initialize from, to = nil, entries = nil
22
- if to
23
- @from = to_revision from, entries
24
- @to = to_revision to, entries
25
- elsif from.kind_of? String
26
- @from, @to = from.split(':').collect { |x| to_revision x, entries }
27
- else
28
- @from = to_revision from, entries
29
- @to = :working_copy
30
- end
31
- end
32
-
33
- def to_revision val, entries
34
- val.kind_of?(Argument) ? val : Argument.create(val, entries: entries)
35
- end
36
-
37
- def to_s
38
- str = @from.to_s
39
- unless working_copy?
40
- str << ':' << @to.to_s
41
- end
42
- str
43
- end
44
-
45
- def head?
46
- # return true/false instead of true/false/nil
47
- @to ? @to.value == 'HEAD' : false
48
- end
49
-
50
- def working_copy?
51
- @to == nil || @to == :wc || @to == :working_copy
52
- end
53
- end
54
- end