Skip to content

Commit

Permalink
Merge pull request #3 from blackducksw/OTWO-1412
Browse files Browse the repository at this point in the history
OTWO-1412
  • Loading branch information
amujumdar committed Mar 9, 2012
2 parents 4991eb4 + 68b9ecc commit 3b24ee8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/scm/adapters/bzr/pull.rb
Expand Up @@ -11,12 +11,28 @@ def pull(from, &block)
run "mkdir -p '#{self.url}'"
run "rm -rf '#{self.url}'"
run "bzr branch '#{from.url}' '#{self.url}'"
clean_up_disk
else
run "cd '#{self.url}' && bzr revert && bzr pull --overwrite '#{from.url}'"
end

yield(1,1) if block_given? # Progress bar callback
end

def clean_up_disk
# Usually a `bzr upgrade` is unnecessary, but it's fatal to miss it when
# required. Because I don't know how to detect in advance whether we
# actually need it, we play it safe and always upgrade.
#
# Unfortunately, not only can we not know whether it is required,
# but the command fails and raises when the upgrade is not required.

begin
run "cd '#{self.url}' && bzr upgrade"
rescue RuntimeError => e
raise unless e.message =~ /already at the most recent format/
end
end

end
end

0 comments on commit 3b24ee8

Please sign in to comment.