mercurial-ruby 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.5.0
@@ -4,7 +4,7 @@
4
4
  #
5
5
  module Mercurial
6
6
 
7
- VERSION = '0.4.0'
7
+ VERSION = '0.5.0'
8
8
 
9
9
  class Error < RuntimeError; end
10
10
 
@@ -9,9 +9,6 @@ module Mercurial
9
9
  #
10
10
  class Diff
11
11
 
12
- # Instance of {Mercurial::Commit Commit}.
13
- attr_reader :commit
14
-
15
12
  # SHA1 hash of version a of the file.
16
13
  attr_reader :hash_a
17
14
 
@@ -27,8 +24,7 @@ module Mercurial
27
24
  # Diff body.
28
25
  attr_reader :body
29
26
 
30
- def initialize(commit, opts={})
31
- @commit = commit
27
+ def initialize(opts={})
32
28
  @hash_a = opts[:hash_a]
33
29
  @hash_b = opts[:hash_b]
34
30
  @file_a = opts[:file_a]
@@ -27,15 +27,19 @@ module Mercurial
27
27
  unless chunks.nil?
28
28
  chunks.map do |piece|
29
29
  piece = "diff" << piece
30
- returning << build(commit, piece)
30
+ returning << build(piece)
31
31
  end
32
32
  end
33
33
  end
34
34
  end
35
35
 
36
+ def for_path(path, revision_a, revision_b)
37
+ build(hg(["diff ? -r ? -r ?", path, revision_a, revision_b]))
38
+ end
39
+
36
40
  private
37
41
 
38
- def build(commit, data)
42
+ def build(data)
39
43
  return if data.empty?
40
44
  hash_a, hash_b = *data.scan(/^diff -r (\w+) -r (\w+)/).first
41
45
 
@@ -48,7 +52,7 @@ module Mercurial
48
52
  body = data[data.index("\n")+1..-1]
49
53
  end
50
54
 
51
- Mercurial::Diff.new(commit,
55
+ Mercurial::Diff.new(
52
56
  :hash_a => hash_a,
53
57
  :hash_b => hash_b,
54
58
  :file_a => file_a,
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mercurial-ruby}
8
- s.version = "0.4.0"
8
+ s.version = "0.5.0"
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-09-15}
12
+ s.date = %q{2011-09-16}
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
@@ -60,7 +60,7 @@ describe Mercurial::CommitFactory do
60
60
 
61
61
  it "should count commits" do
62
62
  count = @repository.commits.count
63
- count.must_equal 36
63
+ count.must_equal 40
64
64
  end
65
65
 
66
66
  it "should iterate through commits" do
@@ -35,4 +35,44 @@ describe Mercurial::DiffFactory do
35
35
  commit.diffs.size.must_equal 0
36
36
  end
37
37
 
38
+ it "should find diffs for path" do
39
+ diff = @repository.diffs.for_path('diff-test.rb', '57a6efe309bf', '9f76ea916c51')
40
+ diff.must_be_kind_of Mercurial::Diff
41
+ diff.hash_a.must_equal '57a6efe309bf'
42
+ diff.hash_b.must_equal'9f76ea916c51'
43
+ diff.file_a.must_equal 'diff-test.rb'
44
+ diff.file_b.must_equal 'diff-test.rb'
45
+ diff.body.must_equal diff_sample
46
+ end
47
+
48
+ private
49
+
50
+ def diff_sample
51
+ %Q[--- a/diff-test.rb Thu Sep 15 23:43:02 2011 +0800
52
+ +++ b/diff-test.rb Thu Sep 15 23:43:52 2011 +0800
53
+ @@ -5,19 +5,17 @@
54
+
55
+ before_filter :repository_detected?, :except => :index
56
+ before_filter :welcome_screen, :only => :index
57
+ - before_filter :prepare_to_show, :only => [:show, :differences, :message]
58
+ before_filter :setup_page, :only => [:index, :repository]
59
+
60
+ caches_action :message, :differences
61
+
62
+ + helper_method :current_branch
63
+ helper_method :repository_scope?
64
+ - helper_method :quick_changeset
65
+ helper_method :changesets_changes_limit
66
+ - helper_method :current_branch
67
+ helper_method :diff_taking_too_much_time_msg
68
+
69
+ def repository
70
+ - if current_repository.import_in_progress?
71
+ + unless current_repository.import_in_progress?
72
+ return render(:template => "changesets/import_in_progress")
73
+ end
74
+ @changesets = find_changesets_for_current_scope
75
+ ]
76
+ end
77
+
38
78
  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 36
27
+ @file_index.count_all.must_equal 40
28
28
  end
29
29
 
30
30
  it "should count commits reachable by specific hash id" do
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: 15
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 4
8
+ - 5
9
9
  - 0
10
- version: 0.4.0
10
+ version: 0.5.0
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-09-15 00:00:00 +08:00
18
+ date: 2011-09-16 00:00:00 +08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency