pvn 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8783d050b1dd5c8455f7207f9a1933b00ac080b3
4
- data.tar.gz: 74df918bdd23b67089dddad91d5736162e72e49f
3
+ metadata.gz: 6b0945592450e9be1066e1c2a6e5b1cabd6e4791
4
+ data.tar.gz: 0634a3af015e06243c293815d5e9f15c838cabfc
5
5
  SHA512:
6
- metadata.gz: a84f65d9a725d0f1d45127836d079f2e6bd7d359664f66f828f6c051ca6ed7092757cdfd5654a48eb96a5a0e90c65fdeae3f23bb488c73b83b0044678301457a
7
- data.tar.gz: c3520d5756c9d08280cf979ec9fbafcda60ca4f366973a9132c10cff1da5a956d4de78a79a1ef37c56558c02a0a5672cc2d7800250ea53a8a1764534a13f2f5f
6
+ metadata.gz: d7d422306e8d5e8098954ffc962d43bb962c188069ec292d23a9bfbbd9859968ab9e98fa4b8bd064b666c88f9b92de8d2046a7ca0b0ba9fce8e3384102d8fade
7
+ data.tar.gz: d3a8cb1fb34373095fb1cde9bd3cb13c5872fd525805cf5d30a929d82d121276cb61c04210d15ddbd4f6f2fc1e185a537bc596c3a4847a6465efc8d4ae516130
data/lib/pvn.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module PVN
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/ruby -w
2
2
  # -*- ruby -*-
3
3
 
4
- require 'svnx/action'
4
+ require 'svnx/base/action'
5
5
  require 'logue/loggable'
6
6
 
7
7
  module PVN; module Diff; end; end
@@ -16,7 +16,7 @@ module PVN::Diff
16
16
 
17
17
  def initialize revision, action
18
18
  @revision = to_revision(revision)
19
- @action = action.kind_of?(SVNx::Action) || SVNx::Action.new(action)
19
+ @action = action.kind_of?(SVNx::Action) ? action : SVNx::Action.new(action)
20
20
  end
21
21
 
22
22
  def to_revision rev
@@ -4,7 +4,7 @@
4
4
  require 'pvn/diff/log_paths'
5
5
  require 'pvn/diff/status_paths'
6
6
  require 'pvn/diff/local_path'
7
- require 'pvn/revision/range'
7
+ require 'svnx/revision/range'
8
8
  require 'logue/loggable'
9
9
 
10
10
  module PVN::Diff
@@ -17,14 +17,14 @@ module PVN::Diff
17
17
  end
18
18
 
19
19
  def diff_revision_to_working_copy revision, whitespace
20
- # fromrev = revision.from.value
21
-
22
- info "revision: #{revision}".color(:cyan)
23
- rev = PVN::Revision::Range.new revision.to_s, 'HEAD'
24
- info "rev: #{rev}".color(:cyan)
20
+ info "revision: #{revision}"
21
+ rev = SVNx::Revision::Range.new revision.to_s, 'HEAD'
22
+ info "rev: #{rev}"
25
23
 
26
24
  logpaths = LogPaths.new rev, @paths
25
+ info "logpaths: #{logpaths}"
27
26
  name_to_logpath = logpaths.to_map
27
+ info "name_to_logpath: #{name_to_logpath}"
28
28
 
29
29
  statuspaths = StatusPaths.new revision, @paths
30
30
  name_to_statuspath = statuspaths.to_map
@@ -43,13 +43,9 @@ module PVN::Diff
43
43
 
44
44
  ### $$$ silliness because I don't have Diff::Name integrated:
45
45
  logname = '/' + name
46
-
47
46
  logpath = name_to_logpath[logname]
48
- info "logpaths: #{logpaths}"
49
-
50
47
  stpath = name_to_statuspath[name]
51
- info "stpath: #{stpath}"
52
-
48
+
53
49
  # frrev = nil
54
50
 
55
51
  if logpath
@@ -12,17 +12,26 @@ module PVN::Diff
12
12
  @elmt = PVN::IO::Element.new :local => @entry.path
13
13
  name = entry.path
14
14
  action = SVNx::Action.new @entry.status
15
- revision = action.added? ? 0 : @elmt.get_info.revision
15
+ info "action: #{action}".color('#4addaf')
16
+ revision = if action.added?
17
+ 0
18
+ elsif action.unversioned?
19
+ nil
20
+ else
21
+ @elmt.get_info.revision
22
+ end
16
23
  super name, revision, action, nil
17
24
  end
18
25
 
19
26
  def show_diff whitespace = nil
20
- case @entry.status
21
- when 'modified'
27
+ info "@entry.status: #{@entry.status}".color('#22c3c3')
28
+ # crappy programming here. this should be pushed into PVN::Element.
29
+ st = @entry.status
30
+ if st.modified?
22
31
  show_as_modified whitespace
23
- when 'deleted'
32
+ elsif st.deleted?
24
33
  show_as_deleted
25
- when 'added'
34
+ elsif st.added?
26
35
  show_as_added
27
36
  end
28
37
  end
@@ -3,6 +3,7 @@
3
3
 
4
4
  require 'pvn/io/element'
5
5
  require 'pvn/diff/path'
6
+ require 'svnx/revision/argument'
6
7
 
7
8
  module PVN::Diff
8
9
  # this is a path wrapping a log entry; it could also be a RemotePath or a
@@ -50,7 +51,7 @@ module PVN::Diff
50
51
  displaypath = get_display_path
51
52
 
52
53
  rev_change = changes.detect do |chg|
53
- revarg = PVN::Revision::Argument.new chg.revision
54
+ revarg = SVNx::Revision::Argument.create chg.revision
54
55
  revarg > revision.from
55
56
  end
56
57
 
