git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] git-gui: Support for "Locators" - address templates
@ 2008-09-24 22:12 pasky
  2008-09-24 22:12 ` [PATCH 1/5] git-gui: Avoid using the term URL when specifying repositories pasky
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: pasky @ 2008-09-24 22:12 UTC (permalink / raw)
  To: git; +Cc: spearce

This patch allows "locators" to be configured and used in the GUI,
basically as URL templates the input string is subsituted into.
The default operation of git-gui is not much affected (only some
labels change to be less confusing).

This is aimed mainly at corporate Git deployments - the integrator
might want to configure the central corporate repository store as
the default locator so that people do not need to type the same
URL over and over but can instead just type the repository name
on the server. Or avid repo.or.cz users might set up a 'repo'
locator pointing at 'git://repo.or.cz/%s'.

In practice, this seems to be a more significant usability improvement
than it might seem. Less technical users appear to be less daunted
to type in just the project name instead of dealing with long URLs.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/5] git-gui: Avoid using the term URL when specifying repositories
  2008-09-24 22:12 [PATCH 0/5] git-gui: Support for "Locators" - address templates pasky
@ 2008-09-24 22:12 ` pasky
  2008-09-24 22:12 ` [PATCH 2/5] git-gui: Make input boxes in init/clone/open dialogs consistent pasky
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: pasky @ 2008-09-24 22:12 UTC (permalink / raw)
  To: git; +Cc: spearce

[-- Attachment #1: t/git-gui/avoid-url.diff --]
[-- Type: text/plain, Size: 2245 bytes --]

Instead, 'Location' is used to label such inputs; in the Clone dialog,
'Source' and 'Target' are also introduced to further clarify the situation.
The intent is to increase GUI consistency in the case location templates
(upcoming) are used - then, other locators than URL may be used.

This patch has been sponsored by Novartis.

Signed-off-by: Petr Baudis <pasky@suse.cz>

---
 git-gui/lib/choose_repository.tcl    |    4 ++--
 git-gui/lib/remote_branch_delete.tcl |    2 +-
 git-gui/lib/transport.tcl            |    2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/git-gui/lib/choose_repository.tcl b/git-gui/lib/choose_repository.tcl
index 3180786..f54d88a 100644
--- a/git-gui/lib/choose_repository.tcl
+++ b/git-gui/lib/choose_repository.tcl
@@ -463,7 +463,7 @@ method _do_clone {} {
 	frame $w_body.args
 	pack $args -fill both
 
-	label $args.origin_l -text [mc "URL:"]
+	label $args.origin_l -text [mc "Source Location:"]
 	entry $args.origin_t \
 		-textvariable @origin_url \
 		-font font_diff \
@@ -473,7 +473,7 @@ method _do_clone {} {
 		-command [cb _open_origin]
 	grid $args.origin_l $args.origin_t $args.origin_b -sticky ew
 
-	label $args.where_l -text [mc "Directory:"]
+	label $args.where_l -text [mc "Target Directory:"]
 	entry $args.where_t \
 		-textvariable @local_path \
 		-font font_diff \
diff --git a/git-gui/lib/remote_branch_delete.tcl b/git-gui/lib/remote_branch_delete.tcl
index c7b8148..a09b9ad 100644
--- a/git-gui/lib/remote_branch_delete.tcl
+++ b/git-gui/lib/remote_branch_delete.tcl
@@ -63,7 +63,7 @@ constructor dialog {} {
 		set urltype url
 	}
 	radiobutton $w.dest.url_r \
-		-text [mc "Arbitrary URL:"] \
+		-text [mc "Arbitrary Location:"] \
 		-value url \
 		-variable @urltype
 	entry $w.dest.url_t \
diff --git a/git-gui/lib/transport.tcl b/git-gui/lib/transport.tcl
index 8e6a9d0..e419d78 100644
--- a/git-gui/lib/transport.tcl
+++ b/git-gui/lib/transport.tcl
@@ -135,7 +135,7 @@ proc do_push_anywhere {} {
 		set push_urltype url
 	}
 	radiobutton $w.dest.url_r \
-		-text [mc "Arbitrary URL:"] \
+		-text [mc "Arbitrary Location:"] \
 		-value url \
 		-variable push_urltype
 	entry $w.dest.url_t \
-- 
tg: (c427559..) t/git-gui/avoid-url (depends on: vanilla/master)

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/5] git-gui: Make input boxes in init/clone/open dialogs consistent
  2008-09-24 22:12 [PATCH 0/5] git-gui: Support for "Locators" - address templates pasky
  2008-09-24 22:12 ` [PATCH 1/5] git-gui: Avoid using the term URL when specifying repositories pasky
