2007-05-08 05:35:48 +02:00
|
|
|
# git-gui transport (fetch/push) support
|
|
|
|
# Copyright (C) 2006, 2007 Shawn Pearce
|
|
|
|
|
|
|
|
proc fetch_from {remote} {
|
2007-05-01 08:59:53 +02:00
|
|
|
set w [console::new \
|
2007-09-20 19:03:43 +02:00
|
|
|
[mc "fetch %s" $remote] \
|
2007-07-21 14:21:34 +02:00
|
|
|
[mc "Fetching new changes from %s" $remote]]
|
2007-05-28 17:04:59 +02:00
|
|
|
set cmds [list]
|
|
|
|
lappend cmds [list exec git fetch $remote]
|
|
|
|
if {[is_config_true gui.pruneduringfetch]} {
|
|
|
|
lappend cmds [list exec git remote prune $remote]
|
|
|
|
}
|
|
|
|
console::chain $w $cmds
|
|
|
|
}
|
|
|
|
|
|
|
|
proc prune_from {remote} {
|
|
|
|
set w [console::new \
|
2007-09-20 19:03:43 +02:00
|
|
|
[mc "remote prune %s" $remote] \
|
2007-07-21 14:21:34 +02:00
|
|
|
[mc "Pruning tracking branches deleted from %s" $remote]]
|
2007-05-28 17:04:59 +02:00
|
|
|
console::exec $w [list git remote prune $remote]
|
2007-05-08 05:35:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
proc push_to {remote} {
|
2007-05-01 08:59:53 +02:00
|
|
|
set w [console::new \
|
2007-09-20 19:03:43 +02:00
|
|
|
[mc "push %s" $remote] \
|
2007-07-21 14:21:34 +02:00
|
|
|
[mc "Pushing changes to %s" $remote]]
|
2007-05-08 05:35:48 +02:00
|
|
|
set cmd [list git push]
|
|
|
|
lappend cmd -v
|
|
|
|
lappend cmd $remote
|
2007-05-01 08:59:53 +02:00
|
|
|
console::exec $w $cmd
|
2007-05-08 05:35:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
proc start_push_anywhere_action {w} {
|
|
|
|
global push_urltype push_remote push_url push_thin push_tags
|
2007-10-02 18:52:22 +02:00
|
|
|
global push_force
|
2008-12-02 16:15:02 +01:00
|
|
|
global repo_config
|
2007-05-08 05:35:48 +02:00
|
|
|
|
2008-12-02 16:15:02 +01:00
|
|
|
set is_mirror 0
|
2007-05-08 05:35:48 +02:00
|
|
|
set r_url {}
|
|
|
|
switch -- $push_urltype {
|
2008-12-02 16:15:02 +01:00
|
|
|
remote {
|
|
|
|
set r_url $push_remote
|
|
|
|
catch {set is_mirror $repo_config(remote.$push_remote.mirror)}
|
|
|
|
}
|
2007-05-08 05:35:48 +02:00
|
|
|
url {set r_url $push_url}
|
|
|
|
}
|
|
|
|
if {$r_url eq {}} return
|
|
|
|
|
|
|
|
set cmd [list git push]
|
|
|
|
lappend cmd -v
|
|
|
|
if {$push_thin} {
|
|
|
|
lappend cmd --thin
|
|
|
|
}
|
2007-10-02 18:52:22 +02:00
|
|
|
if {$push_force} {
|
|
|
|
lappend cmd --force
|
|
|
|
}
|
2007-05-08 05:35:48 +02:00
|
|
|
if {$push_tags} {
|
|
|
|
lappend cmd --tags
|
|
|
|
}
|
|
|
|
lappend cmd $r_url
|
2008-12-02 16:15:02 +01:00
|
|
|
if {$is_mirror} {
|
|
|
|
set cons [console::new \
|
|
|
|
[mc "push %s" $r_url] \
|
|
|
|
[mc "Mirroring to %s" $r_url]]
|
2007-05-08 05:35:48 +02:00
|
|
|
} else {
|
2008-12-02 16:15:02 +01:00
|
|
|
set cnt 0
|
|
|
|
foreach i [$w.source.l curselection] {
|
|
|
|
set b [$w.source.l get $i]
|
|
|
|
lappend cmd "refs/heads/$b:refs/heads/$b"
|
|
|
|
incr cnt
|
|
|
|
}
|
|
|
|
if {$cnt == 0} {
|
|
|
|
return
|
|
|
|
} elseif {$cnt == 1} {
|
|
|
|
set unit branch
|
|
|
|
} else {
|
|
|
|
set unit branches
|
|
|
|
}
|
2007-05-08 05:35:48 +02:00
|
|
|
|
2008-12-02 16:15:02 +01:00
|
|
|
set cons [console::new \
|
|
|
|
[mc "push %s" $r_url] \
|
|
|
|
[mc "Pushing %s %s to %s" $cnt $unit $r_url]]
|
|
|
|
}
|
2007-05-01 08:59:53 +02:00
|
|
|
console::exec $cons $cmd
|
2007-05-08 05:35:48 +02:00
|
|
|
destroy $w
|
|
|
|
}
|
|
|
|
|
|
|
|
trace add variable push_remote write \
|
|
|
|
[list radio_selector push_urltype remote]
|
|
|
|
|
|
|
|
proc do_push_anywhere {} {
|
2007-07-09 00:40:56 +02:00
|
|
|
global all_remotes current_branch
|
2007-05-08 05:35:48 +02:00
|
|
|
global push_urltype push_remote push_url push_thin push_tags
|
2007-10-02 18:52:22 +02:00
|
|
|
global push_force
|
2007-05-08 05:35:48 +02:00
|
|
|
|
|
|
|
set w .push_setup
|
|
|
|
toplevel $w
|
|
|
|
wm geometry $w "+[winfo rootx .]+[winfo rooty .]"
|
|
|
|
|
2007-07-21 14:21:34 +02:00
|
|
|
label $w.header -text [mc "Push Branches"] -font font_uibold
|
2007-05-08 05:35:48 +02:00
|
|
|
pack $w.header -side top -fill x
|
|
|
|
|
|
|
|
frame $w.buttons
|
2007-07-21 14:21:34 +02:00
|
|
|
button $w.buttons.create -text [mc Push] \
|
2007-05-08 05:35:48 +02:00
|
|
|
-default active \
|
|
|
|
-command [list start_push_anywhere_action $w]
|
|
|
|
pack $w.buttons.create -side right
|
2007-07-21 14:21:34 +02:00
|
|
|
button $w.buttons.cancel -text [mc "Cancel"] \
|
2007-05-08 05:35:48 +02:00
|
|
|
-default normal \
|
|
|
|
-command [list destroy $w]
|
|
|
|
pack $w.buttons.cancel -side right -padx 5
|
|
|
|
pack $w.buttons -side bottom -fill x -pady 10 -padx 10
|
|
|
|
|
2007-07-21 14:21:34 +02:00
|
|
|
labelframe $w.source -text [mc "Source Branches"]
|
2007-05-08 05:35:48 +02:00
|
|
|
listbox $w.source.l \
|
|
|
|
-height 10 \
|
|
|
|
-width 70 \
|
|
|
|
-selectmode extended \
|
|
|
|
-yscrollcommand [list $w.source.sby set]
|
2007-07-09 00:40:56 +02:00
|
|
|
foreach h [load_all_heads] {
|
2007-05-08 05:35:48 +02:00
|
|
|
$w.source.l insert end $h
|
|
|
|
if {$h eq $current_branch} {
|
|
|
|
$w.source.l select set end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
scrollbar $w.source.sby -command [list $w.source.l yview]
|
|
|
|
pack $w.source.sby -side right -fill y
|
|
|
|
pack $w.source.l -side left -fill both -expand 1
|
|
|
|
pack $w.source -fill both -expand 1 -pady 5 -padx 5
|
|
|
|
|
2007-07-21 14:21:34 +02:00
|
|
|
labelframe $w.dest -text [mc "Destination Repository"]
|
2007-05-08 05:35:48 +02:00
|
|
|
if {$all_remotes ne {}} {
|
|
|
|
radiobutton $w.dest.remote_r \
|
2007-07-21 14:21:34 +02:00
|
|
|
-text [mc "Remote:"] \
|
2007-05-08 05:35:48 +02:00
|
|
|
-value remote \
|
|
|
|
-variable push_urltype
|
|
|
|
eval tk_optionMenu $w.dest.remote_m push_remote $all_remotes
|
|
|
|
grid $w.dest.remote_r $w.dest.remote_m -sticky w
|
|
|
|
if {[lsearch -sorted -exact $all_remotes origin] != -1} {
|
|
|
|
set push_remote origin
|
|
|
|
} else {
|
|
|
|
set push_remote [lindex $all_remotes 0]
|
|
|
|
}
|
|
|
|
set push_urltype remote
|
|
|
|
} else {
|
|
|
|
set push_urltype url
|
|
|
|
}
|
|
|
|
radiobutton $w.dest.url_r \
|
2008-09-25 00:12:50 +02:00
|
|
|
-text [mc "Arbitrary Location:"] \
|
2007-05-08 05:35:48 +02:00
|
|
|
-value url \
|
|
|
|
-variable push_urltype
|
|
|
|
entry $w.dest.url_t \
|
|
|
|
-borderwidth 1 \
|
|
|
|
-relief sunken \
|
|
|
|
-width 50 \
|
|
|
|
-textvariable push_url \
|
|
|
|
-validate key \
|
|
|
|
-validatecommand {
|
|
|
|
if {%d == 1 && [regexp {\s} %S]} {return 0}
|
|
|
|
if {%d == 1 && [string length %S] > 0} {
|
|
|
|
set push_urltype url
|
|
|
|
}
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
grid $w.dest.url_r $w.dest.url_t -sticky we -padx {0 5}
|
|
|
|
grid columnconfigure $w.dest 1 -weight 1
|
|
|
|
pack $w.dest -anchor nw -fill x -pady 5 -padx 5
|
|
|
|
|
2007-07-21 14:21:34 +02:00
|
|
|
labelframe $w.options -text [mc "Transfer Options"]
|
2007-10-02 18:52:22 +02:00
|
|
|
checkbutton $w.options.force \
|
|
|
|
-text [mc "Force overwrite existing branch (may discard changes)"] \
|
|
|
|
-variable push_force
|
|
|
|
grid $w.options.force -columnspan 2 -sticky w
|
2007-05-08 05:35:48 +02:00
|
|
|
checkbutton $w.options.thin \
|
2007-07-21 14:21:34 +02:00
|
|
|
-text [mc "Use thin pack (for slow network connections)"] \
|
2007-05-08 05:35:48 +02:00
|
|
|
-variable push_thin
|
|
|
|
grid $w.options.thin -columnspan 2 -sticky w
|
|
|
|
checkbutton $w.options.tags \
|
2007-07-21 14:21:34 +02:00
|
|
|
-text [mc "Include tags"] \
|
2007-05-08 05:35:48 +02:00
|
|
|
-variable push_tags
|
|
|
|
grid $w.options.tags -columnspan 2 -sticky w
|
|
|
|
grid columnconfigure $w.options 1 -weight 1
|
|
|
|
pack $w.options -anchor nw -fill x -pady 5 -padx 5
|
|
|
|
|
|
|
|
set push_url {}
|
2007-10-02 18:52:22 +02:00
|
|
|
set push_force 0
|
2007-05-08 05:35:48 +02:00
|
|
|
set push_thin 0
|
|
|
|
set push_tags 0
|
|
|
|
|
|
|
|
bind $w <Visibility> "grab $w; focus $w.buttons.create"
|
|
|
|
bind $w <Key-Escape> "destroy $w"
|
|
|
|
bind $w <Key-Return> [list start_push_anywhere_action $w]
|
2007-07-21 14:21:34 +02:00
|
|
|
wm title $w [append "[appname] ([reponame]): " [mc "Push"]]
|
2007-05-08 05:35:48 +02:00
|
|
|
tkwait window $w
|
|
|
|
}
|