@@ -73,6 +74,8 @@ module PVN::Diff
73
74
  def get_diff_revision change, revision
74
75
  # find the first revision where logpath was in svn, no earlier than the
75
76
  # revision.from value
77
+ info "change: #{change.class}"
78
+ info "change.action: #{change.action}"
76
79
  if change.action.added?
77
80
  change.revision.to_i
78
81
  elsif change.revision.to_i >= revision.from.value
@@ -126,8 +129,8 @@ module PVN::Diff
126
129
 
127
130
  def revisions_later_than revision
128
131
  changes.select do |chg|
129
- x = PVN::Revision::Argument.new chg.revision
130
- y = PVN::Revision::Argument.new revision
132
+ x = SVNx::Revision::Argument.create chg.revision
133
+ y = SVNx::Revision::Argument.create revision
131
134
  x > y
132
135
  end
133
136
  end
@@ -26,12 +26,15 @@ module PVN::Diff
26
26
  end
27
27
 
28
28
  def add_path logentry, logentrypath, pathinfo
29
+ info "logentry: #{logentry}".color('#fa3d3d')
30
+
29
31
  name = logentrypath.name
30
32
  revision = logentry.revision
31
33
  action = logentrypath.action
34
+ info "action: #{action}"
32
35
  url = pathinfo.url
33
36
 
34
- info "action: #{action}"
37
+ info "action: #{action}".color('#fa3d3d')
35
38
  info "url: #{url}"
36
39
 
37
40
  path = @elements.detect { |element| element.name == name }
@@ -32,8 +32,9 @@ module PVN::Diff
32
32
  # (argument); this only handling revision numbers (not dates) for now.
33
33
 
34
34
  rev = change ? [ change.to_i - 1, change.to_i ] : options.revision
35
- info "rev: #{rev}"
36
- @revision = PVN::Revision::Range.new(*rev)
35
+ from, to = rev[0], rev[1]
36
+
37
+ @revision = SVNx::Revision::Range.new from, to
37
38
  info "@revision: #{@revision}"
38
39
 
39
40
  # this indicates that this should be split into two classes:
@@ -20,9 +20,13 @@ module PVN::Diff
20
20
 
21
21
  def add elmt, url
22
22
  status = elmt.find_files_by_status
23
+ info "status: #{status}".color('#33facc')
23
24
  status.entries.each do |entry|
25
+ info "entry: #{entry}".color('#33facc')
24
26
  # we don't care about unversioned entries for diffing.
25
- next if entry.status == 'unversioned'
27
+ info "entry.status: #{entry.status}".color('#33facc')
28
+ info "entry.status.class: #{entry.status.class}".color('#33facc')
29
+ next if entry.status.unversioned?
26
30
 
27
31
  # svn log prepends /; svn status does not
28
32
  # name = '/' + entry.path
@@ -49,9 +53,10 @@ module PVN::Diff
49
53
  # else
50
54
  # it is compared to BASE
51
55
 
52
- info "status_entry.status: #{status_entry.status}"
56
+ info "status_entry.status: #{status_entry.status}".color('#2c2cdd')
53
57
 
54
58
  action = SVNx::Action.new status_entry.status
59
+ info "action: #{action}".color('#2c2cdd')
55
60
  case
56
61
  when action.added?
57
62
  info "added"
@@ -5,9 +5,12 @@ require 'rubygems'
5
5
  require 'logue/loggable'
6
6
  require 'svnx/log/entries'
7
7
  require 'svnx/status/entries'
8
+ require 'svnx/status/command'
8
9
  require 'svnx/info/entries'
10
+ require 'svnx/info/command'
11
+ require 'svnx/cat/command'
9
12
  require 'pvn/io/fselement'
10
- require 'svnx/exec'
13
+ require 'svnx/io/element'
11
14
 
12
15
  module PVN; module IO; end; end
13
16
 
@@ -33,6 +36,9 @@ module PVN::IO
33
36
  @path = args[:path]
34
37
 
35
38
  info "local: #{@local.inspect}"
39
+
40
+ @svnelement = SVNx::IO::Element.new args
41
+ info "@svnelement: #{@svnelement}"
36
42
  end
37
43
 
38
44
  def exist?
@@ -40,28 +46,17 @@ module PVN::IO
40
46
  end
41
47
 
42
48
  def directory?
43
- if exist?
44
- @local.directory?
45
- else
46
- # look it up with svn info
47
- false
48
- end
49
+ @svnelement.directory?
49
50
  end
50
51
 
51
52
  def file?
52
- if exist?
53
- @local.file?
54
- else
55
- raise "need this"
56
- end
53
+ @svnelement.file?
57
54
  end
58
55
 
59
56
  def get_info revision = nil
60
57
  usepath = @local || @path
61
- output = SVNx::Exec.new.info usepath, revision
62
-
63
- infentries = SVNx::Info::Entries.new :xmllines => output
64
- infentries[0]
58
+ inf = SVNx::InfoExec.new path: usepath, revision: revision
59
+ inf.entry
65
60
  end
66
61
 
67
62
  def repo_root
@@ -80,29 +75,14 @@ module PVN::IO
80
75
  end
81
76
  end
82
77
 
83
- # returns a set of entries modified over the given revision
84
- def find_modified_entries revision
85
- svninfo = get_info
86
-
87
- filter = svninfo.url.dup
88
- filter.slice! svninfo.root
89
-
90
- # we can't cache this, because we don't know if there has been an svn
91
- # update since the previous run:
92
- xmllines = SVNx::Exec.new.log @local, revision, nil, true, false
93
- entries = SVNx::Log::Entries.new :xmllines => xmllines
94
-
95
- modified = Set.new
96
-
97
- entries.each do |entry|
98
- entry.paths.each do |epath|
99
- if epath.action == 'M' && epath.name.start_with?(filter)
100
- modified << epath
101
- end
102
- end
103
- end
78
+ def status_to_symbol status
79
+ # add a ? if not there already
80
+ (status.to_s.sub(%r{\??$}, '?')).to_sym
81
+ end
104
82
 
