Shawn O. Pearce | bd11b82 | 2006-11-19 02:57:58 -0500 | [diff] [blame] | 1 | #!/bin/sh |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 2 | # Tcl ignores the next line -*- tcl -*- \ |
Shawn O. Pearce | 4e817d1 | 2007-06-22 01:10:12 -0400 | [diff] [blame] | 3 | if test "z$*" = zversion \ |
| 4 | || test "z$*" = z--version; \ |
| 5 | then \ |
| 6 | echo 'git-gui version @@GITGUI_VERSION@@'; \ |
| 7 | exit; \ |
| 8 | fi; \ |
| 9 | exec wish "$0" -- "$@" |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 10 | |
Shawn O. Pearce | 7e81d4e | 2007-02-12 16:12:04 -0500 | [diff] [blame] | 11 | set appvers {@@GITGUI_VERSION@@} |
Shawn O. Pearce | bdc9ea2 | 2006-11-21 02:36:55 -0500 | [diff] [blame] | 12 | set copyright { |
Shawn O. Pearce | 871f4c9 | 2007-02-18 21:06:48 -0500 | [diff] [blame] | 13 | Copyright © 2006, 2007 Shawn Pearce, et. al. |
Shawn O. Pearce | bdc9ea2 | 2006-11-21 02:36:55 -0500 | [diff] [blame] | 14 | |
Shawn O. Pearce | 0499b24 | 2007-01-20 20:08:20 -0500 | [diff] [blame] | 15 | This program is free software; you can redistribute it and/or modify |
| 16 | it under the terms of the GNU General Public License as published by |
| 17 | the Free Software Foundation; either version 2 of the License, or |
| 18 | (at your option) any later version. |
Shawn O. Pearce | bdc9ea2 | 2006-11-21 02:36:55 -0500 | [diff] [blame] | 19 | |
Shawn O. Pearce | 0499b24 | 2007-01-20 20:08:20 -0500 | [diff] [blame] | 20 | This program is distributed in the hope that it will be useful, |
| 21 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 | GNU General Public License for more details. |
| 24 | |
| 25 | You should have received a copy of the GNU General Public License |
| 26 | along with this program; if not, write to the Free Software |
| 27 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA} |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 28 | |
Shawn O. Pearce | c950c66 | 2007-01-20 21:48:56 -0500 | [diff] [blame] | 29 | ###################################################################### |
| 30 | ## |
Shawn O. Pearce | cfb07cc | 2007-06-02 16:11:26 -0400 | [diff] [blame] | 31 | ## Tcl/Tk sanity check |
| 32 | |
| 33 | if {[catch {package require Tcl 8.4} err] |
| 34 | || [catch {package require Tk 8.4} err] |
| 35 | } { |
| 36 | catch {wm withdraw .} |
| 37 | tk_messageBox \ |
| 38 | -icon error \ |
| 39 | -type ok \ |
| 40 | -title "git-gui: fatal error" \ |
| 41 | -message $err |
| 42 | exit 1 |
| 43 | } |
| 44 | |
| 45 | ###################################################################### |
| 46 | ## |
Shawn O. Pearce | f522c9b | 2007-05-07 23:35:48 -0400 | [diff] [blame] | 47 | ## configure our library |
| 48 | |
| 49 | set oguilib {@@GITGUI_LIBDIR@@} |
Shawn O. Pearce | ea75ee3 | 2007-05-27 00:03:37 -0400 | [diff] [blame] | 50 | set oguirel {@@GITGUI_RELATIVE@@} |
| 51 | if {$oguirel eq {1}} { |
| 52 | set oguilib [file dirname [file dirname [file normalize $argv0]]] |
| 53 | set oguilib [file join $oguilib share git-gui lib] |
| 54 | } elseif {[string match @@* $oguirel]} { |
Shawn O. Pearce | f522c9b | 2007-05-07 23:35:48 -0400 | [diff] [blame] | 55 | set oguilib [file join [file dirname [file normalize $argv0]] lib] |
| 56 | } |
Shawn O. Pearce | b9e7efb | 2007-05-17 18:01:50 -0400 | [diff] [blame] | 57 | set idx [file join $oguilib tclIndex] |
| 58 | catch { |
| 59 | set fd [open $idx r] |
| 60 | if {[gets $fd] eq {# Autogenerated by git-gui Makefile}} { |
| 61 | set idx [list] |
| 62 | while {[gets $fd n] >= 0} { |
| 63 | if {$n ne {} && ![string match #* $n]} { |
| 64 | lappend idx $n |
| 65 | } |
| 66 | } |
| 67 | } else { |
| 68 | set idx {} |
| 69 | } |
| 70 | close $fd |
| 71 | } |
| 72 | if {$idx ne {}} { |
| 73 | set loaded [list] |
| 74 | foreach p $idx { |
| 75 | if {[lsearch -exact $loaded $p] >= 0} continue |
| 76 | puts $p |
| 77 | source [file join $oguilib $p] |
| 78 | lappend loaded $p |
| 79 | } |
| 80 | unset loaded p |
| 81 | } else { |
| 82 | set auto_path [concat [list $oguilib] $auto_path] |
| 83 | } |
Shawn O. Pearce | ea75ee3 | 2007-05-27 00:03:37 -0400 | [diff] [blame] | 84 | unset -nocomplain oguilib oguirel idx fd |
Shawn O. Pearce | f522c9b | 2007-05-07 23:35:48 -0400 | [diff] [blame] | 85 | |
| 86 | if {![catch {set _verbose $env(GITGUI_VERBOSE)}]} { |
| 87 | unset _verbose |
| 88 | rename auto_load real__auto_load |
| 89 | proc auto_load {name args} { |
| 90 | puts stderr "auto_load $name" |
| 91 | return [uplevel 1 real__auto_load $name $args] |
| 92 | } |
| 93 | rename source real__source |
| 94 | proc source {name} { |
| 95 | puts stderr "source $name" |
| 96 | uplevel 1 real__source $name |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | ###################################################################### |
| 101 | ## |
Shawn O. Pearce | c950c66 | 2007-01-20 21:48:56 -0500 | [diff] [blame] | 102 | ## read only globals |
| 103 | |
| 104 | set _appname [lindex [file split $argv0] end] |
| 105 | set _gitdir {} |
Shawn O. Pearce | 20ddfca | 2007-01-28 20:58:47 -0500 | [diff] [blame] | 106 | set _gitexec {} |
Shawn O. Pearce | c950c66 | 2007-01-20 21:48:56 -0500 | [diff] [blame] | 107 | set _reponame {} |
Shawn O. Pearce | 20ddfca | 2007-01-28 20:58:47 -0500 | [diff] [blame] | 108 | set _iscygwin {} |
Shawn O. Pearce | c950c66 | 2007-01-20 21:48:56 -0500 | [diff] [blame] | 109 | |
| 110 | proc appname {} { |
| 111 | global _appname |
| 112 | return $_appname |
| 113 | } |
| 114 | |
Shawn O. Pearce | c2758a1 | 2007-01-20 21:55:05 -0500 | [diff] [blame] | 115 | proc gitdir {args} { |
Shawn O. Pearce | c950c66 | 2007-01-20 21:48:56 -0500 | [diff] [blame] | 116 | global _gitdir |
Shawn O. Pearce | c2758a1 | 2007-01-20 21:55:05 -0500 | [diff] [blame] | 117 | if {$args eq {}} { |
| 118 | return $_gitdir |
| 119 | } |
| 120 | return [eval [concat [list file join $_gitdir] $args]] |
Shawn O. Pearce | c950c66 | 2007-01-20 21:48:56 -0500 | [diff] [blame] | 121 | } |
| 122 | |
Shawn O. Pearce | 20ddfca | 2007-01-28 20:58:47 -0500 | [diff] [blame] | 123 | proc gitexec {args} { |
| 124 | global _gitexec |
| 125 | if {$_gitexec eq {}} { |
Shawn O. Pearce | 8134722 | 2007-02-12 22:48:56 -0500 | [diff] [blame] | 126 | if {[catch {set _gitexec [git --exec-path]} err]} { |
Shawn O. Pearce | 20ddfca | 2007-01-28 20:58:47 -0500 | [diff] [blame] | 127 | error "Git not installed?\n\n$err" |
| 128 | } |
| 129 | } |
| 130 | if {$args eq {}} { |
| 131 | return $_gitexec |
| 132 | } |
| 133 | return [eval [concat [list file join $_gitexec] $args]] |
| 134 | } |
| 135 | |
Shawn O. Pearce | c950c66 | 2007-01-20 21:48:56 -0500 | [diff] [blame] | 136 | proc reponame {} { |
| 137 | global _reponame |
| 138 | return $_reponame |
| 139 | } |
Shawn O. Pearce | da5239d | 2006-11-11 19:03:06 -0500 | [diff] [blame] | 140 | |
Shawn O. Pearce | 20ddfca | 2007-01-28 20:58:47 -0500 | [diff] [blame] | 141 | proc is_MacOSX {} { |
| 142 | global tcl_platform tk_library |
| 143 | if {[tk windowingsystem] eq {aqua}} { |
| 144 | return 1 |
| 145 | } |
| 146 | return 0 |
| 147 | } |
| 148 | |
| 149 | proc is_Windows {} { |
| 150 | global tcl_platform |
| 151 | if {$tcl_platform(platform) eq {windows}} { |
| 152 | return 1 |
| 153 | } |
| 154 | return 0 |
| 155 | } |
| 156 | |
| 157 | proc is_Cygwin {} { |
| 158 | global tcl_platform _iscygwin |
| 159 | if {$_iscygwin eq {}} { |
| 160 | if {$tcl_platform(platform) eq {windows}} { |
| 161 | if {[catch {set p [exec cygpath --windir]} err]} { |
| 162 | set _iscygwin 0 |
| 163 | } else { |
| 164 | set _iscygwin 1 |
| 165 | } |
| 166 | } else { |
| 167 | set _iscygwin 0 |
| 168 | } |
| 169 | } |
| 170 | return $_iscygwin |
| 171 | } |
| 172 | |
Shawn O. Pearce | cf25ddc | 2007-02-08 18:03:41 -0500 | [diff] [blame] | 173 | proc is_enabled {option} { |
| 174 | global enabled_options |
| 175 | if {[catch {set on $enabled_options($option)}]} {return 0} |
| 176 | return $on |
| 177 | } |
| 178 | |
| 179 | proc enable_option {option} { |
| 180 | global enabled_options |
| 181 | set enabled_options($option) 1 |
| 182 | } |
| 183 | |
| 184 | proc disable_option {option} { |
| 185 | global enabled_options |
| 186 | set enabled_options($option) 0 |
| 187 | } |
| 188 | |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 189 | ###################################################################### |
| 190 | ## |
Shawn O. Pearce | 2d19516 | 2006-11-08 23:42:51 -0500 | [diff] [blame] | 191 | ## config |
| 192 | |
Shawn O. Pearce | 51f4d16 | 2006-11-12 03:47:00 -0500 | [diff] [blame] | 193 | proc is_many_config {name} { |
| 194 | switch -glob -- $name { |
| 195 | remote.*.fetch - |
| 196 | remote.*.push |
| 197 | {return 1} |
| 198 | * |
| 199 | {return 0} |
| 200 | } |
| 201 | } |
| 202 | |
Shawn O. Pearce | c539449 | 2007-01-26 04:43:43 -0500 | [diff] [blame] | 203 | proc is_config_true {name} { |
| 204 | global repo_config |
| 205 | if {[catch {set v $repo_config($name)}]} { |
| 206 | return 0 |
| 207 | } elseif {$v eq {true} || $v eq {1} || $v eq {yes}} { |
| 208 | return 1 |
| 209 | } else { |
| 210 | return 0 |
| 211 | } |
| 212 | } |
| 213 | |
Shawn O. Pearce | 6bbd1cb | 2006-11-12 16:24:52 -0500 | [diff] [blame] | 214 | proc load_config {include_global} { |
Shawn O. Pearce | 51f4d16 | 2006-11-12 03:47:00 -0500 | [diff] [blame] | 215 | global repo_config global_config default_config |
| 216 | |
| 217 | array unset global_config |
Shawn O. Pearce | 6bbd1cb | 2006-11-12 16:24:52 -0500 | [diff] [blame] | 218 | if {$include_global} { |
| 219 | catch { |
Shawn O. Pearce | df6287e | 2007-02-08 19:53:36 -0500 | [diff] [blame] | 220 | set fd_rc [open "| git config --global --list" r] |
Shawn O. Pearce | 6bbd1cb | 2006-11-12 16:24:52 -0500 | [diff] [blame] | 221 | while {[gets $fd_rc line] >= 0} { |
| 222 | if {[regexp {^([^=]+)=(.*)$} $line line name value]} { |
| 223 | if {[is_many_config $name]} { |
| 224 | lappend global_config($name) $value |
| 225 | } else { |
| 226 | set global_config($name) $value |
| 227 | } |
Shawn O. Pearce | 51f4d16 | 2006-11-12 03:47:00 -0500 | [diff] [blame] | 228 | } |
| 229 | } |
Shawn O. Pearce | 6bbd1cb | 2006-11-12 16:24:52 -0500 | [diff] [blame] | 230 | close $fd_rc |
Shawn O. Pearce | 51f4d16 | 2006-11-12 03:47:00 -0500 | [diff] [blame] | 231 | } |
Shawn O. Pearce | 51f4d16 | 2006-11-12 03:47:00 -0500 | [diff] [blame] | 232 | } |
Shawn O. Pearce | 6bbd1cb | 2006-11-12 16:24:52 -0500 | [diff] [blame] | 233 | |
| 234 | array unset repo_config |
Shawn O. Pearce | 51f4d16 | 2006-11-12 03:47:00 -0500 | [diff] [blame] | 235 | catch { |
Shawn O. Pearce | df6287e | 2007-02-08 19:53:36 -0500 | [diff] [blame] | 236 | set fd_rc [open "| git config --list" r] |
Shawn O. Pearce | 2d19516 | 2006-11-08 23:42:51 -0500 | [diff] [blame] | 237 | while {[gets $fd_rc line] >= 0} { |
| 238 | if {[regexp {^([^=]+)=(.*)$} $line line name value]} { |
Shawn O. Pearce | 51f4d16 | 2006-11-12 03:47:00 -0500 | [diff] [blame] | 239 | if {[is_many_config $name]} { |
| 240 | lappend repo_config($name) $value |
| 241 | } else { |
| 242 | set repo_config($name) $value |
| 243 | } |
Shawn O. Pearce | 2d19516 | 2006-11-08 23:42:51 -0500 | [diff] [blame] | 244 | } |
| 245 | } |
| 246 | close $fd_rc |
| 247 | } |
| 248 | |
Shawn O. Pearce | 51f4d16 | 2006-11-12 03:47:00 -0500 | [diff] [blame] | 249 | foreach name [array names default_config] { |
| 250 | if {[catch {set v $global_config($name)}]} { |
| 251 | set global_config($name) $default_config($name) |
| 252 | } |
| 253 | if {[catch {set v $repo_config($name)}]} { |
| 254 | set repo_config($name) $default_config($name) |
| 255 | } |
Shawn O. Pearce | 2d19516 | 2006-11-08 23:42:51 -0500 | [diff] [blame] | 256 | } |
| 257 | } |
| 258 | |
Shawn O. Pearce | 8134722 | 2007-02-12 22:48:56 -0500 | [diff] [blame] | 259 | ###################################################################### |
| 260 | ## |
| 261 | ## handy utils |
| 262 | |
| 263 | proc git {args} { |
| 264 | return [eval exec git $args] |
| 265 | } |
| 266 | |
Shawn O. Pearce | 2739291 | 2007-04-28 22:00:02 -0400 | [diff] [blame] | 267 | auto_load tk_optionMenu |
| 268 | rename tk_optionMenu real__tkOptionMenu |
| 269 | proc tk_optionMenu {w varName args} { |
| 270 | set m [eval real__tkOptionMenu $w $varName $args] |
| 271 | $m configure -font font_ui |
| 272 | $w configure -font font_ui |
| 273 | return $m |
| 274 | } |
| 275 | |
Shawn O. Pearce | 2d19516 | 2006-11-08 23:42:51 -0500 | [diff] [blame] | 276 | ###################################################################### |
| 277 | ## |
Shawn O. Pearce | 54acdd9 | 2007-02-13 23:15:25 -0500 | [diff] [blame] | 278 | ## version check |
| 279 | |
| 280 | set req_maj 1 |
| 281 | set req_min 5 |
| 282 | |
| 283 | if {[catch {set v [git --version]} err]} { |
| 284 | catch {wm withdraw .} |
| 285 | error_popup "Cannot determine Git version: |
| 286 | |
| 287 | $err |
| 288 | |
| 289 | [appname] requires Git $req_maj.$req_min or later." |
| 290 | exit 1 |
| 291 | } |
| 292 | if {[regexp {^git version (\d+)\.(\d+)} $v _junk act_maj act_min]} { |
| 293 | if {$act_maj < $req_maj |
| 294 | || ($act_maj == $req_maj && $act_min < $req_min)} { |
| 295 | catch {wm withdraw .} |
| 296 | error_popup "[appname] requires Git $req_maj.$req_min or later. |
| 297 | |
| 298 | You are using $v." |
| 299 | exit 1 |
| 300 | } |
| 301 | } else { |
| 302 | catch {wm withdraw .} |
| 303 | error_popup "Cannot parse Git version string:\n\n$v" |
| 304 | exit 1 |
| 305 | } |
| 306 | unset -nocomplain v _junk act_maj act_min req_maj req_min |
| 307 | |
| 308 | ###################################################################### |
| 309 | ## |
Shawn O. Pearce | 2d19516 | 2006-11-08 23:42:51 -0500 | [diff] [blame] | 310 | ## repository setup |
| 311 | |
Shawn O. Pearce | c612785 | 2007-05-08 21:58:25 -0400 | [diff] [blame] | 312 | if {[catch { |
| 313 | set _gitdir $env(GIT_DIR) |
| 314 | set _prefix {} |
| 315 | }] |
| 316 | && [catch { |
| 317 | set _gitdir [git rev-parse --git-dir] |
| 318 | set _prefix [git rev-parse --show-prefix] |
| 319 | } err]} { |
Shawn O. Pearce | 44be340 | 2006-11-11 19:10:10 -0500 | [diff] [blame] | 320 | catch {wm withdraw .} |
| 321 | error_popup "Cannot find the git directory:\n\n$err" |
Shawn O. Pearce | 2d19516 | 2006-11-08 23:42:51 -0500 | [diff] [blame] | 322 | exit 1 |
| 323 | } |
Shawn O. Pearce | 20ddfca | 2007-01-28 20:58:47 -0500 | [diff] [blame] | 324 | if {![file isdirectory $_gitdir] && [is_Cygwin]} { |
| 325 | catch {set _gitdir [exec cygpath --unix $_gitdir]} |
| 326 | } |
Shawn O. Pearce | c950c66 | 2007-01-20 21:48:56 -0500 | [diff] [blame] | 327 | if {![file isdirectory $_gitdir]} { |
Shawn O. Pearce | dbccbbd | 2006-11-15 22:45:33 -0500 | [diff] [blame] | 328 | catch {wm withdraw .} |
Shawn O. Pearce | c950c66 | 2007-01-20 21:48:56 -0500 | [diff] [blame] | 329 | error_popup "Git directory not found:\n\n$_gitdir" |
Shawn O. Pearce | dbccbbd | 2006-11-15 22:45:33 -0500 | [diff] [blame] | 330 | exit 1 |
| 331 | } |
Shawn O. Pearce | c950c66 | 2007-01-20 21:48:56 -0500 | [diff] [blame] | 332 | if {[lindex [file split $_gitdir] end] ne {.git}} { |
Shawn O. Pearce | dbccbbd | 2006-11-15 22:45:33 -0500 | [diff] [blame] | 333 | catch {wm withdraw .} |
Shawn O. Pearce | 20ddfca | 2007-01-28 20:58:47 -0500 | [diff] [blame] | 334 | error_popup "Cannot use funny .git directory:\n\n$_gitdir" |
Shawn O. Pearce | dbccbbd | 2006-11-15 22:45:33 -0500 | [diff] [blame] | 335 | exit 1 |
| 336 | } |
Shawn O. Pearce | c950c66 | 2007-01-20 21:48:56 -0500 | [diff] [blame] | 337 | if {[catch {cd [file dirname $_gitdir]} err]} { |
Shawn O. Pearce | fbee850 | 2006-11-15 22:13:45 -0500 | [diff] [blame] | 338 | catch {wm withdraw .} |
Shawn O. Pearce | c950c66 | 2007-01-20 21:48:56 -0500 | [diff] [blame] | 339 | error_popup "No working directory [file dirname $_gitdir]:\n\n$err" |
Shawn O. Pearce | fbee850 | 2006-11-15 22:13:45 -0500 | [diff] [blame] | 340 | exit 1 |
Shawn O. Pearce | 2d19516 | 2006-11-08 23:42:51 -0500 | [diff] [blame] | 341 | } |
Shawn O. Pearce | c950c66 | 2007-01-20 21:48:56 -0500 | [diff] [blame] | 342 | set _reponame [lindex [file split \ |
| 343 | [file normalize [file dirname $_gitdir]]] \ |
Shawn O. Pearce | 16d18b8 | 2007-01-20 21:36:21 -0500 | [diff] [blame] | 344 | end] |
Shawn O. Pearce | 2d19516 | 2006-11-08 23:42:51 -0500 | [diff] [blame] | 345 | |
Shawn O. Pearce | 2d19516 | 2006-11-08 23:42:51 -0500 | [diff] [blame] | 346 | ###################################################################### |
| 347 | ## |
Shawn O. Pearce | 372ef95 | 2007-02-18 02:12:32 -0500 | [diff] [blame] | 348 | ## global init |
| 349 | |
| 350 | set current_diff_path {} |
| 351 | set current_diff_side {} |
| 352 | set diff_actions [list] |
| 353 | set ui_status_value {Initializing...} |
| 354 | |
| 355 | set HEAD {} |
| 356 | set PARENT {} |
| 357 | set MERGE_HEAD [list] |
| 358 | set commit_type {} |
| 359 | set empty_tree {} |
| 360 | set current_branch {} |
| 361 | set current_diff_path {} |
| 362 | set selected_commit_type new |
| 363 | |
| 364 | ###################################################################### |
| 365 | ## |
Shawn O. Pearce | e210e67 | 2006-11-06 19:12:58 -0500 | [diff] [blame] | 366 | ## task management |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 367 | |
Shawn O. Pearce | 8f52548 | 2006-11-14 01:29:32 -0500 | [diff] [blame] | 368 | set rescan_active 0 |
Shawn O. Pearce | 131f503 | 2006-11-06 16:07:32 -0500 | [diff] [blame] | 369 | set diff_active 0 |
Shawn O. Pearce | 24263b7 | 2006-11-13 16:06:38 -0500 | [diff] [blame] | 370 | set last_clicked {} |
Shawn O. Pearce | 131f503 | 2006-11-06 16:07:32 -0500 | [diff] [blame] | 371 | |
Shawn O. Pearce | e210e67 | 2006-11-06 19:12:58 -0500 | [diff] [blame] | 372 | set disable_on_lock [list] |
| 373 | set index_lock_type none |
Shawn O. Pearce | 131f503 | 2006-11-06 16:07:32 -0500 | [diff] [blame] | 374 | |
Shawn O. Pearce | e210e67 | 2006-11-06 19:12:58 -0500 | [diff] [blame] | 375 | proc lock_index {type} { |
| 376 | global index_lock_type disable_on_lock |
| 377 | |
Shawn O. Pearce | 043f701 | 2006-11-12 18:16:45 -0500 | [diff] [blame] | 378 | if {$index_lock_type eq {none}} { |
Shawn O. Pearce | e210e67 | 2006-11-06 19:12:58 -0500 | [diff] [blame] | 379 | set index_lock_type $type |
| 380 | foreach w $disable_on_lock { |
| 381 | uplevel #0 $w disabled |
| 382 | } |
| 383 | return 1 |
Shawn O. Pearce | 53716a7 | 2006-11-18 03:31:25 -0500 | [diff] [blame] | 384 | } elseif {$index_lock_type eq "begin-$type"} { |
Shawn O. Pearce | e210e67 | 2006-11-06 19:12:58 -0500 | [diff] [blame] | 385 | set index_lock_type $type |
Shawn O. Pearce | 131f503 | 2006-11-06 16:07:32 -0500 | [diff] [blame] | 386 | return 1 |
| 387 | } |
| 388 | return 0 |
| 389 | } |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 390 | |
Shawn O. Pearce | e210e67 | 2006-11-06 19:12:58 -0500 | [diff] [blame] | 391 | proc unlock_index {} { |
| 392 | global index_lock_type disable_on_lock |
| 393 | |
| 394 | set index_lock_type none |
| 395 | foreach w $disable_on_lock { |
| 396 | uplevel #0 $w normal |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | ###################################################################### |
| 401 | ## |
| 402 | ## status |
| 403 | |
Shawn O. Pearce | f18e40a | 2006-11-20 21:27:22 -0500 | [diff] [blame] | 404 | proc repository_state {ctvar hdvar mhvar} { |
Shawn O. Pearce | c950c66 | 2007-01-20 21:48:56 -0500 | [diff] [blame] | 405 | global current_branch |
Shawn O. Pearce | f18e40a | 2006-11-20 21:27:22 -0500 | [diff] [blame] | 406 | upvar $ctvar ct $hdvar hd $mhvar mh |
| 407 | |
| 408 | set mh [list] |
Shawn O. Pearce | ec6b424 | 2006-11-06 20:50:59 -0500 | [diff] [blame] | 409 | |
Shawn O. Pearce | 8134722 | 2007-02-12 22:48:56 -0500 | [diff] [blame] | 410 | if {[catch {set current_branch [git symbolic-ref HEAD]}]} { |
Shawn O. Pearce | 8553b77 | 2006-11-24 15:38:18 -0500 | [diff] [blame] | 411 | set current_branch {} |
| 412 | } else { |
Shawn O. Pearce | d90d83a | 2006-11-25 02:45:19 -0500 | [diff] [blame] | 413 | regsub ^refs/((heads|tags|remotes)/)? \ |
Shawn O. Pearce | 8553b77 | 2006-11-24 15:38:18 -0500 | [diff] [blame] | 414 | $current_branch \ |
| 415 | {} \ |
| 416 | current_branch |
| 417 | } |
| 418 | |
Shawn O. Pearce | 8134722 | 2007-02-12 22:48:56 -0500 | [diff] [blame] | 419 | if {[catch {set hd [git rev-parse --verify HEAD]}]} { |
Shawn O. Pearce | 4539eac | 2006-11-18 02:50:58 -0500 | [diff] [blame] | 420 | set hd {} |
Shawn O. Pearce | ec6b424 | 2006-11-06 20:50:59 -0500 | [diff] [blame] | 421 | set ct initial |
Shawn O. Pearce | f18e40a | 2006-11-20 21:27:22 -0500 | [diff] [blame] | 422 | return |
Shawn O. Pearce | ec6b424 | 2006-11-06 20:50:59 -0500 | [diff] [blame] | 423 | } |
Shawn O. Pearce | f18e40a | 2006-11-20 21:27:22 -0500 | [diff] [blame] | 424 | |
Shawn O. Pearce | c2758a1 | 2007-01-20 21:55:05 -0500 | [diff] [blame] | 425 | set merge_head [gitdir MERGE_HEAD] |
Shawn O. Pearce | f18e40a | 2006-11-20 21:27:22 -0500 | [diff] [blame] | 426 | if {[file exists $merge_head]} { |
| 427 | set ct merge |
| 428 | set fd_mh [open $merge_head r] |
| 429 | while {[gets $fd_mh line] >= 0} { |
| 430 | lappend mh $line |
| 431 | } |
| 432 | close $fd_mh |
| 433 | return |
| 434 | } |
| 435 | |
| 436 | set ct normal |
Shawn O. Pearce | ec6b424 | 2006-11-06 20:50:59 -0500 | [diff] [blame] | 437 | } |
| 438 | |
Shawn O. Pearce | 4539eac | 2006-11-18 02:50:58 -0500 | [diff] [blame] | 439 | proc PARENT {} { |
| 440 | global PARENT empty_tree |
| 441 | |
Shawn O. Pearce | f18e40a | 2006-11-20 21:27:22 -0500 | [diff] [blame] | 442 | set p [lindex $PARENT 0] |
| 443 | if {$p ne {}} { |
| 444 | return $p |
Shawn O. Pearce | 4539eac | 2006-11-18 02:50:58 -0500 | [diff] [blame] | 445 | } |
| 446 | if {$empty_tree eq {}} { |
Shawn O. Pearce | 8134722 | 2007-02-12 22:48:56 -0500 | [diff] [blame] | 447 | set empty_tree [git mktree << {}] |
Shawn O. Pearce | 4539eac | 2006-11-18 02:50:58 -0500 | [diff] [blame] | 448 | } |
| 449 | return $empty_tree |
| 450 | } |
| 451 | |
Shawn O. Pearce | 46aaf90 | 2007-01-22 17:10:38 -0500 | [diff] [blame] | 452 | proc rescan {after {honor_trustmtime 1}} { |
Shawn O. Pearce | f18e40a | 2006-11-20 21:27:22 -0500 | [diff] [blame] | 453 | global HEAD PARENT MERGE_HEAD commit_type |
Shawn O. Pearce | 0812665 | 2007-01-20 22:06:51 -0500 | [diff] [blame] | 454 | global ui_index ui_workdir ui_status_value ui_comm |
Shawn O. Pearce | 8f52548 | 2006-11-14 01:29:32 -0500 | [diff] [blame] | 455 | global rescan_active file_states |
Shawn O. Pearce | cf25ddc | 2007-02-08 18:03:41 -0500 | [diff] [blame] | 456 | global repo_config |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 457 | |
Shawn O. Pearce | 8f52548 | 2006-11-14 01:29:32 -0500 | [diff] [blame] | 458 | if {$rescan_active > 0 || ![lock_index read]} return |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 459 | |
Shawn O. Pearce | f18e40a | 2006-11-20 21:27:22 -0500 | [diff] [blame] | 460 | repository_state newType newHEAD newMERGE_HEAD |
Shawn O. Pearce | 4539eac | 2006-11-18 02:50:58 -0500 | [diff] [blame] | 461 | if {[string match amend* $commit_type] |
Shawn O. Pearce | f18e40a | 2006-11-20 21:27:22 -0500 | [diff] [blame] | 462 | && $newType eq {normal} |
| 463 | && $newHEAD eq $HEAD} { |
Shawn O. Pearce | e57ca85 | 2006-11-06 21:34:10 -0500 | [diff] [blame] | 464 | } else { |
Shawn O. Pearce | f18e40a | 2006-11-20 21:27:22 -0500 | [diff] [blame] | 465 | set HEAD $newHEAD |
| 466 | set PARENT $newHEAD |
| 467 | set MERGE_HEAD $newMERGE_HEAD |
| 468 | set commit_type $newType |
Shawn O. Pearce | e57ca85 | 2006-11-06 21:34:10 -0500 | [diff] [blame] | 469 | } |
| 470 | |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 471 | array unset file_states |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 472 | |
Shawn O. Pearce | 131f503 | 2006-11-06 16:07:32 -0500 | [diff] [blame] | 473 | if {![$ui_comm edit modified] |
Shawn O. Pearce | 043f701 | 2006-11-12 18:16:45 -0500 | [diff] [blame] | 474 | || [string trim [$ui_comm get 0.0 end]] eq {}} { |
Shawn O. Pearce | b2f3bb1 | 2007-06-11 19:39:55 -0400 | [diff] [blame] | 475 | if {[string match amend* $commit_type]} { |
| 476 | } elseif {[load_message GITGUI_MSG]} { |
Shawn O. Pearce | 131f503 | 2006-11-06 16:07:32 -0500 | [diff] [blame] | 477 | } elseif {[load_message MERGE_MSG]} { |
| 478 | } elseif {[load_message SQUASH_MSG]} { |
| 479 | } |
Shawn O. Pearce | b2c6fcf | 2006-11-11 16:16:25 -0500 | [diff] [blame] | 480 | $ui_comm edit reset |
Shawn O. Pearce | 21d7744 | 2006-11-20 21:59:19 -0500 | [diff] [blame] | 481 | $ui_comm edit modified false |
Shawn O. Pearce | 131f503 | 2006-11-06 16:07:32 -0500 | [diff] [blame] | 482 | } |
| 483 | |
Shawn O. Pearce | 64a906f | 2007-02-08 18:10:05 -0500 | [diff] [blame] | 484 | if {[is_enabled branch]} { |
Shawn O. Pearce | 63faf4d | 2007-02-08 15:59:39 -0500 | [diff] [blame] | 485 | load_all_heads |
| 486 | populate_branch_menu |
| 487 | } |
| 488 | |
Shawn O. Pearce | 46aaf90 | 2007-01-22 17:10:38 -0500 | [diff] [blame] | 489 | if {$honor_trustmtime && $repo_config(gui.trustmtime) eq {true}} { |
Shawn O. Pearce | 8f52548 | 2006-11-14 01:29:32 -0500 | [diff] [blame] | 490 | rescan_stage2 {} $after |
Shawn O. Pearce | e534f3a | 2006-11-07 21:27:29 -0500 | [diff] [blame] | 491 | } else { |
Shawn O. Pearce | 8f52548 | 2006-11-14 01:29:32 -0500 | [diff] [blame] | 492 | set rescan_active 1 |
Shawn O. Pearce | e534f3a | 2006-11-07 21:27:29 -0500 | [diff] [blame] | 493 | set ui_status_value {Refreshing file status...} |
Shawn O. Pearce | 16403d0 | 2006-11-11 21:52:06 -0500 | [diff] [blame] | 494 | set cmd [list git update-index] |
| 495 | lappend cmd -q |
| 496 | lappend cmd --unmerged |
| 497 | lappend cmd --ignore-missing |
| 498 | lappend cmd --refresh |
| 499 | set fd_rf [open "| $cmd" r] |
Shawn O. Pearce | e534f3a | 2006-11-07 21:27:29 -0500 | [diff] [blame] | 500 | fconfigure $fd_rf -blocking 0 -translation binary |
Shawn O. Pearce | 390adae | 2006-11-11 19:40:33 -0500 | [diff] [blame] | 501 | fileevent $fd_rf readable \ |
Shawn O. Pearce | 8f52548 | 2006-11-14 01:29:32 -0500 | [diff] [blame] | 502 | [list rescan_stage2 $fd_rf $after] |
Shawn O. Pearce | e534f3a | 2006-11-07 21:27:29 -0500 | [diff] [blame] | 503 | } |
Shawn O. Pearce | 131f503 | 2006-11-06 16:07:32 -0500 | [diff] [blame] | 504 | } |
| 505 | |
Shawn O. Pearce | 8f52548 | 2006-11-14 01:29:32 -0500 | [diff] [blame] | 506 | proc rescan_stage2 {fd after} { |
Shawn O. Pearce | c950c66 | 2007-01-20 21:48:56 -0500 | [diff] [blame] | 507 | global ui_status_value |
Shawn O. Pearce | 4539eac | 2006-11-18 02:50:58 -0500 | [diff] [blame] | 508 | global rescan_active buf_rdi buf_rdf buf_rlo |
Shawn O. Pearce | 131f503 | 2006-11-06 16:07:32 -0500 | [diff] [blame] | 509 | |
Shawn O. Pearce | 043f701 | 2006-11-12 18:16:45 -0500 | [diff] [blame] | 510 | if {$fd ne {}} { |
Shawn O. Pearce | e534f3a | 2006-11-07 21:27:29 -0500 | [diff] [blame] | 511 | read $fd |
| 512 | if {![eof $fd]} return |
| 513 | close $fd |
| 514 | } |
Shawn O. Pearce | 131f503 | 2006-11-06 16:07:32 -0500 | [diff] [blame] | 515 | |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 516 | set ls_others [list | git ls-files --others -z \ |
| 517 | --exclude-per-directory=.gitignore] |
Shawn O. Pearce | c2758a1 | 2007-01-20 21:55:05 -0500 | [diff] [blame] | 518 | set info_exclude [gitdir info exclude] |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 519 | if {[file readable $info_exclude]} { |
| 520 | lappend ls_others "--exclude-from=$info_exclude" |
| 521 | } |
| 522 | |
Shawn O. Pearce | 868c875 | 2006-11-07 18:34:09 -0500 | [diff] [blame] | 523 | set buf_rdi {} |
| 524 | set buf_rdf {} |
| 525 | set buf_rlo {} |
| 526 | |
Shawn O. Pearce | 8f52548 | 2006-11-14 01:29:32 -0500 | [diff] [blame] | 527 | set rescan_active 3 |
Shawn O. Pearce | 131f503 | 2006-11-06 16:07:32 -0500 | [diff] [blame] | 528 | set ui_status_value {Scanning for modified files ...} |
Shawn O. Pearce | 4539eac | 2006-11-18 02:50:58 -0500 | [diff] [blame] | 529 | set fd_di [open "| git diff-index --cached -z [PARENT]" r] |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 530 | set fd_df [open "| git diff-files -z" r] |
| 531 | set fd_lo [open $ls_others r] |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 532 | |
Shawn O. Pearce | 51a989b | 2007-01-23 04:07:18 -0500 | [diff] [blame] | 533 | fconfigure $fd_di -blocking 0 -translation binary -encoding binary |
| 534 | fconfigure $fd_df -blocking 0 -translation binary -encoding binary |
| 535 | fconfigure $fd_lo -blocking 0 -translation binary -encoding binary |
Shawn O. Pearce | 8f52548 | 2006-11-14 01:29:32 -0500 | [diff] [blame] | 536 | fileevent $fd_di readable [list read_diff_index $fd_di $after] |
| 537 | fileevent $fd_df readable [list read_diff_files $fd_df $after] |
| 538 | fileevent $fd_lo readable [list read_ls_others $fd_lo $after] |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 539 | } |
| 540 | |
Shawn O. Pearce | 131f503 | 2006-11-06 16:07:32 -0500 | [diff] [blame] | 541 | proc load_message {file} { |
Shawn O. Pearce | c950c66 | 2007-01-20 21:48:56 -0500 | [diff] [blame] | 542 | global ui_comm |
Shawn O. Pearce | 131f503 | 2006-11-06 16:07:32 -0500 | [diff] [blame] | 543 | |
Shawn O. Pearce | c2758a1 | 2007-01-20 21:55:05 -0500 | [diff] [blame] | 544 | set f [gitdir $file] |
Shawn O. Pearce | e57ca85 | 2006-11-06 21:34:10 -0500 | [diff] [blame] | 545 | if {[file isfile $f]} { |
Shawn O. Pearce | 131f503 | 2006-11-06 16:07:32 -0500 | [diff] [blame] | 546 | if {[catch {set fd [open $f r]}]} { |
| 547 | return 0 |
| 548 | } |
Shawn O. Pearce | e57ca85 | 2006-11-06 21:34:10 -0500 | [diff] [blame] | 549 | set content [string trim [read $fd]] |
Shawn O. Pearce | 131f503 | 2006-11-06 16:07:32 -0500 | [diff] [blame] | 550 | close $fd |
Shawn O. Pearce | 4e55d19 | 2007-01-25 12:54:59 -0500 | [diff] [blame] | 551 | regsub -all -line {[ \r\t]+$} $content {} content |
Shawn O. Pearce | 131f503 | 2006-11-06 16:07:32 -0500 | [diff] [blame] | 552 | $ui_comm delete 0.0 end |
| 553 | $ui_comm insert end $content |
| 554 | return 1 |
| 555 | } |
| 556 | return 0 |
| 557 | } |
| 558 | |
Shawn O. Pearce | 8f52548 | 2006-11-14 01:29:32 -0500 | [diff] [blame] | 559 | proc read_diff_index {fd after} { |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 560 | global buf_rdi |
| 561 | |
| 562 | append buf_rdi [read $fd] |
Shawn O. Pearce | 868c875 | 2006-11-07 18:34:09 -0500 | [diff] [blame] | 563 | set c 0 |
| 564 | set n [string length $buf_rdi] |
| 565 | while {$c < $n} { |
| 566 | set z1 [string first "\0" $buf_rdi $c] |
| 567 | if {$z1 == -1} break |
| 568 | incr z1 |
| 569 | set z2 [string first "\0" $buf_rdi $z1] |
| 570 | if {$z2 == -1} break |
| 571 | |
Shawn O. Pearce | 868c875 | 2006-11-07 18:34:09 -0500 | [diff] [blame] | 572 | incr c |
Shawn O. Pearce | 8629155 | 2006-11-19 01:00:48 -0500 | [diff] [blame] | 573 | set i [split [string range $buf_rdi $c [expr {$z1 - 2}]] { }] |
Shawn O. Pearce | 51a989b | 2007-01-23 04:07:18 -0500 | [diff] [blame] | 574 | set p [string range $buf_rdi $z1 [expr {$z2 - 1}]] |
Shawn O. Pearce | 1461c5f | 2006-11-19 00:29:55 -0500 | [diff] [blame] | 575 | merge_state \ |
Shawn O. Pearce | 51a989b | 2007-01-23 04:07:18 -0500 | [diff] [blame] | 576 | [encoding convertfrom $p] \ |
Shawn O. Pearce | 8629155 | 2006-11-19 01:00:48 -0500 | [diff] [blame] | 577 | [lindex $i 4]? \ |
| 578 | [list [lindex $i 0] [lindex $i 2]] \ |
Shawn O. Pearce | 1461c5f | 2006-11-19 00:29:55 -0500 | [diff] [blame] | 579 | [list] |
| 580 | set c $z2 |
Shawn O. Pearce | 8629155 | 2006-11-19 01:00:48 -0500 | [diff] [blame] | 581 | incr c |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 582 | } |
Shawn O. Pearce | 868c875 | 2006-11-07 18:34:09 -0500 | [diff] [blame] | 583 | if {$c < $n} { |
| 584 | set buf_rdi [string range $buf_rdi $c end] |
| 585 | } else { |
| 586 | set buf_rdi {} |
| 587 | } |
| 588 | |
Shawn O. Pearce | 8f52548 | 2006-11-14 01:29:32 -0500 | [diff] [blame] | 589 | rescan_done $fd buf_rdi $after |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 590 | } |
| 591 | |
Shawn O. Pearce | 8f52548 | 2006-11-14 01:29:32 -0500 | [diff] [blame] | 592 | proc read_diff_files {fd after} { |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 593 | global buf_rdf |
| 594 | |
| 595 | append buf_rdf [read $fd] |
Shawn O. Pearce | 868c875 | 2006-11-07 18:34:09 -0500 | [diff] [blame] | 596 | set c 0 |
| 597 | set n [string length $buf_rdf] |
| 598 | while {$c < $n} { |
| 599 | set z1 [string first "\0" $buf_rdf $c] |
| 600 | if {$z1 == -1} break |
| 601 | incr z1 |
| 602 | set z2 [string first "\0" $buf_rdf $z1] |
| 603 | if {$z2 == -1} break |
| 604 | |
Shawn O. Pearce | 868c875 | 2006-11-07 18:34:09 -0500 | [diff] [blame] | 605 | incr c |
Shawn O. Pearce | 8629155 | 2006-11-19 01:00:48 -0500 | [diff] [blame] | 606 | set i [split [string range $buf_rdf $c [expr {$z1 - 2}]] { }] |
Shawn O. Pearce | 51a989b | 2007-01-23 04:07:18 -0500 | [diff] [blame] | 607 | set p [string range $buf_rdf $z1 [expr {$z2 - 1}]] |
Shawn O. Pearce | 1461c5f | 2006-11-19 00:29:55 -0500 | [diff] [blame] | 608 | merge_state \ |
Shawn O. Pearce | 51a989b | 2007-01-23 04:07:18 -0500 | [diff] [blame] | 609 | [encoding convertfrom $p] \ |
Shawn O. Pearce | 8629155 | 2006-11-19 01:00:48 -0500 | [diff] [blame] | 610 | ?[lindex $i 4] \ |
Shawn O. Pearce | 1461c5f | 2006-11-19 00:29:55 -0500 | [diff] [blame] | 611 | [list] \ |
Shawn O. Pearce | 8629155 | 2006-11-19 01:00:48 -0500 | [diff] [blame] | 612 | [list [lindex $i 0] [lindex $i 2]] |
Shawn O. Pearce | 1461c5f | 2006-11-19 00:29:55 -0500 | [diff] [blame] | 613 | set c $z2 |
Shawn O. Pearce | 8629155 | 2006-11-19 01:00:48 -0500 | [diff] [blame] | 614 | incr c |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 615 | } |
Shawn O. Pearce | 868c875 | 2006-11-07 18:34:09 -0500 | [diff] [blame] | 616 | if {$c < $n} { |
| 617 | set buf_rdf [string range $buf_rdf $c end] |
| 618 | } else { |
| 619 | set buf_rdf {} |
| 620 | } |
| 621 | |
Shawn O. Pearce | 8f52548 | 2006-11-14 01:29:32 -0500 | [diff] [blame] | 622 | rescan_done $fd buf_rdf $after |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 623 | } |
| 624 | |
Shawn O. Pearce | 8f52548 | 2006-11-14 01:29:32 -0500 | [diff] [blame] | 625 | proc read_ls_others {fd after} { |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 626 | global buf_rlo |
| 627 | |
| 628 | append buf_rlo [read $fd] |
| 629 | set pck [split $buf_rlo "\0"] |
| 630 | set buf_rlo [lindex $pck end] |
| 631 | foreach p [lrange $pck 0 end-1] { |
Shawn O. Pearce | 51a989b | 2007-01-23 04:07:18 -0500 | [diff] [blame] | 632 | merge_state [encoding convertfrom $p] ?O |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 633 | } |
Shawn O. Pearce | 8f52548 | 2006-11-14 01:29:32 -0500 | [diff] [blame] | 634 | rescan_done $fd buf_rlo $after |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 635 | } |
| 636 | |
Shawn O. Pearce | 8f52548 | 2006-11-14 01:29:32 -0500 | [diff] [blame] | 637 | proc rescan_done {fd buf after} { |
Shawn O. Pearce | f522c9b | 2007-05-07 23:35:48 -0400 | [diff] [blame] | 638 | global rescan_active current_diff_path |
Shawn O. Pearce | f7f8d32 | 2006-11-13 04:22:42 -0500 | [diff] [blame] | 639 | global file_states repo_config |
Shawn O. Pearce | 7f1df79 | 2006-11-11 18:38:00 -0500 | [diff] [blame] | 640 | upvar $buf to_clear |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 641 | |
Shawn O. Pearce | f7f8d32 | 2006-11-13 04:22:42 -0500 | [diff] [blame] | 642 | if {![eof $fd]} return |
| 643 | set to_clear {} |
| 644 | close $fd |
Shawn O. Pearce | 8f52548 | 2006-11-14 01:29:32 -0500 | [diff] [blame] | 645 | if {[incr rescan_active -1] > 0} return |
Shawn O. Pearce | 93f654d | 2006-11-07 19:30:54 -0500 | [diff] [blame] | 646 | |
Shawn O. Pearce | 24263b7 | 2006-11-13 16:06:38 -0500 | [diff] [blame] | 647 | prune_selection |
Shawn O. Pearce | f7f8d32 | 2006-11-13 04:22:42 -0500 | [diff] [blame] | 648 | unlock_index |
| 649 | display_all_files |
Shawn O. Pearce | f522c9b | 2007-05-07 23:35:48 -0400 | [diff] [blame] | 650 | if {$current_diff_path ne {}} reshow_diff |
Shawn O. Pearce | 8f52548 | 2006-11-14 01:29:32 -0500 | [diff] [blame] | 651 | uplevel #0 $after |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 652 | } |
| 653 | |
Shawn O. Pearce | 24263b7 | 2006-11-13 16:06:38 -0500 | [diff] [blame] | 654 | proc prune_selection {} { |
| 655 | global file_states selected_paths |
| 656 | |
| 657 | foreach path [array names selected_paths] { |
| 658 | if {[catch {set still_here $file_states($path)}]} { |
| 659 | unset selected_paths($path) |
| 660 | } |
| 661 | } |
| 662 | } |
| 663 | |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 664 | ###################################################################### |
| 665 | ## |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 666 | ## ui helpers |
| 667 | |
Shawn O. Pearce | 21e409a | 2007-01-20 22:45:19 -0500 | [diff] [blame] | 668 | proc mapicon {w state path} { |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 669 | global all_icons |
| 670 | |
Shawn O. Pearce | 21e409a | 2007-01-20 22:45:19 -0500 | [diff] [blame] | 671 | if {[catch {set r $all_icons($state$w)}]} { |
| 672 | puts "error: no icon for $w state={$state} $path" |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 673 | return file_plain |
| 674 | } |
| 675 | return $r |
| 676 | } |
| 677 | |
| 678 | proc mapdesc {state path} { |
| 679 | global all_descs |
| 680 | |
| 681 | if {[catch {set r $all_descs($state)}]} { |
| 682 | puts "error: no desc for state={$state} $path" |
| 683 | return $state |
| 684 | } |
| 685 | return $r |
| 686 | } |
| 687 | |
Shawn O. Pearce | 68e009d | 2006-11-11 17:59:34 -0500 | [diff] [blame] | 688 | proc escape_path {path} { |
Shawn O. Pearce | 42b922f | 2007-02-08 17:13:51 -0500 | [diff] [blame] | 689 | regsub -all {\\} $path "\\\\" path |
Shawn O. Pearce | 68e009d | 2006-11-11 17:59:34 -0500 | [diff] [blame] | 690 | regsub -all "\n" $path "\\n" path |
| 691 | return $path |
| 692 | } |
| 693 | |
Shawn O. Pearce | 16403d0 | 2006-11-11 21:52:06 -0500 | [diff] [blame] | 694 | proc short_path {path} { |
| 695 | return [escape_path [lindex [file split $path] end]] |
| 696 | } |
| 697 | |
Shawn O. Pearce | 93f654d | 2006-11-07 19:30:54 -0500 | [diff] [blame] | 698 | set next_icon_id 0 |
Shawn O. Pearce | 51cc47f | 2006-11-19 01:20:42 -0500 | [diff] [blame] | 699 | set null_sha1 [string repeat 0 40] |
Shawn O. Pearce | 93f654d | 2006-11-07 19:30:54 -0500 | [diff] [blame] | 700 | |
Shawn O. Pearce | 1461c5f | 2006-11-19 00:29:55 -0500 | [diff] [blame] | 701 | proc merge_state {path new_state {head_info {}} {index_info {}}} { |
Shawn O. Pearce | 51cc47f | 2006-11-19 01:20:42 -0500 | [diff] [blame] | 702 | global file_states next_icon_id null_sha1 |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 703 | |
Shawn O. Pearce | 6b29267 | 2006-11-07 19:58:37 -0500 | [diff] [blame] | 704 | set s0 [string index $new_state 0] |
| 705 | set s1 [string index $new_state 1] |
| 706 | |
| 707 | if {[catch {set info $file_states($path)}]} { |
| 708 | set state __ |
| 709 | set icon n[incr next_icon_id] |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 710 | } else { |
Shawn O. Pearce | 6b29267 | 2006-11-07 19:58:37 -0500 | [diff] [blame] | 711 | set state [lindex $info 0] |
| 712 | set icon [lindex $info 1] |
Shawn O. Pearce | 1461c5f | 2006-11-19 00:29:55 -0500 | [diff] [blame] | 713 | if {$head_info eq {}} {set head_info [lindex $info 2]} |
| 714 | if {$index_info eq {}} {set index_info [lindex $info 3]} |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 715 | } |
| 716 | |
Shawn O. Pearce | 1461c5f | 2006-11-19 00:29:55 -0500 | [diff] [blame] | 717 | if {$s0 eq {?}} {set s0 [string index $state 0]} \ |
| 718 | elseif {$s0 eq {_}} {set s0 _} |
| 719 | |
| 720 | if {$s1 eq {?}} {set s1 [string index $state 1]} \ |
| 721 | elseif {$s1 eq {_}} {set s1 _} |
| 722 | |
Shawn O. Pearce | 51cc47f | 2006-11-19 01:20:42 -0500 | [diff] [blame] | 723 | if {$s0 eq {A} && $s1 eq {_} && $head_info eq {}} { |
| 724 | set head_info [list 0 $null_sha1] |
| 725 | } elseif {$s0 ne {_} && [string index $state 0] eq {_} |
Shawn O. Pearce | 1461c5f | 2006-11-19 00:29:55 -0500 | [diff] [blame] | 726 | && $head_info eq {}} { |
| 727 | set head_info $index_info |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 728 | } |
| 729 | |
Shawn O. Pearce | 1461c5f | 2006-11-19 00:29:55 -0500 | [diff] [blame] | 730 | set file_states($path) [list $s0$s1 $icon \ |
| 731 | $head_info $index_info \ |
| 732 | ] |
Shawn O. Pearce | 6b29267 | 2006-11-07 19:58:37 -0500 | [diff] [blame] | 733 | return $state |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 734 | } |
| 735 | |
Shawn O. Pearce | 21e409a | 2007-01-20 22:45:19 -0500 | [diff] [blame] | 736 | proc display_file_helper {w path icon_name old_m new_m} { |
| 737 | global file_lists |
| 738 | |
| 739 | if {$new_m eq {_}} { |
Shawn O. Pearce | 156b292 | 2007-01-25 22:38:59 -0500 | [diff] [blame] | 740 | set lno [lsearch -sorted -exact $file_lists($w) $path] |
Shawn O. Pearce | 21e409a | 2007-01-20 22:45:19 -0500 | [diff] [blame] | 741 | if {$lno >= 0} { |
| 742 | set file_lists($w) [lreplace $file_lists($w) $lno $lno] |
| 743 | incr lno |
| 744 | $w conf -state normal |
| 745 | $w delete $lno.0 [expr {$lno + 1}].0 |
| 746 | $w conf -state disabled |
| 747 | } |
| 748 | } elseif {$old_m eq {_} && $new_m ne {_}} { |
| 749 | lappend file_lists($w) $path |
| 750 | set file_lists($w) [lsort -unique $file_lists($w)] |
Shawn O. Pearce | 156b292 | 2007-01-25 22:38:59 -0500 | [diff] [blame] | 751 | set lno [lsearch -sorted -exact $file_lists($w) $path] |
Shawn O. Pearce | 21e409a | 2007-01-20 22:45:19 -0500 | [diff] [blame] | 752 | incr lno |
| 753 | $w conf -state normal |
| 754 | $w image create $lno.0 \ |
| 755 | -align center -padx 5 -pady 1 \ |
| 756 | -name $icon_name \ |
| 757 | -image [mapicon $w $new_m $path] |
| 758 | $w insert $lno.1 "[escape_path $path]\n" |
| 759 | $w conf -state disabled |
| 760 | } elseif {$old_m ne $new_m} { |
| 761 | $w conf -state normal |
| 762 | $w image conf $icon_name -image [mapicon $w $new_m $path] |
| 763 | $w conf -state disabled |
| 764 | } |
| 765 | } |
| 766 | |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 767 | proc display_file {path state} { |
Shawn O. Pearce | 21e409a | 2007-01-20 22:45:19 -0500 | [diff] [blame] | 768 | global file_states selected_paths |
| 769 | global ui_index ui_workdir |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 770 | |
| 771 | set old_m [merge_state $path $state] |
Shawn O. Pearce | 93f654d | 2006-11-07 19:30:54 -0500 | [diff] [blame] | 772 | set s $file_states($path) |
| 773 | set new_m [lindex $s 0] |
Shawn O. Pearce | 21e409a | 2007-01-20 22:45:19 -0500 | [diff] [blame] | 774 | set icon_name [lindex $s 1] |
| 775 | |
Shawn O. Pearce | 079d0d5 | 2007-01-21 13:18:11 -0500 | [diff] [blame] | 776 | set o [string index $old_m 0] |
| 777 | set n [string index $new_m 0] |
| 778 | if {$o eq {U}} { |
| 779 | set o _ |
Shawn O. Pearce | 3b4db3c | 2007-01-21 12:30:51 -0500 | [diff] [blame] | 780 | } |
Shawn O. Pearce | 079d0d5 | 2007-01-21 13:18:11 -0500 | [diff] [blame] | 781 | if {$n eq {U}} { |
| 782 | set n _ |
| 783 | } |
| 784 | display_file_helper $ui_index $path $icon_name $o $n |
Shawn O. Pearce | 3b4db3c | 2007-01-21 12:30:51 -0500 | [diff] [blame] | 785 | |
Shawn O. Pearce | 079d0d5 | 2007-01-21 13:18:11 -0500 | [diff] [blame] | 786 | if {[string index $old_m 0] eq {U}} { |
| 787 | set o U |
Shawn O. Pearce | 3b4db3c | 2007-01-21 12:30:51 -0500 | [diff] [blame] | 788 | } else { |
Shawn O. Pearce | a4b1786 | 2007-01-21 13:25:06 -0500 | [diff] [blame] | 789 | set o [string index $old_m 1] |
Shawn O. Pearce | 3b4db3c | 2007-01-21 12:30:51 -0500 | [diff] [blame] | 790 | } |
Shawn O. Pearce | 079d0d5 | 2007-01-21 13:18:11 -0500 | [diff] [blame] | 791 | if {[string index $new_m 0] eq {U}} { |
| 792 | set n U |
| 793 | } else { |
| 794 | set n [string index $new_m 1] |
| 795 | } |
| 796 | display_file_helper $ui_workdir $path $icon_name $o $n |
Shawn O. Pearce | 93f654d | 2006-11-07 19:30:54 -0500 | [diff] [blame] | 797 | |
Shawn O. Pearce | e734817 | 2006-11-23 21:40:45 -0500 | [diff] [blame] | 798 | if {$new_m eq {__}} { |
Shawn O. Pearce | e734817 | 2006-11-23 21:40:45 -0500 | [diff] [blame] | 799 | unset file_states($path) |
| 800 | catch {unset selected_paths($path)} |
Shawn O. Pearce | e734817 | 2006-11-23 21:40:45 -0500 | [diff] [blame] | 801 | } |
Shawn O. Pearce | 21e409a | 2007-01-20 22:45:19 -0500 | [diff] [blame] | 802 | } |
Shawn O. Pearce | e734817 | 2006-11-23 21:40:45 -0500 | [diff] [blame] | 803 | |
Shawn O. Pearce | 21e409a | 2007-01-20 22:45:19 -0500 | [diff] [blame] | 804 | proc display_all_files_helper {w path icon_name m} { |
| 805 | global file_lists |
Shawn O. Pearce | 93f654d | 2006-11-07 19:30:54 -0500 | [diff] [blame] | 806 | |
Shawn O. Pearce | 21e409a | 2007-01-20 22:45:19 -0500 | [diff] [blame] | 807 | lappend file_lists($w) $path |
| 808 | set lno [expr {[lindex [split [$w index end] .] 0] - 1}] |
| 809 | $w image create end \ |
| 810 | -align center -padx 5 -pady 1 \ |
| 811 | -name $icon_name \ |
| 812 | -image [mapicon $w $m $path] |
| 813 | $w insert end "[escape_path $path]\n" |
Shawn O. Pearce | 93f654d | 2006-11-07 19:30:54 -0500 | [diff] [blame] | 814 | } |
| 815 | |
| 816 | proc display_all_files {} { |
Shawn O. Pearce | 0812665 | 2007-01-20 22:06:51 -0500 | [diff] [blame] | 817 | global ui_index ui_workdir |
Shawn O. Pearce | 24263b7 | 2006-11-13 16:06:38 -0500 | [diff] [blame] | 818 | global file_states file_lists |
Shawn O. Pearce | 833eda7 | 2007-01-20 23:46:53 -0500 | [diff] [blame] | 819 | global last_clicked |
Shawn O. Pearce | 93f654d | 2006-11-07 19:30:54 -0500 | [diff] [blame] | 820 | |
| 821 | $ui_index conf -state normal |
Shawn O. Pearce | 0812665 | 2007-01-20 22:06:51 -0500 | [diff] [blame] | 822 | $ui_workdir conf -state normal |
Shawn O. Pearce | 93f654d | 2006-11-07 19:30:54 -0500 | [diff] [blame] | 823 | |
Shawn O. Pearce | 7f1df79 | 2006-11-11 18:38:00 -0500 | [diff] [blame] | 824 | $ui_index delete 0.0 end |
Shawn O. Pearce | 0812665 | 2007-01-20 22:06:51 -0500 | [diff] [blame] | 825 | $ui_workdir delete 0.0 end |
Shawn O. Pearce | 24263b7 | 2006-11-13 16:06:38 -0500 | [diff] [blame] | 826 | set last_clicked {} |
Shawn O. Pearce | 7f1df79 | 2006-11-11 18:38:00 -0500 | [diff] [blame] | 827 | |
Shawn O. Pearce | 62aac80 | 2006-11-11 20:00:35 -0500 | [diff] [blame] | 828 | set file_lists($ui_index) [list] |
Shawn O. Pearce | 0812665 | 2007-01-20 22:06:51 -0500 | [diff] [blame] | 829 | set file_lists($ui_workdir) [list] |
Shawn O. Pearce | 62aac80 | 2006-11-11 20:00:35 -0500 | [diff] [blame] | 830 | |
Shawn O. Pearce | 93f654d | 2006-11-07 19:30:54 -0500 | [diff] [blame] | 831 | foreach path [lsort [array names file_states]] { |
| 832 | set s $file_states($path) |
| 833 | set m [lindex $s 0] |
Shawn O. Pearce | 21e409a | 2007-01-20 22:45:19 -0500 | [diff] [blame] | 834 | set icon_name [lindex $s 1] |
| 835 | |
Shawn O. Pearce | 3b4db3c | 2007-01-21 12:30:51 -0500 | [diff] [blame] | 836 | set s [string index $m 0] |
| 837 | if {$s ne {U} && $s ne {_}} { |
Shawn O. Pearce | 21e409a | 2007-01-20 22:45:19 -0500 | [diff] [blame] | 838 | display_all_files_helper $ui_index $path \ |
Shawn O. Pearce | 3b4db3c | 2007-01-21 12:30:51 -0500 | [diff] [blame] | 839 | $icon_name $s |
Shawn O. Pearce | 24263b7 | 2006-11-13 16:06:38 -0500 | [diff] [blame] | 840 | } |
Shawn O. Pearce | 3b4db3c | 2007-01-21 12:30:51 -0500 | [diff] [blame] | 841 | |
| 842 | if {[string index $m 0] eq {U}} { |
| 843 | set s U |
| 844 | } else { |
| 845 | set s [string index $m 1] |
| 846 | } |
| 847 | if {$s ne {_}} { |
Shawn O. Pearce | 21e409a | 2007-01-20 22:45:19 -0500 | [diff] [blame] | 848 | display_all_files_helper $ui_workdir $path \ |
Shawn O. Pearce | 3b4db3c | 2007-01-21 12:30:51 -0500 | [diff] [blame] | 849 | $icon_name $s |
Shawn O. Pearce | 24263b7 | 2006-11-13 16:06:38 -0500 | [diff] [blame] | 850 | } |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 851 | } |
| 852 | |
Shawn O. Pearce | 93f654d | 2006-11-07 19:30:54 -0500 | [diff] [blame] | 853 | $ui_index conf -state disabled |
Shawn O. Pearce | 0812665 | 2007-01-20 22:06:51 -0500 | [diff] [blame] | 854 | $ui_workdir conf -state disabled |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 855 | } |
| 856 | |
Shawn O. Pearce | 35874c1 | 2007-01-29 00:50:41 -0500 | [diff] [blame] | 857 | ###################################################################### |
| 858 | ## |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 859 | ## icons |
| 860 | |
| 861 | set filemask { |
| 862 | #define mask_width 14 |
| 863 | #define mask_height 15 |
| 864 | static unsigned char mask_bits[] = { |
| 865 | 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, |
| 866 | 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, |
| 867 | 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f}; |
| 868 | } |
| 869 | |
| 870 | image create bitmap file_plain -background white -foreground black -data { |
| 871 | #define plain_width 14 |
| 872 | #define plain_height 15 |
| 873 | static unsigned char plain_bits[] = { |
| 874 | 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10, |
| 875 | 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, |
| 876 | 0x02, 0x10, 0x02, 0x10, 0xfe, 0x1f}; |
| 877 | } -maskdata $filemask |
| 878 | |
| 879 | image create bitmap file_mod -background white -foreground blue -data { |
| 880 | #define mod_width 14 |
| 881 | #define mod_height 15 |
| 882 | static unsigned char mod_bits[] = { |
| 883 | 0xfe, 0x01, 0x02, 0x03, 0x7a, 0x05, 0x02, 0x09, 0x7a, 0x1f, 0x02, 0x10, |
| 884 | 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10, |
| 885 | 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f}; |
| 886 | } -maskdata $filemask |
| 887 | |
Shawn O. Pearce | 131f503 | 2006-11-06 16:07:32 -0500 | [diff] [blame] | 888 | image create bitmap file_fulltick -background white -foreground "#007000" -data { |
| 889 | #define file_fulltick_width 14 |
| 890 | #define file_fulltick_height 15 |
| 891 | static unsigned char file_fulltick_bits[] = { |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 892 | 0xfe, 0x01, 0x02, 0x1a, 0x02, 0x0c, 0x02, 0x0c, 0x02, 0x16, 0x02, 0x16, |
| 893 | 0x02, 0x13, 0x00, 0x13, 0x86, 0x11, 0x8c, 0x11, 0xd8, 0x10, 0xf2, 0x10, |
| 894 | 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f}; |
| 895 | } -maskdata $filemask |
| 896 | |
| 897 | image create bitmap file_parttick -background white -foreground "#005050" -data { |
| 898 | #define parttick_width 14 |
| 899 | #define parttick_height 15 |
| 900 | static unsigned char parttick_bits[] = { |
| 901 | 0xfe, 0x01, 0x02, 0x03, 0x7a, 0x05, 0x02, 0x09, 0x7a, 0x1f, 0x02, 0x10, |
| 902 | 0x7a, 0x14, 0x02, 0x16, 0x02, 0x13, 0x8a, 0x11, 0xda, 0x10, 0x72, 0x10, |
| 903 | 0x22, 0x10, 0x02, 0x10, 0xfe, 0x1f}; |
| 904 | } -maskdata $filemask |
| 905 | |
| 906 | image create bitmap file_question -background white -foreground black -data { |
| 907 | #define file_question_width 14 |
| 908 | #define file_question_height 15 |
| 909 | static unsigned char file_question_bits[] = { |
| 910 | 0xfe, 0x01, 0x02, 0x02, 0xe2, 0x04, 0xf2, 0x09, 0x1a, 0x1b, 0x0a, 0x13, |
| 911 | 0x82, 0x11, 0xc2, 0x10, 0x62, 0x10, 0x62, 0x10, 0x02, 0x10, 0x62, 0x10, |
| 912 | 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f}; |
| 913 | } -maskdata $filemask |
| 914 | |
| 915 | image create bitmap file_removed -background white -foreground red -data { |
| 916 | #define file_removed_width 14 |
| 917 | #define file_removed_height 15 |
| 918 | static unsigned char file_removed_bits[] = { |
| 919 | 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10, |
| 920 | 0x1a, 0x16, 0x32, 0x13, 0xe2, 0x11, 0xc2, 0x10, 0xe2, 0x11, 0x32, 0x13, |
| 921 | 0x1a, 0x16, 0x02, 0x10, 0xfe, 0x1f}; |
| 922 | } -maskdata $filemask |
| 923 | |
| 924 | image create bitmap file_merge -background white -foreground blue -data { |
| 925 | #define file_merge_width 14 |
| 926 | #define file_merge_height 15 |
| 927 | static unsigned char file_merge_bits[] = { |
| 928 | 0xfe, 0x01, 0x02, 0x03, 0x62, 0x05, 0x62, 0x09, 0x62, 0x1f, 0x62, 0x10, |
| 929 | 0xfa, 0x11, 0xf2, 0x10, 0x62, 0x10, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10, |
| 930 | 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f}; |
| 931 | } -maskdata $filemask |
| 932 | |
Shawn O. Pearce | 3eddda9 | 2007-01-29 02:50:10 -0500 | [diff] [blame] | 933 | set file_dir_data { |
| 934 | #define file_width 18 |
| 935 | #define file_height 18 |
| 936 | static unsigned char file_bits[] = { |
| 937 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x03, 0x00, |
| 938 | 0x0c, 0x03, 0x00, 0x04, 0xfe, 0x00, 0x06, 0x80, 0x00, 0xff, 0x9f, 0x00, |
| 939 | 0x03, 0x98, 0x00, 0x02, 0x90, 0x00, 0x06, 0xb0, 0x00, 0x04, 0xa0, 0x00, |
| 940 | 0x0c, 0xe0, 0x00, 0x08, 0xc0, 0x00, 0xf8, 0xff, 0x00, 0x00, 0x00, 0x00, |
| 941 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
| 942 | } |
| 943 | image create bitmap file_dir -background white -foreground blue \ |
| 944 | -data $file_dir_data -maskdata $file_dir_data |
| 945 | unset file_dir_data |
Shawn O. Pearce | 35874c1 | 2007-01-29 00:50:41 -0500 | [diff] [blame] | 946 | |
Shawn O. Pearce | 3eddda9 | 2007-01-29 02:50:10 -0500 | [diff] [blame] | 947 | set file_uplevel_data { |
| 948 | #define up_width 15 |
| 949 | #define up_height 15 |
| 950 | static unsigned char up_bits[] = { |
| 951 | 0x80, 0x00, 0xc0, 0x01, 0xe0, 0x03, 0xf0, 0x07, 0xf8, 0x0f, 0xfc, 0x1f, |
| 952 | 0xfe, 0x3f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, |
| 953 | 0xc0, 0x01, 0xc0, 0x01, 0x00, 0x00}; |
| 954 | } |
| 955 | image create bitmap file_uplevel -background white -foreground red \ |
| 956 | -data $file_uplevel_data -maskdata $file_uplevel_data |
| 957 | unset file_uplevel_data |
Shawn O. Pearce | 35874c1 | 2007-01-29 00:50:41 -0500 | [diff] [blame] | 958 | |
Shawn O. Pearce | 6b29267 | 2006-11-07 19:58:37 -0500 | [diff] [blame] | 959 | set ui_index .vpane.files.index.list |
Shawn O. Pearce | 0812665 | 2007-01-20 22:06:51 -0500 | [diff] [blame] | 960 | set ui_workdir .vpane.files.workdir.list |
Shawn O. Pearce | 21e409a | 2007-01-20 22:45:19 -0500 | [diff] [blame] | 961 | |
| 962 | set all_icons(_$ui_index) file_plain |
| 963 | set all_icons(A$ui_index) file_fulltick |
| 964 | set all_icons(M$ui_index) file_fulltick |
| 965 | set all_icons(D$ui_index) file_removed |
| 966 | set all_icons(U$ui_index) file_merge |
| 967 | |
| 968 | set all_icons(_$ui_workdir) file_plain |
| 969 | set all_icons(M$ui_workdir) file_mod |
| 970 | set all_icons(D$ui_workdir) file_question |
Shawn O. Pearce | 3b4db3c | 2007-01-21 12:30:51 -0500 | [diff] [blame] | 971 | set all_icons(U$ui_workdir) file_merge |
Shawn O. Pearce | 21e409a | 2007-01-20 22:45:19 -0500 | [diff] [blame] | 972 | set all_icons(O$ui_workdir) file_plain |
| 973 | |
Shawn O. Pearce | 131f503 | 2006-11-06 16:07:32 -0500 | [diff] [blame] | 974 | set max_status_desc 0 |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 975 | foreach i { |
Shawn O. Pearce | 21e409a | 2007-01-20 22:45:19 -0500 | [diff] [blame] | 976 | {__ "Unmodified"} |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 977 | |
Shawn O. Pearce | ac39160 | 2007-01-20 23:00:28 -0500 | [diff] [blame] | 978 | {_M "Modified, not staged"} |
| 979 | {M_ "Staged for commit"} |
| 980 | {MM "Portions staged for commit"} |
| 981 | {MD "Staged for commit, missing"} |
| 982 | |
| 983 | {_O "Untracked, not staged"} |
| 984 | {A_ "Staged for commit"} |
| 985 | {AM "Portions staged for commit"} |
| 986 | {AD "Staged for commit, missing"} |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 987 | |
Shawn O. Pearce | 21e409a | 2007-01-20 22:45:19 -0500 | [diff] [blame] | 988 | {_D "Missing"} |
Shawn O. Pearce | ac39160 | 2007-01-20 23:00:28 -0500 | [diff] [blame] | 989 | {D_ "Staged for removal"} |
| 990 | {DO "Staged for removal, still present"} |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 991 | |
Shawn O. Pearce | ac39160 | 2007-01-20 23:00:28 -0500 | [diff] [blame] | 992 | {U_ "Requires merge resolution"} |
Shawn O. Pearce | 3b4db3c | 2007-01-21 12:30:51 -0500 | [diff] [blame] | 993 | {UU "Requires merge resolution"} |
Shawn O. Pearce | ac39160 | 2007-01-20 23:00:28 -0500 | [diff] [blame] | 994 | {UM "Requires merge resolution"} |
| 995 | {UD "Requires merge resolution"} |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 996 | } { |
Shawn O. Pearce | 21e409a | 2007-01-20 22:45:19 -0500 | [diff] [blame] | 997 | if {$max_status_desc < [string length [lindex $i 1]]} { |
| 998 | set max_status_desc [string length [lindex $i 1]] |
Shawn O. Pearce | 131f503 | 2006-11-06 16:07:32 -0500 | [diff] [blame] | 999 | } |
Shawn O. Pearce | 21e409a | 2007-01-20 22:45:19 -0500 | [diff] [blame] | 1000 | set all_descs([lindex $i 0]) [lindex $i 1] |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1001 | } |
Shawn O. Pearce | 21e409a | 2007-01-20 22:45:19 -0500 | [diff] [blame] | 1002 | unset i |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1003 | |
| 1004 | ###################################################################### |
| 1005 | ## |
| 1006 | ## util |
| 1007 | |
Shawn O. Pearce | 16fccd7 | 2006-11-12 02:22:21 -0500 | [diff] [blame] | 1008 | proc bind_button3 {w cmd} { |
| 1009 | bind $w <Any-Button-3> $cmd |
| 1010 | if {[is_MacOSX]} { |
| 1011 | bind $w <Control-Button-1> $cmd |
| 1012 | } |
| 1013 | } |
| 1014 | |
Shawn O. Pearce | 35874c1 | 2007-01-29 00:50:41 -0500 | [diff] [blame] | 1015 | proc scrollbar2many {list mode args} { |
| 1016 | foreach w $list {eval $w $mode $args} |
| 1017 | } |
| 1018 | |
| 1019 | proc many2scrollbar {list mode sb top bottom} { |
| 1020 | $sb set $top $bottom |
| 1021 | foreach w $list {$w $mode moveto $top} |
| 1022 | } |
| 1023 | |
Shawn O. Pearce | b494693 | 2006-11-12 00:40:38 -0500 | [diff] [blame] | 1024 | proc incr_font_size {font {amt 1}} { |
| 1025 | set sz [font configure $font -size] |
| 1026 | incr sz $amt |
| 1027 | font configure $font -size $sz |
| 1028 | font configure ${font}bold -size $sz |
Shawn O. Pearce | debcd0f | 2007-06-02 17:15:56 -0400 | [diff] [blame] | 1029 | font configure ${font}italic -size $sz |
Shawn O. Pearce | b494693 | 2006-11-12 00:40:38 -0500 | [diff] [blame] | 1030 | } |
| 1031 | |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1032 | ###################################################################### |
| 1033 | ## |
| 1034 | ## ui commands |
| 1035 | |
Shawn O. Pearce | dccfa67 | 2007-01-20 21:56:25 -0500 | [diff] [blame] | 1036 | set starting_gitk_msg {Starting gitk... please wait...} |
Shawn O. Pearce | cc4b1c0 | 2006-11-06 23:47:05 -0500 | [diff] [blame] | 1037 | |
Shawn O. Pearce | d075242 | 2006-11-21 20:33:09 -0500 | [diff] [blame] | 1038 | proc do_gitk {revs} { |
Shawn O. Pearce | 20ddfca | 2007-01-28 20:58:47 -0500 | [diff] [blame] | 1039 | global env ui_status_value starting_gitk_msg |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1040 | |
Shawn O. Pearce | 20ddfca | 2007-01-28 20:58:47 -0500 | [diff] [blame] | 1041 | # -- Always start gitk through whatever we were loaded with. This |
| 1042 | # lets us bypass using shell process on Windows systems. |
| 1043 | # |
Shawn O. Pearce | 681bfd5 | 2007-05-02 12:44:44 -0400 | [diff] [blame] | 1044 | set cmd [list [info nameofexecutable]] |
Shawn O. Pearce | 20ddfca | 2007-01-28 20:58:47 -0500 | [diff] [blame] | 1045 | lappend cmd [gitexec gitk] |
Shawn O. Pearce | d075242 | 2006-11-21 20:33:09 -0500 | [diff] [blame] | 1046 | if {$revs ne {}} { |
| 1047 | append cmd { } |
| 1048 | append cmd $revs |
Shawn O. Pearce | e210e67 | 2006-11-06 19:12:58 -0500 | [diff] [blame] | 1049 | } |
Shawn O. Pearce | d075242 | 2006-11-21 20:33:09 -0500 | [diff] [blame] | 1050 | |
Shawn O. Pearce | 20ddfca | 2007-01-28 20:58:47 -0500 | [diff] [blame] | 1051 | if {[catch {eval exec $cmd &} err]} { |
Shawn O. Pearce | d075242 | 2006-11-21 20:33:09 -0500 | [diff] [blame] | 1052 | error_popup "Failed to start gitk:\n\n$err" |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1053 | } else { |
Shawn O. Pearce | d075242 | 2006-11-21 20:33:09 -0500 | [diff] [blame] | 1054 | set ui_status_value $starting_gitk_msg |
| 1055 | after 10000 { |
| 1056 | if {$ui_status_value eq $starting_gitk_msg} { |
| 1057 | set ui_status_value {Ready.} |
| 1058 | } |
| 1059 | } |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1060 | } |
| 1061 | } |
| 1062 | |
Shawn O. Pearce | b5834d7 | 2006-11-12 02:27:28 -0500 | [diff] [blame] | 1063 | set is_quitting 0 |
Shawn O. Pearce | c4fe772 | 2006-11-11 19:32:24 -0500 | [diff] [blame] | 1064 | |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1065 | proc do_quit {} { |
Shawn O. Pearce | c950c66 | 2007-01-20 21:48:56 -0500 | [diff] [blame] | 1066 | global ui_comm is_quitting repo_config commit_type |
Shawn O. Pearce | c4fe772 | 2006-11-11 19:32:24 -0500 | [diff] [blame] | 1067 | |
Shawn O. Pearce | b5834d7 | 2006-11-12 02:27:28 -0500 | [diff] [blame] | 1068 | if {$is_quitting} return |
| 1069 | set is_quitting 1 |
Shawn O. Pearce | 131f503 | 2006-11-06 16:07:32 -0500 | [diff] [blame] | 1070 | |
Shawn O. Pearce | db7f34d | 2007-02-08 17:47:17 -0500 | [diff] [blame] | 1071 | if {[winfo exists $ui_comm]} { |
| 1072 | # -- Stash our current commit buffer. |
| 1073 | # |
| 1074 | set save [gitdir GITGUI_MSG] |
| 1075 | set msg [string trim [$ui_comm get 0.0 end]] |
| 1076 | regsub -all -line {[ \r\t]+$} $msg {} msg |
| 1077 | if {(![string match amend* $commit_type] |
| 1078 | || [$ui_comm edit modified]) |
| 1079 | && $msg ne {}} { |
| 1080 | catch { |
| 1081 | set fd [open $save w] |
| 1082 | puts -nonewline $fd $msg |
| 1083 | close $fd |
| 1084 | } |
| 1085 | } else { |
| 1086 | catch {file delete $save} |
Shawn O. Pearce | 131f503 | 2006-11-06 16:07:32 -0500 | [diff] [blame] | 1087 | } |
Shawn O. Pearce | 131f503 | 2006-11-06 16:07:32 -0500 | [diff] [blame] | 1088 | |
Shawn O. Pearce | db7f34d | 2007-02-08 17:47:17 -0500 | [diff] [blame] | 1089 | # -- Stash our current window geometry into this repository. |
| 1090 | # |
| 1091 | set cfg_geometry [list] |
| 1092 | lappend cfg_geometry [wm geometry .] |
| 1093 | lappend cfg_geometry [lindex [.vpane sash coord 0] 1] |
| 1094 | lappend cfg_geometry [lindex [.vpane.files sash coord 0] 0] |
| 1095 | if {[catch {set rc_geometry $repo_config(gui.geometry)}]} { |
| 1096 | set rc_geometry {} |
| 1097 | } |
| 1098 | if {$cfg_geometry ne $rc_geometry} { |
Shawn O. Pearce | 8134722 | 2007-02-12 22:48:56 -0500 | [diff] [blame] | 1099 | catch {git config gui.geometry $cfg_geometry} |
Shawn O. Pearce | db7f34d | 2007-02-08 17:47:17 -0500 | [diff] [blame] | 1100 | } |
Shawn O. Pearce | 51f4d16 | 2006-11-12 03:47:00 -0500 | [diff] [blame] | 1101 | } |
| 1102 | |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1103 | destroy . |
| 1104 | } |
| 1105 | |
| 1106 | proc do_rescan {} { |
Shawn O. Pearce | 8f52548 | 2006-11-14 01:29:32 -0500 | [diff] [blame] | 1107 | rescan {set ui_status_value {Ready.}} |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1108 | } |
| 1109 | |
Shawn O. Pearce | 6e27d82 | 2006-11-06 20:03:36 -0500 | [diff] [blame] | 1110 | proc do_commit {} { |
Shawn O. Pearce | ec6b424 | 2006-11-06 20:50:59 -0500 | [diff] [blame] | 1111 | commit_tree |
Shawn O. Pearce | 6e27d82 | 2006-11-06 20:03:36 -0500 | [diff] [blame] | 1112 | } |
| 1113 | |
Shawn O. Pearce | 24263b7 | 2006-11-13 16:06:38 -0500 | [diff] [blame] | 1114 | proc toggle_or_diff {w x y} { |
Shawn O. Pearce | 20a53c0 | 2007-01-21 11:37:58 -0500 | [diff] [blame] | 1115 | global file_states file_lists current_diff_path ui_index ui_workdir |
Shawn O. Pearce | 24263b7 | 2006-11-13 16:06:38 -0500 | [diff] [blame] | 1116 | global last_clicked selected_paths |
Shawn O. Pearce | 131f503 | 2006-11-06 16:07:32 -0500 | [diff] [blame] | 1117 | |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1118 | set pos [split [$w index @$x,$y] .] |
| 1119 | set lno [lindex $pos 0] |
| 1120 | set col [lindex $pos 1] |
Shawn O. Pearce | 24263b7 | 2006-11-13 16:06:38 -0500 | [diff] [blame] | 1121 | set path [lindex $file_lists($w) [expr {$lno - 1}]] |
| 1122 | if {$path eq {}} { |
| 1123 | set last_clicked {} |
| 1124 | return |
| 1125 | } |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1126 | |
Shawn O. Pearce | 24263b7 | 2006-11-13 16:06:38 -0500 | [diff] [blame] | 1127 | set last_clicked [list $w $lno] |
| 1128 | array unset selected_paths |
| 1129 | $ui_index tag remove in_sel 0.0 end |
Shawn O. Pearce | 0812665 | 2007-01-20 22:06:51 -0500 | [diff] [blame] | 1130 | $ui_workdir tag remove in_sel 0.0 end |
Shawn O. Pearce | 24263b7 | 2006-11-13 16:06:38 -0500 | [diff] [blame] | 1131 | |
| 1132 | if {$col == 0} { |
Shawn O. Pearce | 20a53c0 | 2007-01-21 11:37:58 -0500 | [diff] [blame] | 1133 | if {$current_diff_path eq $path} { |
Shawn O. Pearce | 32e0bca | 2006-11-18 03:03:16 -0500 | [diff] [blame] | 1134 | set after {reshow_diff;} |
| 1135 | } else { |
| 1136 | set after {} |
| 1137 | } |
Shawn O. Pearce | de5f6d5 | 2007-01-20 23:10:30 -0500 | [diff] [blame] | 1138 | if {$w eq $ui_index} { |
Shawn O. Pearce | 74d18d2 | 2006-11-19 00:37:49 -0500 | [diff] [blame] | 1139 | update_indexinfo \ |
Shawn O. Pearce | 93e912c | 2007-01-20 23:07:04 -0500 | [diff] [blame] | 1140 | "Unstaging [short_path $path] from commit" \ |
Shawn O. Pearce | 74d18d2 | 2006-11-19 00:37:49 -0500 | [diff] [blame] | 1141 | [list $path] \ |
| 1142 | [concat $after {set ui_status_value {Ready.}}] |
Shawn O. Pearce | de5f6d5 | 2007-01-20 23:10:30 -0500 | [diff] [blame] | 1143 | } elseif {$w eq $ui_workdir} { |
Shawn O. Pearce | 74d18d2 | 2006-11-19 00:37:49 -0500 | [diff] [blame] | 1144 | update_index \ |
Shawn O. Pearce | 4d583c8 | 2007-01-20 19:07:46 -0500 | [diff] [blame] | 1145 | "Adding [short_path $path]" \ |
Shawn O. Pearce | 74d18d2 | 2006-11-19 00:37:49 -0500 | [diff] [blame] | 1146 | [list $path] \ |
| 1147 | [concat $after {set ui_status_value {Ready.}}] |
| 1148 | } |
Shawn O. Pearce | 24263b7 | 2006-11-13 16:06:38 -0500 | [diff] [blame] | 1149 | } else { |
Shawn O. Pearce | 03e4ec5 | 2006-11-11 17:52:16 -0500 | [diff] [blame] | 1150 | show_diff $path $w $lno |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1151 | } |
| 1152 | } |
| 1153 | |
Shawn O. Pearce | 24263b7 | 2006-11-13 16:06:38 -0500 | [diff] [blame] | 1154 | proc add_one_to_selection {w x y} { |
Shawn O. Pearce | 833eda7 | 2007-01-20 23:46:53 -0500 | [diff] [blame] | 1155 | global file_lists last_clicked selected_paths |
Shawn O. Pearce | 7f1df79 | 2006-11-11 18:38:00 -0500 | [diff] [blame] | 1156 | |
Shawn O. Pearce | 833eda7 | 2007-01-20 23:46:53 -0500 | [diff] [blame] | 1157 | set lno [lindex [split [$w index @$x,$y] .] 0] |
Shawn O. Pearce | 24263b7 | 2006-11-13 16:06:38 -0500 | [diff] [blame] | 1158 | set path [lindex $file_lists($w) [expr {$lno - 1}]] |
| 1159 | if {$path eq {}} { |
| 1160 | set last_clicked {} |
| 1161 | return |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1162 | } |
Shawn O. Pearce | 24263b7 | 2006-11-13 16:06:38 -0500 | [diff] [blame] | 1163 | |
Shawn O. Pearce | 833eda7 | 2007-01-20 23:46:53 -0500 | [diff] [blame] | 1164 | if {$last_clicked ne {} |
| 1165 | && [lindex $last_clicked 0] ne $w} { |
| 1166 | array unset selected_paths |
| 1167 | [lindex $last_clicked 0] tag remove in_sel 0.0 end |
| 1168 | } |
| 1169 | |
Shawn O. Pearce | 24263b7 | 2006-11-13 16:06:38 -0500 | [diff] [blame] | 1170 | set last_clicked [list $w $lno] |
| 1171 | if {[catch {set in_sel $selected_paths($path)}]} { |
| 1172 | set in_sel 0 |
| 1173 | } |
| 1174 | if {$in_sel} { |
| 1175 | unset selected_paths($path) |
| 1176 | $w tag remove in_sel $lno.0 [expr {$lno + 1}].0 |
| 1177 | } else { |
| 1178 | set selected_paths($path) 1 |
| 1179 | $w tag add in_sel $lno.0 [expr {$lno + 1}].0 |
| 1180 | } |
| 1181 | } |
| 1182 | |
| 1183 | proc add_range_to_selection {w x y} { |
Shawn O. Pearce | 833eda7 | 2007-01-20 23:46:53 -0500 | [diff] [blame] | 1184 | global file_lists last_clicked selected_paths |
Shawn O. Pearce | 24263b7 | 2006-11-13 16:06:38 -0500 | [diff] [blame] | 1185 | |
| 1186 | if {[lindex $last_clicked 0] ne $w} { |
| 1187 | toggle_or_diff $w $x $y |
| 1188 | return |
| 1189 | } |
| 1190 | |
Shawn O. Pearce | 833eda7 | 2007-01-20 23:46:53 -0500 | [diff] [blame] | 1191 | set lno [lindex [split [$w index @$x,$y] .] 0] |
Shawn O. Pearce | 24263b7 | 2006-11-13 16:06:38 -0500 | [diff] [blame] | 1192 | set lc [lindex $last_clicked 1] |
| 1193 | if {$lc < $lno} { |
| 1194 | set begin $lc |
| 1195 | set end $lno |
| 1196 | } else { |
| 1197 | set begin $lno |
| 1198 | set end $lc |
| 1199 | } |
| 1200 | |
| 1201 | foreach path [lrange $file_lists($w) \ |
| 1202 | [expr {$begin - 1}] \ |
| 1203 | [expr {$end - 1}]] { |
| 1204 | set selected_paths($path) 1 |
| 1205 | } |
| 1206 | $w tag add in_sel $begin.0 [expr {$end + 1}].0 |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1207 | } |
| 1208 | |
| 1209 | ###################################################################### |
| 1210 | ## |
Shawn O. Pearce | 92148d8 | 2006-11-12 05:27:00 -0500 | [diff] [blame] | 1211 | ## config defaults |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1212 | |
Shawn O. Pearce | 00f949f | 2006-11-12 02:30:02 -0500 | [diff] [blame] | 1213 | set cursor_ptr arrow |
Shawn O. Pearce | b494693 | 2006-11-12 00:40:38 -0500 | [diff] [blame] | 1214 | font create font_diff -family Courier -size 10 |
| 1215 | font create font_ui |
| 1216 | catch { |
| 1217 | label .dummy |
| 1218 | eval font configure font_ui [font actual [.dummy cget -font]] |
| 1219 | destroy .dummy |
| 1220 | } |
| 1221 | |
Shawn O. Pearce | debcd0f | 2007-06-02 17:15:56 -0400 | [diff] [blame] | 1222 | font create font_uiitalic |
Shawn O. Pearce | 92148d8 | 2006-11-12 05:27:00 -0500 | [diff] [blame] | 1223 | font create font_uibold |
| 1224 | font create font_diffbold |
Shawn O. Pearce | debcd0f | 2007-06-02 17:15:56 -0400 | [diff] [blame] | 1225 | font create font_diffitalic |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1226 | |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1227 | foreach class {Button Checkbutton Entry Label |
| 1228 | Labelframe Listbox Menu Message |
Shawn O. Pearce | 6309172 | 2007-06-02 17:18:46 -0400 | [diff] [blame] | 1229 | Radiobutton Spinbox Text} { |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1230 | option add *$class.font font_ui |
| 1231 | } |
| 1232 | unset class |
| 1233 | |
Shawn O. Pearce | 3d5793b | 2007-05-24 02:33:13 -0400 | [diff] [blame] | 1234 | if {[is_MacOSX]} { |
Shawn O. Pearce | 16fccd7 | 2006-11-12 02:22:21 -0500 | [diff] [blame] | 1235 | set M1B M1 |
| 1236 | set M1T Cmd |
Shawn O. Pearce | b673bbc | 2006-11-21 20:21:11 -0500 | [diff] [blame] | 1237 | } else { |
Shawn O. Pearce | 3d5793b | 2007-05-24 02:33:13 -0400 | [diff] [blame] | 1238 | set M1B Control |
| 1239 | set M1T Ctrl |
Shawn O. Pearce | e210e67 | 2006-11-06 19:12:58 -0500 | [diff] [blame] | 1240 | } |
| 1241 | |
Shawn O. Pearce | 92148d8 | 2006-11-12 05:27:00 -0500 | [diff] [blame] | 1242 | proc apply_config {} { |
| 1243 | global repo_config font_descs |
| 1244 | |
| 1245 | foreach option $font_descs { |
| 1246 | set name [lindex $option 0] |
| 1247 | set font [lindex $option 1] |
| 1248 | if {[catch { |
| 1249 | foreach {cn cv} $repo_config(gui.$name) { |
| 1250 | font configure $font $cn $cv |
| 1251 | } |
| 1252 | } err]} { |
| 1253 | error_popup "Invalid font specified in gui.$name:\n\n$err" |
| 1254 | } |
| 1255 | foreach {cn cv} [font configure $font] { |
| 1256 | font configure ${font}bold $cn $cv |
Shawn O. Pearce | debcd0f | 2007-06-02 17:15:56 -0400 | [diff] [blame] | 1257 | font configure ${font}italic $cn $cv |
Shawn O. Pearce | 92148d8 | 2006-11-12 05:27:00 -0500 | [diff] [blame] | 1258 | } |
| 1259 | font configure ${font}bold -weight bold |
Shawn O. Pearce | debcd0f | 2007-06-02 17:15:56 -0400 | [diff] [blame] | 1260 | font configure ${font}italic -slant italic |
Shawn O. Pearce | 92148d8 | 2006-11-12 05:27:00 -0500 | [diff] [blame] | 1261 | } |
| 1262 | } |
| 1263 | |
Shawn O. Pearce | 6b90d39 | 2007-01-27 02:31:01 -0500 | [diff] [blame] | 1264 | set default_config(merge.summary) false |
Shawn O. Pearce | c539449 | 2007-01-26 04:43:43 -0500 | [diff] [blame] | 1265 | set default_config(merge.verbosity) 2 |
Shawn O. Pearce | db45378 | 2007-01-29 02:56:07 -0500 | [diff] [blame] | 1266 | set default_config(user.name) {} |
| 1267 | set default_config(user.email) {} |
| 1268 | |
Shawn O. Pearce | 92148d8 | 2006-11-12 05:27:00 -0500 | [diff] [blame] | 1269 | set default_config(gui.trustmtime) false |
Shawn O. Pearce | 358d8de | 2006-11-12 19:20:02 -0500 | [diff] [blame] | 1270 | set default_config(gui.diffcontext) 5 |
Shawn O. Pearce | c845692 | 2007-01-21 16:28:59 -0500 | [diff] [blame] | 1271 | set default_config(gui.newbranchtemplate) {} |
Shawn O. Pearce | 92148d8 | 2006-11-12 05:27:00 -0500 | [diff] [blame] | 1272 | set default_config(gui.fontui) [font configure font_ui] |
| 1273 | set default_config(gui.fontdiff) [font configure font_diff] |
| 1274 | set font_descs { |
| 1275 | {fontui font_ui {Main Font}} |
| 1276 | {fontdiff font_diff {Diff/Console Font}} |
| 1277 | } |
Shawn O. Pearce | 6bbd1cb | 2006-11-12 16:24:52 -0500 | [diff] [blame] | 1278 | load_config 0 |
Shawn O. Pearce | 92148d8 | 2006-11-12 05:27:00 -0500 | [diff] [blame] | 1279 | apply_config |
| 1280 | |
| 1281 | ###################################################################### |
| 1282 | ## |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1283 | ## feature option selection |
| 1284 | |
Shawn O. Pearce | 258871d | 2007-02-08 19:41:32 -0500 | [diff] [blame] | 1285 | if {[regexp {^git-(.+)$} [appname] _junk subcommand]} { |
| 1286 | unset _junk |
| 1287 | } else { |
| 1288 | set subcommand gui |
| 1289 | } |
| 1290 | if {$subcommand eq {gui.sh}} { |
| 1291 | set subcommand gui |
| 1292 | } |
| 1293 | if {$subcommand eq {gui} && [llength $argv] > 0} { |
| 1294 | set subcommand [lindex $argv 0] |
| 1295 | set argv [lrange $argv 1 end] |
| 1296 | } |
| 1297 | |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1298 | enable_option multicommit |
| 1299 | enable_option branch |
| 1300 | enable_option transport |
| 1301 | |
Shawn O. Pearce | 258871d | 2007-02-08 19:41:32 -0500 | [diff] [blame] | 1302 | switch -- $subcommand { |
Shawn O. Pearce | b90d479 | 2007-02-16 00:24:03 -0500 | [diff] [blame] | 1303 | browser - |
Shawn O. Pearce | 258871d | 2007-02-08 19:41:32 -0500 | [diff] [blame] | 1304 | blame { |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1305 | disable_option multicommit |
| 1306 | disable_option branch |
| 1307 | disable_option transport |
| 1308 | } |
Shawn O. Pearce | 258871d | 2007-02-08 19:41:32 -0500 | [diff] [blame] | 1309 | citool { |
| 1310 | enable_option singlecommit |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1311 | |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1312 | disable_option multicommit |
| 1313 | disable_option branch |
| 1314 | disable_option transport |
| 1315 | } |
| 1316 | } |
| 1317 | |
| 1318 | ###################################################################### |
| 1319 | ## |
Shawn O. Pearce | 92148d8 | 2006-11-12 05:27:00 -0500 | [diff] [blame] | 1320 | ## ui construction |
| 1321 | |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1322 | set ui_comm {} |
| 1323 | |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1324 | # -- Menu Bar |
Shawn O. Pearce | a49c67d | 2006-11-18 03:27:23 -0500 | [diff] [blame] | 1325 | # |
Shawn O. Pearce | b494693 | 2006-11-12 00:40:38 -0500 | [diff] [blame] | 1326 | menu .mbar -tearoff 0 |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1327 | .mbar add cascade -label Repository -menu .mbar.repository |
| 1328 | .mbar add cascade -label Edit -menu .mbar.edit |
Shawn O. Pearce | 64a906f | 2007-02-08 18:10:05 -0500 | [diff] [blame] | 1329 | if {[is_enabled branch]} { |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1330 | .mbar add cascade -label Branch -menu .mbar.branch |
Shawn O. Pearce | 700a65c | 2006-11-24 17:30:12 -0500 | [diff] [blame] | 1331 | } |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1332 | if {[is_enabled multicommit] || [is_enabled singlecommit]} { |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1333 | .mbar add cascade -label Commit -menu .mbar.commit |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1334 | } |
Shawn O. Pearce | 64a906f | 2007-02-08 18:10:05 -0500 | [diff] [blame] | 1335 | if {[is_enabled transport]} { |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1336 | .mbar add cascade -label Merge -menu .mbar.merge |
| 1337 | .mbar add cascade -label Fetch -menu .mbar.fetch |
| 1338 | .mbar add cascade -label Push -menu .mbar.push |
Shawn O. Pearce | 4ccdab0 | 2006-11-12 16:20:36 -0500 | [diff] [blame] | 1339 | } |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1340 | . configure -menu .mbar |
| 1341 | |
Shawn O. Pearce | a4abfa6 | 2006-11-20 23:01:47 -0500 | [diff] [blame] | 1342 | # -- Repository Menu |
Shawn O. Pearce | a49c67d | 2006-11-18 03:27:23 -0500 | [diff] [blame] | 1343 | # |
Shawn O. Pearce | a4abfa6 | 2006-11-20 23:01:47 -0500 | [diff] [blame] | 1344 | menu .mbar.repository |
Shawn O. Pearce | 35874c1 | 2007-01-29 00:50:41 -0500 | [diff] [blame] | 1345 | |
| 1346 | .mbar.repository add command \ |
| 1347 | -label {Browse Current Branch} \ |
Shawn O. Pearce | c74b6c6 | 2007-05-08 20:33:47 -0400 | [diff] [blame] | 1348 | -command {browser::new $current_branch} |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1349 | trace add variable current_branch write ".mbar.repository entryconf [.mbar.repository index last] -label \"Browse \$current_branch\" ;#" |
Shawn O. Pearce | 35874c1 | 2007-01-29 00:50:41 -0500 | [diff] [blame] | 1350 | .mbar.repository add separator |
| 1351 | |
Shawn O. Pearce | d075242 | 2006-11-21 20:33:09 -0500 | [diff] [blame] | 1352 | .mbar.repository add command \ |
| 1353 | -label {Visualize Current Branch} \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1354 | -command {do_gitk $current_branch} |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1355 | trace add variable current_branch write ".mbar.repository entryconf [.mbar.repository index last] -label \"Visualize \$current_branch\" ;#" |
Shawn O. Pearce | 5753ef1 | 2007-01-25 13:01:16 -0500 | [diff] [blame] | 1356 | .mbar.repository add command \ |
| 1357 | -label {Visualize All Branches} \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1358 | -command {do_gitk --all} |
Shawn O. Pearce | d075242 | 2006-11-21 20:33:09 -0500 | [diff] [blame] | 1359 | .mbar.repository add separator |
Shawn O. Pearce | 75e355d | 2006-11-20 22:22:10 -0500 | [diff] [blame] | 1360 | |
Shawn O. Pearce | cf25ddc | 2007-02-08 18:03:41 -0500 | [diff] [blame] | 1361 | if {[is_enabled multicommit]} { |
Shawn O. Pearce | 0fd49d0 | 2007-01-24 15:21:01 -0500 | [diff] [blame] | 1362 | .mbar.repository add command -label {Database Statistics} \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1363 | -command do_stats |
Shawn O. Pearce | 0fd49d0 | 2007-01-24 15:21:01 -0500 | [diff] [blame] | 1364 | |
Shawn O. Pearce | 81c0f29 | 2007-01-20 18:38:12 -0500 | [diff] [blame] | 1365 | .mbar.repository add command -label {Compress Database} \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1366 | -command do_gc |
Shawn O. Pearce | 4aca740 | 2006-11-15 22:35:26 -0500 | [diff] [blame] | 1367 | |
Shawn O. Pearce | a4abfa6 | 2006-11-20 23:01:47 -0500 | [diff] [blame] | 1368 | .mbar.repository add command -label {Verify Database} \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1369 | -command do_fsck_objects |
Shawn O. Pearce | 444f92d | 2006-11-20 21:43:41 -0500 | [diff] [blame] | 1370 | |
Shawn O. Pearce | a4abfa6 | 2006-11-20 23:01:47 -0500 | [diff] [blame] | 1371 | .mbar.repository add separator |
Shawn O. Pearce | 75e355d | 2006-11-20 22:22:10 -0500 | [diff] [blame] | 1372 | |
Shawn O. Pearce | 20ddfca | 2007-01-28 20:58:47 -0500 | [diff] [blame] | 1373 | if {[is_Cygwin]} { |
| 1374 | .mbar.repository add command \ |
| 1375 | -label {Create Desktop Icon} \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1376 | -command do_cygwin_shortcut |
Shawn O. Pearce | 20ddfca | 2007-01-28 20:58:47 -0500 | [diff] [blame] | 1377 | } elseif {[is_Windows]} { |
Shawn O. Pearce | a4abfa6 | 2006-11-20 23:01:47 -0500 | [diff] [blame] | 1378 | .mbar.repository add command \ |
Shawn O. Pearce | 4aca740 | 2006-11-15 22:35:26 -0500 | [diff] [blame] | 1379 | -label {Create Desktop Icon} \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1380 | -command do_windows_shortcut |
Shawn O. Pearce | 06c3111 | 2006-11-18 00:31:00 -0500 | [diff] [blame] | 1381 | } elseif {[is_MacOSX]} { |
Shawn O. Pearce | a4abfa6 | 2006-11-20 23:01:47 -0500 | [diff] [blame] | 1382 | .mbar.repository add command \ |
Shawn O. Pearce | 06c3111 | 2006-11-18 00:31:00 -0500 | [diff] [blame] | 1383 | -label {Create Desktop Icon} \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1384 | -command do_macosx_app |
Shawn O. Pearce | 4aca740 | 2006-11-15 22:35:26 -0500 | [diff] [blame] | 1385 | } |
Shawn O. Pearce | 4ccdab0 | 2006-11-12 16:20:36 -0500 | [diff] [blame] | 1386 | } |
Shawn O. Pearce | 85ab313 | 2006-11-25 03:38:39 -0500 | [diff] [blame] | 1387 | |
Shawn O. Pearce | a4abfa6 | 2006-11-20 23:01:47 -0500 | [diff] [blame] | 1388 | .mbar.repository add command -label Quit \ |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1389 | -command do_quit \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1390 | -accelerator $M1T-Q |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1391 | |
Shawn O. Pearce | 9861671 | 2006-11-11 15:51:41 -0500 | [diff] [blame] | 1392 | # -- Edit Menu |
| 1393 | # |
| 1394 | menu .mbar.edit |
| 1395 | .mbar.edit add command -label Undo \ |
| 1396 | -command {catch {[focus] edit undo}} \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1397 | -accelerator $M1T-Z |
Shawn O. Pearce | 9861671 | 2006-11-11 15:51:41 -0500 | [diff] [blame] | 1398 | .mbar.edit add command -label Redo \ |
| 1399 | -command {catch {[focus] edit redo}} \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1400 | -accelerator $M1T-Y |
Shawn O. Pearce | 9861671 | 2006-11-11 15:51:41 -0500 | [diff] [blame] | 1401 | .mbar.edit add separator |
| 1402 | .mbar.edit add command -label Cut \ |
| 1403 | -command {catch {tk_textCut [focus]}} \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1404 | -accelerator $M1T-X |
Shawn O. Pearce | 9861671 | 2006-11-11 15:51:41 -0500 | [diff] [blame] | 1405 | .mbar.edit add command -label Copy \ |
| 1406 | -command {catch {tk_textCopy [focus]}} \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1407 | -accelerator $M1T-C |
Shawn O. Pearce | 9861671 | 2006-11-11 15:51:41 -0500 | [diff] [blame] | 1408 | .mbar.edit add command -label Paste \ |
| 1409 | -command {catch {tk_textPaste [focus]; [focus] see insert}} \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1410 | -accelerator $M1T-V |
Shawn O. Pearce | 9861671 | 2006-11-11 15:51:41 -0500 | [diff] [blame] | 1411 | .mbar.edit add command -label Delete \ |
| 1412 | -command {catch {[focus] delete sel.first sel.last}} \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1413 | -accelerator Del |
Shawn O. Pearce | 9861671 | 2006-11-11 15:51:41 -0500 | [diff] [blame] | 1414 | .mbar.edit add separator |
| 1415 | .mbar.edit add command -label {Select All} \ |
| 1416 | -command {catch {[focus] tag add sel 0.0 end}} \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1417 | -accelerator $M1T-A |
Shawn O. Pearce | 9861671 | 2006-11-11 15:51:41 -0500 | [diff] [blame] | 1418 | |
Shawn O. Pearce | 85ab313 | 2006-11-25 03:38:39 -0500 | [diff] [blame] | 1419 | # -- Branch Menu |
| 1420 | # |
Shawn O. Pearce | 64a906f | 2007-02-08 18:10:05 -0500 | [diff] [blame] | 1421 | if {[is_enabled branch]} { |
Shawn O. Pearce | 700a65c | 2006-11-24 17:30:12 -0500 | [diff] [blame] | 1422 | menu .mbar.branch |
| 1423 | |
| 1424 | .mbar.branch add command -label {Create...} \ |
| 1425 | -command do_create_branch \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1426 | -accelerator $M1T-N |
Shawn O. Pearce | 700a65c | 2006-11-24 17:30:12 -0500 | [diff] [blame] | 1427 | lappend disable_on_lock [list .mbar.branch entryconf \ |
| 1428 | [.mbar.branch index last] -state] |
| 1429 | |
| 1430 | .mbar.branch add command -label {Delete...} \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1431 | -command do_delete_branch |
Shawn O. Pearce | 700a65c | 2006-11-24 17:30:12 -0500 | [diff] [blame] | 1432 | lappend disable_on_lock [list .mbar.branch entryconf \ |
| 1433 | [.mbar.branch index last] -state] |
Shawn O. Pearce | fd234df | 2007-02-26 11:22:10 -0500 | [diff] [blame] | 1434 | |
| 1435 | .mbar.branch add command -label {Reset...} \ |
Shawn O. Pearce | a6c9b08 | 2007-05-02 13:56:27 -0400 | [diff] [blame] | 1436 | -command merge::reset_hard |
Shawn O. Pearce | fd234df | 2007-02-26 11:22:10 -0500 | [diff] [blame] | 1437 | lappend disable_on_lock [list .mbar.branch entryconf \ |
| 1438 | [.mbar.branch index last] -state] |
Shawn O. Pearce | 700a65c | 2006-11-24 17:30:12 -0500 | [diff] [blame] | 1439 | } |
| 1440 | |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1441 | # -- Commit Menu |
Shawn O. Pearce | a49c67d | 2006-11-18 03:27:23 -0500 | [diff] [blame] | 1442 | # |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1443 | if {[is_enabled multicommit] || [is_enabled singlecommit]} { |
| 1444 | menu .mbar.commit |
Shawn O. Pearce | 24ac9b7 | 2006-11-18 20:59:49 -0500 | [diff] [blame] | 1445 | |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1446 | .mbar.commit add radiobutton \ |
| 1447 | -label {New Commit} \ |
| 1448 | -command do_select_commit_type \ |
| 1449 | -variable selected_commit_type \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1450 | -value new |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1451 | lappend disable_on_lock \ |
| 1452 | [list .mbar.commit entryconf [.mbar.commit index last] -state] |
Shawn O. Pearce | 24ac9b7 | 2006-11-18 20:59:49 -0500 | [diff] [blame] | 1453 | |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1454 | .mbar.commit add radiobutton \ |
| 1455 | -label {Amend Last Commit} \ |
| 1456 | -command do_select_commit_type \ |
| 1457 | -variable selected_commit_type \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1458 | -value amend |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1459 | lappend disable_on_lock \ |
| 1460 | [list .mbar.commit entryconf [.mbar.commit index last] -state] |
Shawn O. Pearce | 24ac9b7 | 2006-11-18 20:59:49 -0500 | [diff] [blame] | 1461 | |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1462 | .mbar.commit add separator |
Shawn O. Pearce | 24ac9b7 | 2006-11-18 20:59:49 -0500 | [diff] [blame] | 1463 | |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1464 | .mbar.commit add command -label Rescan \ |
| 1465 | -command do_rescan \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1466 | -accelerator F5 |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1467 | lappend disable_on_lock \ |
| 1468 | [list .mbar.commit entryconf [.mbar.commit index last] -state] |
Shawn O. Pearce | 24ac9b7 | 2006-11-18 20:59:49 -0500 | [diff] [blame] | 1469 | |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1470 | .mbar.commit add command -label {Add To Commit} \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1471 | -command do_add_selection |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1472 | lappend disable_on_lock \ |
| 1473 | [list .mbar.commit entryconf [.mbar.commit index last] -state] |
Shawn O. Pearce | 24ac9b7 | 2006-11-18 20:59:49 -0500 | [diff] [blame] | 1474 | |
Shawn O. Pearce | 24d2bf2 | 2007-02-08 19:44:49 -0500 | [diff] [blame] | 1475 | .mbar.commit add command -label {Add Existing To Commit} \ |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1476 | -command do_add_all \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1477 | -accelerator $M1T-I |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1478 | lappend disable_on_lock \ |
| 1479 | [list .mbar.commit entryconf [.mbar.commit index last] -state] |
Shawn O. Pearce | 24ac9b7 | 2006-11-18 20:59:49 -0500 | [diff] [blame] | 1480 | |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1481 | .mbar.commit add command -label {Unstage From Commit} \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1482 | -command do_unstage_selection |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1483 | lappend disable_on_lock \ |
| 1484 | [list .mbar.commit entryconf [.mbar.commit index last] -state] |
Shawn O. Pearce | e734817 | 2006-11-23 21:40:45 -0500 | [diff] [blame] | 1485 | |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1486 | .mbar.commit add command -label {Revert Changes} \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1487 | -command do_revert_selection |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1488 | lappend disable_on_lock \ |
| 1489 | [list .mbar.commit entryconf [.mbar.commit index last] -state] |
Shawn O. Pearce | e734817 | 2006-11-23 21:40:45 -0500 | [diff] [blame] | 1490 | |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1491 | .mbar.commit add separator |
Shawn O. Pearce | 1461c5f | 2006-11-19 00:29:55 -0500 | [diff] [blame] | 1492 | |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1493 | .mbar.commit add command -label {Sign Off} \ |
| 1494 | -command do_signoff \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1495 | -accelerator $M1T-S |
Shawn O. Pearce | 24ac9b7 | 2006-11-18 20:59:49 -0500 | [diff] [blame] | 1496 | |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1497 | .mbar.commit add command -label Commit \ |
| 1498 | -command do_commit \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1499 | -accelerator $M1T-Return |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1500 | lappend disable_on_lock \ |
| 1501 | [list .mbar.commit entryconf [.mbar.commit index last] -state] |
| 1502 | } |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1503 | |
Shawn O. Pearce | 9b28a8b | 2007-02-26 11:17:11 -0500 | [diff] [blame] | 1504 | # -- Merge Menu |
| 1505 | # |
| 1506 | if {[is_enabled branch]} { |
| 1507 | menu .mbar.merge |
| 1508 | .mbar.merge add command -label {Local Merge...} \ |
Shawn O. Pearce | a6c9b08 | 2007-05-02 13:56:27 -0400 | [diff] [blame] | 1509 | -command merge::dialog |
Shawn O. Pearce | 9b28a8b | 2007-02-26 11:17:11 -0500 | [diff] [blame] | 1510 | lappend disable_on_lock \ |
| 1511 | [list .mbar.merge entryconf [.mbar.merge index last] -state] |
| 1512 | .mbar.merge add command -label {Abort Merge...} \ |
Shawn O. Pearce | a6c9b08 | 2007-05-02 13:56:27 -0400 | [diff] [blame] | 1513 | -command merge::reset_hard |
Shawn O. Pearce | 9b28a8b | 2007-02-26 11:17:11 -0500 | [diff] [blame] | 1514 | lappend disable_on_lock \ |
| 1515 | [list .mbar.merge entryconf [.mbar.merge index last] -state] |
| 1516 | |
| 1517 | } |
| 1518 | |
| 1519 | # -- Transport Menu |
| 1520 | # |
| 1521 | if {[is_enabled transport]} { |
| 1522 | menu .mbar.fetch |
| 1523 | |
| 1524 | menu .mbar.push |
| 1525 | .mbar.push add command -label {Push...} \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1526 | -command do_push_anywhere |
Shawn O. Pearce | 9b28a8b | 2007-02-26 11:17:11 -0500 | [diff] [blame] | 1527 | } |
| 1528 | |
Shawn O. Pearce | 0c8d783 | 2006-11-21 02:33:56 -0500 | [diff] [blame] | 1529 | if {[is_MacOSX]} { |
| 1530 | # -- Apple Menu (Mac OS X only) |
| 1531 | # |
| 1532 | .mbar add cascade -label Apple -menu .mbar.apple |
| 1533 | menu .mbar.apple |
Shawn O. Pearce | 82aa235 | 2006-11-20 23:55:51 -0500 | [diff] [blame] | 1534 | |
Shawn O. Pearce | c950c66 | 2007-01-20 21:48:56 -0500 | [diff] [blame] | 1535 | .mbar.apple add command -label "About [appname]" \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1536 | -command do_about |
Shawn O. Pearce | 5ac58f5 | 2007-02-14 00:10:20 -0500 | [diff] [blame] | 1537 | .mbar.apple add command -label "Options..." \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1538 | -command do_options |
Shawn O. Pearce | 0c8d783 | 2006-11-21 02:33:56 -0500 | [diff] [blame] | 1539 | } else { |
| 1540 | # -- Edit Menu |
| 1541 | # |
| 1542 | .mbar.edit add separator |
| 1543 | .mbar.edit add command -label {Options...} \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1544 | -command do_options |
Shawn O. Pearce | 0c8d783 | 2006-11-21 02:33:56 -0500 | [diff] [blame] | 1545 | |
Shawn O. Pearce | 557afe8 | 2006-12-07 22:07:38 -0500 | [diff] [blame] | 1546 | # -- Tools Menu |
| 1547 | # |
Shawn O. Pearce | 7e508eb | 2007-06-26 15:27:35 -0400 | [diff] [blame^] | 1548 | if {[is_Cygwin] && [file exists /usr/local/miga/lib/gui-miga]} { |
Shawn O. Pearce | 557afe8 | 2006-12-07 22:07:38 -0500 | [diff] [blame] | 1549 | proc do_miga {} { |
Shawn O. Pearce | c950c66 | 2007-01-20 21:48:56 -0500 | [diff] [blame] | 1550 | global ui_status_value |
Shawn O. Pearce | 557afe8 | 2006-12-07 22:07:38 -0500 | [diff] [blame] | 1551 | if {![lock_index update]} return |
| 1552 | set cmd [list sh --login -c "/usr/local/miga/lib/gui-miga \"[pwd]\""] |
| 1553 | set miga_fd [open "|$cmd" r] |
| 1554 | fconfigure $miga_fd -blocking 0 |
| 1555 | fileevent $miga_fd readable [list miga_done $miga_fd] |
| 1556 | set ui_status_value {Running miga...} |
| 1557 | } |
| 1558 | proc miga_done {fd} { |
| 1559 | read $fd 512 |
| 1560 | if {[eof $fd]} { |
| 1561 | close $fd |
| 1562 | unlock_index |
| 1563 | rescan [list set ui_status_value {Ready.}] |
| 1564 | } |
| 1565 | } |
| 1566 | .mbar add cascade -label Tools -menu .mbar.tools |
| 1567 | menu .mbar.tools |
| 1568 | .mbar.tools add command -label "Migrate" \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1569 | -command do_miga |
Shawn O. Pearce | 557afe8 | 2006-12-07 22:07:38 -0500 | [diff] [blame] | 1570 | lappend disable_on_lock \ |
| 1571 | [list .mbar.tools entryconf [.mbar.tools index last] -state] |
| 1572 | } |
Shawn O. Pearce | 273984f | 2007-01-28 20:00:36 -0500 | [diff] [blame] | 1573 | } |
Shawn O. Pearce | 557afe8 | 2006-12-07 22:07:38 -0500 | [diff] [blame] | 1574 | |
Shawn O. Pearce | 273984f | 2007-01-28 20:00:36 -0500 | [diff] [blame] | 1575 | # -- Help Menu |
| 1576 | # |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1577 | .mbar add cascade -label Help -menu .mbar.help |
Shawn O. Pearce | 273984f | 2007-01-28 20:00:36 -0500 | [diff] [blame] | 1578 | menu .mbar.help |
Shawn O. Pearce | 0c8d783 | 2006-11-21 02:33:56 -0500 | [diff] [blame] | 1579 | |
Shawn O. Pearce | 273984f | 2007-01-28 20:00:36 -0500 | [diff] [blame] | 1580 | if {![is_MacOSX]} { |
Shawn O. Pearce | c950c66 | 2007-01-20 21:48:56 -0500 | [diff] [blame] | 1581 | .mbar.help add command -label "About [appname]" \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1582 | -command do_about |
Shawn O. Pearce | 0c8d783 | 2006-11-21 02:33:56 -0500 | [diff] [blame] | 1583 | } |
| 1584 | |
Shawn O. Pearce | 273984f | 2007-01-28 20:00:36 -0500 | [diff] [blame] | 1585 | set browser {} |
| 1586 | catch {set browser $repo_config(instaweb.browser)} |
Shawn O. Pearce | 20ddfca | 2007-01-28 20:58:47 -0500 | [diff] [blame] | 1587 | set doc_path [file dirname [gitexec]] |
Shawn O. Pearce | 273984f | 2007-01-28 20:00:36 -0500 | [diff] [blame] | 1588 | set doc_path [file join $doc_path Documentation index.html] |
| 1589 | |
Shawn O. Pearce | 20ddfca | 2007-01-28 20:58:47 -0500 | [diff] [blame] | 1590 | if {[is_Cygwin]} { |
Shawn O. Pearce | ee40599 | 2007-02-18 19:06:09 -0500 | [diff] [blame] | 1591 | set doc_path [exec cygpath --mixed $doc_path] |
Shawn O. Pearce | 273984f | 2007-01-28 20:00:36 -0500 | [diff] [blame] | 1592 | } |
| 1593 | |
| 1594 | if {$browser eq {}} { |
| 1595 | if {[is_MacOSX]} { |
| 1596 | set browser open |
Shawn O. Pearce | 20ddfca | 2007-01-28 20:58:47 -0500 | [diff] [blame] | 1597 | } elseif {[is_Cygwin]} { |
Shawn O. Pearce | 273984f | 2007-01-28 20:00:36 -0500 | [diff] [blame] | 1598 | set program_files [file dirname [exec cygpath --windir]] |
| 1599 | set program_files [file join $program_files {Program Files}] |
| 1600 | set firefox [file join $program_files {Mozilla Firefox} firefox.exe] |
| 1601 | set ie [file join $program_files {Internet Explorer} IEXPLORE.EXE] |
| 1602 | if {[file exists $firefox]} { |
| 1603 | set browser $firefox |
| 1604 | } elseif {[file exists $ie]} { |
| 1605 | set browser $ie |
| 1606 | } |
| 1607 | unset program_files firefox ie |
| 1608 | } |
| 1609 | } |
| 1610 | |
| 1611 | if {[file isfile $doc_path]} { |
| 1612 | set doc_url "file:$doc_path" |
| 1613 | } else { |
| 1614 | set doc_url {http://www.kernel.org/pub/software/scm/git/docs/} |
| 1615 | } |
| 1616 | |
| 1617 | if {$browser ne {}} { |
| 1618 | .mbar.help add command -label {Online Documentation} \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1619 | -command [list exec $browser $doc_url &] |
Shawn O. Pearce | 273984f | 2007-01-28 20:00:36 -0500 | [diff] [blame] | 1620 | } |
| 1621 | unset browser doc_path doc_url |
Shawn O. Pearce | 82aa235 | 2006-11-20 23:55:51 -0500 | [diff] [blame] | 1622 | |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1623 | # -- Standard bindings |
| 1624 | # |
Shawn O. Pearce | 39fa2a9 | 2007-06-11 23:52:43 -0400 | [diff] [blame] | 1625 | wm protocol . WM_DELETE_WINDOW do_quit |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1626 | bind all <$M1B-Key-q> do_quit |
| 1627 | bind all <$M1B-Key-Q> do_quit |
| 1628 | bind all <$M1B-Key-w> {destroy [winfo toplevel %W]} |
| 1629 | bind all <$M1B-Key-W> {destroy [winfo toplevel %W]} |
| 1630 | |
Shawn O. Pearce | 3e45ee1 | 2007-05-08 22:36:01 -0400 | [diff] [blame] | 1631 | set subcommand_args {} |
| 1632 | proc usage {} { |
| 1633 | puts stderr "usage: $::argv0 $::subcommand $::subcommand_args" |
| 1634 | exit 1 |
| 1635 | } |
| 1636 | |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1637 | # -- Not a normal commit type invocation? Do that instead! |
| 1638 | # |
Shawn O. Pearce | 258871d | 2007-02-08 19:41:32 -0500 | [diff] [blame] | 1639 | switch -- $subcommand { |
Shawn O. Pearce | b90d479 | 2007-02-16 00:24:03 -0500 | [diff] [blame] | 1640 | browser { |
Shawn O. Pearce | 3e45ee1 | 2007-05-08 22:36:01 -0400 | [diff] [blame] | 1641 | set subcommand_args {rev?} |
| 1642 | switch [llength $argv] { |
| 1643 | 0 { |
| 1644 | set current_branch [git symbolic-ref HEAD] |
| 1645 | regsub ^refs/((heads|tags|remotes)/)? \ |
| 1646 | $current_branch {} current_branch |
Shawn O. Pearce | b90d479 | 2007-02-16 00:24:03 -0500 | [diff] [blame] | 1647 | } |
Shawn O. Pearce | 3e45ee1 | 2007-05-08 22:36:01 -0400 | [diff] [blame] | 1648 | 1 { |
| 1649 | set current_branch [lindex $argv 0] |
| 1650 | } |
| 1651 | default usage |
| 1652 | } |
Shawn O. Pearce | c74b6c6 | 2007-05-08 20:33:47 -0400 | [diff] [blame] | 1653 | browser::new $current_branch |
Shawn O. Pearce | b90d479 | 2007-02-16 00:24:03 -0500 | [diff] [blame] | 1654 | return |
| 1655 | } |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1656 | blame { |
Shawn O. Pearce | 3e45ee1 | 2007-05-08 22:36:01 -0400 | [diff] [blame] | 1657 | set subcommand_args {rev? path?} |
Shawn O. Pearce | a0db0d6 | 2007-05-08 22:48:47 -0400 | [diff] [blame] | 1658 | set head {} |
Shawn O. Pearce | 3e45ee1 | 2007-05-08 22:36:01 -0400 | [diff] [blame] | 1659 | set path {} |
| 1660 | set is_path 0 |
| 1661 | foreach a $argv { |
| 1662 | if {$is_path || [file exists $_prefix$a]} { |
| 1663 | if {$path ne {}} usage |
Shawn O. Pearce | 6b3d8b9 | 2007-05-09 18:35:04 -0400 | [diff] [blame] | 1664 | set path $_prefix$a |
Shawn O. Pearce | 3e45ee1 | 2007-05-08 22:36:01 -0400 | [diff] [blame] | 1665 | break |
| 1666 | } elseif {$a eq {--}} { |
| 1667 | if {$path ne {}} { |
Shawn O. Pearce | a0db0d6 | 2007-05-08 22:48:47 -0400 | [diff] [blame] | 1668 | if {$head ne {}} usage |
| 1669 | set head $path |
Shawn O. Pearce | 3e45ee1 | 2007-05-08 22:36:01 -0400 | [diff] [blame] | 1670 | set path {} |
| 1671 | } |
| 1672 | set is_path 1 |
Shawn O. Pearce | a0db0d6 | 2007-05-08 22:48:47 -0400 | [diff] [blame] | 1673 | } elseif {$head eq {}} { |
| 1674 | if {$head ne {}} usage |
| 1675 | set head $a |
Shawn O. Pearce | 3e45ee1 | 2007-05-08 22:36:01 -0400 | [diff] [blame] | 1676 | } else { |
| 1677 | usage |
| 1678 | } |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1679 | } |
Shawn O. Pearce | 3e45ee1 | 2007-05-08 22:36:01 -0400 | [diff] [blame] | 1680 | unset is_path |
| 1681 | |
Shawn O. Pearce | a0db0d6 | 2007-05-08 22:48:47 -0400 | [diff] [blame] | 1682 | if {$head eq {}} { |
Shawn O. Pearce | 3e45ee1 | 2007-05-08 22:36:01 -0400 | [diff] [blame] | 1683 | set current_branch [git symbolic-ref HEAD] |
| 1684 | regsub ^refs/((heads|tags|remotes)/)? \ |
| 1685 | $current_branch {} current_branch |
Shawn O. Pearce | a0db0d6 | 2007-05-08 22:48:47 -0400 | [diff] [blame] | 1686 | } else { |
| 1687 | set current_branch $head |
Shawn O. Pearce | 3e45ee1 | 2007-05-08 22:36:01 -0400 | [diff] [blame] | 1688 | } |
Shawn O. Pearce | a0db0d6 | 2007-05-08 22:48:47 -0400 | [diff] [blame] | 1689 | |
| 1690 | if {$path eq {}} usage |
| 1691 | blame::new $head $path |
Shawn O. Pearce | 258871d | 2007-02-08 19:41:32 -0500 | [diff] [blame] | 1692 | return |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1693 | } |
Shawn O. Pearce | 258871d | 2007-02-08 19:41:32 -0500 | [diff] [blame] | 1694 | citool - |
| 1695 | gui { |
| 1696 | if {[llength $argv] != 0} { |
| 1697 | puts -nonewline stderr "usage: $argv0" |
| 1698 | if {$subcommand ne {gui} && [appname] ne "git-$subcommand"} { |
| 1699 | puts -nonewline stderr " $subcommand" |
| 1700 | } |
| 1701 | puts stderr {} |
| 1702 | exit 1 |
| 1703 | } |
| 1704 | # fall through to setup UI for commits |
| 1705 | } |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1706 | default { |
Shawn O. Pearce | c0f7a6c | 2007-02-21 01:24:57 -0500 | [diff] [blame] | 1707 | puts stderr "usage: $argv0 \[{blame|browser|citool}\]" |
Shawn O. Pearce | 2ebba52 | 2007-02-08 19:10:52 -0500 | [diff] [blame] | 1708 | exit 1 |
| 1709 | } |
| 1710 | } |
| 1711 | |
Shawn O. Pearce | 8553b77 | 2006-11-24 15:38:18 -0500 | [diff] [blame] | 1712 | # -- Branch Control |
| 1713 | # |
| 1714 | frame .branch \ |
| 1715 | -borderwidth 1 \ |
| 1716 | -relief sunken |
| 1717 | label .branch.l1 \ |
| 1718 | -text {Current Branch:} \ |
| 1719 | -anchor w \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1720 | -justify left |
Shawn O. Pearce | 8553b77 | 2006-11-24 15:38:18 -0500 | [diff] [blame] | 1721 | label .branch.cb \ |
| 1722 | -textvariable current_branch \ |
| 1723 | -anchor w \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1724 | -justify left |
Shawn O. Pearce | 8553b77 | 2006-11-24 15:38:18 -0500 | [diff] [blame] | 1725 | pack .branch.l1 -side left |
| 1726 | pack .branch.cb -side left -fill x |
| 1727 | pack .branch -side top -fill x |
| 1728 | |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1729 | # -- Main Window Layout |
Shawn O. Pearce | a49c67d | 2006-11-18 03:27:23 -0500 | [diff] [blame] | 1730 | # |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1731 | panedwindow .vpane -orient vertical |
| 1732 | panedwindow .vpane.files -orient horizontal |
Shawn O. Pearce | c5a1eb8 | 2007-01-21 17:50:42 -0500 | [diff] [blame] | 1733 | .vpane add .vpane.files -sticky nsew -height 100 -width 200 |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1734 | pack .vpane -anchor n -side top -fill both -expand 1 |
| 1735 | |
| 1736 | # -- Index File List |
Shawn O. Pearce | a49c67d | 2006-11-18 03:27:23 -0500 | [diff] [blame] | 1737 | # |
Shawn O. Pearce | c5a1eb8 | 2007-01-21 17:50:42 -0500 | [diff] [blame] | 1738 | frame .vpane.files.index -height 100 -width 200 |
Johannes Sixt | a1a4975 | 2007-05-08 13:33:06 +0200 | [diff] [blame] | 1739 | label .vpane.files.index.title -text {Staged Changes (Will Be Committed)} \ |
Matthijs Melchior | 9adccb0 | 2007-06-05 23:50:02 +0200 | [diff] [blame] | 1740 | -background lightgreen |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1741 | text $ui_index -background white -borderwidth 0 \ |
Shawn O. Pearce | c5a1eb8 | 2007-01-21 17:50:42 -0500 | [diff] [blame] | 1742 | -width 20 -height 10 \ |
Shawn O. Pearce | 3c23697 | 2007-01-21 14:58:01 -0500 | [diff] [blame] | 1743 | -wrap none \ |
Shawn O. Pearce | 6c6dd01 | 2006-11-11 20:33:30 -0500 | [diff] [blame] | 1744 | -cursor $cursor_ptr \ |
Shawn O. Pearce | 3c23697 | 2007-01-21 14:58:01 -0500 | [diff] [blame] | 1745 | -xscrollcommand {.vpane.files.index.sx set} \ |
| 1746 | -yscrollcommand {.vpane.files.index.sy set} \ |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1747 | -state disabled |
Shawn O. Pearce | 3c23697 | 2007-01-21 14:58:01 -0500 | [diff] [blame] | 1748 | scrollbar .vpane.files.index.sx -orient h -command [list $ui_index xview] |
| 1749 | scrollbar .vpane.files.index.sy -orient v -command [list $ui_index yview] |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1750 | pack .vpane.files.index.title -side top -fill x |
Shawn O. Pearce | 3c23697 | 2007-01-21 14:58:01 -0500 | [diff] [blame] | 1751 | pack .vpane.files.index.sx -side bottom -fill x |
| 1752 | pack .vpane.files.index.sy -side right -fill y |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1753 | pack $ui_index -side left -fill both -expand 1 |
| 1754 | .vpane.files add .vpane.files.index -sticky nsew |
| 1755 | |
Shawn O. Pearce | 0812665 | 2007-01-20 22:06:51 -0500 | [diff] [blame] | 1756 | # -- Working Directory File List |
Shawn O. Pearce | a49c67d | 2006-11-18 03:27:23 -0500 | [diff] [blame] | 1757 | # |
Shawn O. Pearce | c5a1eb8 | 2007-01-21 17:50:42 -0500 | [diff] [blame] | 1758 | frame .vpane.files.workdir -height 100 -width 200 |
Johannes Sixt | a1a4975 | 2007-05-08 13:33:06 +0200 | [diff] [blame] | 1759 | label .vpane.files.workdir.title -text {Unstaged Changes (Will Not Be Committed)} \ |
Matthijs Melchior | 9adccb0 | 2007-06-05 23:50:02 +0200 | [diff] [blame] | 1760 | -background lightsalmon |
Shawn O. Pearce | 0812665 | 2007-01-20 22:06:51 -0500 | [diff] [blame] | 1761 | text $ui_workdir -background white -borderwidth 0 \ |
Shawn O. Pearce | c5a1eb8 | 2007-01-21 17:50:42 -0500 | [diff] [blame] | 1762 | -width 20 -height 10 \ |
Shawn O. Pearce | 3c23697 | 2007-01-21 14:58:01 -0500 | [diff] [blame] | 1763 | -wrap none \ |
Shawn O. Pearce | 6c6dd01 | 2006-11-11 20:33:30 -0500 | [diff] [blame] | 1764 | -cursor $cursor_ptr \ |
Shawn O. Pearce | 3c23697 | 2007-01-21 14:58:01 -0500 | [diff] [blame] | 1765 | -xscrollcommand {.vpane.files.workdir.sx set} \ |
| 1766 | -yscrollcommand {.vpane.files.workdir.sy set} \ |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1767 | -state disabled |
Shawn O. Pearce | 3c23697 | 2007-01-21 14:58:01 -0500 | [diff] [blame] | 1768 | scrollbar .vpane.files.workdir.sx -orient h -command [list $ui_workdir xview] |
| 1769 | scrollbar .vpane.files.workdir.sy -orient v -command [list $ui_workdir yview] |
Shawn O. Pearce | 0812665 | 2007-01-20 22:06:51 -0500 | [diff] [blame] | 1770 | pack .vpane.files.workdir.title -side top -fill x |
Shawn O. Pearce | 3c23697 | 2007-01-21 14:58:01 -0500 | [diff] [blame] | 1771 | pack .vpane.files.workdir.sx -side bottom -fill x |
| 1772 | pack .vpane.files.workdir.sy -side right -fill y |
Shawn O. Pearce | 0812665 | 2007-01-20 22:06:51 -0500 | [diff] [blame] | 1773 | pack $ui_workdir -side left -fill both -expand 1 |
| 1774 | .vpane.files add .vpane.files.workdir -sticky nsew |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1775 | |
Shawn O. Pearce | 0812665 | 2007-01-20 22:06:51 -0500 | [diff] [blame] | 1776 | foreach i [list $ui_index $ui_workdir] { |
Matthijs Melchior | 9adccb0 | 2007-06-05 23:50:02 +0200 | [diff] [blame] | 1777 | $i tag conf in_diff -background lightgray |
| 1778 | $i tag conf in_sel -background lightgray |
Shawn O. Pearce | 24263b7 | 2006-11-13 16:06:38 -0500 | [diff] [blame] | 1779 | } |
| 1780 | unset i |
Shawn O. Pearce | 131f503 | 2006-11-06 16:07:32 -0500 | [diff] [blame] | 1781 | |
Shawn O. Pearce | 0fb8f9c | 2006-11-07 20:27:46 -0500 | [diff] [blame] | 1782 | # -- Diff and Commit Area |
Shawn O. Pearce | a49c67d | 2006-11-18 03:27:23 -0500 | [diff] [blame] | 1783 | # |
Shawn O. Pearce | 8009dcd | 2006-11-12 06:53:56 -0500 | [diff] [blame] | 1784 | frame .vpane.lower -height 300 -width 400 |
Shawn O. Pearce | 0fb8f9c | 2006-11-07 20:27:46 -0500 | [diff] [blame] | 1785 | frame .vpane.lower.commarea |
| 1786 | frame .vpane.lower.diff -relief sunken -borderwidth 1 |
| 1787 | pack .vpane.lower.commarea -side top -fill x |
| 1788 | pack .vpane.lower.diff -side bottom -fill both -expand 1 |
Shawn O. Pearce | 0fd49d0 | 2007-01-24 15:21:01 -0500 | [diff] [blame] | 1789 | .vpane add .vpane.lower -sticky nsew |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1790 | |
| 1791 | # -- Commit Area Buttons |
Shawn O. Pearce | a49c67d | 2006-11-18 03:27:23 -0500 | [diff] [blame] | 1792 | # |
Shawn O. Pearce | 0fb8f9c | 2006-11-07 20:27:46 -0500 | [diff] [blame] | 1793 | frame .vpane.lower.commarea.buttons |
| 1794 | label .vpane.lower.commarea.buttons.l -text {} \ |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1795 | -anchor w \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1796 | -justify left |
Shawn O. Pearce | 0fb8f9c | 2006-11-07 20:27:46 -0500 | [diff] [blame] | 1797 | pack .vpane.lower.commarea.buttons.l -side top -fill x |
| 1798 | pack .vpane.lower.commarea.buttons -side left -fill y |
Shawn O. Pearce | 131f503 | 2006-11-06 16:07:32 -0500 | [diff] [blame] | 1799 | |
Shawn O. Pearce | 0fb8f9c | 2006-11-07 20:27:46 -0500 | [diff] [blame] | 1800 | button .vpane.lower.commarea.buttons.rescan -text {Rescan} \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1801 | -command do_rescan |
Shawn O. Pearce | 0fb8f9c | 2006-11-07 20:27:46 -0500 | [diff] [blame] | 1802 | pack .vpane.lower.commarea.buttons.rescan -side top -fill x |
Shawn O. Pearce | 390adae | 2006-11-11 19:40:33 -0500 | [diff] [blame] | 1803 | lappend disable_on_lock \ |
| 1804 | {.vpane.lower.commarea.buttons.rescan conf -state} |
Shawn O. Pearce | 131f503 | 2006-11-06 16:07:32 -0500 | [diff] [blame] | 1805 | |
Shawn O. Pearce | 24d2bf2 | 2007-02-08 19:44:49 -0500 | [diff] [blame] | 1806 | button .vpane.lower.commarea.buttons.incall -text {Add Existing} \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1807 | -command do_add_all |
Shawn O. Pearce | 7fe7e73 | 2006-11-08 22:48:34 -0500 | [diff] [blame] | 1808 | pack .vpane.lower.commarea.buttons.incall -side top -fill x |
Shawn O. Pearce | 390adae | 2006-11-11 19:40:33 -0500 | [diff] [blame] | 1809 | lappend disable_on_lock \ |
| 1810 | {.vpane.lower.commarea.buttons.incall conf -state} |
Shawn O. Pearce | 131f503 | 2006-11-06 16:07:32 -0500 | [diff] [blame] | 1811 | |
Shawn O. Pearce | 0fb8f9c | 2006-11-07 20:27:46 -0500 | [diff] [blame] | 1812 | button .vpane.lower.commarea.buttons.signoff -text {Sign Off} \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1813 | -command do_signoff |
Shawn O. Pearce | 0fb8f9c | 2006-11-07 20:27:46 -0500 | [diff] [blame] | 1814 | pack .vpane.lower.commarea.buttons.signoff -side top -fill x |
Shawn O. Pearce | 131f503 | 2006-11-06 16:07:32 -0500 | [diff] [blame] | 1815 | |
Shawn O. Pearce | 0fb8f9c | 2006-11-07 20:27:46 -0500 | [diff] [blame] | 1816 | button .vpane.lower.commarea.buttons.commit -text {Commit} \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1817 | -command do_commit |
Shawn O. Pearce | 0fb8f9c | 2006-11-07 20:27:46 -0500 | [diff] [blame] | 1818 | pack .vpane.lower.commarea.buttons.commit -side top -fill x |
Shawn O. Pearce | 390adae | 2006-11-11 19:40:33 -0500 | [diff] [blame] | 1819 | lappend disable_on_lock \ |
| 1820 | {.vpane.lower.commarea.buttons.commit conf -state} |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1821 | |
| 1822 | # -- Commit Message Buffer |
Shawn O. Pearce | a49c67d | 2006-11-18 03:27:23 -0500 | [diff] [blame] | 1823 | # |
Shawn O. Pearce | 0fb8f9c | 2006-11-07 20:27:46 -0500 | [diff] [blame] | 1824 | frame .vpane.lower.commarea.buffer |
Shawn O. Pearce | 24ac9b7 | 2006-11-18 20:59:49 -0500 | [diff] [blame] | 1825 | frame .vpane.lower.commarea.buffer.header |
Shawn O. Pearce | 0fb8f9c | 2006-11-07 20:27:46 -0500 | [diff] [blame] | 1826 | set ui_comm .vpane.lower.commarea.buffer.t |
Shawn O. Pearce | 24ac9b7 | 2006-11-18 20:59:49 -0500 | [diff] [blame] | 1827 | set ui_coml .vpane.lower.commarea.buffer.header.l |
| 1828 | radiobutton .vpane.lower.commarea.buffer.header.new \ |
| 1829 | -text {New Commit} \ |
| 1830 | -command do_select_commit_type \ |
| 1831 | -variable selected_commit_type \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1832 | -value new |
Shawn O. Pearce | 24ac9b7 | 2006-11-18 20:59:49 -0500 | [diff] [blame] | 1833 | lappend disable_on_lock \ |
| 1834 | [list .vpane.lower.commarea.buffer.header.new conf -state] |
| 1835 | radiobutton .vpane.lower.commarea.buffer.header.amend \ |
| 1836 | -text {Amend Last Commit} \ |
| 1837 | -command do_select_commit_type \ |
| 1838 | -variable selected_commit_type \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1839 | -value amend |
Shawn O. Pearce | 24ac9b7 | 2006-11-18 20:59:49 -0500 | [diff] [blame] | 1840 | lappend disable_on_lock \ |
| 1841 | [list .vpane.lower.commarea.buffer.header.amend conf -state] |
Shawn O. Pearce | a49c67d | 2006-11-18 03:27:23 -0500 | [diff] [blame] | 1842 | label $ui_coml \ |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1843 | -anchor w \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1844 | -justify left |
Shawn O. Pearce | 4539eac | 2006-11-18 02:50:58 -0500 | [diff] [blame] | 1845 | proc trace_commit_type {varname args} { |
| 1846 | global ui_coml commit_type |
| 1847 | switch -glob -- $commit_type { |
| 1848 | initial {set txt {Initial Commit Message:}} |
| 1849 | amend {set txt {Amended Commit Message:}} |
| 1850 | amend-initial {set txt {Amended Initial Commit Message:}} |
Shawn O. Pearce | f18e40a | 2006-11-20 21:27:22 -0500 | [diff] [blame] | 1851 | amend-merge {set txt {Amended Merge Commit Message:}} |
Shawn O. Pearce | 4539eac | 2006-11-18 02:50:58 -0500 | [diff] [blame] | 1852 | merge {set txt {Merge Commit Message:}} |
| 1853 | * {set txt {Commit Message:}} |
| 1854 | } |
| 1855 | $ui_coml conf -text $txt |
| 1856 | } |
| 1857 | trace add variable commit_type write trace_commit_type |
Shawn O. Pearce | 24ac9b7 | 2006-11-18 20:59:49 -0500 | [diff] [blame] | 1858 | pack $ui_coml -side left -fill x |
| 1859 | pack .vpane.lower.commarea.buffer.header.amend -side right |
| 1860 | pack .vpane.lower.commarea.buffer.header.new -side right |
| 1861 | |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1862 | text $ui_comm -background white -borderwidth 1 \ |
Shawn O. Pearce | 9861671 | 2006-11-11 15:51:41 -0500 | [diff] [blame] | 1863 | -undo true \ |
Shawn O. Pearce | b2c6fcf | 2006-11-11 16:16:25 -0500 | [diff] [blame] | 1864 | -maxundo 20 \ |
Shawn O. Pearce | 9861671 | 2006-11-11 15:51:41 -0500 | [diff] [blame] | 1865 | -autoseparators true \ |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1866 | -relief sunken \ |
Shawn O. Pearce | 0fb8f9c | 2006-11-07 20:27:46 -0500 | [diff] [blame] | 1867 | -width 75 -height 9 -wrap none \ |
Shawn O. Pearce | b494693 | 2006-11-12 00:40:38 -0500 | [diff] [blame] | 1868 | -font font_diff \ |
Shawn O. Pearce | 6c6dd01 | 2006-11-11 20:33:30 -0500 | [diff] [blame] | 1869 | -yscrollcommand {.vpane.lower.commarea.buffer.sby set} |
Shawn O. Pearce | 390adae | 2006-11-11 19:40:33 -0500 | [diff] [blame] | 1870 | scrollbar .vpane.lower.commarea.buffer.sby \ |
| 1871 | -command [list $ui_comm yview] |
Shawn O. Pearce | 24ac9b7 | 2006-11-18 20:59:49 -0500 | [diff] [blame] | 1872 | pack .vpane.lower.commarea.buffer.header -side top -fill x |
Shawn O. Pearce | 0fb8f9c | 2006-11-07 20:27:46 -0500 | [diff] [blame] | 1873 | pack .vpane.lower.commarea.buffer.sby -side right -fill y |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 1874 | pack $ui_comm -side left -fill y |
Shawn O. Pearce | 0fb8f9c | 2006-11-07 20:27:46 -0500 | [diff] [blame] | 1875 | pack .vpane.lower.commarea.buffer -side left -fill y |
| 1876 | |
Shawn O. Pearce | 0e79431 | 2006-11-11 20:24:23 -0500 | [diff] [blame] | 1877 | # -- Commit Message Buffer Context Menu |
| 1878 | # |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 1879 | set ctxm .vpane.lower.commarea.buffer.ctxm |
| 1880 | menu $ctxm -tearoff 0 |
| 1881 | $ctxm add command \ |
| 1882 | -label {Cut} \ |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 1883 | -command {tk_textCut $ui_comm} |
| 1884 | $ctxm add command \ |
| 1885 | -label {Copy} \ |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 1886 | -command {tk_textCopy $ui_comm} |
| 1887 | $ctxm add command \ |
| 1888 | -label {Paste} \ |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 1889 | -command {tk_textPaste $ui_comm} |
| 1890 | $ctxm add command \ |
| 1891 | -label {Delete} \ |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 1892 | -command {$ui_comm delete sel.first sel.last} |
| 1893 | $ctxm add separator |
| 1894 | $ctxm add command \ |
| 1895 | -label {Select All} \ |
Shawn O. Pearce | 75e78c8 | 2007-01-22 18:31:12 -0500 | [diff] [blame] | 1896 | -command {focus $ui_comm;$ui_comm tag add sel 0.0 end} |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 1897 | $ctxm add command \ |
| 1898 | -label {Copy All} \ |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 1899 | -command { |
Shawn O. Pearce | 0e79431 | 2006-11-11 20:24:23 -0500 | [diff] [blame] | 1900 | $ui_comm tag add sel 0.0 end |
| 1901 | tk_textCopy $ui_comm |
| 1902 | $ui_comm tag remove sel 0.0 end |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 1903 | } |
| 1904 | $ctxm add separator |
| 1905 | $ctxm add command \ |
| 1906 | -label {Sign Off} \ |
Shawn O. Pearce | 0e79431 | 2006-11-11 20:24:23 -0500 | [diff] [blame] | 1907 | -command do_signoff |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 1908 | bind_button3 $ui_comm "tk_popup $ctxm %X %Y" |
Shawn O. Pearce | 0e79431 | 2006-11-11 20:24:23 -0500 | [diff] [blame] | 1909 | |
Shawn O. Pearce | 0fb8f9c | 2006-11-07 20:27:46 -0500 | [diff] [blame] | 1910 | # -- Diff Header |
Shawn O. Pearce | a49c67d | 2006-11-18 03:27:23 -0500 | [diff] [blame] | 1911 | # |
Shawn O. Pearce | 20a53c0 | 2007-01-21 11:37:58 -0500 | [diff] [blame] | 1912 | proc trace_current_diff_path {varname args} { |
| 1913 | global current_diff_path diff_actions file_states |
| 1914 | if {$current_diff_path eq {}} { |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 1915 | set s {} |
| 1916 | set f {} |
| 1917 | set p {} |
| 1918 | set o disabled |
| 1919 | } else { |
Shawn O. Pearce | 20a53c0 | 2007-01-21 11:37:58 -0500 | [diff] [blame] | 1920 | set p $current_diff_path |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 1921 | set s [mapdesc [lindex $file_states($p) 0] $p] |
| 1922 | set f {File:} |
| 1923 | set p [escape_path $p] |
| 1924 | set o normal |
| 1925 | } |
| 1926 | |
| 1927 | .vpane.lower.diff.header.status configure -text $s |
| 1928 | .vpane.lower.diff.header.file configure -text $f |
| 1929 | .vpane.lower.diff.header.path configure -text $p |
| 1930 | foreach w $diff_actions { |
| 1931 | uplevel #0 $w $o |
| 1932 | } |
| 1933 | } |
Shawn O. Pearce | 20a53c0 | 2007-01-21 11:37:58 -0500 | [diff] [blame] | 1934 | trace add variable current_diff_path write trace_current_diff_path |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 1935 | |
Matthijs Melchior | 9adccb0 | 2007-06-05 23:50:02 +0200 | [diff] [blame] | 1936 | frame .vpane.lower.diff.header -background gold |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 1937 | label .vpane.lower.diff.header.status \ |
Matthijs Melchior | 9adccb0 | 2007-06-05 23:50:02 +0200 | [diff] [blame] | 1938 | -background gold \ |
Shawn O. Pearce | 3e7b0e1 | 2006-11-12 22:06:37 -0500 | [diff] [blame] | 1939 | -width $max_status_desc \ |
| 1940 | -anchor w \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1941 | -justify left |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 1942 | label .vpane.lower.diff.header.file \ |
Matthijs Melchior | 9adccb0 | 2007-06-05 23:50:02 +0200 | [diff] [blame] | 1943 | -background gold \ |
Shawn O. Pearce | fce89e4 | 2006-11-13 00:48:44 -0500 | [diff] [blame] | 1944 | -anchor w \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1945 | -justify left |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 1946 | label .vpane.lower.diff.header.path \ |
Matthijs Melchior | 9adccb0 | 2007-06-05 23:50:02 +0200 | [diff] [blame] | 1947 | -background gold \ |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 1948 | -anchor w \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 1949 | -justify left |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 1950 | pack .vpane.lower.diff.header.status -side left |
| 1951 | pack .vpane.lower.diff.header.file -side left |
| 1952 | pack .vpane.lower.diff.header.path -fill x |
| 1953 | set ctxm .vpane.lower.diff.header.ctxm |
| 1954 | menu $ctxm -tearoff 0 |
| 1955 | $ctxm add command \ |
| 1956 | -label {Copy} \ |
Shawn O. Pearce | fce89e4 | 2006-11-13 00:48:44 -0500 | [diff] [blame] | 1957 | -command { |
| 1958 | clipboard clear |
| 1959 | clipboard append \ |
| 1960 | -format STRING \ |
| 1961 | -type STRING \ |
Shawn O. Pearce | 20a53c0 | 2007-01-21 11:37:58 -0500 | [diff] [blame] | 1962 | -- $current_diff_path |
Shawn O. Pearce | fce89e4 | 2006-11-13 00:48:44 -0500 | [diff] [blame] | 1963 | } |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 1964 | lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state] |
| 1965 | bind_button3 .vpane.lower.diff.header.path "tk_popup $ctxm %X %Y" |
Shawn O. Pearce | 0fb8f9c | 2006-11-07 20:27:46 -0500 | [diff] [blame] | 1966 | |
| 1967 | # -- Diff Body |
Shawn O. Pearce | a49c67d | 2006-11-18 03:27:23 -0500 | [diff] [blame] | 1968 | # |
Shawn O. Pearce | 0fb8f9c | 2006-11-07 20:27:46 -0500 | [diff] [blame] | 1969 | frame .vpane.lower.diff.body |
| 1970 | set ui_diff .vpane.lower.diff.body.t |
| 1971 | text $ui_diff -background white -borderwidth 0 \ |
| 1972 | -width 80 -height 15 -wrap none \ |
Shawn O. Pearce | b494693 | 2006-11-12 00:40:38 -0500 | [diff] [blame] | 1973 | -font font_diff \ |
Shawn O. Pearce | 0fb8f9c | 2006-11-07 20:27:46 -0500 | [diff] [blame] | 1974 | -xscrollcommand {.vpane.lower.diff.body.sbx set} \ |
| 1975 | -yscrollcommand {.vpane.lower.diff.body.sby set} \ |
Shawn O. Pearce | 0fb8f9c | 2006-11-07 20:27:46 -0500 | [diff] [blame] | 1976 | -state disabled |
| 1977 | scrollbar .vpane.lower.diff.body.sbx -orient horizontal \ |
| 1978 | -command [list $ui_diff xview] |
| 1979 | scrollbar .vpane.lower.diff.body.sby -orient vertical \ |
| 1980 | -command [list $ui_diff yview] |
| 1981 | pack .vpane.lower.diff.body.sbx -side bottom -fill x |
| 1982 | pack .vpane.lower.diff.body.sby -side right -fill y |
| 1983 | pack $ui_diff -side left -fill both -expand 1 |
| 1984 | pack .vpane.lower.diff.header -side top -fill x |
| 1985 | pack .vpane.lower.diff.body -side bottom -fill both -expand 1 |
| 1986 | |
Shawn O. Pearce | 30b14ed | 2007-01-24 21:30:23 -0500 | [diff] [blame] | 1987 | $ui_diff tag conf d_cr -elide true |
Shawn O. Pearce | ca52156 | 2007-01-21 14:49:45 -0500 | [diff] [blame] | 1988 | $ui_diff tag conf d_@ -foreground blue -font font_diffbold |
| 1989 | $ui_diff tag conf d_+ -foreground {#00a000} |
Shawn O. Pearce | fec4a78 | 2007-01-21 13:12:02 -0500 | [diff] [blame] | 1990 | $ui_diff tag conf d_- -foreground red |
| 1991 | |
Shawn O. Pearce | ca52156 | 2007-01-21 14:49:45 -0500 | [diff] [blame] | 1992 | $ui_diff tag conf d_++ -foreground {#00a000} |
Shawn O. Pearce | fec4a78 | 2007-01-21 13:12:02 -0500 | [diff] [blame] | 1993 | $ui_diff tag conf d_-- -foreground red |
| 1994 | $ui_diff tag conf d_+s \ |
Shawn O. Pearce | ca52156 | 2007-01-21 14:49:45 -0500 | [diff] [blame] | 1995 | -foreground {#00a000} \ |
| 1996 | -background {#e2effa} |
Shawn O. Pearce | fec4a78 | 2007-01-21 13:12:02 -0500 | [diff] [blame] | 1997 | $ui_diff tag conf d_-s \ |
| 1998 | -foreground red \ |
Shawn O. Pearce | ca52156 | 2007-01-21 14:49:45 -0500 | [diff] [blame] | 1999 | -background {#e2effa} |
Shawn O. Pearce | fec4a78 | 2007-01-21 13:12:02 -0500 | [diff] [blame] | 2000 | $ui_diff tag conf d_s+ \ |
Shawn O. Pearce | ca52156 | 2007-01-21 14:49:45 -0500 | [diff] [blame] | 2001 | -foreground {#00a000} \ |
| 2002 | -background ivory1 |
Shawn O. Pearce | fec4a78 | 2007-01-21 13:12:02 -0500 | [diff] [blame] | 2003 | $ui_diff tag conf d_s- \ |
| 2004 | -foreground red \ |
Shawn O. Pearce | ca52156 | 2007-01-21 14:49:45 -0500 | [diff] [blame] | 2005 | -background ivory1 |
Shawn O. Pearce | fec4a78 | 2007-01-21 13:12:02 -0500 | [diff] [blame] | 2006 | |
| 2007 | $ui_diff tag conf d<<<<<<< \ |
| 2008 | -foreground orange \ |
| 2009 | -font font_diffbold |
| 2010 | $ui_diff tag conf d======= \ |
| 2011 | -foreground orange \ |
| 2012 | -font font_diffbold |
| 2013 | $ui_diff tag conf d>>>>>>> \ |
| 2014 | -foreground orange \ |
| 2015 | -font font_diffbold |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 2016 | |
Shawn O. Pearce | ca52156 | 2007-01-21 14:49:45 -0500 | [diff] [blame] | 2017 | $ui_diff tag raise sel |
| 2018 | |
Shawn O. Pearce | 0e79431 | 2006-11-11 20:24:23 -0500 | [diff] [blame] | 2019 | # -- Diff Body Context Menu |
| 2020 | # |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 2021 | set ctxm .vpane.lower.diff.body.ctxm |
| 2022 | menu $ctxm -tearoff 0 |
| 2023 | $ctxm add command \ |
Shawn O. Pearce | 68c30b4 | 2007-01-21 13:27:43 -0500 | [diff] [blame] | 2024 | -label {Refresh} \ |
Shawn O. Pearce | 68c30b4 | 2007-01-21 13:27:43 -0500 | [diff] [blame] | 2025 | -command reshow_diff |
Shawn O. Pearce | 86773d9 | 2007-01-24 20:39:30 -0500 | [diff] [blame] | 2026 | lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state] |
Shawn O. Pearce | 68c30b4 | 2007-01-21 13:27:43 -0500 | [diff] [blame] | 2027 | $ctxm add command \ |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 2028 | -label {Copy} \ |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 2029 | -command {tk_textCopy $ui_diff} |
| 2030 | lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state] |
| 2031 | $ctxm add command \ |
| 2032 | -label {Select All} \ |
Shawn O. Pearce | 75e78c8 | 2007-01-22 18:31:12 -0500 | [diff] [blame] | 2033 | -command {focus $ui_diff;$ui_diff tag add sel 0.0 end} |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 2034 | lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state] |
| 2035 | $ctxm add command \ |
| 2036 | -label {Copy All} \ |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 2037 | -command { |
Shawn O. Pearce | 0e79431 | 2006-11-11 20:24:23 -0500 | [diff] [blame] | 2038 | $ui_diff tag add sel 0.0 end |
| 2039 | tk_textCopy $ui_diff |
| 2040 | $ui_diff tag remove sel 0.0 end |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 2041 | } |
| 2042 | lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state] |
| 2043 | $ctxm add separator |
| 2044 | $ctxm add command \ |
Shawn O. Pearce | a25c518 | 2007-01-24 21:20:57 -0500 | [diff] [blame] | 2045 | -label {Apply/Reverse Hunk} \ |
Shawn O. Pearce | a25c518 | 2007-01-24 21:20:57 -0500 | [diff] [blame] | 2046 | -command {apply_hunk $cursorX $cursorY} |
| 2047 | set ui_diff_applyhunk [$ctxm index last] |
| 2048 | lappend diff_actions [list $ctxm entryconf $ui_diff_applyhunk -state] |
| 2049 | $ctxm add separator |
| 2050 | $ctxm add command \ |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 2051 | -label {Decrease Font Size} \ |
Shawn O. Pearce | b494693 | 2006-11-12 00:40:38 -0500 | [diff] [blame] | 2052 | -command {incr_font_size font_diff -1} |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 2053 | lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state] |
| 2054 | $ctxm add command \ |
| 2055 | -label {Increase Font Size} \ |
Shawn O. Pearce | b494693 | 2006-11-12 00:40:38 -0500 | [diff] [blame] | 2056 | -command {incr_font_size font_diff 1} |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 2057 | lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state] |
| 2058 | $ctxm add separator |
| 2059 | $ctxm add command \ |
| 2060 | -label {Show Less Context} \ |
Shawn O. Pearce | b8848f7 | 2007-05-31 23:32:54 -0400 | [diff] [blame] | 2061 | -command {if {$repo_config(gui.diffcontext) >= 1} { |
Shawn O. Pearce | 358d8de | 2006-11-12 19:20:02 -0500 | [diff] [blame] | 2062 | incr repo_config(gui.diffcontext) -1 |
| 2063 | reshow_diff |
| 2064 | }} |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 2065 | lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state] |
| 2066 | $ctxm add command \ |
| 2067 | -label {Show More Context} \ |
Shawn O. Pearce | b8848f7 | 2007-05-31 23:32:54 -0400 | [diff] [blame] | 2068 | -command {if {$repo_config(gui.diffcontext) < 99} { |
Shawn O. Pearce | 358d8de | 2006-11-12 19:20:02 -0500 | [diff] [blame] | 2069 | incr repo_config(gui.diffcontext) |
| 2070 | reshow_diff |
Shawn O. Pearce | b8848f7 | 2007-05-31 23:32:54 -0400 | [diff] [blame] | 2071 | }} |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 2072 | lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state] |
| 2073 | $ctxm add separator |
| 2074 | $ctxm add command -label {Options...} \ |
Shawn O. Pearce | 8009dcd | 2006-11-12 06:53:56 -0500 | [diff] [blame] | 2075 | -command do_options |
Shawn O. Pearce | a25c518 | 2007-01-24 21:20:57 -0500 | [diff] [blame] | 2076 | bind_button3 $ui_diff " |
| 2077 | set cursorX %x |
| 2078 | set cursorY %y |
| 2079 | if {\$ui_index eq \$current_diff_side} { |
| 2080 | $ctxm entryconf $ui_diff_applyhunk -label {Unstage Hunk From Commit} |
| 2081 | } else { |
| 2082 | $ctxm entryconf $ui_diff_applyhunk -label {Stage Hunk For Commit} |
| 2083 | } |
| 2084 | tk_popup $ctxm %X %Y |
| 2085 | " |
Shawn O. Pearce | b9a75e3 | 2007-01-25 12:55:20 -0500 | [diff] [blame] | 2086 | unset ui_diff_applyhunk |
Shawn O. Pearce | 0e79431 | 2006-11-11 20:24:23 -0500 | [diff] [blame] | 2087 | |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 2088 | # -- Status Bar |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 2089 | # |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 2090 | label .status -textvariable ui_status_value \ |
| 2091 | -anchor w \ |
| 2092 | -justify left \ |
| 2093 | -borderwidth 1 \ |
Shawn O. Pearce | 7416bbc | 2007-04-28 23:14:08 -0400 | [diff] [blame] | 2094 | -relief sunken |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 2095 | pack .status -anchor w -side bottom -fill x |
| 2096 | |
Shawn O. Pearce | 2d19516 | 2006-11-08 23:42:51 -0500 | [diff] [blame] | 2097 | # -- Load geometry |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 2098 | # |
Shawn O. Pearce | 2d19516 | 2006-11-08 23:42:51 -0500 | [diff] [blame] | 2099 | catch { |
Shawn O. Pearce | 51f4d16 | 2006-11-12 03:47:00 -0500 | [diff] [blame] | 2100 | set gm $repo_config(gui.geometry) |
Shawn O. Pearce | c4fe772 | 2006-11-11 19:32:24 -0500 | [diff] [blame] | 2101 | wm geometry . [lindex $gm 0] |
| 2102 | .vpane sash place 0 \ |
| 2103 | [lindex [.vpane sash coord 0] 0] \ |
| 2104 | [lindex $gm 1] |
| 2105 | .vpane.files sash place 0 \ |
| 2106 | [lindex $gm 2] \ |
| 2107 | [lindex [.vpane.files sash coord 0] 1] |
Shawn O. Pearce | c4fe772 | 2006-11-11 19:32:24 -0500 | [diff] [blame] | 2108 | unset gm |
Shawn O. Pearce | 390adae | 2006-11-11 19:40:33 -0500 | [diff] [blame] | 2109 | } |
Shawn O. Pearce | 2d19516 | 2006-11-08 23:42:51 -0500 | [diff] [blame] | 2110 | |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 2111 | # -- Key Bindings |
Shawn O. Pearce | e8ab644 | 2006-11-15 18:55:05 -0500 | [diff] [blame] | 2112 | # |
Shawn O. Pearce | ec6b424 | 2006-11-06 20:50:59 -0500 | [diff] [blame] | 2113 | bind $ui_comm <$M1B-Key-Return> {do_commit;break} |
Shawn O. Pearce | 93e912c | 2007-01-20 23:07:04 -0500 | [diff] [blame] | 2114 | bind $ui_comm <$M1B-Key-i> {do_add_all;break} |
| 2115 | bind $ui_comm <$M1B-Key-I> {do_add_all;break} |
Shawn O. Pearce | 9861671 | 2006-11-11 15:51:41 -0500 | [diff] [blame] | 2116 | bind $ui_comm <$M1B-Key-x> {tk_textCut %W;break} |
| 2117 | bind $ui_comm <$M1B-Key-X> {tk_textCut %W;break} |
| 2118 | bind $ui_comm <$M1B-Key-c> {tk_textCopy %W;break} |
| 2119 | bind $ui_comm <$M1B-Key-C> {tk_textCopy %W;break} |
| 2120 | bind $ui_comm <$M1B-Key-v> {tk_textPaste %W; %W see insert; break} |
| 2121 | bind $ui_comm <$M1B-Key-V> {tk_textPaste %W; %W see insert; break} |
| 2122 | bind $ui_comm <$M1B-Key-a> {%W tag add sel 0.0 end;break} |
| 2123 | bind $ui_comm <$M1B-Key-A> {%W tag add sel 0.0 end;break} |
| 2124 | |
| 2125 | bind $ui_diff <$M1B-Key-x> {tk_textCopy %W;break} |
| 2126 | bind $ui_diff <$M1B-Key-X> {tk_textCopy %W;break} |
| 2127 | bind $ui_diff <$M1B-Key-c> {tk_textCopy %W;break} |
| 2128 | bind $ui_diff <$M1B-Key-C> {tk_textCopy %W;break} |
| 2129 | bind $ui_diff <$M1B-Key-v> {break} |
| 2130 | bind $ui_diff <$M1B-Key-V> {break} |
| 2131 | bind $ui_diff <$M1B-Key-a> {%W tag add sel 0.0 end;break} |
| 2132 | bind $ui_diff <$M1B-Key-A> {%W tag add sel 0.0 end;break} |
Shawn O. Pearce | b2c6fcf | 2006-11-11 16:16:25 -0500 | [diff] [blame] | 2133 | bind $ui_diff <Key-Up> {catch {%W yview scroll -1 units};break} |
| 2134 | bind $ui_diff <Key-Down> {catch {%W yview scroll 1 units};break} |
| 2135 | bind $ui_diff <Key-Left> {catch {%W xview scroll -1 units};break} |
| 2136 | bind $ui_diff <Key-Right> {catch {%W xview scroll 1 units};break} |
Shawn O. Pearce | 60aa065 | 2007-05-01 15:51:09 -0400 | [diff] [blame] | 2137 | bind $ui_diff <Key-k> {catch {%W yview scroll -1 units};break} |
| 2138 | bind $ui_diff <Key-j> {catch {%W yview scroll 1 units};break} |
| 2139 | bind $ui_diff <Key-h> {catch {%W xview scroll -1 units};break} |
| 2140 | bind $ui_diff <Key-l> {catch {%W xview scroll 1 units};break} |
| 2141 | bind $ui_diff <Control-Key-b> {catch {%W yview scroll -1 pages};break} |
| 2142 | bind $ui_diff <Control-Key-f> {catch {%W yview scroll 1 pages};break} |
Shawn O. Pearce | 23effa7 | 2007-01-25 12:57:57 -0500 | [diff] [blame] | 2143 | bind $ui_diff <Button-1> {focus %W} |
Shawn O. Pearce | 49b86f0 | 2006-11-11 15:16:01 -0500 | [diff] [blame] | 2144 | |
Shawn O. Pearce | 64a906f | 2007-02-08 18:10:05 -0500 | [diff] [blame] | 2145 | if {[is_enabled branch]} { |
Shawn O. Pearce | bd29ebc | 2007-01-21 01:34:55 -0500 | [diff] [blame] | 2146 | bind . <$M1B-Key-n> do_create_branch |
| 2147 | bind . <$M1B-Key-N> do_create_branch |
| 2148 | } |
| 2149 | |
Shawn O. Pearce | 07123f4 | 2006-11-07 02:57:46 -0500 | [diff] [blame] | 2150 | bind all <Key-F5> do_rescan |
| 2151 | bind all <$M1B-Key-r> do_rescan |
| 2152 | bind all <$M1B-Key-R> do_rescan |
| 2153 | bind . <$M1B-Key-s> do_signoff |
| 2154 | bind . <$M1B-Key-S> do_signoff |
Shawn O. Pearce | 93e912c | 2007-01-20 23:07:04 -0500 | [diff] [blame] | 2155 | bind . <$M1B-Key-i> do_add_all |
| 2156 | bind . <$M1B-Key-I> do_add_all |
Shawn O. Pearce | 07123f4 | 2006-11-07 02:57:46 -0500 | [diff] [blame] | 2157 | bind . <$M1B-Key-Return> do_commit |
Shawn O. Pearce | 0812665 | 2007-01-20 22:06:51 -0500 | [diff] [blame] | 2158 | foreach i [list $ui_index $ui_workdir] { |
Shawn O. Pearce | 24263b7 | 2006-11-13 16:06:38 -0500 | [diff] [blame] | 2159 | bind $i <Button-1> "toggle_or_diff $i %x %y; break" |
| 2160 | bind $i <$M1B-Button-1> "add_one_to_selection $i %x %y; break" |
| 2161 | bind $i <Shift-Button-1> "add_range_to_selection $i %x %y; break" |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 2162 | } |
Shawn O. Pearce | 62aac80 | 2006-11-11 20:00:35 -0500 | [diff] [blame] | 2163 | unset i |
| 2164 | |
| 2165 | set file_lists($ui_index) [list] |
Shawn O. Pearce | 0812665 | 2007-01-20 22:06:51 -0500 | [diff] [blame] | 2166 | set file_lists($ui_workdir) [list] |
Shawn O. Pearce | a49c67d | 2006-11-18 03:27:23 -0500 | [diff] [blame] | 2167 | |
Shawn O. Pearce | 19c8214 | 2007-04-14 15:10:48 -0400 | [diff] [blame] | 2168 | wm title . "[appname] ([reponame]) [file normalize [file dirname [gitdir]]]" |
Shawn O. Pearce | cb07fc2 | 2006-11-06 14:20:27 -0500 | [diff] [blame] | 2169 | focus -force $ui_comm |
Shawn O. Pearce | 1d8b3cb | 2006-11-21 15:28:14 -0500 | [diff] [blame] | 2170 | |
Shawn O. Pearce | 85ab313 | 2006-11-25 03:38:39 -0500 | [diff] [blame] | 2171 | # -- Warn the user about environmental problems. Cygwin's Tcl |
| 2172 | # does *not* pass its env array onto any processes it spawns. |
| 2173 | # This means that git processes get none of our environment. |
Shawn O. Pearce | 1d8b3cb | 2006-11-21 15:28:14 -0500 | [diff] [blame] | 2174 | # |
Shawn O. Pearce | 20ddfca | 2007-01-28 20:58:47 -0500 | [diff] [blame] | 2175 | if {[is_Cygwin]} { |
Shawn O. Pearce | 1d8b3cb | 2006-11-21 15:28:14 -0500 | [diff] [blame] | 2176 | set ignored_env 0 |
| 2177 | set suggest_user {} |
| 2178 | set msg "Possible environment issues exist. |
| 2179 | |
| 2180 | The following environment variables are probably |
| 2181 | going to be ignored by any Git subprocess run |
Shawn O. Pearce | c950c66 | 2007-01-20 21:48:56 -0500 | [diff] [blame] | 2182 | by [appname]: |
Shawn O. Pearce | 1d8b3cb | 2006-11-21 15:28:14 -0500 | [diff] [blame] | 2183 | |
| 2184 | " |
| 2185 | foreach name [array names env] { |
| 2186 | switch -regexp -- $name { |
| 2187 | {^GIT_INDEX_FILE$} - |
| 2188 | {^GIT_OBJECT_DIRECTORY$} - |
| 2189 | {^GIT_ALTERNATE_OBJECT_DIRECTORIES$} - |
| 2190 | {^GIT_DIFF_OPTS$} - |
| 2191 | {^GIT_EXTERNAL_DIFF$} - |
| 2192 | {^GIT_PAGER$} - |
| 2193 | {^GIT_TRACE$} - |
| 2194 | {^GIT_CONFIG$} - |
| 2195 | {^GIT_CONFIG_LOCAL$} - |
| 2196 | {^GIT_(AUTHOR|COMMITTER)_DATE$} { |
| 2197 | append msg " - $name\n" |
| 2198 | incr ignored_env |
| 2199 | } |
| 2200 | {^GIT_(AUTHOR|COMMITTER)_(NAME|EMAIL)$} { |
| 2201 | append msg " - $name\n" |
| 2202 | incr ignored_env |
| 2203 | set suggest_user $name |
| 2204 | } |
| 2205 | } |
| 2206 | } |
| 2207 | if {$ignored_env > 0} { |
| 2208 | append msg " |
| 2209 | This is due to a known issue with the |
| 2210 | Tcl binary distributed by Cygwin." |
| 2211 | |
| 2212 | if {$suggest_user ne {}} { |
| 2213 | append msg " |
| 2214 | |
| 2215 | A good replacement for $suggest_user |
| 2216 | is placing values for the user.name and |
| 2217 | user.email settings into your personal |
| 2218 | ~/.gitconfig file. |
| 2219 | " |
| 2220 | } |
| 2221 | warn_popup $msg |
| 2222 | } |
| 2223 | unset ignored_env msg suggest_user name |
| 2224 | } |
| 2225 | |
Shawn O. Pearce | 85ab313 | 2006-11-25 03:38:39 -0500 | [diff] [blame] | 2226 | # -- Only initialize complex UI if we are going to stay running. |
| 2227 | # |
Shawn O. Pearce | 64a906f | 2007-02-08 18:10:05 -0500 | [diff] [blame] | 2228 | if {[is_enabled transport]} { |
Shawn O. Pearce | 4ccdab0 | 2006-11-12 16:20:36 -0500 | [diff] [blame] | 2229 | load_all_remotes |
Shawn O. Pearce | bb1ad51 | 2006-11-25 03:35:33 -0500 | [diff] [blame] | 2230 | load_all_heads |
Shawn O. Pearce | 85ab313 | 2006-11-25 03:38:39 -0500 | [diff] [blame] | 2231 | |
Shawn O. Pearce | c5ab47c | 2007-01-21 01:31:14 -0500 | [diff] [blame] | 2232 | populate_branch_menu |
Shawn O. Pearce | 3f7fd92 | 2007-01-25 17:16:22 -0500 | [diff] [blame] | 2233 | populate_fetch_menu |
| 2234 | populate_push_menu |
Shawn O. Pearce | 4ccdab0 | 2006-11-12 16:20:36 -0500 | [diff] [blame] | 2235 | } |
Shawn O. Pearce | 85ab313 | 2006-11-25 03:38:39 -0500 | [diff] [blame] | 2236 | |
Shawn O. Pearce | 8ff487c | 2007-01-20 21:23:21 -0500 | [diff] [blame] | 2237 | # -- Only suggest a gc run if we are going to stay running. |
| 2238 | # |
Shawn O. Pearce | cf25ddc | 2007-02-08 18:03:41 -0500 | [diff] [blame] | 2239 | if {[is_enabled multicommit]} { |
Shawn O. Pearce | 8ff487c | 2007-01-20 21:23:21 -0500 | [diff] [blame] | 2240 | set object_limit 2000 |
| 2241 | if {[is_Windows]} {set object_limit 200} |
Shawn O. Pearce | 8134722 | 2007-02-12 22:48:56 -0500 | [diff] [blame] | 2242 | regexp {^([0-9]+) objects,} [git count-objects] _junk objects_current |
Shawn O. Pearce | 8ff487c | 2007-01-20 21:23:21 -0500 | [diff] [blame] | 2243 | if {$objects_current >= $object_limit} { |
| 2244 | if {[ask_popup \ |
| 2245 | "This repository currently has $objects_current loose objects. |
| 2246 | |
Eygene Ryabinkin | 53a291a | 2007-03-27 14:31:55 +0400 | [diff] [blame] | 2247 | To maintain optimal performance it is strongly recommended that you compress the database when more than $object_limit loose objects exist. |
Shawn O. Pearce | 8ff487c | 2007-01-20 21:23:21 -0500 | [diff] [blame] | 2248 | |
| 2249 | Compress the database now?"] eq yes} { |
| 2250 | do_gc |
| 2251 | } |
| 2252 | } |
| 2253 | unset object_limit _junk objects_current |
| 2254 | } |
| 2255 | |
Shawn O. Pearce | 53716a7 | 2006-11-18 03:31:25 -0500 | [diff] [blame] | 2256 | lock_index begin-read |
Shawn O. Pearce | 8f52548 | 2006-11-14 01:29:32 -0500 | [diff] [blame] | 2257 | after 1 do_rescan |