aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/migrator.rb
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/migrator.rb')
-rw-r--r--Library/Homebrew/migrator.rb39
1 files changed, 34 insertions, 5 deletions
diff --git a/Library/Homebrew/migrator.rb b/Library/Homebrew/migrator.rb
index a80cf0c59..a58ca2059 100644
--- a/Library/Homebrew/migrator.rb
+++ b/Library/Homebrew/migrator.rb
@@ -122,6 +122,13 @@ class Migrator
end
def from_same_taps?
+ new_tap = if old_tap
+ if migrate_tap = old_tap.tap_migrations[formula.oldname]
+ new_tap_user, new_tap_repo, = migrate_tap.split("/")
+ "#{new_tap_user}/#{new_tap_repo}"
+ end
+ end
+
if formula.tap == old_tap
true
# Homebrew didn't use to update tabs while performing tap-migrations,
@@ -129,7 +136,7 @@ class Migrator
# so we check if there is an entry about oldname migrated to tap and if
# newname's tap is the same as tap to which oldname migrated, then we
# can perform migrations and the taps for oldname and newname are the same.
- elsif formula.tap && old_tap && formula.tap == old_tap.tap_migrations[formula.oldname]
+ elsif formula.tap && old_tap && formula.tap == new_tap
fix_tabs
true
else
@@ -147,15 +154,25 @@ class Migrator
end
def migrate
- if new_cellar.exist?
- onoe "#{new_cellar} already exists; remove it manually and run brew migrate #{oldname}."
- return
+ if old_cellar.exist? && new_cellar.exist?
+ conflicted = false
+ old_cellar.each_child do |c|
+ if (new_cellar/c.basename).exist?
+ conflicted = true
+ onoe "#{new_cellar/c.basename} already exists."
+ end
+ end
+ if conflicted
+ onoe "Remove #{new_cellar} manually and run brew migrate #{oldname}."
+ return
+ end
end
begin
oh1 "Migrating #{Formatter.identifier(oldname)} to #{Formatter.identifier(newname)}"
lock
unlink_oldname
+ unlink_newname if new_cellar.exist?
move_to_new_directory
repin
link_oldname_cellar
@@ -178,7 +195,11 @@ class Migrator
# move everything from Cellar/oldname to Cellar/newname
def move_to_new_directory
puts "Moving to: #{new_cellar}"
- FileUtils.mv(old_cellar, new_cellar)
+ if new_cellar.exist?
+ FileUtils.mv(old_cellar.children, new_cellar)
+ else
+ FileUtils.mv(old_cellar, new_cellar)
+ end
end
def repin
@@ -207,6 +228,14 @@ class Migrator
end
end
+ def unlink_newname
+ oh1 "Unlinking #{Formatter.identifier(newname)}"
+ new_cellar.subdirs.each do |d|
+ keg = Keg.new(d)
+ keg.unlink
+ end
+ end
+
def link_newname
oh1 "Linking #{Formatter.identifier(newname)}"
new_keg = Keg.new(new_linked_keg_record)