105
- modified
83
+ # returns a set of entries matching status for the given revision
84
+ def find_entries revision, status
85
+ @svnelement.find_in_log revision, status
106
86
  end
107
87
 
108
88
  def cat revision, use_cache = false
@@ -116,29 +96,18 @@ module PVN::IO
116
96
  path << '@' << revision.to_s
117
97
  end
118
98
  info "path: #{path}"
119
- SVNx::Exec.new.cat path, nil, use_cache
99
+ catexec = SVNx::CatExec.new path: path, revision: nil, use_cache: use_cache
100
+ catexec.output
120
101
  end
121
102
 
122
- # returns a set of local files that are in the given status
103
+ # returns a set of local files that have the given status/action
123
104
  def find_files_by_status status = nil
124
- xmllines = SVNx::Exec.new.status @local, false
125
- entries = SVNx::Status::Entries.new :xmllines => xmllines
126
-
127
- entries.select do |entry|
128
- status.nil? || entry.status == status
129
- end
130
- end
131
-
132
- # returns a set of local files that are in modified status
133
- def find_modified_files
134
- find_files_by_status 'modified'
105
+ @svnelement.find_by_status status
135
106
  end
136
107
 
137
108
  # returns log entries
138
109
  def logentries revision
139
- # use_cache should be conditional on revision:
140
- xmllines = SVNx::Exec.new.log @local, revision.to_s, nil, true, false
141
- SVNx::Log::Entries.new :xmllines => xmllines
110
+ @svnelement.log_entries :revision => revision
142
111
  end
143
112
 
144
113
  def <=> other
@@ -5,8 +5,7 @@ require 'pvn/io/element'
5
5
  require 'pvn/log/formatter/entries_formatter'
6
6
  require 'pvn/log/options'
7
7
  require 'pvn/command/command'
8
- require 'pvn/log/entries'
9
- require 'pvn/log/user_entries'
8
+ require 'svnx/log/command'
10
9
 
11
10
  module PVN::Log
12
11
  class Command < PVN::Command::Command
@@ -41,11 +40,39 @@ module PVN::Log
41
40
  info "paths: #{paths}"
42
41
 
43
42
  allentries = Array.new
44
-
45
- entcls = options.user ? UserEntries : Entries
46
43
 
47
- paths.each do |path|
48
- allentries.concat entcls.new(path, options).entries
44
+ args = { revision: options.revision, limit: options.limit, files: options.files, use_cache: false }
45
+
46
+ if options.user
47
+ limit = args[:limit]
48
+ args[:limit] = nil
49
+ args[:user] = options.user
50
+
51
+ paths.each do |path|
52
+ args[:path] = path
53
+
54
+ exec = SVNx::LogExec.new args
55
+ # SVNx::Entries => Array entries:
56
+
57
+ userentries = Hash.new
58
+ exec.entries.entries.each do |entry|
59
+ break if userentries.size >= limit
60
+ if entry.author == args[:user]
61
+ userentries[userentries.size] = entry
62
+ end
63
+ end
64
+
65
+ raise "ERROR: no matching log entries for '#{args[:user]}'" if userentries.empty?
66
+
67
+ allentries.concat userentries.values
68
+ end
69
+ else
70
+ paths.each do |path|
71
+ args[:path] = path
72
+ exec = SVNx::LogExec.new args
73
+ # SVNx::Entries => Array entries:
74
+ allentries.concat exec.entries.entries
75
+ end
49
76
  end
50
77
 
51
78
  # we can show relative revisions for a single path, without filtering by
@@ -58,7 +85,7 @@ module PVN::Log
58
85
  from_tail = show_relative && !options.limit
59
86
 
60
87
  ef = PVN::Log::EntriesFormatter.new options.color, allentries, from_head, from_tail
61
- puts ef.format
88
+ $io.puts ef.format
62
89
  end
63
90
  end
64
91
  end
@@ -11,7 +11,11 @@ module PVN::Log
11
11
  'M' => :modified,
12
12
  'A' => :added,
13
13
  'D' => :deleted,
14
- 'R' => :renamed
14
+ 'R' => :renamed,
15
+ SVNx::Action::MODIFIED => :modified,
16
+ SVNx::Action::ADDED => :added,
17
+ SVNx::Action::DELETED => :deleted,
18
+ # SVNx::Action::RENAMED => :renamed
15
19
  }
16
20
 
17
21
  def initialize use_colors, paths
@@ -26,7 +30,7 @@ module PVN::Log
26
30
  if field = PATH_ACTIONS[path.action]
27
31
  pstr << colorize(path.name, field)
28
32
  else
29
- raise "wtf?: #{path.action}"
33
+ raise "wtf?: #{path.action.inspect}; #{path.action.class}"
30
34
  end
31
35
 
32
36
  if path.kind == 'dir'
@@ -3,14 +3,14 @@
3
3
 
4
4
  require 'pvn/io/element'
5
5
  require 'pvn/pct/differ'
6
- require 'svnx/exec'
7
6
 
8
7
  module PVN::Pct
9
8
  class LocalDiffer < Differ
10
9
  def get_diff_counts path, options
11
10
  elmt = PVN::IO::Element.new :local => path
12
- modified = elmt.find_modified_files
13
-
11
+ modified = elmt.find_files_by_status :modified
12
+ info "modified: #{modified}".color('#fa4434')
13
+
14
14
  # total = PVN::DiffCount.new
15
15
 
16
16
  modified = modified.sort_by { |n| n.path }
