pvn 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/README.markdown +3 -2
  2. data/bin/modify_timestamps.rb +31 -0
  3. data/bin/populate.rb +231 -0
  4. data/bin/quote.rb +206 -0
  5. data/lib/pvn/app.rb +4 -1
  6. data/lib/pvn/io/element.rb +9 -0
  7. data/lib/pvn/subcommands/base/command.rb +15 -15
  8. data/lib/pvn/subcommands/base/options.rb +4 -0
  9. data/lib/pvn/subcommands/diff/command.rb +46 -0
  10. data/lib/pvn/subcommands/diff/differ.rb +65 -0
  11. data/lib/pvn/subcommands/diff/local_differ.rb +103 -0
  12. data/lib/pvn/subcommands/diff/options.rb +28 -0
  13. data/lib/pvn/subcommands/diff/repository_differ.rb +145 -0
  14. data/lib/pvn/subcommands/log/command.rb +29 -11
  15. data/lib/pvn/subcommands/log/options.rb +0 -4
  16. data/lib/pvn/subcommands/pct/command.rb +10 -176
  17. data/lib/pvn/subcommands/pct/diffcount.rb +4 -2
  18. data/lib/pvn/subcommands/pct/differ.rb +34 -0
  19. data/lib/pvn/subcommands/pct/local_differ.rb +103 -0
  20. data/lib/pvn/subcommands/pct/options.rb +0 -4
  21. data/lib/pvn/subcommands/pct/repository_differ.rb +78 -0
  22. data/lib/pvn/subcommands/revision/base_option.rb +48 -0
  23. data/lib/pvn/subcommands/revision/revision_option.rb +2 -37
  24. data/lib/pvn/subcommands/status/command.rb +13 -8
  25. data/lib/pvn/subcommands/status/options.rb +0 -4
  26. data/lib/svnx/cat/command.rb +2 -0
  27. data/lib/svnx/info/entry.rb +3 -0
  28. data/lib/synoption/exception.rb +12 -0
  29. data/lib/synoption/set.rb +26 -0
  30. data/test/integration/pvn/subcommands/diff/command_test.rb +153 -0
  31. data/test/integration/svnx/log/test.rb +1 -1
  32. data/test/unit/pvn/revision/entry_test.rb +0 -13
  33. data/test/unit/svnx/info/entries_test.rb +3 -3
  34. data/test/unit/svnx/info/entry_test.rb +3 -2
  35. data/test/unit/svnx/status/entries_test.rb +1 -1
  36. data/test/unit/synoption/set_test.rb +34 -18
  37. metadata +20 -4
data/README.markdown CHANGED
@@ -10,7 +10,7 @@ everything svn does, but better. Maybe some day that will happen.
10
10
  SUMMARY
11
11
  -------
12
12
 
13
- svn [ options ] file ...
13
+ pvn [ options ] file ...
14
14
 
15
15
  FEATURES
16
16
  --------
@@ -31,7 +31,7 @@ Thus for the following list of revisions for a path:
31
31
 
32
32
  Relative revision +0 is r1049, -1 is r1947, +1 is r1143, and so on.
33
33
 
34
- **Colorized logging**. The "log" subcommand works in pvn as it does with svn,
34
+ **Colorized logging**. The *log* subcommand works in pvn as it does with svn,
35
35
  except that output is colorized, differing for the elements (file, directory) and
36
36
  the status of the element (added, deleted, changed). The logging output also
37
37
  shows the relative revision.
@@ -39,4 +39,5 @@ shows the relative revision.
39
39
  **Sorted names**. Pvn differs from Subversion in that for all subcommands, file names
40
40
  are printed in sorted order, improving legibility.
41
41
 
