Skip to content

Commit

Permalink
Compare revisions feature
Browse files Browse the repository at this point in the history
  • Loading branch information
timcharper committed Feb 4, 2008
1 parent 4fe304b commit 6ca4f18
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ else
base = filepaths.first
end
revisions = log.choose_revision(base, "Choose revisions for #{filepaths.map{|f| SCM::Git.make_local_path(f)}.join(',')}", :multiple)
revisions = log.choose_revision(base, "Choose revisions for #{filepaths.map{|f| SCM::Git.make_local_path(f)}.join(',')}", :multiple, :sort => true)
if revisions.nil?
puts "Canceled"
Expand All @@ -39,7 +39,7 @@ end</string>
<key>keyEquivalent</key>
<string>^G</string>
<key>name</key>
<string>Diff revisions</string>
<string>Compare Revisions</string>
<key>output</key>
<string>showAsHTML</string>
<key>uuid</key>
Expand Down
2 changes: 1 addition & 1 deletion Commands/Git Resolve Conflicts.tmCommand
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ File.open(right_file, "w") { |f| f.puts right }
<key>keyEquivalent</key>
<string>^G</string>
<key>name</key>
<string>Resolve Conflicts</string>
<string>Edit Conflicts with FileMerge</string>
<key>output</key>
<string>showAsTooltip</string>
<key>uuid</key>
Expand Down
17 changes: 10 additions & 7 deletions Support/lib/commands/log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def run(fullpath = paths.first)
end

# on failure: returns nil
def choose_revision(path, prompt = "Choose a revision", number_of_revisions = 1)
def choose_revision(path, prompt = "Choose a revision", number_of_revisions = 1, options = {})
path = make_local_path(path)
# Validate file
# puts command("status", path)
Expand All @@ -88,21 +88,19 @@ def choose_revision(path, prompt = "Choose a revision", number_of_revisions = 1)
# Display progress dialog
# Show the log
revision = 0
log_data = nil

TextMate::UI.dialog(:nib => ListNib,
:center => true,
:parameters => {'title' => prompt,'entries' => [], 'hideProgressIndicator' => false}) do |dialog|

# Parse the log
plist = []
log_data = stringify(log(path, :limit => 200))
dialog.parameters = {'entries' => log_data, 'hideProgressIndicator' => true}

dialog.wait_for_input do |params|
# puts "<br/>" * 10
revision = params['returnArgument']
button_clicked = params['returnButton']
# STDERR.puts params['returnButton']
# STDERR.puts "Want:#{number_of_revisions} got:#{revision.length}"

if (button_clicked != nil) and (button_clicked == 'Cancel')
false # exit
Expand All @@ -115,12 +113,17 @@ def choose_revision(path, prompt = "Choose a revision", number_of_revisions = 1)
end
end
end

# dialog.close
end

# Return the revision number or nil
revision = nil if revision == 0
if options[:sort] && revision
time_revision_pairs = []
selected_entries = log_data.select{ |l| revision.include?(l["rev"]) }
selected_entries.sort!{ |a,b| a["date"] <=> b["date"] } # sorts them descending (latest on the bottom)
selected_entries.reverse! if options[:sort] == :asc
revision = selected_entries.map{|se| se["rev"]}
end
revision
end

Expand Down
1 change: 1 addition & 0 deletions info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<string>FF012371-E6C2-4D97-BCD2-9B6237C9BF5B</string>
<string>7F8D2058-E106-40DC-9FBE-F32A1202D158</string>
<string>E56D4990-B615-4788-A46C-5D0CDE750D56</string>
<string>E9180CC9-BA7D-4271-A0A4-0263D8A71F46</string>
<string>------------------------------------</string>
<string>7CE2C842-EBC4-443C-8DDB-3B16AC593D9A</string>
<string>9EAEC1C1-9979-4DB8-9877-A619580412AA</string>
Expand Down

0 comments on commit 6ca4f18

Please sign in to comment.