@@ -18,9 +18,9 @@ module PVN::Pct
18
18
  diff_counts = Array.new
19
19
 
20
20
  modified.each do |entry|
21
- info "entry.path: #{entry.path}"
22
- lines = SVNx::Exec.new.cat entry.path, nil, false
23
- svn_count = lines.size
21
+ info "entry.path: #{entry.path}".color('#fa4434')
22
+ catexec = SVNx::CatExec.new path: entry.path, revision: nil, use_cache: false
23
+ svn_count = catexec.output.size
24
24
  local_count = Pathname.new(entry.path).readlines.size
25
25
 
26
26
  dc = PVN::DiffCount.new svn_count, local_count, entry.path
@@ -3,7 +3,7 @@
3
3
 
4
4
  require 'pvn/io/element'
5
5
  require 'pvn/pct/differ'
6
- require 'pvn/revision/range'
6
+ require 'svnx/revision/range'
7
7
  require 'rainbow'
8
8
 
9
9
  module PVN::Pct
@@ -21,7 +21,7 @@ module PVN::Pct
21
21
  end
22
22
 
23
23
  def get_modified elmt, fromrev, torev
24
- modified = elmt.find_modified_entries [ fromrev + ':' + torev ]
24
+ modified = elmt.find_entries [ fromrev + ':' + torev ], :modified
25
25
  modified.collect { |m| m.name }.sort.uniq
26
26
  end
27
27
 
@@ -45,12 +45,14 @@ module PVN::Pct
45
45
 
46
46
  def get_diff_counts path, options
47
47
  revision = options.revision
48
+ info "revision: #{revision}".color('#fafa33')
48
49
 
49
50
  # revision -r20 is like diff -c20:
50
51
  fromrev, torev = get_from_to_revisions revision
51
52
 
52
53
  elmt = PVN::IO::Element.new :local => path
53
54
  modnames = get_modified elmt, fromrev, torev
55
+ info "modnames: #{modnames}"
54
56
 
55
57
  reporoot = elmt.repo_root
56
58
 
@@ -64,6 +66,7 @@ module PVN::Pct
64
66
  modnames.each do |mod|
65
67
  fullpath = reporoot + mod
66
68
  elmt = PVN::IO::Element.new :path => fullpath
69
+ info "elmt: #{elmt}"
67
70
 
68
71
  next unless has_revisions? elmt, fromrev, torev
69
72
  next if directory? elmt
@@ -2,7 +2,7 @@
2
2
  # -*- ruby -*-
3
3
 
4
4
  require 'synoption/option'
5
- require 'svnx/exec'
5
+ require 'svnx/revision/argument'
6
6
 
7
7
  module PVN
8
8
  class BaseRevisionOption < Synoption::Option
@@ -19,22 +19,23 @@ module PVN
19
19
 
20
20
  def resolve_value optset, unprocessed
21
21
  val = value
22
- if PVN::Revision::RELATIVE_REVISION_RE.match val
22
+ if SVNx::Revision::RELATIVE_REVISION_RE.match val
23
23
  @value = relative_to_absolute val, unprocessed[0]
24
24
  end
25
25
  end
26
26
 
27
27
  def relative_to_absolute rel, path
28
28
  limit = rel[0, 1] == '-' ? rel.to_i.abs : nil
29
- xmllines = run_log_command limit, path
30
-
29
+ entries = run_log_command limit, path
30
+
31
31
  # This is Argument, not Range, because we're getting the value
32
- reventry = PVN::Revision::Argument.new rel, xmllines
32
+ reventry = SVNx::Revision::Argument.create rel, entries: entries
33
33
  reventry.value.to_s
34
34
  end
35
35
 
36
36
  def run_log_command limit, path
37
- SVNx::Exec.new.log path, nil, limit, false, false
37
+ logexec = SVNx::LogExec.new path: path, limit: limit, revision: nil, verbose: false, use_cache: false
38
+ logexec.entries
38
39
  end
39
40
 
40
41
  def entry
@@ -2,23 +2,10 @@
2
2
  # -*- ruby -*-
3
3
 
4
4
  require 'logue/loggable'
5
- require 'pvn/log/entries'
6
5
  require 'pvn/seek/seeker'
6
+ require 'svnx/log/command'
7
7
 
8
8
  module PVN::Seek
9
- class PathLogOptions
10
- def initialize revision
11
- @revision = revision
12
- end
13
-
14
- def limit; nil; end
15
- def verbose; nil; end
16
- def revision; @revision; end
17
- def user; nil; end
18
- def use_cache; nil; end
19
- def files; end
20
- end
21
-
22
9
  class Path
23
10
  include Logue::Loggable
24
11
 
@@ -36,8 +23,9 @@ module PVN::Seek
36
23
  end
37
24
 
38
25
  def get_entries revision
39
- logentries = PVN::Log::Entries.new @path, PathLogOptions.new(revision)
40
- logentries.to_a
26
+ args = { revision: revision, limit: nil, files: nil, use_cache: nil, path: @path }
27
+ exec = SVNx::LogExec.new args
28
+ exec.entries.to_a
41
29
  end
42
30
 
43
31
  def show_no_match type, entries
@@ -1,10 +1,9 @@
1
1
  #!/usr/bin/ruby -w
2
2
  # -*- ruby -*-
3
3
 
4
- require 'pvn/log/entries'
5
4
  require 'logue/loggable'
6
- require 'svnx/exec'
7
5
  require 'pvn/seek/match'
6
+ require 'svnx/cat/command'
8
7
 
9
8
  module PVN::Seek
10
9
  class Seeker
@@ -18,8 +17,8 @@ module PVN::Seek
18
17
  end
19
18
 
20
19
  def cat revision