42
+ **Caching**. Output from some commands is cached, for speed.
42
43
 
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'rubygems'
5
+ require 'riel'
6
+
7
+ # read a Subversion dump file, modifying its dates from now - 1 hour to target date
8
+
9
+ earliest = Time.local(2009)
10
+ latest = Time.new - 3600
11
+
12
+ puts "earliest: #{earliest}"
13
+ puts "latest : #{latest}"
14
+
15
+ interval = latest.to_i - earliest.to_i
16
+
17
+ puts "interval: #{interval}"
18
+
19
+ ndates = 3
20
+
21
+ 0.upto(ndates) do |n|
22
+ time = Time.at(earliest + (interval / (1 + n)))
23
+ puts "time : #{time}"
24
+ # fake microseconds (available in Ruby 1.9, but not in 1.8)
25
+ ms = rand(1000000)
26
+ str = time.strftime "%FT%T." + sprintf("%06d", ms) + "Z"
27
+ puts "str : #{str}"
28
+ end
29
+
30
+ # svn format:
31
+ # 2011-12-25T00:18:34.971497Z
data/bin/populate.rb ADDED
@@ -0,0 +1,231 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'rubygems'
5
+ require 'riel'
6
+
7
+ Log.level = Log::DEBUG
8
+
9
+ # for diff (diffj, xmldiff):
10
+ # multiple revisions of those file types (.java, .xml)
11
+
12
+ # for pct, diff, etc.
13
+ # locally changed files
14
+ # revisions
15
+
16
+ # checkins of one file, multiple files
17
+
18
+ # add, change and delete in one checkin
19
+
20
+ class Change
21
+ def initialize user, comment, files = Hash.new
22
+
23
+ end
24
+ end
25
+
26
+
27
+ module SVN
28
+ FROMREPO = '/Programs/Subversion/Repositories/pvntestbed.from'
29
+ TOREPO = '/Programs/Subversion/Repositories/pvntestbed.to'
30
+ CHECKOUT_DIR = '/Programs/pvn'
31
+ DUMPFILE = '/tmp/pvntestbed.dump'
32
+
33
+ COMPRESSED_FILES = %w{ zip gzip tar tar.gz bz2 tar.bz2 jar }
34
+ BINARY_FILES = %w{ jpg png pdf class }
35
+ TEXT_FILES = %w{ rb rake java txt class pl pm xml html css gradle }
36
+
37
+ module ClassMethods
38
+ end
39
+
40
+ def self.included base
41
+ base.extend ClassMethods
42
+ end
43
+ end
44
+
45
+ class SVN::Base
46
+ include Loggable
47
+
48
+ def run_command *cmd
49
+ cmdstr = cmd.join(' ')
50
+ info "cmdstr: #{cmdstr}".red
51
+ # return if true
52
+
53
+ IO.popen(cmd.join(' ')) do |io|
54
+ puts io.readlines
55
+ end
56
+ end
57
+
58
+ def remove dir
59
+ pn = Pathname.new dir
60
+ if pn.exist?
61
+ dest = "/tmp/#{pn.basename}." + Time.new.to_i.to_s
62
+ info "copying #{dir} to #{dest}"
63
+ FileUtils.cp_r dir, dest
64
+
65
+ info "removing #{pn}".red
66
+ pn.rmtree if pn.exist?
67
+ end
68
+ end
69
+ end
70
+
71
+ module SVN
72
+ class Repository < Base
73
+ attr_reader :dir
74
+
75
+ def initialize dir
76
+ @dir = dir
77
+ end
78
+
79
+ def create
80
+ remove dir
81
+
82
+ run_command 'svnadmin', 'create', dir
83
+ run_command 'chgrp', 'lusers', '-R', dir
84
+ end
85
+
86
+ def dump
87
+ run_command 'svnadmin', 'dump', @dir, '>', DUMPFILE
88
+ end
89
+
90
+ def load
91
+ run_command 'svnadmin', 'load', @dir, '<', DUMPFILE
92
+ end
93
+
94
+ def checkout
95
+ remove CHECKOUT_DIR
96
+
97
+ run_command 'svn', 'co', 'file://' + @dir, CHECKOUT_DIR + '/' + Pathname.new(@dir).basename
98
+ end
99
+ end
100
+ end
101
+
102
+
103
+ class SvnRepoCreator
104
+
105
+ end
106
+
107
+ module SVN
108
+ class Populator < Base
109
+
110
+ # text files are by different versions:
111
+ # Foo.0.add.java == add
112
+ # Foo.1.mod.java == modify
113
+ # Foo.2.mod.java == modify
114
+ # Foo.3.del.java == delete
115
+
116
+ # Foo.4.add.java == add (second time)
117
+ # Foo.5.mod.java == modify
118
+ # Foo.6.chg.java == change, but do not check in
119
+
120
+ # path/to/something/Bar.txt
121
+
122
+ # Name.0.add.zip = { Foo.0.add.java, Bar.1.mod.txt, Baz.0.png }:
123
+ # change to Foo.java, Bar.txt, Baz.png
124
+ # create zipfile
125
+ # add zipfile
126
+
127
+ # Name.1.chg.zip = { Foo.1.java, Bar.3.txt, Baz.1.png }:
128
+ # change to Foo.java, Bar.txt, Baz.png
129
+ # delete zipfile
130
+ # create zipfile
131
+ # modify zipfile
132
+
133
+ USERS = [
134
+ 'Bart',
135
+ 'Jim',
136
+ 'Taggart',
137
+ 'Hedley Lamarr',
138
+ 'Lili Von Shtupp',
139
+ 'Governor William J. Lepetomane',
140
+ 'Lyle',
141
+ 'Mongo',
142
+ 'Buddy Bizarre',
143
+ 'Miss Stein'
144
+ ]
145
+
146
+ DOMAIN = 'rockridge.com'
147
+
148
+ def initialize
149
+ create_src_repo
150
+
151
+ generate
152
+
153
+ modify_dates
154
+
155
+ create_dest_repo
156
+
157
+ cleanup
158
+
159
+ # svn co 'file://' + TOREPO /Programs/pvntestbed
160
+ end
161
+
162
+ def create_src_repo
163
+ pn = Pathname.new TOREPO
164
+ pn.rmtree if pn.exist?
165
+
166
+ run_command 'svnadmin', 'create', FROMREPO
167
+ run_command 'chgrp', 'lusers', '-R', FROMREPO
168
+ end
169
+
170
+ def generate
171
+ # add subdirectories
172
+ # add files
173
+
174
+ dir = Pathname.new TMPDIR
175
+ info "dir: #{dir}".cyan
176
+ dir.rmtree if dir.exist?
177
+
178
+ run_command 'svn', 'co', 'file://' + FROMREPO, TMPDIR
179
+ Dir.chdir dir
180
+
181
+ # ln -s deleted FileToDelete.txt
182
+ end
183
+
184
+ def modify_dates
185
+ # modify dates in DUMPFILE
186
+ # start with 2011-12-10, increment randomly, not going past present date
187
+ end
188
+
189
+ def create_dest_repo
190
+ run_command 'svnadmin', 'dump', FROMREPO, '>', DUMPFILE
191
+ run_command 'svnadmin', 'create', TOREPO
192
+ run_command 'svnadmin', 'load', TOREPO, '<', DUMPFILE
193
+ end
194
+
195
+ def cleanup
196
+ pn = Pathname.new FROMREPO
197
+ info "pn: #{pn}".yellow
198
+ pn.rmtree
199
+ end
200
+
201
+ def add_file dir, fname, username, password = nil # password evidently not used.
202
+ end
203
+
204
+ def delete_file dir, fname, username
205
+ end
206
+
207
+ def change_file dir, fname, username
208
+ end
209
+ end
210
+ end
211
+
212
+ repo = nil
213
+
214
+ ARGV.each do |arg|
215
+ case arg
216
+ when "from"
217
+ repo = SVN::Repository.new SVN::FROMREPO
218
+ when "to"
219
+ repo = SVN::Repository.new SVN::TOREPO
220
+ when "create"
221
+ repo.create
222
+ when "dump"
223
+ repo.dump
224
+ when "checkout"
225
+ repo.checkout
226
+ when "load"
227
+ repo.load
228
+ else
229
+ raise "invalid argument: #{arg}"
230
+ end
231
+ end
data/bin/quote.rb ADDED
@@ -0,0 +1,206 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'rubygems'
5
+ require 'riel'
6
+
7
+ class Quotes < Hash
8
+ def initialize
9
+ super { |h, k| h[k] = Array.new }
10
+
11
+ DATA.each do |line|
12
+ line.chomp!
13
+ next if line.empty?
14
+ who, quote = line.split(':', 2)
15
+ # puts "who: #{who}"
16
+ # puts "quote: #{quote}"
17
+ self[who.strip] << quote.strip
18
+ end
19
+ end
20
+
21
+ def print_random
22
+ who, quote = get_random
23
+ puts who
24
+ puts quote
25
+ end
26
+
27
+ def get_random
28
+ who = keys.rand
29
+ puts who
30
+ [ who, self[who].rand.dup ]
31
+ end
32
+ end
33
+
34
+ quotes = Quotes.new
35
+
36
+ if false
37
+ quotes.print_random
38
+ end
39
+
40
+ if false
41
+ quotes.sort.each do |who, qtes|
42
+ printf "%4d %s\n", qtes.length, who
43
+ end
44
+ end
45
+
46
+ if false
47
+ printf "%4d %s\n", quotes.values.inject(0) { |s, n| s + n.length }, "total"
48
+ end
49
+
50
+ # as svn commit:
51
+ user, comment = quotes.get_random
52
+ comment.gsub! '"', '\\"'
53
+ comment.gsub! '!', '\\!'
54
+ if comment.length > 80
55
+ # reformat
56
+ comment.gsub! %r{(\w+.{70,90}) +}, '\1' + "\n"
57
+ end
58
+ puts "svn commit -m \"#{comment}\" --username '#{user}' ."
59
+
60
+ __END__
61
+
62
+ Lyle:Come on, boys! The way you're lollygaggin' around here with them picks and them shovels, you'd think it was a hundert an' twenty degrees!... Can't be more than a hundert an' fourteen!
63
+ Hedley Lamarr: There might be a legal precedent. Land snatching ... L-l-land. See snatch."
64
+ Hedley Lamarr: If I could find a sheriff who so offends the people of Rock Ridge that his very appearance would drive them out of town! Wherever will I find such a man? ... Why am I asking you?
65
+ Jim: No. Don't do that, don't do that. If you shoot him you'll just make him mad.
66
+ Jim: What did you expect? "Welcome, sonny"? "Make yourself at home"? "Marry my daughter"? You've got to remember that these are just simple farmers. These are people of the land. The common clay of the new West. You know ... morons.
67
+ Lili von Shtupp: Willkommen, Bienvenue, Welcome, C'mon in.
68
+ Taggart: Ah'm werkin' fer Mel Brooks!
69
+ Taggart: Le Petomane Thruway. Now what'll that asshole think of next? Does anybody got a dime? Somebody has to go back and get a shitload of dimes.
70
+ Mongo: Mongo only pawn in the game of life.
71
+ Mongo: Mongo like candy!
72
+
73
+ Bart: Are we awake?
74
+ Jim: We're not sure. Are we...black?
75
+ Bart: Yes we are.
76
+ Jim: Then we're awake. But we're very puzzled.
77
+
78
+ Bart: What's your name?
79
+ Jim: My name's Jim, but most people call me ... Jim.
80
+
81
+ Bart: Well Jim, since you are my guest and I am your host, what are your pleasures. What do you like to do?
82
+ Jim: Oh, I don't know. Play chess ...
83
+ Bart: Well, let's play chess.
84
+
85
+ Bart: By the power invested in me by the honorable William J. Le Petomane, I hereby assume the duties of sheriff in and for the township of Rock Ridge.
86
+
87
+ Dr. Johnson: Hold it men! He's not bluffing!
88
+ Dr. Samuel Johnson: Listen to him, men; he's just crazy enough to do it!
89
+ Harriet Johnson: Isn't anyone going to help that poor man?
90
+ Dr. Samuel Johnson: Hush, Harriet! That's a sure way to get him killed!
91
+ Bart: Oh, baby, you are so talented, and they so dumb!
92
+
93
+ Hedley Lamarr: My mind is aglow with whirling, transient nodes of thought careening through a cosmic vapor of invention.
94
+ Taggart: Ditto!
95
+ Hedley Lamarr: Ditto?! Ditto, you provincial putz?!
96
+
97
+ Hedley Lamarr: My mind is a raging torrent, flooded with rivulets of thought, cascading into a waterfall of creative alternatives...
98
+
99
+ Hedley Lamarr: I want rustlers, cut throats, murderers, bounty hunters, desperados, mugs, pugs, thugs, nitwits, halfwits, dimwits, vipers, snipers, con men, Indian agents, Mexican bandits, muggers, buggerers, bushwhackers, hornswogglers, horse thieves, bull dykes, train robbers, bank robbers, ass-kickers, shit-kickers, and Methodists!
100
+
101
+ Taggart: What in the Wide World of Sports is a-goin' on here? I hired you people to get some track laid ...
102
+
103
+ Buddy Bizarre: CUT! What in the hell do you think you're doing here? This is a closed set.
104
+ Buddy Bizarre: Not in the face.
105
+
106
+ Hedley Lamarr: "Head them off at the pass?" I hate that cliche!
107
+
108
+ Lyle: Don't pay no attention to that alky. He can't hold a gun, much less shoot it.
109
+
110
+ Bart: Well, don't just stand there looking stupid, grasping your hands in pain. How about a round of applause for The Waco Kid?
111
+
112
+ Hedley Lamarr: Charming. Sign right here.
113
+
114
+ Harriet Johnson: ... wish to express our extreme displeasure with your choice of sheriff. Please remove him immediately! The fact that you have sent him here just goes to prove that you are the leading asshole in the state!
115
+
116
+ Lili von Shtupp: A wed wose. How womantic.
117
+
118
+ Bart: A man drink like that and he don't eat, he is going to DIE.
119
+
120
+ Mongo: Huh-huh, naw, Mongo straight.
121
+
122
+ Hedley Lamarr: Meeting adjourned. Oh, I am sorry, sir, I didn't mean to overstep my bounds. You say that.
123
+ Governor William J. Le Petomane: It is?
124
+ Hedley Lamarr: Here, sir, play with this.
125
+
126
+ Gabby Johnson: I wash born here, an I wash raished here, and dad gum it, I am gonna die here, an no sidewindin' bushwackin', hornswagglin' cracker croaker is gonna rouin me bishen cutter.
127
+
128
+ Taggart: Dang, that was lucky. Doggone near lost a four hundred dollar handcar.
129
+
130
+ Lyle: Send wire, main office, tell them I said "ow". Gotcha!
131
+
132
+ Bart: And they was right.
133
+
134
+ Dr. Samuel Johnson: He said the sheriff's near.
135
+
136
+ Howard Johnson: As honorary chairman of the welcoming committee, it's my privilege to present a laurel and hearty handshake to our new ...
137
+
138
+ Bart: No, thank you. Fifteen is my limit on schnitzengruben.
139
+
140
+ Bart: And now, for my next impression ... Jesse Owens.
141
+
142
+
143
+ Hedley Lamarr: Men, you are about to embark on a great crusade to stamp out runaway decency in the west. Now you men will only be risking your lives, whilst I will be risking an almost certain Academy Award nomination for Best Supporting Actor.
144
+
145
+ Jim: See? In another twenty-five years, you'll be able to shake their hands in broad daylight.
146
+
147
+ Howard Johnson: Y'know, Nietzsche says: "Out of chaos comes order."
148
+
149
+ Bart: Well, raise my rent. You are The Kid.
150
+
151
+ Bart: ... to tell the family secret, my grandmother was Dutch.
152
+
153
+ Bart: All right, you caught me. To speak the plain truth, it's getting pretty damn dull around here.
154
+
155
+ Lili von Shtupp: Vhy don't you admit it? He's too much of man for you. I know. You're going to need an army to beat him! You're finished. Fertig! Verfallen! Verlumpt! Verblunget! Verkackt!
156
+
157
+ Hedley Lamarr: Elementary, cactus head.
158
+
159
+ Governor William J. Le Petomane: Ha ha... wrong person. Forgive me. No offense intended.
160
+
161
+ Buddy Bizarre: Watch me! It's so simple! Give me the playback!
162
+
163
+ Buddy Bizarre: Sounds like steam escaping.
164
+
165
+ Bart: Hey, Charlie? Let me ask you something: what is it that's not exactly water and it ain't exactly earth?
166
+
167
+ Bart: Well, can't you see that's the last act of a desperate man?
168
+
169
+ Howard Johnson: We don't care if it's the first act of "Henry V," we're leaving!
170
+
171
+ Hedley Lamarr: Alright, I'm through being Mr. Goodbar, the time has come to act and act quickly.
172
+
173
+ Governor William J. Le Petomane: We've gotta protect our phoney baloney jobs, gentlemen!
174
+
175
+ Reverend Johnson: Gentlemen, gentlemen, allow not hatred to rule the day.
176
+
177
+ Olson Johnson: Now who can argue with that? I think we're all indebted to Gabby Johnson for clearly stating what needed to be said. I'm particulary glad that these lovely children were here today to hear that speech. Not only was it authentic frontier gibberish, it expressed a courage little seen in this day and age.
178
+
179
+ Olson Johnson: What are we made of? Our fathers came across the prairies, fought Indians, fought drought, fought locusts, fought Dix... remember when Richard Dix came in here and tried to take over this town? Well, we didn't give up then, and by gum, we're not going to give up now!
180
+
181
+ Governor William J. Le Petomane: I didn't get a "harrumph" out of that guy!
182
+ Hedley Lamarr: Give the Governor harrumph!
183
+
184
+ Governor William J. Le Petomane: You watch your ass.
185
+
186
+ Reverend Johnson: O Lord, do we have the strength to carry off this mighty task in one night?
187
+
188
+ Hedley Lamarr: Ah, Haley vs. United States. Haley: 7, United States: nothing. You see, it can be done!
189
+
190
+ Hedley Lamarr: Chewing gum on line, eh? I hope you brought enough for everybody.
191
+
192
+ Jim: Boy, is he strict!
193
+
194
+ Hedley Lamarr: This is the bill that will convert the state hospital for the insane into the William J. Le Petomane memorial gambling casino for the insane.
195
+
196
+ Governor William J. Le Petomane: Gentlemen, this bill will be a giant step forward in the treatment of the insane gambler.
197
+
198
+
199
+ Hedley Lamarr: Now go do... that voodoo... that YOU do... SO WELL...!
200
+
201
+ Van Johnson: Sheriff! Mongo's back! He's breaking up the whole town! You've got to help us, please!
202
+ Bart: Did you hear that? Now it's "please". This morning, I couldn't get the time of day. Who is this Mongo, anyway?
203
+ Jim: Well, Mongo ain't exactly a "who". He's more of a "what".
204
+ Van Johnson: What he said.
205
+ Van Johnson: Oh, thank you, Sheriff! Oh, thank you very much! Thank you!
206
+ Van Johnson: The fool's going to... I mean, the sheriff's going to do it!
data/lib/pvn/app.rb CHANGED
@@ -11,9 +11,10 @@ require 'svnx/log/entries'
11
11
  require 'pvn/subcommands/log/command'