@ 2008-09-24 22:12 ` pasky
  2008-09-24 22:12 ` [PATCH 3/5] git-gui: Squash populate_{push,fetch}_menu to populate_remotes_menu pasky
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: pasky @ 2008-09-24 22:12 UTC (permalink / raw)
  To: git; +Cc: spearce

[-- Attachment #1: t/git-gui/ldialogs-consistent.diff --]
[-- Type: text/plain, Size: 1742 bytes --]

Before, the input boxes would not be sunken and would have larger border,
which is inconsistent with the rest of the inputboxes for repository
locations in the git-gui UI.

This patch has been sponsored by Novartis.

Signed-off-by: Petr Baudis <pasky@suse.cz>

---
 git-gui/lib/choose_repository.tcl |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/git-gui/lib/choose_repository.tcl b/git-gui/lib/choose_repository.tcl
index f54d88a..9091316 100644
--- a/git-gui/lib/choose_repository.tcl
+++ b/git-gui/lib/choose_repository.tcl
@@ -381,7 +381,8 @@ method _do_new {} {
 	label $w_body.where.l -text [mc "Directory:"]
 	entry $w_body.where.t \
 		-textvariable @local_path \
-		-font font_diff \
+		-borderwidth 1 \
+		-relief sunken \
 		-width 50
 	button $w_body.where.b \
 		-text [mc "Browse"] \
@@ -466,7 +467,8 @@ method _do_clone {} {
 	label $args.origin_l -text [mc "Source Location:"]
 	entry $args.origin_t \
 		-textvariable @origin_url \
-		-font font_diff \
+		-borderwidth 1 \
+		-relief sunken \
 		-width 50
 	button $args.origin_b \
 		-text [mc "Browse"] \
@@ -476,7 +478,8 @@ method _do_clone {} {
 	label $args.where_l -text [mc "Target Directory:"]
 	entry $args.where_t \
 		-textvariable @local_path \
-		-font font_diff \
+		-borderwidth 1 \
+		-relief sunken \
 		-width 50
 	button $args.where_b \
 		-text [mc "Browse"] \
@@ -979,7 +982,8 @@ method _do_open {} {
 	label $w_body.where.l -text [mc "Repository:"]
 	entry $w_body.where.t \
 		-textvariable @local_path \
-		-font font_diff \
+		-borderwidth 1 \
+		-relief sunken \
 		-width 50
 	button $w_body.where.b \
 		-text [mc "Browse"] \
-- 
tg: (cdbf2d1..) t/git-gui/ldialogs-consistent (depends on: t/git-gui/avoid-url)

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/5] git-gui: Squash populate_{push,fetch}_menu to populate_remotes_menu
  2008-09-24 22:12 [PATCH 0/5] git-gui: Support for "Locators" - address templates pasky
  2008-09-24 22:12 ` [PATCH 1/5] git-gui: Avoid using the term URL when specifying repositories pasky
  2008-09-24 22:12 ` [PATCH 2/5] git-gui: Make input boxes in init/clone/open dialogs consistent pasky
@ 2008-09-24 22:12 ` pasky
  2008-09-24 22:23   ` Petr Baudis
  2008-09-24 22:12 ` [PATCH 4/5] git-gui: Factor out URL inputbox construction to location_input pasky
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 9+ messages in thread
From: pasky @ 2008-09-24 22:12 UTC (permalink / raw)
  To: git; +Cc: spearce

[-- Attachment #1: t/git-gui/populate-refactor.diff --]
[-- Type: text/plain, Size: 4505 bytes --]

The meat of the routines is now separated to add_fetch_entry() and
add_push_entry(). This refactoring will allow easy implementation of adding
individual remotes later.

This patch has been sponsored by Novartis.

Signed-off-by: Petr Baudis <pasky@suse.cz>

---
 git-gui/git-gui.sh     |    3 +-
 git-gui/lib/remote.tcl |  137 ++++++++++++++++++++++++------------------------
 2 files changed, 70 insertions(+), 70 deletions(-)

diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
index 10d8a44..75bd460 100755
--- a/git-gui/git-gui.sh
+++ b/git-gui/git-gui.sh
@@ -3100,8 +3100,7 @@ if {[is_enabled transport]} {
 	load_all_remotes
 
 	set n [.mbar.remote index end]
-	populate_push_menu
-	populate_fetch_menu
+	populate_remotes_menu
 	set n [expr {[.mbar.remote index end] - $n}]
 	if {$n > 0} {
 		if {[.mbar.remote type 0] eq "tearoff"} { incr n }
diff --git a/git-gui/lib/remote.tcl b/git-gui/lib/remote.tcl
index 0e86dda..d97c851 100644
--- a/git-gui/lib/remote.tcl
+++ b/git-gui/lib/remote.tcl
@@ -132,91 +132,92 @@ proc load_all_remotes {} {
 	set all_remotes [lsort -unique $all_remotes]
 }
 
-proc populate_fetch_menu {} {
-	global all_remotes repo_config
-
+proc add_fetch_entry {r} {
+	global repo_config
 	set remote_m .mbar.remote
 	set fetch_m $remote_m.fetch
 	set prune_m $remote_m.prune
-
-	foreach r $all_remotes {
-		set enable 0
-		if {![catch {set a $repo_config(remote.$r.url)}]} {
-			if {![catch {set a $repo_config(remote.$r.fetch)}]} {
-				set enable 1
-			}
-		} else {
-			catch {
-				set fd [open [gitdir remotes $r] r]
-				while {[gets $fd n] >= 0} {
-					if {[regexp {^Pull:[ \t]*([^:]+):} $n]} {
-						set enable 1
-						break
-					}
+	set enable 0
+	if {![catch {set a $repo_config(remote.$r.url)}]} {
+		if {![catch {set a $repo_config(remote.$r.fetch)}]} {
+			set enable 1
+		}
+	} else {
+		catch {
+			set fd [open [gitdir remotes $r] r]
+			while {[gets $fd n] >= 0} {
+				if {[regexp {^Pull:[ \t]*([^:]+):} $n]} {
+					set enable 1
+					break
 				}
-				close $fd
 			}
+			close $fd
 		}
+	}
 
-		if {$enable} {
-			if {![winfo exists $fetch_m]} {
-				menu $prune_m
-				$remote_m insert 0 cascade \
-					-label [mc "Prune from"] \
-					-menu $prune_m
-
-				menu $fetch_m
-				$remote_m insert 0 cascade \
-					-label [mc "Fetch from"] \
-					-menu $fetch_m
-			}
-
-			$fetch_m add command \
-				-label $r \
-				-command [list fetch_from $r]
-			$prune_m add command \
-				-label $r \
-				-command [list prune_from $r]
+	if {$enable} {
+		if {![winfo exists $fetch_m]} {
+			menu $prune_m
+			$remote_m insert 0 cascade \
+				-label [mc "Prune from"] \
+				-menu $prune_m
+
+			menu $fetch_m
+			$remote_m insert 0 cascade \
+				-label [mc "Fetch from"] \
+				-menu $fetch_m
 		}
+
+		$fetch_m add command \
+			-label $r \
+			-command [list fetch_from $r]
+		$prune_m add command \
+			-label $r \
+			-command [list prune_from $r]
 	}
 }
 
-proc populate_push_menu {} {
-	global all_remotes repo_config
-
+proc add_push_entry {r} {
+	global repo_config
 	set remote_m .mbar.remote
 	set push_m $remote_m.push
-
-	foreach r $all_remotes {
-		set enable 0
-		if {![catch {set a $repo_config(remote.$r.url)}]} {
-			if {![catch {set a $repo_config(remote.$r.push)}]} {
-				set enable 1
-			}
-		} else {
-			catch {
-				set fd [open [gitdir remotes $r] r]
-				while {[gets $fd n] >= 0} {
-					if {[regexp {^Push:[ \t]*([^:]+):} $n]} {
-						set enable 1
-						break
-					}
+	set enable 0
+	if {![catch {set a $repo_config(remote.$r.url)}]} {
+		if {![catch {set a $repo_config(remote.$r.push)}]} {
+			set enable 1
+		}
+	} else {
+		catch {
+			set fd [open [gitdir remotes $r] r]
+			while {[gets $fd n] >= 0} {
+				if {[regexp {^Push:[ \t]*([^:]+):} $n]} {
+					set enable 1
+					break
 				}
-				close $fd
 			}
+			close $fd
 		}
+	}
 
-		if {$enable} {
-			if {![winfo exists $push_m]} {
-				menu $push_m
-				$remote_m insert 0 cascade \
-					-label [mc "Push to"] \
-					-menu $push_m
-			}
-
-			$push_m add command \
-				-label $r \
-				-command [list push_to $r]
+	if {$enable} {
+		if {![winfo exists $push_m]} {
+			menu $push_m
+			$remote_m insert 0 cascade \
+				-label [mc "Push to"] \
+				-menu $push_m
 		}
+
+		$push_m add command \
+			-label $r \
+			-command [list push_to $r]
+	}
+}
+
+proc populate_remotes_menu {} {
+	global all_remotes
+
+	foreach r $all_remotes {
+		add_fetch_entry $r
+		add_push_entry $r
 	}
 }
-- 
tg: (c427559..) t/git-gui/populate-refactor (depends on: vanilla/master)

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/5] git-gui: Factor out URL inputbox construction to location_input
  2008-09-24 22:12 [PATCH 0/5] git-gui: Support for "Locators" - address templates pasky
                   ` (2 preceding siblings ...)
  2008-09-24 22:12 ` [PATCH 3/5] git-gui: Squash populate_{push,fetch}_menu to populate_remotes_menu pasky
@ 2008-09-24 22:12 ` pasky
  2008-09-24 22:12 ` [PATCH 5/5] git-gui: Support for user-provided locator templates pasky
  2008-09-25 21:26 ` [PATCH 0/5] git-gui: Support for "Locators" - address templates Daniel Barkalow
  5 siblings, 0 replies; 9+ messages in thread
From: pasky @ 2008-09-24 22:12 UTC (permalink / raw)
  To: git; +Cc: spearce

[-- Attachment #1: t/git-gui/ldialogs-refactor.diff --]
[-- Type: text/plain, Size: 4566 bytes --]

This will make it easier to introduce custom locators.

This patch has been sponsored by Novartis.

Signed-off-by: Petr Baudis <pasky@suse.cz>

---
 git-gui/lib/choose_repository.tcl    |    6 +---
 git-gui/lib/remote_add.tcl           |    6 +---
 git-gui/lib/remote_branch_delete.tcl |   11 +-------
 git-gui/lib/transport.tcl            |   46 ++++++++++++++++++++-------------
 4 files changed, 31 insertions(+), 38 deletions(-)

diff --git a/git-gui/lib/choose_repository.tcl b/git-gui/lib/choose_repository.tcl
index 9091316..1c951ae 100644
--- a/git-gui/lib/choose_repository.tcl
+++ b/git-gui/lib/choose_repository.tcl
@@ -465,11 +465,7 @@ method _do_clone {} {
 	pack $args -fill both
 
 	label $args.origin_l -text [mc "Source Location:"]
-	entry $args.origin_t \
-		-textvariable @origin_url \
-		-borderwidth 1 \
-		-relief sunken \
-		-width 50
+	location_input $args.origin_t @origin_url
 	button $args.origin_b \
 		-text [mc "Browse"] \
 		-command [cb _open_origin]
diff --git a/git-gui/lib/remote_add.tcl b/git-gui/lib/remote_add.tcl
index 89e88ee..b4a9ede 100644
--- a/git-gui/lib/remote_add.tcl
+++ b/git-gui/lib/remote_add.tcl
@@ -49,11 +49,7 @@ constructor dialog {} {
 
 	label $w.desc.loc_l -text [mc "Location:"]
 	set w_loc $w.desc.loc_t
-	entry $w_loc \
-		-borderwidth 1 \
-		-relief sunken \
-		-width 40 \
-		-textvariable @location
+	location_input $w_loc @location
 	grid $w.desc.loc_l $w_loc -sticky we -padx {0 5}
 
 	grid columnconfigure $w.desc 1 -weight 1
diff --git a/git-gui/lib/remote_branch_delete.tcl b/git-gui/lib/remote_branch_delete.tcl
index a09b9ad..14a4c15 100644
--- a/git-gui/lib/remote_branch_delete.tcl
+++ b/git-gui/lib/remote_branch_delete.tcl
@@ -66,16 +66,7 @@ constructor dialog {} {
 		-text [mc "Arbitrary Location:"] \
 		-value url \
 		-variable @urltype
-	entry $w.dest.url_t \
-		-borderwidth 1 \
-		-relief sunken \
-		-width 50 \
-		-textvariable @url \
-		-validate key \
-		-validatecommand {
-			if {%d == 1 && [regexp {\s} %S]} {return 0}
-			return 1
-		}
+	location_input $w.dest.url_t @url
 	trace add variable @url write [cb _write_url]
 	grid $w.dest.url_r $w.dest.url_t -sticky we -padx {0 5}
 	grid columnconfigure $w.dest 1 -weight 1
diff --git a/git-gui/lib/transport.tcl b/git-gui/lib/transport.tcl
index e419d78..b8ceebe 100644
--- a/git-gui/lib/transport.tcl
+++ b/git-gui/lib/transport.tcl
@@ -30,6 +30,21 @@ proc push_to {remote} {
 	console::exec $w $cmd
 }
 
+proc location_input {widget urlvar} {
+	global repo_config
+
+	entry $widget \
+		-borderwidth 1 \
+		-relief sunken \
+		-width 50 \
+		-textvariable $urlvar \
+		-validate key \
+		-validatecommand {
+			if {%d == 1 && [regexp {\s} %S]} {return 0}
+			return 1
+		}
+}
+
 proc start_push_anywhere_action {w} {
 	global push_urltype push_remote push_url push_thin push_tags
 	global push_force
@@ -77,11 +92,22 @@ proc start_push_anywhere_action {w} {
 trace add variable push_remote write \
 	[list radio_selector push_urltype remote]
 
+proc push_anywhere_urltype {args} {
+	global push_urltype
+	set push_urltype url
+	warn_popup "blablabla"
+}
+
 proc do_push_anywhere {} {
 	global all_remotes current_branch
 	global push_urltype push_remote push_url push_thin push_tags
 	global push_force
 
+	set push_url {}
+	set push_force 0
+	set push_thin 0
+	set push_tags 0
+
 	set w .push_setup
 	toplevel $w
 	wm geometry $w "+[winfo rootx .]+[winfo rooty .]"
@@ -138,19 +164,8 @@ proc do_push_anywhere {} {
 		-text [mc "Arbitrary Location:"] \
 		-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
-		}
+	location_input $w.dest.url_t push_url
+	trace add variable push_url write push_anywhere_urltype
 	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
@@ -171,11 +186,6 @@ proc do_push_anywhere {} {
 	grid columnconfigure $w.options 1 -weight 1
 	pack $w.options -anchor nw -fill x -pady 5 -padx 5
 
-	set push_url {}
-	set push_force 0
-	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]
-- 
tg: (4e2c8cc..) t/git-gui/ldialogs-refactor (depends on: t/git-gui/ldialogs-consistent t/git-gui/remote-add)

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 5/5] git-gui: Support for user-provided locator templates
  2008-09-24 22:12 [PATCH 0/5] git-gui: Support for "Locators" - address templates pasky
                   ` (3 preceding siblings ...)
  2008-09-24 22:12 ` [PATCH 4/5] git-gui: Factor out URL inputbox construction to location_input pasky
@ 2008-09-24 22:12 ` pasky
  2008-09-25 21:26 ` [PATCH 0/5] git-gui: Support for "Locators" - address templates Daniel Barkalow
  5 siblings, 0 replies; 9+ messages in thread
From: pasky @ 2008-09-24 22:12 UTC (permalink / raw)
  To: git; +Cc: spearce

[-- Attachment #1: t/git-gui/locators.diff --]
[-- Type: text/plain, Size: 6681 bytes --]

Users can now configure their own 'locator' templates, which they
can use to easen entering of common URLs; in all location inputs,
they can choose from the defined locators (and raw URL entry) and
their input is then substituted to the locator template.

Signed-off-by: Petr Baudis <pasky@suse.cz>

---
 Documentation/config.txt             |   25 ++++++++++++++++
 git-gui/lib/choose_repository.tcl    |    7 ++++-
 git-gui/lib/remote_add.tcl           |    2 +-
 git-gui/lib/remote_branch_delete.tcl |    2 +-
 git-gui/lib/transport.tcl            |   52 +++++++++++++++++++++++++++++++--
 5 files changed, 81 insertions(+), 7 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index bea867d..f3e82c6 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -788,6 +788,21 @@ gui.pruneduringfetch::
 	"true" if linkgit:git-gui[1] should prune tracking branches when
 	performing a fetch. The default value is "false".
 
+gui.pulllocator::
+	Specifies the locator pre-selected for cloning and pulling
+	in case any locator templates (see 'locator.*.template')
+	are available. Set to 'URL' to default to the URL entry.
+
+gui.pushlocator::
+	Specifies the locator pre-selected for pushing
+	in case any locator templates (see 'locator.*.template')
+	are available. Set to 'URL' to default to the URL entry.
+
+gui.remotelocator::
+	Specifies the locator pre-selected when adding remotes
+	in case any locator templates (see 'locator.*.template')
+	are available. Set to 'URL' to default to the URL entry.
+
 gui.trustmtime::
 	Determines if linkgit:git-gui[1] should trust the file modification
 	timestamp or not. By default the timestamps are not trusted.
@@ -891,6 +906,16 @@ instaweb.port::
 	The port number to bind the gitweb httpd to. See
 	linkgit:git-instaweb[1].
 
+locator.<name>.template::
+	Normally, you specify repository locations e.g. when cloning
+	or adding remotes by some kind of full-fledged URL-ish specifier.
+	This option lets you specify templates for the most common locations
+	so that you do not have to type out the full URLs all the time;
+	'%s' in the template is substituted by user input. Thus, for example
+	'locator.ror.template = "git://git.kernel.org/%s"' would let you
+	easily refer to kernel.org projects. Currently, the user-defined
+	locators are supported only by linkgit:git-gui[1].
+
 log.date::
 	Set default date-time mode for the log command. Setting log.date
 	value is similar to using 'git-log'\'s --date option. The value is one of the
diff --git a/git-gui/lib/choose_repository.tcl b/git-gui/lib/choose_repository.tcl
index 1c951ae..e05d3a9 100644
--- a/git-gui/lib/choose_repository.tcl
+++ b/git-gui/lib/choose_repository.tcl
@@ -465,7 +465,7 @@ method _do_clone {} {
 	pack $args -fill both
 
 	label $args.origin_l -text [mc "Source Location:"]
-	location_input $args.origin_t @origin_url
+	location_input $args.origin_t @origin_url pull
 	button $args.origin_b \
 		-text [mc "Browse"] \
 		-command [cb _open_origin]
@@ -541,6 +541,11 @@ method _open_origin {} {
 		return
 	}
 	set origin_url $p
+
+	# Fix up locators in case we use them
+	global _locator_template _locator_input
+	set _locator_template URL
+	set _locator_input $p
 }
 
 method _update_clone {args} {
diff --git a/git-gui/lib/remote_add.tcl b/git-gui/lib/remote_add.tcl
index b4a9ede..dec9dcb 100644
--- a/git-gui/lib/remote_add.tcl
+++ b/git-gui/lib/remote_add.tcl
@@ -49,7 +49,7 @@ constructor dialog {} {
 
 	label $w.desc.loc_l -text [mc "Location:"]
 	set w_loc $w.desc.loc_t
-	location_input $w_loc @location
+	location_input $w_loc @location remote
 	grid $w.desc.loc_l $w_loc -sticky we -padx {0 5}
 
 	grid columnconfigure $w.desc 1 -weight 1
diff --git a/git-gui/lib/remote_branch_delete.tcl b/git-gui/lib/remote_branch_delete.tcl
index 14a4c15..5cdab49 100644
--- a/git-gui/lib/remote_branch_delete.tcl
+++ b/git-gui/lib/remote_branch_delete.tcl
@@ -66,7 +66,7 @@ constructor dialog {} {
 		-text [mc "Arbitrary Location:"] \
 		-value url \
 		-variable @urltype
-	location_input $w.dest.url_t @url
+	location_input $w.dest.url_t @url push
 	trace add variable @url write [cb _write_url]
 	grid $w.dest.url_r $w.dest.url_t -sticky we -padx {0 5}
 	grid columnconfigure $w.dest 1 -weight 1
diff --git a/git-gui/lib/transport.tcl b/git-gui/lib/transport.tcl
index b8ceebe..277e6b8 100644
--- a/git-gui/lib/transport.tcl
+++ b/git-gui/lib/transport.tcl
@@ -30,19 +30,63 @@ proc push_to {remote} {
 	console::exec $w $cmd
 }
 
-proc location_input {widget urlvar} {
+proc locator_update {args} {
 	global repo_config
+	global _locator_template _locator_input _locator_var
+	regsub -all %s "$repo_config(locator.$_locator_template.template)" \
+		$_locator_input $_locator_var
+}
+
+proc location_input {widget urlvar op} {
+	global repo_config all_locators
+	set all_locators [list]
+
+	set repo_config(locator.URL.template) "%s"
+	foreach line [array names repo_config locator.*.template] {
+		if {![regexp ^locator\.(.*)\.template\$ $line line name]} continue
+		lappend all_locators $name
+	}
+
+	# 1 == just the default URL locator
+	if {[llength $all_locators] == 1} {
+		entry $widget \
+			-borderwidth 1 \
+			-relief sunken \
+			-width 50 \
+			-textvariable $urlvar \
+			-validate key \
+			-validatecommand {
+				if {%d == 1 && [regexp {\s} %S]} {return 0}
+				return 1
+			}
+		return 0
+	}
+
+	if {[catch {set default_locator $repo_config(gui.${op}locator)}]} {
+		set default_locator [lindex $all_locators 0]
+	}
+
+	global _locator_template _locator_input _locator_var
+	trace remove variable _locator_input write locator_update
+	set _locator_template $default_locator
+	set _locator_input {}
+	set _locator_var $urlvar
+	trace add variable _locator_input write locator_update
 
-	entry $widget \
+	frame $widget
+	eval tk_optionMenu $widget.l _locator_template $all_locators
+	entry $widget.s \
 		-borderwidth 1 \
 		-relief sunken \
 		-width 50 \
-		-textvariable $urlvar \
+		-textvariable _locator_input \
 		-validate key \
 		-validatecommand {
 			if {%d == 1 && [regexp {\s} %S]} {return 0}
 			return 1
 		}
+	pack $widget.l -side left
+	pack $widget.s -side right -fill x
 }
 
 proc start_push_anywhere_action {w} {
@@ -164,7 +208,7 @@ proc do_push_anywhere {} {
 		-text [mc "Arbitrary Location:"] \
 		-value url \
 		-variable push_urltype
-	location_input $w.dest.url_t push_url
+	location_input $w.dest.url_t push_url push
 	trace add variable push_url write push_anywhere_urltype
 	grid $w.dest.url_r $w.dest.url_t -sticky we -padx {0 5}
 	grid columnconfigure $w.dest 1 -weight 1
-- 
tg: (d617ccd..) t/git-gui/locators (depends on: t/git-gui/ldialogs-refactor)

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/5] git-gui: Squash populate_{push,fetch}_menu to populate_remotes_menu
  2008-09-24 22:12 ` [PATCH 3/5] git-gui: Squash populate_{push,fetch}_menu to populate_remotes_menu pasky
@ 2008-09-24 22:23   ` Petr Baudis
  0 siblings, 0 replies; 9+ messages in thread
From: Petr Baudis @ 2008-09-24 22:23 UTC (permalink / raw)
  To: git; +Cc: spearce

On Thu, Sep 25, 2008 at 12:12:52AM +0200, pasky@suse.cz wrote:
> The meat of the routines is now separated to add_fetch_entry() and
> add_push_entry(). This refactoring will allow easy implementation of adding
> individual remotes later.
> 
> This patch has been sponsored by Novartis.
> 
> Signed-off-by: Petr Baudis <pasky@suse.cz>

Sorry, this patch slipped through from another series ;-) - please
disregard.

Also, the PATCH 4/5 has slight dependency on the git-gui remotes series,
but the change to git-gui/lib/remote_add.tcl can just be trimmed if this
would be to go in earlier.

-- 
				Petr "Pasky" Baudis
People who take cold baths never have rheumatism, but they have
cold baths.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/5] git-gui: Support for "Locators" - address templates
  2008-09-24 22:12 [PATCH 0/5] git-gui: Support for "Locators" - address templates pasky
                   ` (4 preceding siblings ...)
  2008-09-24 22:12 ` [PATCH 5/5] git-gui: Support for user-provided locator templates pasky
@ 2008-09-25 21:26 ` Daniel Barkalow
  2008-09-26 14:33   ` Shawn O. Pearce
  5 siblings, 1 reply; 9+ messages in thread
From: Daniel Barkalow @ 2008-09-25 21:26 UTC (permalink / raw)
  To: pasky; +Cc: git, spearce

On Thu, 25 Sep 2008, pasky@suse.cz wrote:

> This patch allows "locators" to be configured and used in the GUI,
> basically as URL templates the input string is subsituted into.
> The default operation of git-gui is not much affected (only some
> labels change to be less confusing).
> 
> This is aimed mainly at corporate Git deployments - the integrator
> might want to configure the central corporate repository store as
> the default locator so that people do not need to type the same
> URL over and over but can instead just type the repository name
> on the server. Or avid repo.or.cz users might set up a 'repo'
> locator pointing at 'git://repo.or.cz/%s'.

Can this be set up to use the "url.<base>.insteadOf" configuration? Part 
of my goal with that feature was to make it easy for me to reference 
projects on my work's central repository store. That is, put in your 
~/gitconfig:

[url "git://repo.or.cz/"]
	insteadOf = repo:

And "git clone repo:alt-git" works.

It'd be nice to share the config somehow so that the same settings can be 
used both in git-gui and on the command line. (I wrote the code so that a 
user can swap patterns of URLs work for other people but aren't good for 
that particular user, but it also applies to user-provided shorthand 
URLs.)

	-Daniel
*This .sig left intentionally blank*

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/5] git-gui: Support for "Locators" - address templates
  2008-09-25 21:26 ` [PATCH 0/5] git-gui: Support for "Locators" - address templates Daniel Barkalow
@ 2008-09-26 14:33   ` Shawn O. Pearce
  0 siblings, 0 replies; 9+ messages in thread
From: Shawn O. Pearce @ 2008-09-26 14:33 UTC (permalink / raw)
  To: Daniel Barkalow; +Cc: pasky, git

Daniel Barkalow <barkalow@iabervon.org> wrote:
> On Thu, 25 Sep 2008, pasky@suse.cz wrote:
> 
> > This patch allows "locators" to be configured and used in the GUI,
> > basically as URL templates the input string is subsituted into.
> 
> Can this be set up to use the "url.<base>.insteadOf" configuration? Part 
> of my goal with that feature was to make it easy for me to reference 
> projects on my work's central repository store. That is, put in your 
> ~/gitconfig:
> 
> [url "git://repo.or.cz/"]
> 	insteadOf = repo:
> 
> And "git clone repo:alt-git" works.

That's a good idea.

When I saw the locator patch come by I thought a bit about the
insteadOf idea, but didn't make it far enough to open an email
discussion about it.

Pasky?
 
-- 
Shawn.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-09-26 14:35 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-24 22:12 [PATCH 0/5] git-gui: Support for "Locators" - address templates pasky
2008-09-24 22:12 ` [PATCH 1/5] git-gui: Avoid using the term URL when specifying repositories pasky
2008-09-24 22:12 ` [PATCH 2/5] git-gui: Make input boxes in init/clone/open dialogs consistent pasky
2008-09-24 22:12 ` [PATCH 3/5] git-gui: Squash populate_{push,fetch}_menu to populate_remotes_menu pasky
2008-09-24 22:23   ` Petr Baudis
2008-09-24 22:12 ` [PATCH 4/5] git-gui: Factor out URL inputbox construction to location_input pasky
2008-09-24 22:12 ` [PATCH 5/5] git-gui: Support for user-provided locator templates pasky
2008-09-25 21:26 ` [PATCH 0/5] git-gui: Support for "Locators" - address templates Daniel Barkalow
2008-09-26 14:33   ` Shawn O. Pearce

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).