p4tools 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
- GEM
2
- remote: https://rubygems.org/
3
- specs:
4
- P4Ruby-mingwx86 (2014.1)
5
- ffi (1.9.0-x86-mingw32)
6
- rautomation (0.14.1)
7
- ffi (= 1.9.0)
8
-
9
- PLATFORMS
10
- x86-mingw32
11
-
12
- DEPENDENCIES
13
- P4Ruby-mingwx86 (~> 2014.1)
14
- rautomation (= 0.14.1)
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ P4Ruby-mingwx86 (2014.1)
5
+ ffi (1.9.0-x86-mingw32)
6
+ rautomation (0.14.1)
7
+ ffi (= 1.9.0)
8
+
9
+ PLATFORMS
10
+ x86-mingw32
11
+
12
+ DEPENDENCIES
13
+ P4Ruby-mingwx86 (~> 2014.1)
14
+ rautomation (= 0.14.1)
data/lib/commands/move.rb CHANGED
@@ -15,7 +15,7 @@ module P4Tools
15
15
  help ''
16
16
  arg :workspace, "Name of the new workspace. If 'switch' option provided, this will be ignored.", :short => '-w', :type => :string
17
17
  arg :switch, 'Switch between workspaces, only 2 workspace name allowed.', :short => '-i', :type => :strings
18
- arg :changelist, 'Changelist number to move.', :short => '-c', :type => :int, :required => true
18
+ arg :changelists, 'Changelist numbers to move.', :short => '-c', :type => :ints, :required => true
19
19
  arg :revert, 'Revert before move.', :short => '-r'
20
20
  arg :shelve, 'Shelve before move.', :short => '-s'
21
21
  end
@@ -25,17 +25,27 @@ module P4Tools
25
25
  def initialize(args)
26
26
  @args = args
27
27
  @p4 = P4Tools.connection
28
- @changelist = @args[:changelist]
29
- @is_not_empty = !empty_changelist?(@changelist)
28
+ workspaces = @args[:switch]
29
+
30
+ if workspaces
31
+ validate_workspaces(workspaces)
32
+
33
+ @workspaces = Hash[workspaces.permutation.to_a]
34
+ end
30
35
  end
31
36
 
32
37
  def run
33
- shelve
34
- revert
38
+ @args[:changelists].each do |changelist|
39
+ @changelist = changelist
40
+ @is_not_empty = !empty_changelist?(@changelist)
35
41
 
36
- changelist_spec = @p4.fetch_change(@changelist)
37
- changelist_spec['Client'] = get_workspace(changelist_spec)
38
- @p4.save_change(changelist_spec)
42
+ shelve
43
+ revert
44
+
45
+ changelist_spec = @p4.fetch_change(@changelist)
46
+ changelist_spec['Client'] = get_workspace(changelist_spec)
47
+ @p4.save_change(changelist_spec)
48
+ end
39
49
  end
40
50
 
41
51
 
@@ -54,26 +64,25 @@ module P4Tools
54
64
  end
55
65
 
56
66
  def get_workspace(changelist_spec)
57
- if @args[:switch]
67
+ if @workspaces
58
68
  current = changelist_spec['Client']
59
- workspaces = @args[:switch]
60
-
61
- validate_workspaces(workspaces, current)
69
+ validate_current(current)
62
70
 
63
- workspaces.delete(current)
64
- workspaces.first
71
+ @workspaces[current]
65
72
  else
66
73
  @args[:workspace]
67
74
  end
68
75
  end
69
76
 
70
- def validate_workspaces(workspaces, current)
71
- if workspaces.length != 2
72
- raise(ArgumentError, 'The switch parameter need to contains 2 workspace names exactly!')
77
+ def validate_current(current_workspace)
78
+ unless @workspaces.include?(current_workspace)
79
+ raise(ArgumentError, "The switch parameter does not contains the currently active workspace: #{current_workspace}!")
73
80
  end
81
+ end
74
82
 
75
- unless workspaces.include?(current)
76
- raise(ArgumentError, "The switch parameter does not contains the currently active workspace: #{current}!")
83
+ def validate_workspaces(workspaces)
84
+ if workspaces.length != 2
85
+ raise(ArgumentError, 'The switch parameter need to contains 2 workspace names exactly!')
77
86
  end
78
87
  end
79
88
  end
@@ -5,13 +5,18 @@ module P4Tools
5
5
  parameters = []
6
6
  parameters.push('-w') if arguments[:delete_added_files]
7
7
 