12
12
  require 'pvn/subcommands/pct/command'
13
13
  require 'pvn/subcommands/status/command'
14
+ require 'pvn/subcommands/diff/command'
14
15
 
15
16
  # the old ones:
16
- require 'pvn/diff/diffcmd'
17
+ # require 'pvn/diff/diffcmd'
17
18
  # require 'pvn/pct/pctcmd'
18
19
  require 'pvn/describe'
19
20
  require 'pvn/upp/uppcmd'
@@ -48,6 +49,8 @@ module PVN::App
48
49
  run_command PVN::Subcommands::Pct::Command, args
49
50
  when "status"
50
51
  run_command PVN::Subcommands::Status::Command, args
52
+ when "diff"
53
+ run_command PVN::Subcommands::Diff::Command, args
51
54
  else
52
55
  $stderr.puts "ERROR: subcommand not valid: #{arg}"
53
56
  exit(-1)
@@ -14,6 +14,8 @@ require 'svnx/status/entries'
14
14
  require 'svnx/info/command'
15
15
  require 'svnx/info/entries'
16
16
 
17
+ require 'svnx/cat/command'
18
+
17
19
  require 'pvn/io/fselement'
18
20
 
19
21
  module PVN; module IO; end; end
@@ -122,6 +124,13 @@ module PVN::IO
122
124
  modified