21
- ex = SVNx::Exec.new
22
- ex.cat @path, revision, true
20
+ ex = SVNx::CatExec.new path: @path, revision: revision, use_cache: true
21
+ ex.output
23
22
  end
24
23
 
25
24
  def matches? previous_entry, current_entry
@@ -17,9 +17,9 @@ module PVN::Status
17
17
  def format
18
18
  lines = Array.new
19
19
  lines << if use_colors
20
- " " + colorize(entry.path, entry.status.to_sym)
20
+ " " + colorize(entry.path, entry.status.type)
21
21
  else
22
- "#{entry.status[0 .. 0].upcase} #{entry.path}"
22
+ "#{entry.status.type.to_s[0 .. 0].upcase} #{entry.path}"
23
23
  end
24
24
  lines
25
25
  end
@@ -20,9 +20,19 @@ module PVN::Diff
20
20
  if Logue::Log.verbose
21
21
  puts strio.string
22
22
  end
23
-
23
+
24
24
  actlines = strio.string.split "\n"
25
25
 
26
+ if false
27
+ puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
28
+ puts actlines
29
+ puts "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"
30
+
31
+ puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
32
+ puts explines
33
+ puts "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"
34
+ end
35
+
26
36
  assert_arrays_equal explines, actlines
27
37
 
28
38
  $io = $stdout
@@ -99,7 +109,7 @@ module PVN::Diff
99
109
 
100
110
  # -r20 means -r20:working_copy
101
111
 
102
- revision = PVN::Revision::Range.new 20, nil
112
+ revision = SVNx::Revision::Range.new 20, nil
103
113
  whitespace = false
104
114
  paths = %w{ . }
105
115
 
@@ -3,7 +3,7 @@
3
3
 
4
4
  require 'integration/tc'
5
5
  require 'pvn/diff/log_paths'
6
- require 'pvn/revision/range'
6
+ require 'svnx/revision/range'
7
7
 
8
8
  module PVN::Diff
9
9
  class LogPathsTestCase < PVN::IntegrationTestCase
@@ -15,7 +15,7 @@ module PVN::Diff
15
15
  end
16
16
 
17
17
  def test_revision_to_revision
18
- revision = PVN::Revision::Range.new '15', '16'
18
+ revision = SVNx::Revision::Range.new '15', '16'
19
19
  paths = %w{ . }
20
20
  logpaths = LogPaths.new revision, paths
