mercurial-ruby 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.0
1
+ 0.6.1
@@ -68,8 +68,8 @@ module Mercurial
68
68
  hash_id == '0'*40
69
69
  end
70
70
 
71
- def diffs
72
- repository.diffs.for_commit(self)
71
+ def diffs(cmd_options={})
72
+ repository.diffs.for_commit(self, cmd_options)
73
73
  end
74
74
 
75
75
  def parents
@@ -33,8 +33,10 @@ module Mercurial
33
33
  end
34
34
  end
35
35
 
36
- def for_path(path, revision_a, revision_b, cmd_options={})
37
- build(hg(["diff ? -r ? -r ?", path, revision_a, revision_b], cmd_options))
36
+ def for_path(path, revision_a, revision_b, options={}, cmd_options={})
37
+ cmd = "diff ? -r ? -r ?"
38
+ cmd << ' -w' if options[:ignore_whitespace]
39
+ build(hg([cmd, path, revision_a, revision_b], cmd_options))
38
40
  end
39
41
 
40
42
  private
@@ -47,8 +49,8 @@ module Mercurial
47
49
  file_a = binary_file
48
50
  body = 'Binary files differ'
49
51
  else
50
- file_a = data.scan(/^--- (?:a\/(.+)|\/dev\/null)\t/).flatten.first
51
- file_b = data.scan(/^\+\+\+ (?:b\/(.+)|\/dev\/null)\t/).flatten.first
52
+ file_a = data.scan(/^\[?--- (?:a\/([^\+]+)|\/dev\/null)-?\]?\t/).flatten.first
53
+ file_b = data.scan(/^\{?\+\+\+ (?:b\/([^\+]+)|\/dev\/null)\+?\}?\t/).flatten.first
52
54
  body = data[data.index("\n")+1..-1]
53
55
  end
54
56
 
@@ -64,4 +66,4 @@ module Mercurial
64
66
 
65
67
  end
66
68
 
67
- end
69
+ end
@@ -65,8 +65,8 @@ module Mercurial
65
65
  @_entries ||= repository.nodes.entries_for(path, revision, self)
66
66
  end
67
67
 
68
- def diff_to(revision_b)
69
- repository.diffs.for_path(path, revision, revision_b)
68
+ def diff_to(revision_b, options={})
69
+ repository.diffs.for_path(path, revision, revision_b, options)
70
70
  end
71
71
 
72
72
  def blame
@@ -105,4 +105,4 @@ module Mercurial
105
105
 
106
106
  end
107
107
 
108
- end
108
+ end
@@ -21,6 +21,11 @@ module Mercurial
21
21
 
22
22
  build << cmd
23
23
  to_run = build.join(' && ')
24
+
25
+ if pipe_cmd = options[:pipe]
26
+ to_run << " | #{ pipe_cmd }"
27
+ end
28
+
24
29
  Mercurial::Command.new(to_run, options).execute
25
30
  end
26
31
 
@@ -4,7 +4,7 @@
4
4
  #
5
5
  module Mercurial
6
6
 
7
- VERSION = '0.6.0'
7
+ VERSION = '0.6.1'
8
8
 
9
9
  class Error < RuntimeError; end
10
10
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mercurial-ruby}
8
- s.version = "0.6.0"
8
+ s.version = "0.6.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ilya Sabanin"]
12
- s.date = %q{2011-11-25}
12
+ s.date = %q{2011-12-08}
13
13
  s.description = %q{Ruby API for Mercurial DVCS.}
14
14
  s.email = %q{ilya.sabanin@gmail.com}