123
125
  end
124
126
 
127
+ def cat_remote rev = nil
128
+ raise "revision not yet supported: #{rev}" if rev
129
+ catargs = SVNx::CatCommandArgs.new :path => @local, :use_cache => false
130
+ cmd = SVNx::CatCommand.new catargs
131
+ cmd.execute
132
+ end
133
+
125
134
  # returns a set of local files that are in the given status
126
135
  def find_files
127
136
  end
@@ -50,21 +50,6 @@ module PVN::Subcommands::Base
50
50
  def example *ex
51
51
  getdoc.examples << ex
52
52
  end
53
-
54
- alias_method :init, :new
55
- alias_method :new_for_help, :new
56
-
57
- def new args
58
- options = optset
59
- options.process args
60
-
61
- if options.help
62
- cmd = new_for_help nil
63
- cmd.show_help
64
- else
65
- init options
66
- end
67
- end
68
53
  end
69
54
 
70
55
  def to_doc io
@@ -75,5 +60,20 @@ module PVN::Subcommands::Base
75
60
  def show_help
76
61
  to_doc $stdout
77
62
  end
63
+
64
+ def initialize args
65
+ options = self.class.optset
66
+ options.process args
67
+
68
+ if options.help
69
+ cmd.show_help
70
+ else
71
+ init options
72
+ end
73
+ end
74
+
75
+ def init options
76
+ raise "implement this to handle non-help options"
77
+ end
78
78
  end
