git-gui: Started construction of fetch and push operations.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Nov 6, 2006 at 23:13 UTC
8c0ce436826f01e17cba90ebcaf6483ad3b8c984
1 file changed
+124
git-gui
+124
@@ -584,6 +584,34 @@ proc commit_stage2 {fd_wt curHEAD msg} {
584
update_status "Changes committed as $cmt_id."
585
}
586
587
+######################################################################
588
+##
589
+## fetch pull push
590
+
591
+proc fetch_from {remote} {
592
+ set w [new_console "fetch $remote" \
593
+ "Fetching new changes from $remote"]
594
+ set cmd [list | git fetch]
595
+ lappend -v
596
+ lappend cmd $remote
597
+ lappend cmd |& cat
598
+ set fd_f [open $cmd r]
599
+ fconfigure $fd_f -blocking 0 -translation auto
600
+ fileevent $fd_f readable [list console_read $w $fd_f]
601
+}
602
+
603
+proc push_to {remote} {
604
+ set w [new_console "push $remote" \
605
+ "Pushing changes to $remote"]
606
+ set cmd [list | git push]
607
+ lappend -v
608
+ lappend cmd $remote
609
+ lappend cmd |& cat
610
+ set fd_f [open $cmd r]
611
+ fconfigure $fd_f -blocking 0 -translation auto
612
+ fileevent $fd_f readable [list console_read $w $fd_f]
613
+}
614
+
615
######################################################################
616
##
617
## ui helpers
@@ -765,6 +793,41 @@ proc toggle_mode {path} {
793
}
794
}
795
796
+######################################################################
797
+##
798
+## config (fetch push pull)
799
+
800
+proc load_all_remotes {} {
801
+ global gitdir all_remotes
802
+
803
+ set all_remotes [list]
804
+ set rm_dir [file join $gitdir remotes]
805
+ if {[file isdirectory $rm_dir]} {
806
+ set all_remotes [concat $all_remotes \
807
+ [glob -types f -tails -directory $rm_dir * *]]
808
+ }
809
+
810
+ set fd_rc [open "| git repo-config --list" r]
811
+ while {[gets $fd_rc line] >= 0} {
812
+ if {[regexp ^remote\.(.*)\.url= $line line name]} {
813
+ lappend all_remotes $name
814
+ }
815
+ }
816
+ close $fd_rc
817
+
818
+ set all_remotes [lsort -unique $all_remotes]
819
+}
820
+
821
+proc populate_remote_menu {m pfx op} {
822
+ global gitdir all_remotes mainfont
823
+
824
+ foreach remote $all_remotes {
825
+ $m add command -label "$pfx $remote..." \
826
+ -command [list $op $remote] \
827
+ -font $mainfont
828
+ }
829
+}
830
+
831
######################################################################
832
##
833
## icons
@@ -888,6 +951,7 @@ proc show_msg {w top msg} {
951
pack $w.m -side top -fill x -padx 5 -pady 10
952
button $w.ok -text OK \
953
-width 15 \
954
+ -font $mainfont \
955
-command "destroy $top"
956
pack $w.ok -side bottom
957
bind $top <Visibility> "grab $top; focus $top"
@@ -931,6 +995,7 @@ proc hook_failed_popup {hook msg} {
995
996
button $w.ok -text OK \
997
-width 15 \
998
+ -font $mainfont \
999
-command "destroy $w"
1000
pack $w.ok -side bottom
1001
@@ -940,6 +1005,58 @@ proc hook_failed_popup {hook msg} {
1005
tkwait window $w
1006
}
1007
1008
+set next_console_id 0
1009
+
1010
+proc new_console {short_title long_title} {
1011
+ global next_console_id gitdir appname mainfont difffont
1012
+
1013
+ set w .console[incr next_console_id]
1014
+ toplevel $w
1015
+ frame $w.m
1016
+ label $w.m.l1 -text "$long_title:" \
1017
+ -anchor w \
1018
+ -justify left \
1019
+ -font [concat $mainfont bold]
1020
+ text $w.m.t \
1021
+ -background white -borderwidth 1 \
1022
+ -relief sunken \
1023
+ -width 80 -height 10 \
1024
+ -font $difffont \
1025
+ -state disabled \
1026
+ -yscrollcommand [list $w.m.sby set]
1027
+ scrollbar $w.m.sby -command [list $w.m.t yview]
1028
+ pack $w.m.l1 -side top -fill x
1029
+ pack $w.m.sby -side right -fill y
1030
+ pack $w.m.t -side left -fill both -expand 1
1031
+ pack $w.m -side top -fill both -expand 1 -padx 5 -pady 10
1032
+
1033
+ button $w.ok -text {OK} \
1034
+ -width 15 \
1035
+ -font $mainfont \
1036
+ -state disabled \
1037
+ -command "destroy $w"
1038
+ pack $w.ok -side bottom
1039
+
1040
+ bind $w <Visibility> "focus $w"
1041
+ bind $w <Destroy> break
1042
+ wm title $w "$appname ([file dirname [file normalize [file dirname $gitdir]]]): $short_title"
1043
+ return $w
1044
+}
1045
+
1046
+proc console_read {w fd} {
1047
+ $w.m.t conf -state normal
1048
+ while {[gets $fd line] >= 0} {
1049
+ $w.m.t insert end $line
1050
+ $w.m.t insert end "\n"
1051
+ }
1052
+ $w.m.t conf -state disabled
1053
+
1054
+ if {[eof $fd]} {
1055
+ close $fd
1056
+ $w.ok conf -state normal
1057
+ }
1058
+}
1059
+
1060
######################################################################
1061
##
1062
## ui commands
@@ -1083,6 +1200,7 @@ menu .mbar -tearoff 0
1200
.mbar add cascade -label Commit -menu .mbar.commit
1201
.mbar add cascade -label Fetch -menu .mbar.fetch
1202
.mbar add cascade -label Pull -menu .mbar.pull
1203
+.mbar add cascade -label Push -menu .mbar.push
1204
. configure -menu .mbar
1205
1206
# -- Project Menu
@@ -1131,6 +1249,9 @@ menu .mbar.fetch
1249
# -- Pull Menu
1250
menu .mbar.pull
1251
1252
+# -- Push Menu
1253
+menu .mbar.push
1254
+
1255
# -- Main Window Layout
1256
panedwindow .vpane -orient vertical
1257
panedwindow .vpane.files -orient horizontal
@@ -1345,4 +1466,7 @@ if {$appname == {git-citool}} {
1466
1467
wm title . "$appname ([file normalize [file dirname $gitdir]])"
1468
focus -force $ui_comm
1469
+load_all_remotes
1470
+populate_remote_menu .mbar.fetch From fetch_from
1471
+populate_remote_menu .mbar.push To push_to
1472
update_status