21
21
  exppaths = [
@@ -2,7 +2,7 @@
2
2
  # -*- ruby -*-
3
3
 
4
4
  require 'pvn/diff/status_paths'
5
- require 'pvn/revision/range'
5
+ require 'svnx/revision/range'
6
6
  require 'pp'
7
7
  require 'integration/tc'
8
8
 
@@ -17,7 +17,7 @@ module PVN::Diff
17
17
 
18
18
  def test_to_working_copy
19
19
  # revision doesn't matter:
20
- revision = PVN::Revision::Range.new '20'
20
+ revision = SVNx::Revision::Range.new '20'
21
21
  paths = %w{ . }
22
22
  statuspaths = StatusPaths.new revision, paths
23
23
  expnames = [
@@ -7,21 +7,14 @@ require 'stringio'
7
7
 
8
8
  module PVN::Log
9
9
  class CommandTest < PVN::IntegrationTestCase
10
-
11
- def test_path
12
- Command.new [ PT_DIRNAME ]
13
- end
14
-
15
10
  def test_invalid_path
16
11
  assert_raises(RuntimeError) do
17
12
  Command.new %w{ /this/doesnt/exist }
18
13
  end
19
14
  end
20
15
 
21
- def test_user
22
- # filter_for_user
23
- # fetch_log_in_pieces (-n LIMIT, LIMIT * 2, LIMIT * 4, LIMIT * 8 ... )
24
- # PVN::Log::Command.new [ PT_DIRNAME ]
16
+ def assert_command_output expected, args = Array.new
17
+ super PVN::Log::Command, expected, args
25
18
  end
26
19
 
27
20
  def test_doc
@@ -80,7 +73,54 @@ module PVN::Log
80
73
  " Prints log entries only for user 'barney', with the default limit.",
81
74
  ]
82
75
 
83
- assert_command_output Command, expected, %w{ -h }
76
+ assert_command_output expected, %w{ -h }
77
+ end
78
+
79
+ def test_command_default
80
+ expected = Array.new
81
+ expected << "\e[1m22\e[0m \e[1m-1\e[0m \e[1m\e[36mLyle\e[0m \e[1m\e[35m12-09-18 11:32:19\e[0m"
82
+ expected << ""
83
+ expected << "\e[37mDon't pay no attention to that alky. He can't hold a gun, much less shoot it.\e[0m"
84
+ expected << ""
85
+ expected << "-------------------------------------------------------"
86
+ expected << "\e[1m21\e[0m \e[1m-2\e[0m \e[1m\e[36mGovernor William J. Le Petomane\e[0m \e[1m\e[35m12-09-18 11:30:10\e[0m"
87
+ expected << ""
88
+ expected << "\e[37mWe've gotta protect our phoney baloney jobs, gentlemen!\e[0m"
89
+ expected << ""
90
+ expected << "-------------------------------------------------------"
91
+ expected << "\e[1m20\e[0m \e[1m-3\e[0m \e[1m\e[36mHoward Johnson\e[0m \e[1m\e[35m12-09-18 11:28:08\e[0m"
92
+ expected << ""
93
+ expected << "\e[37mY'know, Nietzsche says: \"Out of chaos comes order.\"\e[0m"
94
+ expected << ""
95
+ expected << "-------------------------------------------------------"
96
+ expected << "\e[1m19\e[0m \e[1m-4\e[0m \e[1m\e[36mLili von Shtupp\e[0m \e[1m\e[35m12-09-16 14:24:07\e[0m"
97
+ expected << ""
98
+ expected << "\e[37m\e[0m"
99
+ expected << ""
100
+ expected << "-------------------------------------------------------"
101
+ expected << "\e[1m18\e[0m \e[1m-5\e[0m \e[1m\e[36mLili von Shtupp\e[0m \e[1m\e[35m12-09-16 14:09:45\e[0m"
102
+ expected << ""
103
+ expected << "\e[37mWillkommen, Bienvenue, Welcome, C'mon in.\e[0m"
104
+ expected << ""
105
+ expected << "-------------------------------------------------------"
106
+
107
+ assert_command_output expected
108
+ end
109
+
110
+ def test_command_user
111
+ expected = Array.new
112
+ expected << "\e[1m13\e[0m \e[1m\e[36mJim\e[0m \e[1m\e[35m12-09-16 13:51:55\e[0m"
113
+ expected << ""
114
+ expected << "\e[37mWe're not sure. Are we...black?\e[0m"
115
+ expected << ""
116
+ expected << "-------------------------------------------------------"
117
+ expected << "\e[1m3\e[0m \e[1m\e[36mJim\e[0m \e[1m\e[35m12-09-15 17:29:15\e[0m"
118
+ expected << ""
119
+ expected << "\e[37mBoy, is he strict!\e[0m"
120
+ expected << ""
121
+ expected << "-------------------------------------------------------"
122
+
123
+ assert_command_output expected, %w{ -u Jim }
84
124
  end
85
125
  end
86
126
  end
@@ -7,7 +7,7 @@ require 'pvn/io/element'
7
7
  require 'resources'
8
8
 
9
9
  module PVN::IO::IOElement
10
- class LogTestCase ###$$$ < PVN::Log::TestCase
10
+ class LogTestCase ### < PVN::Log::TestCase
11
11
  def assert_log_entries_size expsize, dirlog
12
12
  assert_equal expsize, dirlog.entries.size
13
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pvn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Pace
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-12 00:00:00.000000000 Z
11
+ date: 2013-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: synoption
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - '>='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.0.2
33
+ version: 0.3.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '>='
39
39
  - !ruby/object:Gem::Version
40
- version: 0.0.2
40
+ version: 0.3.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: riel
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -107,7 +107,6 @@ files:
107
107
  - lib/pvn/io/element.rb
108
108
  - lib/pvn/io/fselement.rb
109
109
  - lib/pvn/log/command.rb
110
- - lib/pvn/log/entries.rb
111
110
  - lib/pvn/log/formatter/date_formatter.rb
112
111
  - lib/pvn/log/formatter/entries_formatter.rb
113
112
  - lib/pvn/log/formatter/entry_formatter.rb
@@ -116,17 +115,13 @@ files:
116
115
  - lib/pvn/log/formatter/path_formatter.rb
117
116
  - lib/pvn/log/formatter/summary_formatter.rb
118
117
  - lib/pvn/log/options.rb
119
- - lib/pvn/log/user_entries.rb
120
118
  - lib/pvn/pct/command.rb
121
119
  - lib/pvn/pct/differ.rb
122
120
  - lib/pvn/pct/local_differ.rb
123
121
  - lib/pvn/pct/options.rb
124
122
  - lib/pvn/pct/repository_differ.rb
125
- - lib/pvn/revision/argument.rb
126
123
  - lib/pvn/revision/base_option.rb
127
- - lib/pvn/revision/error.rb
128
124
  - lib/pvn/revision/multiple_revisions_option.rb
129
- - lib/pvn/revision/range.rb
130
125
  - lib/pvn/revision/revision_option.rb
131
126
  - lib/pvn/revision/revision_regexp_option.rb
132
127
  - lib/pvn/seek/command.rb
@@ -159,9 +154,7 @@ files:
159
154
  - test/unit/pvn/io/element/log/log_test.rb
160
155
  - test/unit/pvn/log/formatter/entry_formatter_test.rb
161
156
  - test/unit/pvn/log/options_test.rb
162
- - test/unit/pvn/revision/argument_test.rb
163
157
  - test/unit/pvn/revision/multiple_revisions_option_test.rb
164
- - test/unit/pvn/revision/range_test.rb
165
158
  - test/unit/pvn/revision/revision_option_test.rb
166
159
  - test/unit/pvn/revision/revision_regexp_option_test.rb
167
160
  homepage: http://www.incava.org/projects/pvn
@@ -205,8 +198,6 @@ test_files:
205
198
  - test/unit/pvn/io/element/log/log_test.rb
206
199
  - test/unit/pvn/log/formatter/entry_formatter_test.rb
207
200
  - test/unit/pvn/log/options_test.rb
208
- - test/unit/pvn/revision/argument_test.rb
209
201
  - test/unit/pvn/revision/multiple_revisions_option_test.rb
210
- - test/unit/pvn/revision/range_test.rb
211
202
  - test/unit/pvn/revision/revision_option_test.rb
212
203
  - test/unit/pvn/revision/revision_regexp_option_test.rb
@@ -1,28 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # -*- ruby -*-
3
-
4
- require 'logue/loggable'
5
- require 'svnx/exec'
6
- require 'svnx/log/entries'
7
-
8
- module PVN::Log
9
- class Entries < SVNx::Log::Entries
10
- include Logue::Loggable
11
-
12
- def initialize path, options
13
- revision = options.revision
14
- limit = limit options
15
- verbose = options.files
16
-
17
- # we can't cache this, because we don't know if there has been an svn
18
- # update since the previous run:
19
- use_cache = false
20
- xmllines = SVNx::Exec.new.log path, revision, limit, verbose, use_cache
21
- super :xmllines => xmllines
22
- end
23
-
24
- def limit options
25
- options.limit
26
- end
27
- end
28
- end
@@ -1,38 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # -*- ruby -*-
3
-
4
- require 'pvn/log/entries'
5
- require 'logue/loggable'
6
-
7
- module PVN::Log
8
- class UserEntries < PVN::Log::Entries
9
- include Logue::Loggable
10
-
11
- def initialize path, options
12
- @user = options.user
13
- @limit = options.limit
14
-
15
- super
16
-
17
- filter_entries_for_user
18
- end
19
-
20
- def limit options
21
- nil
22
- end
23
-
24
- def filter_entries_for_user
25
- userentries = Hash.new
26
- each do |entry|
27
- break if userentries.size >= @limit
28
- if entry.author == @user
29
- userentries[userentries.size] = entry
30
- end
31
- end
32
-
33
- raise "ERROR: no matching log entries for '#{@user}'" if userentries.empty?
34
-
35
- @entries = userentries
36
- end
37
- end
38
- end
@@ -1,118 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # -*- ruby -*-
3
-
4
- require 'svnx/log/entries'
5
- require 'pvn/revision/error'
6
- require 'logue/loggable'
7
-
8
- module PVN; module Revision; end; end
9
-
10
- # We represent what svn calls a revision (-r134:{2010-1-1}) as a Range,
11
- # consisting of a from and to (optional) Argument.
12
- module PVN::Revision
13
- RELATIVE_REVISION_RE = Regexp.new '^([\+\-])(\d+)$'
14
-
15
- # Returns the Nth revision from the given logging output.
16
-
17
- # -n means to count from the end of the list.
18
- # +n means to count from the beginning of the list.
19
- # n means the literal revision number.
20
- class Argument
21
- include Logue::Loggable, Comparable
22
-
23
- DATE_REGEXP = Regexp.new '^\{(.*?)\}'
24
- SVN_ARGUMENT_WORDS = %w{ HEAD BASE COMMITTED PREV }
25
-
26
- # these are also valid revisions
27
- # :working_copy
28
- # :head
29
-
30
- attr_reader :value
31
- attr_reader :log_entry
32
-
33
- class << self
34
- alias_method :orig_new, :new
35
-
36
- def new value, xmllines = nil
37
- # these are lines from "svn log -v <file>"
38
- if xmllines.kind_of? Array
39
- xmllines = xmllines.join ''
40
- end
41
-
42
- case value
43
- when Fixnum
44
- if value < 0
45
- RelativeArgument.orig_new value, xmllines
46
- else
47
- FixnumArgument.orig_new value
48
- end
49
- when String
50
- if SVN_ARGUMENT_WORDS.include? value
51
- StringArgument.orig_new value
52
- elsif md = RELATIVE_REVISION_RE.match(value)
53
- RelativeArgument.orig_new md[0].to_i, xmllines
54
- elsif DATE_REGEXP.match value
55
- StringArgument.orig_new value
56
- else
57
- FixnumArgument.orig_new value.to_i
58
- end
59
- when Symbol
60
- raise RevisionError.new "symbol not yet handled"
61
- when Date
62
- # $$$ this (and Time) will probably have to be converted to svn's format
63
- raise RevisionError.new "date not yet handled"
64
- when Time
65
- raise RevisionError.new "time not yet handled"
66
- end
67
- end
68
-
69
- def matches_relative? str
70
- RELATIVE_REVISION_RE.match str
71
- end
72
- end
73
-
74
- def initialize value
75
- @value = value
76
- end
77
-
78
- def to_s
79
- @value.to_s
80
- end
81
-
82
- def <=> other
83
- @value <=> other.value
84
- end
85
- end
86
-
87
- class FixnumArgument < Argument
88
- end
89
-
90
- class StringArgument < Argument
91
- end
92
-
93
- class WorkingCopyArgument < Argument
94
- end
95
-
96
- # this is of the form -3, which is revision[-3] (second one from the most
97
- # recent; -1 is the most recent).
98
- class RelativeArgument < FixnumArgument
99
- def initialize value, xmllines
100
- unless xmllines
101
- raise RevisionError.new "cannot determine relative revision without xmllines"
102
- end
103
-
104
- logentries = SVNx::Log::Entries.new :xmllines => xmllines
105
- nentries = logentries.size
106
-
107
- # logentries are in descending order, so the most recent one is index 0
108
-
109
- if value.abs > nentries
110
- raise RevisionError.new "ERROR: no entry for revision: #{value.abs}; number of entries: #{nentries}"
111
- else
112
- idx = value < 0 ? -1 + value.abs : nentries - value
113
- @log_entry = logentries[idx]
114
- super @log_entry.revision.to_i
115
- end
116
- end
117
- end
118
- end
@@ -1,11 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # -*- ruby -*-
3
-
4
- module PVN; module Revision; end; end
5
-
6
- module PVN
7
- module Revision
8
- class RevisionError < RuntimeError
9
- end
10
- end
11
- end
@@ -1,50 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # -*- ruby -*-
3
-
4
- require 'svnx/log/entries'
5
- require 'pvn/revision/argument'
6
- require 'logue/loggable'
7
-
8
- module PVN; module Revision; end; end
9
-
10
- module PVN::Revision
11
- # this is of the form: -r123:456
12
- class Range
13
- include Logue::Loggable
14
-
15
- attr_reader :from
16
- attr_reader :to
17
-
18
- def initialize from, to = nil, xmllines = nil
19
- if to
20
- @from = to_revision from, xmllines
21
- @to = to_revision to, xmllines
22
- elsif from.kind_of? String
23
- @from, @to = from.split(':').collect { |x| to_revision x, xmllines }
24
- else
25
- @from = to_revision from, xmllines
26
- @to = :working_copy
27
- end
28
- end
29
-
30
- def to_revision val, xmllines
31
- val.kind_of?(Argument) || Argument.new(val, xmllines)
32
- end
33
-
34
- def to_s
35
- str = @from.to_s
36
- unless working_copy?
37
- str << ':' << @to.to_s
38
- end
39
- str
40
- end
41
-
42
- def head?
43
- @to == :head
44
- end
45
-
46
- def working_copy?
47
- @to == nil || @to == :wc || @to == :working_copy
48
- end
49
- end
50
- end
@@ -1,157 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # -*- ruby -*-
3
-
4
- require 'tc'
5
- require 'svnx/log/entries'
6
- require 'pvn/revision/argument'
7
-
8
- require 'resources'
9
-
10
- module PVN::Revision
11
- class ArgumentTestCase < PVN::TestCase
12
- def setup
13
- # This is the equivalent of "log" at revision 22, when this file was added
14
- # at revision 13. Using this instead of just "log" when regenerating the
15
- # resource files keeps the revisions from bouncing around.
16
- @xmllines = Resources::PT_LOG_R22_13_SECONDFILE_TXT.readlines
17
- end
18
-
19
- def create_argument value
20
- Argument.new value, @xmllines
21
- end
22
-
23
- def assert_argument_value exp_value, value
24
- arg = create_argument value
25
- assert_equal exp_value, arg.value
26
- end
27
-
28
- def assert_argument_value_raises value
29
- assert_raises(PVN::Revision::RevisionError) do
30
- assert_argument_value nil, value
31
- end
32
- end
33
-
34
- def assert_argument_to_s exp_str, value
35
- arg = create_argument value
36
- assert_equal exp_str, arg.to_s
37
- end
38
-
39
- def assert_compare op, exp, xval, yval
40
- x = create_argument xval
41
- y = create_argument yval
42
- msg = "xval: #{xval}; yval: #{yval}"
43
- assert_equal exp, x.send(op, y), msg
44
- end
45
-
46
- def assert_argument_eq expeq, xval, yval
47
- # it's the emoticon programming language
48
- assert_compare :==, expeq, xval, yval
49
- end
50
-
51
- def assert_argument_gt expeq, xval, yval
52
- assert_compare :>, expeq, xval, yval
53
- end
54
-
55
- def test_absolute_midrange
56
- assert_argument_value 19, 19
57
- end
58
-
59
- def test_absolute_most_recent
60
- assert_argument_value 22, 22
61
- end
62
-
63
- def test_absolute_least_recent
64
- assert_argument_value 13, 13
65
- end
66
-
67
- def test_absolute_midrange_as_string
68
- assert_argument_value 19, '19'
69
- end
70
-
71
- def test_absolute_most_recent_as_string
72
- assert_argument_value 22, '22'
73
- end
74
-
75
- def test_absolute_least_recent_as_string
76
- assert_argument_value 13, '13'
77
- end
78
-
79
- def test_svn_word
80
- %w{ HEAD BASE COMMITTED PREV }.each do |word|
81
- assert_argument_value word, word
82
- end
83
- end
84
-
85
- def test_negative_most_recent
86
- assert_argument_value 22, -1
87
- end
88
-
89
- def test_negative_second_most_recent
90
- assert_argument_value 20, -2
91
- end
92
-
93
- def test_negative_least_recent
94
- assert_argument_value 13, -5
95
- end
96
-
97
- def test_negative_too_far_back
98
- assert_argument_value_raises(-6)
99
- end
100
-
101
- def test_negative_most_recent_as_string
102
- assert_argument_value 22, '-1'
103
- end
104
-
105
- def test_negative_second_most_recent_as_string
106
- assert_argument_value 20, '-2'
107
- end
108
-
109
- def test_negative_least_recent_as_string
110
- assert_argument_value 13, '-5'
111
- end
112
-
113
- def test_negative_too_far_back_as_string
114
- assert_argument_value_raises '-6'
115
- end
116
-
117
- def test_positive_most_recent
118
- assert_argument_value 22, '+5'
119
- end
120
-
121
- def test_positive_second_most_recent
122
- assert_argument_value 20, '+4'
123
- end
124
-
125
- def test_positive_least_recent
126
- assert_argument_value 13, '+1'
127
- end
128
-
129
- def test_positive_too_far_forward
130
- assert_argument_value_raises '+6'
131
- end
132
-
133
- def xxxtest_range_svn_word_to_number
134
- assert_argument_value 'BASE:1', 'BASE:1'
135
- end
136
-
137
- def xxxtest_date
138
- assert_argument_to_s '1967-12-10', '1967-12-10'
139
- end
140
-
141
- def test_to_s
142
- assert_argument_to_s '5', '5'
143
- assert_argument_to_s 'HEAD', 'HEAD'
144
- end
145
-
146
- def test_eq
147
- assert_argument_eq true, '5', '5'
148
- assert_argument_eq false, '4', '5'
149
- assert_argument_eq false, '5', '4'
150
- end
151
-
152
- def test_gt
153
- assert_argument_gt true, '17', '16'
154
- assert_argument_gt false, '13', '14'
155
- end
156
- end
157
- end
@@ -1,26 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # -*- ruby -*-
3
-
4
- require 'tc'
5
- require 'svnx/log/entries'
6
- require 'pvn/revision/range'
7
-
8
- require 'resources'
9
-
10
- module PVN::Revision
11
- class RangeTestCase < PVN::TestCase
12
- def test_init
13
- rr = Range.new '143:199'
14
- assert_equal '143', rr.from.to_s
15
- assert_equal '199', rr.to.to_s
16
- assert_equal '143:199', rr.to_s
17
- end
18
-
19
- def test_to_working_copy
20
- rr = Range.new '143'
21
- assert_equal '143', rr.from.to_s
22
- assert_nil rr.to
23
- assert_equal '143', rr.to_s
24
- end
25
- end
26
- end