79
79
  end
@@ -16,6 +16,10 @@ module PVN::Subcommands::Base
16
16
  end
17
17
 
18
18
  class OptionSet < PVN::OptionSet
19
+ def name
20
+ self.class.to_s.split('::')[-2].downcase
21
+ end
22
+
19
23
  def paths
20
24
  unprocessed
21
25
  end
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'pvn/io/element'
5
+ require 'pvn/subcommands/diff/options'
6
+ require 'pvn/subcommands/base/command'
7
+ require 'pvn/subcommands/diff/local_differ'
8
+ require 'pvn/subcommands/diff/repository_differ'
9
+ require 'tempfile'
10
+ require 'synoption/exception'
11
+
12
+ module PVN::Subcommands::Diff
13
+ class Command < PVN::Subcommands::Base::Command
14
+
15
+ subcommands [ "diff" ]
16
+ description "Shows the changes to files."
17
+ usage "[OPTIONS] FILE..."
18
+ summary [ "Compare two revisions, filtering through external programs.",
19
+ "For each file compared, the file extension is used to find",
20
+ "a diff program.",
21
+ "As with other pvn subcommands, 'pvn log' accepts relative ",
22
+ "revisions."
23
+ ]
24
+
25
+ optscls
26
+
27
+ example "pvn diff foo.rb", "Compares foo.rb against the last updated version."
28
+ example "pvn diff -3 StringExt.java", "Compares StringExt.java at change (HEAD - 3), using a Java-specific program such as DiffJ."
29
+ example "pvn diff -r +4 -w", "Compares the 4th revision against the working copy, ignoring whitespace."
30
+ example "pvn diff -c 1948", "Compares revision 1948 against 1947."
31
+ example "pvn diff -c -8", "Compares revision (HEAD - 8) against (HEAD - 9)."
32
+ example "pvn diff -c +7", "Compares revision (BASE + 7) against (BASE + 6)."
33
+
34
+ def init options
35
+ if options.revision && options.change
36
+ raise PVN::OptionException.new "diff does not accept both revision '#{options.revision}' and change '#{options.change}' values"
37
+ end
38
+
39
+ if options.revision || options.change
40
+ differ = RepositoryDiffer.new options
41
+ else
42
+ differ = LocalDiffer.new options
43
+ end
44
+ end
45
+ end
46
+ end