8
- if arguments[:changelist]
9
- parameters.push('-c').push(arguments[:changelist]).push('//...')
8
+ if arguments[:changelists]
9
+ parameters.push('-c').push('').push('//...')
10
+
11
+ arguments[:changelists].each do |changelist|
12
+ parameters[-2] = changelist
13
+ p4.run_revert(parameters)
14
+ end
10
15
  else
11
16
  parameters.push(*arguments[:files])
17
+ p4.run_revert(parameters)
12
18
  end
13
19
 
14
- p4.run_revert(parameters)
15
20
  end
16
21
 
17
22
  def self.set_options(opts)
@@ -21,7 +26,7 @@ module P4Tools
21
26
  help 'Options:'
22
27
  help ''
23
28
  arg :delete_added_files, 'Delete added files.', :short => '-d'
24
- arg :changelist, 'Changelist number.', :short => '-c', :type => :int
29
+ arg :changelists, 'Changelist numbers.', :short => '-c', :type => :ints
25
30
  arg :files, 'The absolute path of the files to delete.', :short => '-f', :type => :strings
26
31
  end
27
32
  end
data/lib/p4_tools.rb CHANGED
@@ -3,7 +3,6 @@ require_relative 'p4tools/environment'
3
3
  require_relative 'p4tools/p4_delegate'
4
4
  require_relative 'p4tools/utils/utils'
5
5
  require_relative 'p4tools/utils/command_utils'
6
- require_relative 'p4tools/utils/window_manager'
7
6
  require_relative 'p4tools/parsers/command_parser'
8
7
  require_relative 'p4tools/parsers/trollop_custom'
9
8
  require_relative 'p4tools/parsers/command_options'
@@ -22,7 +21,6 @@ module P4Tools
22
21
 
23
22
  begin
24
23
  run_commands(entries)
25
- WindowManager.refresh if global_arguments[:refresh]
26
24
  ensure
27
25
  @p4.disconnect
28
26
  end
@@ -39,7 +37,6 @@ module P4Tools
39
37
  help ''
40
38
  help 'Global options:'
41
39
  help ''
42
- arg :refresh, 'Send a refresh keystroke(F5) to the Visual Client.', :short => '-r'
43
40
  arg :p4config, 'Absolute path of the P4CONFIG file.', :short => '-p', :type => :string
44
41
  end
45
42
  end
@@ -24,16 +24,14 @@ module P4Tools
24
24
 
25
25
  # @return [Boolean]
26
26
  def files_are_identical?
27
- if @check_diff
28
- intersection = @shelved_files & @opened_files
27
+ identical = true
29
28
 
30
- intersection.each do |file|
31
- diff = @p4.run(%W{ diff -Od #{file}@=#{@changelist} })
32
- return false unless diff.empty?
33
- end
29
+ if @check_diff
30
+ shelve_revisions = @opened_files.map { |file| file + "@=#{@changelist}" }
31
+ identical = @p4.run_diff('-Od', *shelve_revisions).empty?
34
32
  end
35
33
 
36
- true
34
+ identical
37
35
  end
38
36
  end
39
37
  end
data/p4tools.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'p4tools'
3
- gem.version = '0.1.1'
3
+ gem.version = '0.1.2'
4
4
 
5
5
  gem.author = ['Norbert Csibra']
6
6
  gem.email = 'napispam@gmail.com'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: p4tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-22 00:00:00.000000000 Z
12
+ date: 2014-04-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: P4Ruby-mingwx86
@@ -51,7 +51,6 @@ files:
51
51
  - lib/p4tools/utils/command_utils.rb
52
52
  - lib/p4tools/utils/utils.rb
53
53
  - lib/p4tools/utils/validators/shelve_validator.rb
54
- - lib/p4tools/utils/window_manager.rb
55
54
  - p4tools.gemspec
56
55
  homepage: https://github.com/ncsibra/P4Tools
57
56
  licenses: []
@@ -73,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
72
  version: '0'
74
73
  requirements: []
75
74
  rubyforge_project:
76
- rubygems_version: 1.8.28
75
+ rubygems_version: 1.8.23
77
76
  signing_key:
78
77
  specification_version: 3
79
78
  summary: Simple command line tool to run custom perforce commands.
@@ -1,18 +0,0 @@
1
- module P4Tools
2
- module WindowManager
3
- def self.refresh
4
- try_require
5
-
6
- window = RAutomation::Window.new(:title => /Perforce P4V/i)
7
- window.send_keys(:f5) if window.exist?
8
- end
9
-
10
- def self.try_require
11
- begin
12
- require 'rautomation'
13
- rescue
14
- raise(LoadError, "To use this module please install the 'rautomation' gem, version '0.14.1'. It might not work with other versions. Use command: 'gem install rautomation -v 0.14.1'")
15
- end
16
- end
17
- end
18
- end