Class: Repository::Migration

Inherits:
Object
  • Object
show all
Defined in:
lib/repository/migration.rb

Constant Summary collapse

Conflict =
Class.new(StandardError)
MESSAGES =
{
  :stale_file => [
    "Your local changes to the following files would be overwritten by checkout:",
    "Please commit your changes or stash them before you switch branches."
  ],
  :stale_directory => [
    "Updating the following directories would lose untracked files in them:",
    "\n"
  ],
  :untracked_overwritten => [
    "The following untracked working tree files would be overwritten by checkout:",
    "Please move or remove them before you switch branches."
  ],
  :untracked_removed => [
    "The following untracked working tree files would be removed by checkout:",
    "Please move or remove them before you switch branches."
  ]
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository, tree_diff) ⇒ Migration

Returns a new instance of Migration.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/repository/migration.rb', line 30

def initialize(repository, tree_diff)
  @repo = repository
  @diff = tree_diff

  @inspector = Inspector.new(repository)

  @changes = { :create => [], :update => [], :delete => [] }
  @mkdirs  = Set.new
  @rmdirs  = Set.new
  @errors  = []

  @conflicts = {
    :stale_file            => SortedSet.new,
    :stale_directory       => SortedSet.new,
    :untracked_overwritten => SortedSet.new,
    :untracked_removed     => SortedSet.new
  }
end

Instance Attribute Details

#changesObject (readonly)

Returns the value of attribute changes.



28
29
30
# File 'lib/repository/migration.rb', line 28

def changes
  @changes
end

#errorsObject (readonly)

Returns the value of attribute errors.



28
29
30
# File 'lib/repository/migration.rb', line 28

def errors
  @errors
end

#mkdirsObject (readonly)

Returns the value of attribute mkdirs.



28
29
30
# File 'lib/repository/migration.rb', line 28

def mkdirs
  @mkdirs
end

#rmdirsObject (readonly)

Returns the value of attribute rmdirs.



28
29
30
# File 'lib/repository/migration.rb', line 28

def rmdirs
  @rmdirs
end

Instance Method Details

#apply_changesObject



49
50
51
52
53
# File 'lib/repository/migration.rb', line 49

def apply_changes
  plan_changes
  update_workspace
  update_index
end

#blob_data(oid) ⇒ Object



55
56
57
# File 'lib/repository/migration.rb', line 55

def blob_data(oid)
  @repo.database.load(oid).data
end