15
15
  s.extra_rdoc_files = [
Binary file
@@ -8,8 +8,8 @@ describe Mercurial::CommitFactory do
8
8
 
9
9
  it "should find commits after specific revision" do
10
10
  commits = @repository.commits.after('2d32410d9629')
11
- commits.size.must_equal 4
12
- commits.map(&:hash_id).must_equal %w(88b5cc7860153671b0d3aa3c16d01ecad987490e 57a6efe309bfa6c8054084de8c26490fca8a6104 f67625ea8586cd5c4d43c883a273db3ef7f38716 9f76ea916c5100bf61f533c33a6aa9f22532d526)
11
+ commits.size.must_equal 6
12
+ commits.map(&:hash_id).must_equal %w(88b5cc7860153671b0d3aa3c16d01ecad987490e 57a6efe309bfa6c8054084de8c26490fca8a6104 f67625ea8586cd5c4d43c883a273db3ef7f38716 9f76ea916c5100bf61f533c33a6aa9f22532d526 b6f6f764b939fc4be234574010247d40c683c322 e47455b9a2383085b400d649af4360b943c6d3cf)
13
13
  end
14
14
 
15
15
  it "should find commits before specific revision" do
@@ -82,7 +82,7 @@ describe Mercurial::CommitFactory do
82
82
 
83
83
  it "should count commits" do
84
84
  count = @repository.commits.count
85
- count.must_equal 40
85
+ count.must_equal 42
86
86
  end
87
87
 
88
88
  it "should count range of commits" do
@@ -5,7 +5,7 @@ describe Mercurial::DiffFactory do
5
5
  before do
6
6
  @repository = Mercurial::Repository.open(Fixtures.test_repo)
7
7
  end
8
-
8
+
9
9
  it "should find diffs for commit" do
10
10
  commit = @repository.commits.by_hash_id('54d96f4b1a26')
11
11
  diffs = @repository.diffs.for_commit(commit)
@@ -44,6 +44,11 @@ describe Mercurial::DiffFactory do
44
44
  diff.file_b.must_equal 'diff-test.rb'
45
45
  diff.body.must_equal diff_sample
46
46
  end
47
+
48
+ it "should ignore whitespace" do
49
+ diff = @repository.diffs.for_path('superman.txt', 'b6f6f764b939', 'e47455b9a238', :ignore_whitespace => true)
50
+ diff.body.must_equal diff_sample_2
51
+ end
47
52
 
48
53
  private
49
54
 
@@ -74,5 +79,16 @@ private
74
79
  @changesets = find_changesets_for_current_scope
75
80
  ]
76
81
  end
82
+
83
+ def diff_sample_2
84
+ %Q[--- a/superman.txt Thu Dec 01 15:52:30 2011 -0500
85
+ +++ b/superman.txt Thu Dec 01 15:57:43 2011 -0500
86
+ @@ -1,3 +1,3 @@
87
+
88
+ -^ whitespace change above
89
+ +^ whitespace change above and below
90
+ This is a superman file.
91
+ ]
92
+ end
77
93
 
78
- end
94
+ end
@@ -24,7 +24,7 @@ describe Mercurial::FileIndex do
24
24
  end
25
25
 
26
26
  it "should count all commits" do
27
- @file_index.count_all.must_equal 40
27
+ @file_index.count_all.must_equal 42
28
28
  end
29
29
 
30
30
  it "should count commits reachable by specific hash id" do
@@ -120,4 +120,4 @@ directory_1/specification.rb
120
120
  directory_1/tasks.rb]
121
121
  end
122
122
 
123
- end
123
+ end
data/test/test_shell.rb CHANGED
@@ -6,6 +6,10 @@ describe Mercurial::Shell do
6
6
  @repository = Mercurial::Repository.open(Fixtures.test_repo)
7
7
  @shell = @repository.shell
8
8
  end
9
+
10
+ it "should accept piping" do
11
+ assert_equal '1', @shell.hg('log', :pipe => "grep '9:0f41dd2ec166' -wc").strip
12
+ end
9
13
 
10
14
  it "should compile commands" do
11
15
  command_mock = mock('command', :execute => true)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mercurial-ruby
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 0
10
- version: 0.6.0
9
+ - 1
10
+ version: 0.6.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ilya Sabanin
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-25 00:00:00 +08:00
18
+ date: 2011-12-08 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency