public
Description: Piston is a utility that eases vendor branch management. This repository is a complete reimplementation of Piston to provide different backends, depending on the repositories and working copies you pistonize from.
Homepage: http://piston.rubyforge.org/
Clone URL: git://github.com/francois/piston.git
Search Repo:
Piston::Svn::Revision can validate itself.

An SVN revision is valid if the repository location still exists and has 
the same UUID as what we previously found.
francois (author)
Tue May 13 16:36:07 -0700 2008
commit  0d066f30f00db013c1dd0ac62b464156dc061b92
tree    9762b08026534fd007a708420adf00b4445d3a22
parent  880fa0676dd04e9530252964b17b2f1065610274
...
4
5
6
 
 
 
 
7
8
9
...
52
53
54
 
 
 
 
 
 
 
 
 
 
 
 
55
56
57
...
4
5
6
7
8
9
10
11
12
13
...
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
0
@@ -4,6 +4,10 @@
0
 module Piston
0
   module Svn
0
     class Revision < Piston::Revision
0
+ class InvalidRevision < RuntimeError; end
0
+ class RepositoryMoved < InvalidRevision; end
0
+ class UuidChanged < InvalidRevision; end
0
+
0
       def client
0
         @client ||= Piston::Svn::Client.instance
0
       end
0
@@ -52,6 +56,18 @@
0
 
0
         Pathname.new(abspath).dirname.mkpath
0
         FileUtils.cp(@wcpath + relpath, abspath)
0
+ end
0
+
0
+ def validate!
0
+ data = svn(:info, "--revision", revision, repository.url)
0
+ info = YAML.load(data)
0
+ actual_uuid = info["Repository UUID"]
0
+ raise RepositoryMoved, "Repository at #{repository.url} does not exist anymore:\n#{data}" if actual_uuid.blank?
0
+ raise UuidChanged, "Expected repository at #{repository.url} to have UUID #{recalled_uuid} but found #{actual_uuid}" if recalled_uuid != actual_uuid
0
+ end
0
+
0
+ def recalled_uuid
0
+ recalled_values[Piston::Svn::UUID]
0
       end
0
     end
0
   end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
0
@@ -1 +1,50 @@
0
+require File.dirname(__FILE__) + "/../../../test_helper"
0
+
0
+class TestSvnRevisionValidation < Test::Unit::TestCase
0
+ def setup
0
+ @repository = mock("repository")
0
+ @repository.stubs(:url).returns("svn://svn.my-repos.com/projects/libcalc/trunk")
0
+ end
0
+
0
+ def test_revision_is_invalid_unless_same_uuid
0
+ rev = new_revision("HEAD", Piston::Svn::UUID => "1234")
0
+ rev.expects(:svn).with(:info, "--revision", "HEAD", @repository.url).returns(INFO)
0
+ assert_raise Piston::Svn::Revision::UuidChanged do
0
+ rev.validate!
0
+ end
0
+ end
0
+
0
+ def test_revision_is_invalid_if_repository_location_does_not_exist_anymore
0
+ rev = new_revision("HEAD", Piston::Svn::UUID => "038cbeb6-2227-0410-91ec-8f9533625906")
0
+ rev.expects(:svn).with(:info, "--revision", "HEAD", @repository.url).returns("#{@repository.url}: (Not a valid URL)")
0
+ assert_raise Piston::Svn::Revision::RepositoryMoved do
0
+ rev.validate!
0
+ end
0
+ end
0
+
0
+ def test_revision_is_valid_if_repository_is_present_and_same_uuid
0
+ rev = new_revision("HEAD", Piston::Svn::UUID => "038cbeb6-2227-0410-91ec-8f9533625906")
0
+ rev.expects(:svn).with(:info, "--revision", "HEAD", @repository.url).returns(INFO)
0
+ assert_nothing_raised do
0
+ rev.validate!
0
+ end
0
+ end
0
+
0
+ protected
0
+ def new_revision(rev, recalled_values={})
0
+ Piston::Svn::Revision.new(@repository, rev, recalled_values)
0
+ end
0
+
0
+ INFO = <<EOF
0
+Path: project
0
+URL: svn://svn.my-repos.com/projects/libcalc/trunk
0
+Repository Root: svn://svn.my-repos.com/projects
0
+Repository UUID: 038cbeb6-2227-0410-91ec-8f9533625906
0
+Revision: 1234
0
+Node Kind: directory
0
+Last Changed Author: francois
0
+Last Changed Rev: 1232
0
+Last Changed Date: 2008-04-06 21:57:10 -0400 (Sun, 06 Apr 2008)
0
+EOF
0
+end

Comments

    No one has commented yet.