* [PATCH] gitk: Add a "Save file as" menu item
@ 2013-07-21 12:38 Andreas Amann
2013-07-21 18:13 ` Peter Krefting
0 siblings, 1 reply; 5+ messages in thread
From: Andreas Amann @ 2013-07-21 12:38 UTC (permalink / raw)
To: Paul Mackerras; +Cc: git
Previously, there was no easy way to save a particular file from the
currently selected revision.
This patch adds a menu item "Save file as" to the file list popup
menu, which opens a file selection dialog to determine the name under
which a file should be saved. The default filename is of the form
"[shortid] basename". If the current revision is the index, the
default pattern is of the form "[index] basename". This works for
both, the "Patch" and "Tree" view. The menu item is disabled for the
"local uncommitted changes" fake revision.
Signed-off-by: Andreas Amann <andreas.amann@web.de>
---
gitk | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/gitk b/gitk
index 5cd00d8..dbedaf6 100755
--- a/gitk
+++ b/gitk
@@ -2595,6 +2595,7 @@ proc makewindow {} {
{mc "Highlight this too" command {flist_hl 0}}
{mc "Highlight this only" command {flist_hl 1}}
{mc "External diff" command {external_diff}}
+ {mc "Save file as" command {save_file_as}}
{mc "Blame parent commit" command {external_blame 1}}
}
$flist_menu configure -tearoff 0
@@ -3378,6 +3379,7 @@ proc sel_flist {w x y} {
proc pop_flist_menu {w X Y x y} {
global ctext cflist cmitmode flist_menu flist_menu_file
global treediffs diffids
+ global nullid
stopfinding
set l [lindex [split [$w index "@$x,$y"] "."] 0]
@@ -3395,6 +3397,12 @@ proc pop_flist_menu {w X Y x y} {
}
# Disable "External diff" item in tree mode
$flist_menu entryconf 2 -state $xdiffstate
+ set savefilestate "normal"
+ if {[lindex $diffids 0] eq $nullid} {
+ set savefilestate "disabled"
+ }
+ # Disable "Save file as" item for worktree
+ $flist_menu entryconf 3 -state $savefilestate
tk_popup $flist_menu $X $Y
}
@@ -3496,6 +3504,28 @@ proc external_diff_get_one_file {diffid filename diffdir} {
"revision $diffid"]
}
+proc save_file_as {} {
+ global nullid nullid2
+ global flist_menu_file
+ global diffids
+
+ set diffid [lindex $diffids 0]
+ if {$diffid == $nullid} {
+ return
+ } elseif {$diffid == $nullid2} {
+ set diffidtext "\[index\]"
+ set diffid ""
+ } else {
+ set diffidtext "\[[shortids $diffid]\]"
+ }
+ set difffile "$diffidtext [file tail $flist_menu_file]"
+ set difffile [tk_getSaveFile -initialfile $difffile -title "Save file as" -parent .]
+ if {$difffile eq {}} {
+ return
+ }
+ save_file_from_commit $diffid:$flist_menu_file $difffile "revision $diffid"
+}
+
proc external_diff {} {
global nullid nullid2
global flist_menu_file
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] gitk: Add a "Save file as" menu item
2013-07-21 12:38 [PATCH] gitk: Add a "Save file as" menu item Andreas Amann
@ 2013-07-21 18:13 ` Peter Krefting
2013-07-21 19:53 ` Andreas Amann
2013-07-21 19:55 ` [PATCH v2] " Andreas Amann
0 siblings, 2 replies; 5+ messages in thread
From: Peter Krefting @ 2013-07-21 18:13 UTC (permalink / raw)
To: Andreas Amann; +Cc: Paul Mackerras, git
Andreas Amann:
> + set difffile "$diffidtext [file tail $flist_menu_file]"
> + set difffile [tk_getSaveFile -initialfile $difffile -title "Save file as" -parent .]
> + if {$difffile eq {}} {
> + return
> + }
> + save_file_from_commit $diffid:$flist_menu_file $difffile "revision $diffid"
I might be misunderstanding the code (this is not one of my preferred
programming languages), but it looks like this is missing the gettext
markers necessary to get these strings localized.
--
\\// Peter - http://www.softwolves.pp.se/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gitk: Add a "Save file as" menu item
2013-07-21 18:13 ` Peter Krefting
@ 2013-07-21 19:53 ` Andreas Amann
2013-07-21 19:55 ` [PATCH v2] " Andreas Amann
1 sibling, 0 replies; 5+ messages in thread
From: Andreas Amann @ 2013-07-21 19:53 UTC (permalink / raw)
To: Peter Krefting; +Cc: Paul Mackerras, git
Peter Krefting <peter@softwolves.pp.se> writes:
> Andreas Amann:
>
>> + set difffile "$diffidtext [file tail $flist_menu_file]"
>> + set difffile [tk_getSaveFile -initialfile $difffile -title "Save file as" -parent .]
>> + if {$difffile eq {}} {
>> + return
>> + }
>> + save_file_from_commit $diffid:$flist_menu_file $difffile "revision $diffid"
>
> I might be misunderstanding the code (this is not one of my preferred
> programming languages), but it looks like this is missing the gettext
> markers necessary to get these strings localized.
thanks for pointing this out. Will resend an updated patch.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] gitk: Add a "Save file as" menu item
2013-07-21 18:13 ` Peter Krefting
2013-07-21 19:53 ` Andreas Amann
@ 2013-07-21 19:55 ` Andreas Amann
2013-07-28 15:30 ` [PATCH v3] " Andreas Amann
1 sibling, 1 reply; 5+ messages in thread
From: Andreas Amann @ 2013-07-21 19:55 UTC (permalink / raw)
To: git; +Cc: Paul Mackerras, Peter Krefting
Previously, there was no easy way to save a particular file from the
currently selected revision.
This patch adds a menu item "Save file as" to the file list popup
menu, which opens a file selection dialog to determine the name under
which a file should be saved. The default filename is of the form
"[shortid] basename". If the current revision is the index, the
default pattern is of the form "[index] basename". This works for
both, the "Patch" and "Tree" view. The menu item is disabled for the
"local uncommitted changes" fake revision.
Signed-off-by: Andreas Amann <andreas.amann@web.de>
---
gitk | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/gitk b/gitk
index 5cd00d8..b5a70b5 100755
--- a/gitk
+++ b/gitk
@@ -2595,6 +2595,7 @@ proc makewindow {} {
{mc "Highlight this too" command {flist_hl 0}}
{mc "Highlight this only" command {flist_hl 1}}
{mc "External diff" command {external_diff}}
+ {mc "Save file as" command {save_file_as}}
{mc "Blame parent commit" command {external_blame 1}}
}
$flist_menu configure -tearoff 0
@@ -3378,6 +3379,7 @@ proc sel_flist {w x y} {
proc pop_flist_menu {w X Y x y} {
global ctext cflist cmitmode flist_menu flist_menu_file
global treediffs diffids
+ global nullid
stopfinding
set l [lindex [split [$w index "@$x,$y"] "."] 0]
@@ -3395,6 +3397,12 @@ proc pop_flist_menu {w X Y x y} {
}
# Disable "External diff" item in tree mode
$flist_menu entryconf 2 -state $xdiffstate
+ set savefilestate "normal"
+ if {[lindex $diffids 0] eq $nullid} {
+ set savefilestate "disabled"
+ }
+ # Disable "Save file as" item "local uncommited changes" revision
+ $flist_menu entryconf 3 -state $savefilestate
tk_popup $flist_menu $X $Y
}
@@ -3496,6 +3504,30 @@ proc external_diff_get_one_file {diffid filename diffdir} {
"revision $diffid"]
}
+proc save_file_as {} {
+ global nullid nullid2
+ global flist_menu_file
+ global diffids
+
+ set diffid [lindex $diffids 0]
+ if {$diffid == $nullid} {
+ return
+ } elseif {$diffid == $nullid2} {
+ set diffidtext [mc "index"]
+ set diffid ""
+ set whattext $diffidtext
+ } else {
+ set diffidtext [shortids $diffid]
+ set whattext "[mc "revision"] $diffidtext"
+ }
+ set difffile "\[$diffidtext\] [file tail $flist_menu_file]"
+ set difffile [tk_getSaveFile -initialfile $difffile -title [mc "Save file as"] -parent .]
+ if {$difffile eq {}} {
+ return
+ }
+ save_file_from_commit $diffid:$flist_menu_file $difffile $whattext
+}
+
proc external_diff {} {
global nullid nullid2
global flist_menu_file
--
1.8.3.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3] gitk: Add a "Save file as" menu item
2013-07-21 19:55 ` [PATCH v2] " Andreas Amann
@ 2013-07-28 15:30 ` Andreas Amann
0 siblings, 0 replies; 5+ messages in thread
From: Andreas Amann @ 2013-07-28 15:30 UTC (permalink / raw)
To: git; +Cc: Paul Mackerras, Peter Krefting
Previously, there was no easy way to save a particular file from the
currently selected revision.
This patch adds a menu item "Save file as" to the file list popup
menu, which opens a file selection dialog to determine the name under
which a file should be saved. The default filename is of the form
"[shortid] basename". If the current revision is the index, the
default pattern is of the form "[index] basename". This works for
both, the "Patch" and "Tree" view. The menu item is disabled for the
"local uncommitted changes" fake revision.
Signed-off-by: Andreas Amann <andreas.amann@web.de>
---
gitk | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
The previous version V2 of the patch did not work, when gitk was started
in a subdirectory of the repo and a file was saved from tree view. This
is now fixed.
diff --git a/gitk b/gitk
index 5cd00d8..6b66f18 100755
--- a/gitk
+++ b/gitk
@@ -2595,6 +2595,7 @@ proc makewindow {} {
{mc "Highlight this too" command {flist_hl 0}}
{mc "Highlight this only" command {flist_hl 1}}
{mc "External diff" command {external_diff}}
+ {mc "Save file as" command {save_file_as}}
{mc "Blame parent commit" command {external_blame 1}}
}
$flist_menu configure -tearoff 0
@@ -3378,6 +3379,7 @@ proc sel_flist {w x y} {
proc pop_flist_menu {w X Y x y} {
global ctext cflist cmitmode flist_menu flist_menu_file
global treediffs diffids
+ global nullid
stopfinding
set l [lindex [split [$w index "@$x,$y"] "."] 0]
@@ -3395,6 +3397,12 @@ proc pop_flist_menu {w X Y x y} {
}
# Disable "External diff" item in tree mode
$flist_menu entryconf 2 -state $xdiffstate
+ set savefilestate "normal"
+ if {[lindex $diffids 0] eq $nullid} {
+ set savefilestate "disabled"
+ }
+ # Disable "Save file as" item "local uncommited changes" revision
+ $flist_menu entryconf 3 -state $savefilestate
tk_popup $flist_menu $X $Y
}
@@ -3496,6 +3504,34 @@ proc external_diff_get_one_file {diffid filename diffdir} {
"revision $diffid"]
}
+proc save_file_as {} {
+ global nullid nullid2
+ global flist_menu_file cmitmode
+ global diffids
+
+ set diffid [lindex $diffids 0]
+ if {$diffid == $nullid} {
+ return
+ } elseif {$diffid == $nullid2} {
+ set diffidtext [mc "index"]
+ set diffid ""
+ set whattext $diffidtext
+ } else {
+ set diffidtext [shortids $diffid]
+ set whattext "[mc "revision"] $diffidtext"
+ }
+ set diffid $diffid:
+ if {$cmitmode eq "tree"} {
+ set diffid $diffid./
+ }
+ set difffile "\[$diffidtext\] [file tail $flist_menu_file]"
+ set difffile [tk_getSaveFile -initialfile $difffile -title [mc "Save file as"] -parent .]
+ if {$difffile eq {}} {
+ return
+ }
+ save_file_from_commit $diffid$flist_menu_file $difffile $whattext
+}
+
proc external_diff {} {
global nullid nullid2
global flist_menu_file
--
1.8.3.3
Andreas Amann <a.amann@ucc.ie> writes:
> Previously, there was no easy way to save a particular file from the
> currently selected revision.
>
> This patch adds a menu item "Save file as" to the file list popup
> menu, which opens a file selection dialog to determine the name under
> which a file should be saved. The default filename is of the form
> "[shortid] basename". If the current revision is the index, the
> default pattern is of the form "[index] basename". This works for
> both, the "Patch" and "Tree" view. The menu item is disabled for the
> "local uncommitted changes" fake revision.
>
> Signed-off-by: Andreas Amann <andreas.amann@web.de>
> ---
> gitk | 32 ++++++++++++++++++++++++++++++++
> 1 file changed, 32 insertions(+)
>
> diff --git a/gitk b/gitk
> index 5cd00d8..b5a70b5 100755
> --- a/gitk
> +++ b/gitk
> @@ -2595,6 +2595,7 @@ proc makewindow {} {
> {mc "Highlight this too" command {flist_hl 0}}
> {mc "Highlight this only" command {flist_hl 1}}
> {mc "External diff" command {external_diff}}
> + {mc "Save file as" command {save_file_as}}
> {mc "Blame parent commit" command {external_blame 1}}
> }
> $flist_menu configure -tearoff 0
> @@ -3378,6 +3379,7 @@ proc sel_flist {w x y} {
> proc pop_flist_menu {w X Y x y} {
> global ctext cflist cmitmode flist_menu flist_menu_file
> global treediffs diffids
> + global nullid
>
> stopfinding
> set l [lindex [split [$w index "@$x,$y"] "."] 0]
> @@ -3395,6 +3397,12 @@ proc pop_flist_menu {w X Y x y} {
> }
> # Disable "External diff" item in tree mode
> $flist_menu entryconf 2 -state $xdiffstate
> + set savefilestate "normal"
> + if {[lindex $diffids 0] eq $nullid} {
> + set savefilestate "disabled"
> + }
> + # Disable "Save file as" item "local uncommited changes" revision
> + $flist_menu entryconf 3 -state $savefilestate
> tk_popup $flist_menu $X $Y
> }
>
> @@ -3496,6 +3504,30 @@ proc external_diff_get_one_file {diffid filename diffdir} {
> "revision $diffid"]
> }
>
> +proc save_file_as {} {
> + global nullid nullid2
> + global flist_menu_file
> + global diffids
> +
> + set diffid [lindex $diffids 0]
> + if {$diffid == $nullid} {
> + return
> + } elseif {$diffid == $nullid2} {
> + set diffidtext [mc "index"]
> + set diffid ""
> + set whattext $diffidtext
> + } else {
> + set diffidtext [shortids $diffid]
> + set whattext "[mc "revision"] $diffidtext"
> + }
> + set difffile "\[$diffidtext\] [file tail $flist_menu_file]"
> + set difffile [tk_getSaveFile -initialfile $difffile -title [mc "Save file as"] -parent .]
> + if {$difffile eq {}} {
> + return
> + }
> + save_file_from_commit $diffid:$flist_menu_file $difffile $whattext
> +}
> +
> proc external_diff {} {
> global nullid nullid2
> global flist_menu_file
> --
> 1.8.3.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-07-28 15:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-21 12:38 [PATCH] gitk: Add a "Save file as" menu item Andreas Amann
2013-07-21 18:13 ` Peter Krefting
2013-07-21 19:53 ` Andreas Amann
2013-07-21 19:55 ` [PATCH v2] " Andreas Amann
2013-07-28 15:30 ` [PATCH v3] " Andreas Amann
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).