svp 0.1.0 → 0.1.1
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.
- data/CHANGELOG +1 -1
- data/Rakefile +1 -1
- data/lib/svp/add.rb +1 -1
- data/lib/svp/cli.rb +11 -3
- data/lib/svp/delete.rb +2 -1
- data/lib/svp/modify.rb +2 -1
- data/lib/svp/p4.rb +4 -2
- data/lib/svp/version.rb +1 -1
- data/lib/svp/workspace.rb +24 -13
- metadata +3 -3
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
@@ -11,7 +11,7 @@ require File.join(File.dirname(__FILE__), 'lib', 'svp', 'version')
|
|
11
11
|
|
12
12
|
AUTHOR = "Simon Harris"
|
13
13
|
EMAIL = "support@redhillconsulting.com.au"
|
14
|
-
DESCRIPTION = "
|
14
|
+
DESCRIPTION = "SVN facade for Perforce. Supports offline diff, status, revert. Doesn't require a permanent client configuration."
|
15
15
|
HOMEPATH = 'http://svp.rubyforge.org'
|
16
16
|
BIN_FILES = %w( svp )
|
17
17
|
|
data/lib/svp/add.rb
CHANGED
data/lib/svp/cli.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'uri'
|
3
3
|
require 'yaml'
|
4
|
+
require 'svp/version'
|
4
5
|
require 'svp/workspace'
|
5
6
|
|
6
7
|
module Svp
|
@@ -10,11 +11,17 @@ module Svp
|
|
10
11
|
command = ARGV.first
|
11
12
|
args = ARGV[1..-1]
|
12
13
|
config = nil
|
14
|
+
|
15
|
+
if command == "version"
|
16
|
+
puts "svp, version #{VERSION::STRING}"
|
17
|
+
puts "Copyright (c) 2006 RedHill Consulting, Pty. Ltd. All rights reserved."
|
18
|
+
exit
|
19
|
+
end
|
13
20
|
|
14
21
|
if command == "checkout"
|
15
22
|
depot_uri = args[0]
|
16
23
|
work_dir = File.join(work_dir, args[1] || File.basename(depot_uri))
|
17
|
-
config = { "revision" => 0, "depot_uri" => depot_uri }
|
24
|
+
config = { "revision" => 0, "depot_uri" => depot_uri, "ignores" => [] }
|
18
25
|
command = "update"
|
19
26
|
end
|
20
27
|
|
@@ -23,9 +30,10 @@ module Svp
|
|
23
30
|
|
24
31
|
config = YAML::load(IO.read(config_file)) unless config
|
25
32
|
|
26
|
-
workspace = Workspace.new(URI.parse(config["depot_uri"]), work_dir, svp_dir, config["revision"])
|
27
|
-
workspace.send(command.to_sym, args)
|
33
|
+
workspace = Workspace.new(URI.parse(config["depot_uri"]), work_dir, svp_dir, config["revision"], config["ignores"])
|
34
|
+
workspace.send(command.to_sym, *args)
|
28
35
|
config["revision"] = workspace.revision
|
36
|
+
config["ignores"] = workspace.ignores
|
29
37
|
|
30
38
|
File.open(config_file, "w") { |io| YAML::dump(config, io) }
|
31
39
|
end
|
data/lib/svp/delete.rb
CHANGED
data/lib/svp/modify.rb
CHANGED
data/lib/svp/p4.rb
CHANGED
@@ -50,11 +50,13 @@ EOS
|
|
50
50
|
print command
|
51
51
|
print "<"
|
52
52
|
print input
|
53
|
-
IO.popen(command_line(command), 'r+') { |io| io.puts input; io.close_write; io.read }
|
53
|
+
output = IO.popen(command_line(command), 'r+') { |io| io.puts input; io.close_write; io.read }
|
54
54
|
else
|
55
55
|
puts command
|
56
|
-
IO.popen(command_line(command)) { |io| io.read }
|
56
|
+
output = IO.popen(command_line(command)) { |io| io.read }
|
57
57
|
end
|
58
|
+
print output
|
59
|
+
output
|
58
60
|
ensure
|
59
61
|
@success = $?.success?
|
60
62
|
end
|
data/lib/svp/version.rb
CHANGED
data/lib/svp/workspace.rb
CHANGED
@@ -6,13 +6,14 @@ require 'svp/p4'
|
|
6
6
|
|
7
7
|
module Svp
|
8
8
|
class Workspace
|
9
|
-
attr_reader :revision
|
9
|
+
attr_reader :revision, :ignores
|
10
10
|
|
11
|
-
def initialize(depot_uri, work_dir, svp_dir, revision)
|
11
|
+
def initialize(depot_uri, work_dir, svp_dir, revision, ignores)
|
12
12
|
@depot_uri = depot_uri
|
13
13
|
@work_dir = work_dir
|
14
14
|
@svp_dir = svp_dir
|
15
15
|
@revision = revision
|
16
|
+
@ignores = ignores
|
16
17
|
@base_dir = File.join(@svp_dir, "base")
|
17
18
|
|
18
19
|
FileUtils.mkdir_p(@work_dir)
|
@@ -23,9 +24,13 @@ module Svp
|
|
23
24
|
changes = changes(paths)
|
24
25
|
remote_exec do |p4|
|
25
26
|
changes.each { |change| change.prepare_to_commit(p4) }
|
26
|
-
p4.submit
|
27
|
-
|
28
|
-
|
27
|
+
if p4.submit =~ /^Change (\d+) submitted./
|
28
|
+
@revision = $1.to_i
|
29
|
+
changes.each { |change| change.commit }
|
30
|
+
puts "Committed revision #{@revision}."
|
31
|
+
else
|
32
|
+
changes.each { |change| change.rollback(p4) }
|
33
|
+
end
|
29
34
|
end
|
30
35
|
end
|
31
36
|
|
@@ -40,10 +45,15 @@ module Svp
|
|
40
45
|
changes(paths).each { |change| change.diff }
|
41
46
|
end
|
42
47
|
|
48
|
+
def ignore(*patterns)
|
49
|
+
patterns.each { |pattern| @ignores << pattern }
|
50
|
+
end
|
51
|
+
|
43
52
|
def info(*remove_me)
|
44
|
-
puts "
|
45
|
-
puts "
|
46
|
-
puts "
|
53
|
+
puts "Path: #{@work_dir}"
|
54
|
+
puts "URL: #{@depot_uri}"
|
55
|
+
puts "Revision: #{@revision}"
|
56
|
+
puts "Ignores: #{@ignores.join(', ')}"
|
47
57
|
end
|
48
58
|
|
49
59
|
def revert(*paths)
|
@@ -54,7 +64,6 @@ module Svp
|
|
54
64
|
changes(paths).each do |change|
|
55
65
|
change.status
|
56
66
|
end
|
57
|
-
puts "At revision #{@revision}."
|
58
67
|
end
|
59
68
|
|
60
69
|
def update(*remove_me)
|
@@ -64,13 +73,14 @@ module Svp
|
|
64
73
|
p4.changes("-m 1").scan(/^Change (\d+) on/) do |revision|
|
65
74
|
revision = revision.first.to_i
|
66
75
|
if @revision < revision
|
67
|
-
puts "Updating changes from revision #{@revision} to #{revision}"
|
68
76
|
p4.sync("@#{@revision.next},@#{revision}")
|
69
77
|
changes.each { |change| change.commit(p4) }
|
70
78
|
@revision = revision
|
71
79
|
end
|
72
80
|
end
|
73
81
|
end
|
82
|
+
|
83
|
+
puts "At revision #{@revision}."
|
74
84
|
end
|
75
85
|
|
76
86
|
private
|
@@ -79,13 +89,14 @@ module Svp
|
|
79
89
|
P4.execute(@depot_uri, @work_dir) { |p4| yield p4 }
|
80
90
|
end
|
81
91
|
|
82
|
-
def changes(paths
|
92
|
+
def changes(*paths)
|
93
|
+
paths = [""] if paths.empty?
|
83
94
|
changes = []
|
84
95
|
|
85
96
|
paths.each do |path|
|
86
97
|
base_path = File.expand_path(File.join(@base_dir, path))
|
87
98
|
work_path = File.expand_path(File.join(@work_dir, path))
|
88
|
-
|
99
|
+
|
89
100
|
`diff -Nqr #{base_path} #{work_path}`.each_line do |line|
|
90
101
|
next unless line =~ /^Files (.*?) and (.*?) differ$/
|
91
102
|
|
@@ -110,7 +121,7 @@ module Svp
|
|
110
121
|
end
|
111
122
|
|
112
123
|
def ignored?(file)
|
113
|
-
file =~ /^#{@svp_dir}/
|
124
|
+
file =~ /^#{@svp_dir}/ || @ignores.any? { |pattern| file =~ /^#{File.join(@work_dir, pattern)}/ }
|
114
125
|
end
|
115
126
|
end
|
116
127
|
end
|
metadata
CHANGED
@@ -3,15 +3,15 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: svp
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
6
|
+
version: 0.1.1
|
7
7
|
date: 2006-10-18 00:00:00 +10:00
|
8
|
-
summary:
|
8
|
+
summary: SVN facade for Perforce. Supports offline diff, status, revert. Doesn't require a permanent client configuration.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
11
|
email: support@redhillconsulting.com.au
|
12
12
|
homepage: http://svp.rubyforge.org
|
13
13
|
rubyforge_project:
|
14
|
-
description:
|
14
|
+
description: SVN facade for Perforce. Supports offline diff, status, revert. Doesn't require a permanent client configuration.
|
15
15
|
autorequire:
|
16
16
|
default_executable:
|
17
17
|
bindir: bin
|