tkrev_9.6.1/ 0000775 0001750 0001750 00000000000 15034253755 013265 5 ustar dorothyr dorothyr tkrev_9.6.1/LICENSE.txt 0000664 0001750 0001750 00000043100 15034253755 015106 0 ustar dorothyr dorothyr GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, see .
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
, 1 April 1989
Moe Ghoul, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
tkrev_9.6.1/FAQ.txt 0000664 0001750 0001750 00000022016 15034253755 014436 0 ustar dorothyr dorothyr Q1. I get an error that says "error in startup script-invalid command name
"picklist_load" while executing "picklist_load"
(file"usr/local/bin/tkrev"line 1)
Q2. The "Hide" and "Show" fields don't seem to do anything.
Q3. How do I log in to a remote server?
Q4. Can I use a diff tool other than tkdiff with tkrev?
Q5. How do I import a new module?
Q6. I can't get the Module Browser to work with my CVSROOT/modules file!
Q7. I haven't put the tkrev extensions in my CVSROOT/modules file yet. Can
I still use tkrev to check out a project?
Q8. What good are modules anyway?
Q9. I'm seeing strange behavior - things just don't act right.
Q10. Why is the Branch Browser so slow in Subversion?
Q11. How to run tkrev on Mac OSX?
Q12. Which Xdefaults affect tkrev?
-----------------------------------------------------------------
Q1. I get an error that says "error in startup script-invalid command name
"picklist_load" while executing "picklist_load"
(file"usr/local/bin/tkrev"line 1)
A. Did you run doinstall.tcl?
If yes, make sure you don't have a TCLROOT environment variable
that's pointing to somewhere other than where it put tkrev' .tcl
files.
If that's not the trouble, do "command -v tkrev" to find which tkrev
you're executing. Look at that file and see what TclRoot is set to.
Are the .tcl files in $TclRoot/tkrev? Is there a tclIndex there?
-----------------------------------------------------------------
Q2. The "Hide" and "Show" fields don't seem to do anything.
A. "Hide" works exactly the way a .cvsignore file works. That is, it
causes non-CVS files with the pattern to be ignored. It's meant
for hiding .o files and such. Any file under CVS control will be
listed anyway.
"Show" is the inverse - it hides non-CVS files except for those with
the pattern.
-----------------------------------------------------------------
Q3. How do I log in to a remote server?
A. There's no way to transmit a password through tkrev, but luckily you
don't have to. If it's a pserver, do "cvs login" once from the command
line, then start tkrev. CVS client saves your password (encrypted) in
your .cvspass file.
For remote access via ssh, you normally upload your public key to the
remote machine so it won't ask for a password. (If you have a shell
account, it goes in ~/.ssh/authorized_keys.) Then you set your
environment like this:
% setenv CVSROOT username@cvs.tkrev.sourceforge.net:/cvsroot/project
% setenv CVS_RSH ssh
If you can't use authorized keys for some reason, you can use ssh-agent:
% ssh-agent $SHELL
% setenv CVSROOT username@cvs.tkrev.sourceforge.net:/cvsroot/project
% setenv CVS_RSH ssh
% ssh-add (type passphrase)
% tkrev
-----------------------------------------------------------------
Q4. Can I use a diff tool other than tkdiff with tkrev?
A. Yes, by changing cvscfg(tkdiff). You usually have to write a wrapper for
your diff tool to get it to check out the versions, and and deal with its
particular command-line options, which are probably different from tkdiff's.
In the contrib directory, there is a gvim-wrapper called "cvsdiff" which can
be used as-is or as a model for wrapping your favorite diff tool.
-----------------------------------------------------------------
Q5. How do I import a new module?
Get your new directory the way you want it.
Cd into the directory.
Press the big "Module Browser" button in the top part of the tkrev UI.
In the Module Browser, press the rightmost button on the bottom, the
one that shows a folder and an up arrow.
In the dialog that pops up, fill in a descriptive title for the module.
This will be what you see in the right side of the Module Browser.
OK the dialog. Several things happen now. The directory is
imported, the CVSROOT/module file is updated, your original directory is
saved as directory.orig, and the newly created module is checked out.
When the dust clears, you should find the original Working Directory
Browser showing the files in the newly created, checked out module.
The most common cause of failure here is not having the proper
permissions to write to the repository.
-----------------------------------------------------------------
Q6. I can't get the Module Browser to work with my CVSROOT/modules file!
A. Make sure the fields in your file are separated by TABS! Does your editor
automatically de-tab when you save a file? (Hint: if your editor has syntax
highlighting, use the Makefile mode.)
Not quite every possible module arrangement that can be specified in the
modules file can be reflected in the Module Browser. That's a little
better in version 7.x than it was previously, but the tradeoff was that
there's less freedom to create fictional directory trees.
-----------------------------------------------------------------
Q7. I haven't put the tkrev extensions in my CVSROOT/modules file yet. Can
I still use tkrev to check out a project?
A. Yes. Start tkrev. Open the Module Browser. It will be empty because
there's no modules file, but type the name of the project in the "Module"
entry. Press the Checkout button (the ball with the arrow).
-----------------------------------------------------------------
Q8. What good are modules anyway?
A. It's hard to see the utility of modules unless you have projects that
have nested directories. Defining a directory as a module makes it
behave as though it were at the top level of your repository. For example,
the repository may contain documentation in a structure like this:
manuals
|
| - programA - reference manual
| |
| |------appnotes
|
| - programB - reference manual
|
|------appnotes
If I didn't use modules and I wanted to check out only the programA
documents, I'd have to say "cvs co manuals/programA". But since I have a
line in the CVSROOT/modules file that says
programA manuals/programA
I can say "cvs co programA". That may not help much in this simple example,
but as the project tree gets deeper, it becomes handy. You can also make a
module out of different directories that are not so obviously grouped, or
make a module that includes some files in a directory and not others.
-----------------------------------------------------------------
Q9. I'm seeing strange behavior - things just don't act right.
A. Do you have a .cvsrc file or other .cvs* files lurking about? If you
change cvs's behaviour in certain ways, it can trick tkrev. Be especially
careful of modifying "cvs log".
-----------------------------------------------------------------
Q10. Why is the Branch Browser so slow in Subversion?
A. Actually it's a lot faster as of tkrev version 9.0.
It's because SVN doesn't have tags or branches, it only has copies. The
brute-force method I came up with to reconstruct a diagram requires a lot of
repository accesses for branches and tags. Open the trace window and take a
look at what tkrev is doing to build that diagram. It will give you something
to watch while it's chugging, at least.
If you convert a CVS repository to SVN, my recommendation would be to
discard non-branch tags. If there are very many, most likely all but the
most recent ones have value only as archaeological curiosities anyway.
There's a cvscfg setting that determines how many tags are too many to
process. I figured that would be different depending on how remote the
repository is. There's also an option on the branch browser not to process
non-branch tags at all. If you can't get rid of them, that's probably what
you'll need to do.
-----------------------------------------------------------------
Q11. How to run tkrev on Mac OSX?
A.
My favorite way of running tkrev on the Mac is simply to install the
platform-independent tkrev in /usr/local/bin or someplace like that, and invoke it
from the command line. With the full Mac version of Wish installed, there
will be a /usr/bin/wish that invokes the Wish.app. (Install Wish and do
"command -v wish" to see how that works.)
If you want to have a double-clickable app bundle, you can use something like
Platypus (https://sveinbjorn.org/platypus) to create a wrapper.
Or, you can run it in X11 on the Mac if you've installed XQuartz.
-----------------------------------------------------------------
Q12. Which Xdefaults affect tkrev?
A.
To set your own colors, you can use these entries in your Xdefaults
tkrev*background: gray80
tkrev*foreground: black
tkrev*Menu.background: gray65
tkrev*Menu.foreground: white
tkrev*Button.background: gray75
tkrev*Button.foreground: black
tkrev*Canvas.background: gray90
tkrev*Canvas.foreground: black
tkrev*Text.background: gray90
tkrev*Text.foreground: black
tkrev*Text.selectBackground: slateblue
tkrev*Text.selectForeground: white
tkrev*Menu.font: {Serif 12}
tkrev*Button.font: {Serif 11}
tkrev*Label.font: {Cantarell 10}
tkrev*List.font: {Cantarell 10}
tkrev*Text.font: {DejaVu Sans Mono 10}
tkrev_9.6.1/tkrev/ 0000775 0001750 0001750 00000000000 15034253755 014420 5 ustar dorothyr dorothyr tkrev_9.6.1/tkrev/errors.tcl 0000664 0001750 0001750 00000003160 13765056474 016450 0 ustar dorothyr dorothyr #
# Tcl Library
#
#
# Procedures for unimplemented procedures and error messages used by
# TkRev.
#
proc cvsok {mess {parent {.}} } {
# Sometimes cancel is meaningless, we just want an acknowlegement
if {! [winfo exists $parent]} {set parent .}
set title {Acknowledge!}
tk_messageBox \
-icon info \
-title $title \
-message $mess \
-parent $parent \
-type ok
}
proc cvsconfirm {mess {parent {.}} } {
global cvscfg
if {$cvscfg(confirm_prompt) != "true"} { return "ok" }
if {! [winfo exists $parent]} {set parent .}
set title {Confirm!}
set answer [tk_messageBox \
-icon question \
-title $title \
-message $mess \
-parent $parent \
-type okcancel]
gen_log:log D "$answer"
return $answer
}
# This one doesn't check cvscfg(confirm_prompt) preference
proc cvsalwaysconfirm {mess {parent {.}} } {
if {! [winfo exists $parent]} {set parent .}
set title {Confirm!}
set answer [tk_messageBox \
-icon question \
-title $title \
-message $mess \
-parent $parent \
-type okcancel]
gen_log:log D "$answer"
return $answer
}
proc cvsfail {mess {parent {.}} } {
if {! [winfo exists $parent]} {set parent .}
set title {TkRev Warning!}
tk_messageBox \
-icon warning \
-title $title \
-message $mess \
-parent $parent \
-type ok
}
proc cvserror {mess {parent {.}} } {
if {! [winfo exists $parent]} {set parent .}
set title {TkRev Error!}
tk_messageBox \
-icon error \
-title $title \
-message $mess \
-parent $parent \
-type ok
exit_cleanup 0
}
tkrev_9.6.1/tkrev/modules.tcl 0000664 0001750 0001750 00000007367 14715566005 016611 0 ustar dorothyr dorothyr #
# Tcl Library for TkRev
#
#
# Procedures to parse the CVS modules file and store whatever is
# read into various associative arrays, sorted, and unsorted lists.
#
#
# Global variables:
#
# modval
# The string that specifies or defines the module.
# modtitle
# The descriptive title of the module. If not specified, modval is used.
# cvscfg
# General configuration variables (array)
# filenames
# For each module, the list of files that it contains.
proc gather_mod_index {} {
#
# Creates a new global list called modlist for the report printouts
#
global cvscfg
global modtitle
global dcontents
global dparent
global modlist
global modlist_sorted
#gen_log:log T "ENTER ()"
set modlist {}
set dlist {}
if {! [info exists modtitle]} {
gen_log:log T "LEAVE (no modtitle array)"
return
}
foreach d [array names dcontents] {
#gen_log:log D "dcontents($d) is $dcontents($d)"
foreach i $dcontents($d) {
lappend dlist $i
set path [file join $d $i]
set dparent($path) $d
#gen_log:log D "dparent($path) is $d"
}
}
foreach mcode [array names modtitle] {
# Skip aliases
if {[string match "-a *" $modtitle($mcode)]} {
continue
}
# Dont add subdirs to the list
set match 0
foreach i $dlist {
if {$i == $mcode} {
set match 1
}
}
if {! $match} {
lappend modlist "$mcode\t$modtitle($mcode)"
}
}
set modlist_sorted [lsort $modlist]
if {$cvscfg(logging) && [regexp -nocase {d} $cvscfg(log_classes)]} {
foreach idx $modlist_sorted {
#gen_log:log D "$idx"
set dname [lindex $idx 0]
if {[info exists dparent($dname)]} {
#gen_log:log D " PARENT: $dparent($dname)"
}
if {[info exists dcontents($dname)]} {
#gen_log:log D " CHILDREN: $dcontents($dname)"
}
set desc [find_subdirs $dname 0]
if {$desc != ""} {
#gen_log:log D " SUBDIRS: $desc"
}
}
}
#gen_log:log T "LEAVE"
}
proc find_filenames {mcode} {
#
# This does the work of setting up the filenames array for a module,
# containing the list of file names within it.
#
global filenames
global cwd
global cvs
global cvscfg
global checkout_version
global feedback
gen_log:log T "ENTER ($mcode)"
if {[info exists filenames($mcode)]} {
set filenames($mcode) ""
}
# Trick of using rdiff to list files without checking them out
# derived from "cvsls" by Eugene Kramer
# cvs 1.9:
# Need to use -f with pserver, or it skips files that havent
# changed. With local repository, it reports them as new.
# But without pserver, it skips them with -f but not without!
# cvs 1.10.8:
# Both pserver and local act like 1.9 local, that is, -f makes
# it skip new files.
set commandline \
"$cvs -d $cvscfg(cvsroot) rdiff -s -D 01/01/1971 $mcode"
gen_log:log C $commandline
catch {exec {*}$commandline} view_this
set view_lines [split $view_this "\n"]
foreach line $view_lines {
gen_log:log D "$line"
if {[string match "File *" $line]} {
set lst [split $line]
set cut [expr {[llength $lst] - 6}]
set dname [join [lrange $lst 1 $cut]]
#gen_log:log D "$dname"
lappend filenames($mcode) $dname
}
}
gen_log:log T "LEAVE"
}
proc find_subdirs {mname level} {
global dcontents
global subdirs
#gen_log:log T "ENTER ($mname $level)"
if {$level == 0} {
set subdirs {}
}
if {[info exists dcontents($mname)]} {
#gen_log:log D "$mname contents: {$dcontents($mname)}"
foreach d $dcontents($mname) {
set path [file join $mname $d]
if {[info exists dcontents($path)]} {
lappend subdirs $path
}
find_subdirs $path 1
}
}
#gen_log:log T "LEAVE ($subdirs)"
return $subdirs
}
tkrev_9.6.1/tkrev/cvs_import.tcl 0000664 0001750 0001750 00000016700 15015446517 017314 0 ustar dorothyr dorothyr #
# Tcl Library for TkRev
#
# Import new files and directories into a CVS repository
proc cvs_import_setup {} {
global cwd
global incvs
global insvn
global ingit
global inrcs
global cvsglb
gen_log:log T "ENTER"
# Make sure we're not in a directory that's already under revision control
lassign [vcs_detect [pwd]] incvs insvn inrcs ingit
if {$incvs} {
cvsok "This directory is already in CVS.\nCan\'t import here!" .import
gen_log:log T "LEAVE"
return
}
if {$insvn} {
cvsok "There are Subversion directories here.\nPlease remove them first." .import
gen_log:log T "LEAVE"
return
}
if {$ingit} {
cvsok "There are Git directories here.\nPlease remove them first." .import
gen_log:log T "LEAVE"
return
}
if {$inrcs} {
cvsok "There are RCS directories here.\nPlease remove them first." .import
gen_log:log T "LEAVE"
return
}
if {[winfo exists .import]} {
wm deiconify .import
raise .import
grab set .import
gen_log:log T "LEAVE"
return
}
# Set some defaults
set cvsglb(newcode) [file tail $cwd]
set cvsglb(newdir) $cvsglb(newcode)
set cvsglb(newdesc) "Imported"
# Give it a default. This is what you get without the -b option.
set cvsglb(newvers) 1.1.1
toplevel .import
grab set .import
frame .import.top
message .import.top.explain -justify left -width 500 -relief groove \
-text "This will import the current directory and its sub-directories\
into CVS, creating a new module. If you haven't created a CVS repository,\
you must do that first with \"cvs init.\""
label .import.top.lnewcode -text "New Module Name" -anchor w
label .import.top.lnewdir -text "Path relative to \$CVSROOT" -anchor w
label .import.top.lnewdesc -text "Descriptive Title" -anchor w
label .import.top.lnewvers -text "Initial Version Number" -anchor w
entry .import.top.tnewcode -textvariable cvsglb(newcode) -width 40
entry .import.top.tnewdir -textvariable cvsglb(newdir) -width 40
entry .import.top.tnewdesc -textvariable cvsglb(newdesc) -width 40
entry .import.top.tnewvers -textvariable cvsglb(newvers) -width 40
grid .import.top.explain -column 0 -row 0 -columnspan 3 -sticky ew
grid .import.top.lnewcode -column 0 -row 1 -sticky w
grid .import.top.tnewcode -column 1 -row 1 -sticky ew
grid .import.top.lnewdir -column 0 -row 2 -sticky w
grid .import.top.tnewdir -column 1 -row 2 -sticky ew
grid .import.top.lnewdesc -column 0 -row 3 -sticky w
grid .import.top.tnewdesc -column 1 -row 3 -sticky ew
grid .import.top.lnewvers -column 0 -row 4 -sticky w
grid .import.top.tnewvers -column 1 -row 4 -sticky ew
frame .import.down -relief groove -borderwidth 2
button .import.down.ok -text "OK" \
-command {
if {! [cvs_import_errorcheck]} {
grab release .import
wm withdraw .import
cvs_import_do
}
}
button .import.down.quit -text "Cancel" \
-command {
grab release .import
wm withdraw .import
}
pack .import.down -side bottom -expand yes -fill x
pack .import.top -side top -expand yes -fill x
pack .import.down.ok -side left -expand yes
pack .import.down.quit -side left -expand yes
wm title .import "Create a New Module"
wm minsize .import 1 1
gen_log:log T "LEAVE"
}
proc cvs_import_errorcheck {} {
global cvscfg
global cvsglb
global modlist_sorted
global modval
global cvs
set error_exists 0
# Make sure the repository exists
set command "$cvs -d $cvscfg(cvsroot) rlog"
set ret [catch {exec {*}$command} output]
if {$ret} {
cvsok "Repository $cvscfg(cvsroot) isn't reachable or doesn't exist" .import
set error_exists 1
}
# Other error checks
if { $cvsglb(newcode) == "" } {
cvsok "You must type in a new module name." .import
set error_exists 1
}
if { $cvsglb(newdir) == "" } {
cvsok "You must type in a new module path directory." .import
set error_exists 1
}
# In case the module browser isn't running
if {! [info exists modlist_sorted]} {
modbrowse_run
}
# Make sure it isn't a duplicate key
foreach {key value} [array get modval] {
if { $cvsglb(newcode) == $key } {
cvsok "$cvsglb(newcode) is not a new Module" .import
set error_exists 1
}
}
if {$error_exists} {
return 1
}
return 0
}
proc cvs_import_do {} {
global cvs
global cvsglb
global cvscfg
global cwd
global modlist_sorted
global modval
global modtitle
global ExModList ExModDirList
gen_log:log T "ENTER"
set imdir [pwd]
# See if all apropriate Directories in newdirname exist. CVS import will
# create them, but we'll want to make a #D entry.
set cvsglb(newdir) [string trimleft $cvsglb(newdir) "/"]
set pathname [file dirname $cvsglb(newdir)]
set need_Dir 0
if {$pathname != "."} {
foreach idx $modlist_sorted {
lappend knowndirs [lindex $idx 0]
}
gen_log:log D "looking for $pathname in known directories ($knowndirs)"
if {$pathname ni $knowndirs} {
set need_Dir 1
}
}
# Make a baseline tag
set versions [split $cvsglb(newvers) ".,/ -"]
set baseline "baseline-[join $versions {_}]"
set commandline "$cvs -d \"$cvscfg(cvsroot)\" import -m \"Imported using TkRev\""
# Let it default to 1.1.1 or you will have big problems later from cvs.
#if {$cvsglb(newvers) != ""} {
#append commandline " -b 1.1.1"
#}
append commandline " \"$cvsglb(newdir)\" IMPORT $baseline"
set v [viewer::new "Import Module"]
$v\::log "\nCVS Import\n"
$v\::do "$commandline"
$v\::wait
update
# Update the modules file.
set commandline "$cvs -d $cvscfg(cvsroot) -w checkout CVSROOT/modules"
$v\::log "\nCheckout New Module\n"
$v\::do "$commandline"
$v\::wait
cd CVSROOT
gen_log:log F "CD [pwd]"
set modfile [open modules a]
if {$need_Dir} {
puts $modfile ""
gen_log:log D "#D $pathname"
puts $modfile "#D $pathname"
}
gen_log:log D "#M\t$cvsglb(newcode)\t$cvsglb(newdesc)"
puts $modfile "#M\t$cvsglb(newcode)\t$cvsglb(newdesc)"
gen_log:log D "$cvsglb(newcode)\t$cvsglb(newdir)"
puts $modfile "$cvsglb(newcode)\t$cvsglb(newdir)"
close $modfile
set commandline "$cvs -d $cvscfg(cvsroot) ci -m \"added $cvsglb(newcode)\" modules"
$v\::log "\nCVS Checkin CVSROOT\n"
$v\::do "$commandline"
$v\::wait
cd ../
gen_log:log F "CD [pwd]"
set commandline "$cvs -d $cvscfg(cvsroot) -Q release -d CVSROOT"
$v\::do "$commandline"
$v\::wait
modbrowse_run
# Now check out the new module
cd ..
gen_log:log F "CD [pwd]"
# We have to move the original stuff entirely out of the way.
# Otherwise checkout won't do the whole tree.
gen_log:log F "MOVE $imdir $imdir.orig"
if {[file isdirectory $imdir.orig]} {
file delete -force -- $imdir.orig
}
file rename $imdir $imdir.orig
set commandline \
"$cvs -d $cvscfg(cvsroot) checkout -R \"$cvsglb(newcode)\""
#gen_log:log C "$commandline"
$v\::log "\nCVS Checkout\n"
$v\::do "$commandline"
$v\::wait
# cd to the checked out module. $cwd is the correct directory to cd to
# only if the name of the new module is the same as the directory name
# where the source code is in. Define ckmoddir to be used instead.
set ckmoddir $cwd
if { $cvsglb(newcode) != [file tail $cwd] } {
set ckmoddir [file join [file dirname $cwd] $cvsglb(newcode)]
}
if { [catch "cd $ckmoddir" err]} {
cvsok "$err" .import
} else {
gen_log:log F "CD [pwd]"
}
if {$cvscfg(auto_status)} {
setup_dir
}
gen_log:log T "LEAVE"
}
tkrev_9.6.1/tkrev/tclIndex 0000664 0001750 0001750 00000061266 15024334743 016124 0 ustar dorothyr dorothyr # Tcl autoload index file, version 2.0
# This file is generated by the "auto_mkindex" command
# and sourced to set up indexing information for one or
# more commands. Typically each line is a command that
# sets an element in the auto_index array, where the
# element name is the name of a command and the value is
# a script that loads the command.
set auto_index(::annotate::new) [list source [file join $dir annotate.tcl]]
set auto_index(::branch_diagram::new) [list source [file join $dir branch_diagram.tcl]]
set auto_index(cvs_notincvs) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_sandbox_runcmd) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_sandbox_filetags) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_workdir_status) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_remove_file) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_remove_dir) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_edit) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_unedit) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_history) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_add) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_add_dir) [list source [file join $dir cvs.tcl]]
set auto_index(add_subdirs) [list source [file join $dir cvs.tcl]]
set auto_index(rem_subdirs) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_fileview_update) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_fileview_checkout) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_log) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_log_rev) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_annotate) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_annotate_r) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_commit) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_tag) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_update) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_opt_update) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_merge) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_merge_tag_seq) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_status) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_check) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_checkout) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_filelog) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_export) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_patch) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_diff) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_version) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_reconcile_conflict) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_gettaglist) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_release) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_rtag) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_commit_dialog) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_ascii) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_binary) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_revert) [list source [file join $dir cvs.tcl]]
set auto_index(read_cvs_dir) [list source [file join $dir cvs.tcl]]
set auto_index(parse_cvsmodules) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_modbrowse_tree) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_lock) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_directory_merge) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_branches) [list source [file join $dir cvs.tcl]]
set auto_index(::cvs_branchlog::new) [list source [file join $dir cvs.tcl]]
set auto_index(cvs_import_setup) [list source [file join $dir cvs_import.tcl]]
set auto_index(cvs_import_errorcheck) [list source [file join $dir cvs_import.tcl]]
set auto_index(cvs_import_do) [list source [file join $dir cvs_import.tcl]]
set auto_index(cvs_subimport_setup) [list source [file join $dir cvs_subimport.tcl]]
set auto_index(cvs_subimport_do) [list source [file join $dir cvs_subimport.tcl]]
set auto_index(getExistModDialog) [list source [file join $dir cvs_subimport.tcl]]
set auto_index(moduleDialog) [list source [file join $dir cvs_subimport.tcl]]
set auto_index(dialog_FormCreate) [list source [file join $dir dialog.tcl]]
set auto_index(dialog_FormComplete) [list source [file join $dir dialog.tcl]]
set auto_index(dialog_cvs_checkout) [list source [file join $dir dialog.tcl]]
set auto_index(dialog_cvs_export) [list source [file join $dir dialog.tcl]]
set auto_index(dialog_svn_checkout) [list source [file join $dir dialog.tcl]]
set auto_index(dialog_git_clone) [list source [file join $dir dialog.tcl]]
set auto_index(dialog_svn_tag) [list source [file join $dir dialog.tcl]]
set auto_index(dialog_cvs_patch) [list source [file join $dir dialog.tcl]]
set auto_index(dialog_svn_patch) [list source [file join $dir dialog.tcl]]
set auto_index(rtag_dialog) [list source [file join $dir dialog.tcl]]
set auto_index(add_dialog) [list source [file join $dir dialog.tcl]]
set auto_index(tag_dialog) [list source [file join $dir dialog.tcl]]
set auto_index(branch_dialog) [list source [file join $dir dialog.tcl]]
set auto_index(subtract_dialog) [list source [file join $dir dialog.tcl]]
set auto_index(edit_dialog) [list source [file join $dir dialog.tcl]]
set auto_index(unedit_dialog) [list source [file join $dir dialog.tcl]]
set auto_index(cvs_update_options) [list source [file join $dir dialog.tcl]]
set auto_index(update_set_defaults) [list source [file join $dir dialog.tcl]]
set auto_index(addir_dialog) [list source [file join $dir dialog.tcl]]
set auto_index(subtractdir_dialog) [list source [file join $dir dialog.tcl]]
set auto_index(file_input_and_do) [list source [file join $dir dialog.tcl]]
set auto_index(release_dialog) [list source [file join $dir dialog.tcl]]
set auto_index(svn_update_options) [list source [file join $dir dialog.tcl]]
set auto_index(assemble_mergetags) [list source [file join $dir dialog.tcl]]
set auto_index(dialog_merge_notice) [list source [file join $dir dialog.tcl]]
set auto_index(commit_history) [list source [file join $dir dialog.tcl]]
set auto_index(history_browser) [list source [file join $dir dialog.tcl]]
set auto_index(git_update_options) [list source [file join $dir dialog.tcl]]
set auto_index(toggle_state) [list source [file join $dir dialog.tcl]]
set auto_index(comparediff) [list source [file join $dir diff.tcl]]
set auto_index(comparediff_files) [list source [file join $dir diff.tcl]]
set auto_index(comparediff_r) [list source [file join $dir diff.tcl]]
set auto_index(comparediff_sandbox) [list source [file join $dir diff.tcl]]
set auto_index(DirCanvas:create) [list source [file join $dir dircanvas.tcl]]
set auto_index(DirCanvas:newitem) [list source [file join $dir dircanvas.tcl]]
set auto_index(DirCanvas:deltree) [list source [file join $dir dircanvas.tcl]]
set auto_index(DirCanvas:unselectall) [list source [file join $dir dircanvas.tcl]]
set auto_index(DirCanvas:displaycolumns) [list source [file join $dir dircanvas.tcl]]
set auto_index(DirCanvas:sort_by_col) [list source [file join $dir dircanvas.tcl]]
set auto_index(DirCanvas:adjust_columnwidths) [list source [file join $dir dircanvas.tcl]]
set auto_index(DirCanvas:popup) [list source [file join $dir dircanvas.tcl]]
set auto_index(DirCanvas:bindings) [list source [file join $dir dircanvas.tcl]]
set auto_index(DirCanvas:makepopup) [list source [file join $dir dircanvas.tcl]]
set auto_index(DirCanvas:choose_icon) [list source [file join $dir dircanvas.tcl]]
set auto_index(cvsok) [list source [file join $dir errors.tcl]]
set auto_index(cvsconfirm) [list source [file join $dir errors.tcl]]
set auto_index(cvsalwaysconfirm) [list source [file join $dir errors.tcl]]
set auto_index(cvsfail) [list source [file join $dir errors.tcl]]
set auto_index(cvserror) [list source [file join $dir errors.tcl]]
set auto_index(cvs_usercmd) [list source [file join $dir exec.tcl]]
set auto_index(cvs_execcmd) [list source [file join $dir exec.tcl]]
set auto_index(cvs_catchcmd) [list source [file join $dir exec.tcl]]
set auto_index(::exec::new) [list source [file join $dir exec.tcl]]
set auto_index(::viewer::new) [list source [file join $dir exec.tcl]]
set auto_index(status_colortags) [list source [file join $dir exec.tcl]]
set auto_index(patch_colortags) [list source [file join $dir exec.tcl]]
set auto_index(rcslog_colortags) [list source [file join $dir exec.tcl]]
set auto_index(truncate_git_graph) [list source [file join $dir exec.tcl]]
set auto_index(::view_output::new) [list source [file join $dir exec.tcl]]
set auto_index(viewer_window) [list source [file join $dir exec.tcl]]
set auto_index(browse_files) [list source [file join $dir filebrowse.tcl]]
set auto_index(filepath) [list source [file join $dir filebrowse.tcl]]
set auto_index(module_filelog) [list source [file join $dir filebrowse.tcl]]
set auto_index(module_fileview) [list source [file join $dir filebrowse.tcl]]
set auto_index(module_tagview) [list source [file join $dir filebrowse.tcl]]
set auto_index(gen_log:init) [list source [file join $dir gen_log.tcl]]
set auto_index(gen_log:log) [list source [file join $dir gen_log.tcl]]
set auto_index(gen_log:quit) [list source [file join $dir gen_log.tcl]]
set auto_index(gen_log:clear) [list source [file join $dir gen_log.tcl]]
set auto_index(gen_log:save) [list source [file join $dir gen_log.tcl]]
set auto_index(gen_log:changeclass) [list source [file join $dir gen_log.tcl]]
set auto_index(gen_log:color) [list source [file join $dir gen_log.tcl]]
set auto_index(read_git_dir) [list source [file join $dir git.tcl]]
set auto_index(git_workdir_status) [list source [file join $dir git.tcl]]
set auto_index(find_git_remote) [list source [file join $dir git.tcl]]
set auto_index(parse_gitlist) [list source [file join $dir git.tcl]]
set auto_index(git_push) [list source [file join $dir git.tcl]]
set auto_index(git_fetch) [list source [file join $dir git.tcl]]
set auto_index(git_list_tags) [list source [file join $dir git.tcl]]
set auto_index(git_log) [list source [file join $dir git.tcl]]
set auto_index(git_rm) [list source [file join $dir git.tcl]]
set auto_index(git_remove_dir) [list source [file join $dir git.tcl]]
set auto_index(git_add) [list source [file join $dir git.tcl]]
set auto_index(git_rename_ask) [list source [file join $dir git.tcl]]
set auto_index(git_rename) [list source [file join $dir git.tcl]]
set auto_index(git_reset) [list source [file join $dir git.tcl]]
set auto_index(git_status) [list source [file join $dir git.tcl]]
set auto_index(git_log_rev) [list source [file join $dir git.tcl]]
set auto_index(git_show) [list source [file join $dir git.tcl]]
set auto_index(git_patch) [list source [file join $dir git.tcl]]
set auto_index(git_check) [list source [file join $dir git.tcl]]
set auto_index(git_commit_dialog) [list source [file join $dir git.tcl]]
set auto_index(git_commit) [list source [file join $dir git.tcl]]
set auto_index(git_tag) [list source [file join $dir git.tcl]]
set auto_index(git_branch) [list source [file join $dir git.tcl]]
set auto_index(git_opt_update) [list source [file join $dir git.tcl]]
set auto_index(git_checkout) [list source [file join $dir git.tcl]]
set auto_index(git_clone) [list source [file join $dir git.tcl]]
set auto_index(git_reconcile_conflict) [list source [file join $dir git.tcl]]
set auto_index(git_annotate) [list source [file join $dir git.tcl]]
set auto_index(git_annotate_r) [list source [file join $dir git.tcl]]
set auto_index(git_annotate_range) [list source [file join $dir git.tcl]]
set auto_index(git_fileview) [list source [file join $dir git.tcl]]
set auto_index(git_branches) [list source [file join $dir git.tcl]]
set auto_index(git_fast_diagram) [list source [file join $dir git.tcl]]
set auto_index(::git_branchlog::new) [list source [file join $dir git.tcl]]
set auto_index(list_within_list) [list source [file join $dir git.tcl]]
set auto_index(list_comm) [list source [file join $dir git.tcl]]
set auto_index(prune_branchlist) [list source [file join $dir git.tcl]]
set auto_index(aboutbox) [list source [file join $dir help.tcl]]
set auto_index(help_cvs_version) [list source [file join $dir help.tcl]]
set auto_index(wish_version) [list source [file join $dir help.tcl]]
set auto_index(post_text) [list source [file join $dir help.tcl]]
set auto_index(put_text) [list source [file join $dir help.tcl]]
set auto_index(clear_text) [list source [file join $dir help.tcl]]
set auto_index(hyperlink) [list source [file join $dir help.tcl]]
set auto_index(do_help) [list source [file join $dir help.tcl]]
set auto_index(define_sections) [list source [file join $dir help.tcl]]
set auto_index(table_of_contents) [list source [file join $dir help.tcl]]
set auto_index(man_description) [list source [file join $dir help.tcl]]
set auto_index(man_cli_options) [list source [file join $dir help.tcl]]
set auto_index(man_current_directory) [list source [file join $dir help.tcl]]
set auto_index(man_branch_diagram_browser) [list source [file join $dir help.tcl]]
set auto_index(man_directory_branch_viewer) [list source [file join $dir help.tcl]]
set auto_index(man_module_browser) [list source [file join $dir help.tcl]]
set auto_index(man_importing_new_modules) [list source [file join $dir help.tcl]]
set auto_index(man_importing_to_existing_module) [list source [file join $dir help.tcl]]
set auto_index(man_vendor_merge) [list source [file join $dir help.tcl]]
set auto_index(man_configuration_files) [list source [file join $dir help.tcl]]
set auto_index(man_environment_variables) [list source [file join $dir help.tcl]]
set auto_index(man_user_defined_menu) [list source [file join $dir help.tcl]]
set auto_index(man_cvs_modules_file) [list source [file join $dir help.tcl]]
set auto_index(::joincanvas::new) [list source [file join $dir joincanvas.tcl]]
set auto_index(cvs_joincanvas) [list source [file join $dir joincanvas.tcl]]
set auto_index(join_getlog) [list source [file join $dir joincanvas.tcl]]
set auto_index(load_all_images) [list source [file join $dir load_images.tcl]]
set auto_index(menubar_menus) [list source [file join $dir menubar.tcl]]
set auto_index(workdir_menus) [list source [file join $dir menubar.tcl]]
set auto_index(git_branch_menu) [list source [file join $dir menubar.tcl]]
set auto_index(help_menu) [list source [file join $dir menubar.tcl]]
set auto_index(modbrowse_menus) [list source [file join $dir menubar.tcl]]
set auto_index(about_menus) [list source [file join $dir menubar.tcl]]
set auto_index(git_tools_menu) [list source [file join $dir menubar.tcl]]
set auto_index(modbrowse_setup) [list source [file join $dir modbrowse.tcl]]
set auto_index(modbrowse_guess_vcs) [list source [file join $dir modbrowse.tcl]]
set auto_index(modbrowse_run) [list source [file join $dir modbrowse.tcl]]
set auto_index(module_exit) [list source [file join $dir modbrowse.tcl]]
set auto_index(ModTree:create) [list source [file join $dir modbrowse.tcl]]
set auto_index(ModTree:destroy) [list source [file join $dir modbrowse.tcl]]
set auto_index(gather_mod_index) [list source [file join $dir modules.tcl]]
set auto_index(find_filenames) [list source [file join $dir modules.tcl]]
set auto_index(find_subdirs) [list source [file join $dir modules.tcl]]
set auto_index(prefdialog) [list source [file join $dir preferences.tcl]]
set auto_index(prefs_general) [list source [file join $dir preferences.tcl]]
set auto_index(prefs_diagram) [list source [file join $dir preferences.tcl]]
set auto_index(prefs_cvs) [list source [file join $dir preferences.tcl]]
set auto_index(prefs_subversion) [list source [file join $dir preferences.tcl]]
set auto_index(prefs_git) [list source [file join $dir preferences.tcl]]
set auto_index(prefs_close) [list source [file join $dir preferences.tcl]]
set auto_index(rcs_notinrcs) [list source [file join $dir rcs.tcl]]
set auto_index(rcs_branches) [list source [file join $dir rcs.tcl]]
set auto_index(rcs_checkout) [list source [file join $dir rcs.tcl]]
set auto_index(rcs_lock) [list source [file join $dir rcs.tcl]]
set auto_index(rcs_checkin) [list source [file join $dir rcs.tcl]]
set auto_index(rcs_commit_dialog) [list source [file join $dir rcs.tcl]]
set auto_index(rcs_tag) [list source [file join $dir rcs.tcl]]
set auto_index(rcs_workdir_status) [list source [file join $dir rcs.tcl]]
set auto_index(rcs_check) [list source [file join $dir rcs.tcl]]
set auto_index(rcs_log) [list source [file join $dir rcs.tcl]]
set auto_index(rcs_log_rev) [list source [file join $dir rcs.tcl]]
set auto_index(rcs_fileview_checkout) [list source [file join $dir rcs.tcl]]
set auto_index(rcs_revert) [list source [file join $dir rcs.tcl]]
set auto_index(find_rcsfiles) [list source [file join $dir rcs.tcl]]
set auto_index(colors:open_cde_resourcefile) [list source [file join $dir style_params.tcl]]
set auto_index(colors:read_cde_palette) [list source [file join $dir style_params.tcl]]
set auto_index(colors:get_cde_params) [list source [file join $dir style_params.tcl]]
set auto_index(colors:get_gtk_theme) [list source [file join $dir style_params.tcl]]
set auto_index(colors:get_x11_resources) [list source [file join $dir style_params.tcl]]
set auto_index(colors:add_options) [list source [file join $dir style_params.tcl]]
set auto_index(colors:shades) [list source [file join $dir style_params.tcl]]
set auto_index(colors:sanitize_fontspec) [list source [file join $dir style_params.tcl]]
set auto_index(colors:rgb2hex) [list source [file join $dir style_params.tcl]]
set auto_index(colors:contrast) [list source [file join $dir style_params.tcl]]
set auto_index(colors:match_desktop) [list source [file join $dir style_params.tcl]]
set auto_index(read_svn_dir) [list source [file join $dir svn.tcl]]
set auto_index(svn_lock) [list source [file join $dir svn.tcl]]
set auto_index(svn_workdir_status) [list source [file join $dir svn.tcl]]
set auto_index(svn_add) [list source [file join $dir svn.tcl]]
set auto_index(svn_remove_file) [list source [file join $dir svn.tcl]]
set auto_index(svn_status) [list source [file join $dir svn.tcl]]
set auto_index(svn_check) [list source [file join $dir svn.tcl]]
set auto_index(svn_update) [list source [file join $dir svn.tcl]]
set auto_index(svn_opt_update) [list source [file join $dir svn.tcl]]
set auto_index(svn_commit_dialog) [list source [file join $dir svn.tcl]]
set auto_index(svn_commit) [list source [file join $dir svn.tcl]]
set auto_index(svn_rename_ask) [list source [file join $dir svn.tcl]]
set auto_index(svn_rename) [list source [file join $dir svn.tcl]]
set auto_index(svn_annotate) [list source [file join $dir svn.tcl]]
set auto_index(svn_annotate_r) [list source [file join $dir svn.tcl]]
set auto_index(svn_ddiff) [list source [file join $dir svn.tcl]]
set auto_index(svn_patch) [list source [file join $dir svn.tcl]]
set auto_index(svn_delete) [list source [file join $dir svn.tcl]]
set auto_index(svn_jit_listdir) [list source [file join $dir svn.tcl]]
set auto_index(svn_jit_dircmd) [list source [file join $dir svn.tcl]]
set auto_index(parse_svnmodules) [list source [file join $dir svn.tcl]]
set auto_index(svn_closedir) [list source [file join $dir svn.tcl]]
set auto_index(svn_log) [list source [file join $dir svn.tcl]]
set auto_index(svn_log_rev) [list source [file join $dir svn.tcl]]
set auto_index(svn_difflog_rev) [list source [file join $dir svn.tcl]]
set auto_index(svn_show_rev) [list source [file join $dir svn.tcl]]
set auto_index(svn_info) [list source [file join $dir svn.tcl]]
set auto_index(svn_reconcile_conflict) [list source [file join $dir svn.tcl]]
set auto_index(svn_resolve) [list source [file join $dir svn.tcl]]
set auto_index(svn_revert) [list source [file join $dir svn.tcl]]
set auto_index(svn_tag) [list source [file join $dir svn.tcl]]
set auto_index(svn_rcopy) [list source [file join $dir svn.tcl]]
set auto_index(svn_pathforcopy) [list source [file join $dir svn.tcl]]
set auto_index(svn_merge) [list source [file join $dir svn.tcl]]
set auto_index(svn_merge_tag_seq) [list source [file join $dir svn.tcl]]
set auto_index(svn_checkout) [list source [file join $dir svn.tcl]]
set auto_index(svn_filecat) [list source [file join $dir svn.tcl]]
set auto_index(svn_filelog) [list source [file join $dir svn.tcl]]
set auto_index(svn_fileview) [list source [file join $dir svn.tcl]]
set auto_index(svn_directory_merge) [list source [file join $dir svn.tcl]]
set auto_index(svn_branches) [list source [file join $dir svn.tcl]]
set auto_index(safe_url) [list source [file join $dir svn.tcl]]
set auto_index(::svn_branchlog::new) [list source [file join $dir svn.tcl]]
set auto_index(svn_import_run) [list source [file join $dir svn_import.tcl]]
set auto_index(svn_do_import) [list source [file join $dir svn_import.tcl]]
set auto_index(set_tooltips) [list source [file join $dir tooltips.tcl]]
set auto_index(internal_tooltips_PopUp) [list source [file join $dir tooltips.tcl]]
set auto_index(internal_tooltips_PopDown) [list source [file join $dir tooltips.tcl]]
set auto_index(scrollbindings) [list source [file join $dir ui_misc.tcl]]
set auto_index(copy_paste_popup) [list source [file join $dir ui_misc.tcl]]
set auto_index(ro_textbindings) [list source [file join $dir ui_misc.tcl]]
set auto_index(save_viewcontents) [list source [file join $dir ui_misc.tcl]]
set auto_index(get_textlines) [list source [file join $dir ui_misc.tcl]]
set auto_index(search_textwidget_init) [list source [file join $dir ui_misc.tcl]]
set auto_index(search_textwidget) [list source [file join $dir ui_misc.tcl]]
set auto_index(search_listbox_init) [list source [file join $dir ui_misc.tcl]]
set auto_index(search_listbox) [list source [file join $dir ui_misc.tcl]]
set auto_index(dragbind) [list source [file join $dir ui_misc.tcl]]
set auto_index(wheelbind) [list source [file join $dir ui_misc.tcl]]
set auto_index(busy_start) [list source [file join $dir ui_misc.tcl]]
set auto_index(busy_done) [list source [file join $dir ui_misc.tcl]]
set auto_index(dialog_position) [list source [file join $dir ui_misc.tcl]]
set auto_index(picklist_load) [list source [file join $dir ui_misc.tcl]]
set auto_index(picklist_used) [list source [file join $dir ui_misc.tcl]]
set auto_index(picklist_save) [list source [file join $dir ui_misc.tcl]]
set auto_index(validate_dirpath) [list source [file join $dir ui_misc.tcl]]
set auto_index(change_dir) [list source [file join $dir ui_misc.tcl]]
set auto_index(tildecheck) [list source [file join $dir ui_misc.tcl]]
set auto_index(tildChk) [list source [file join $dir ui_misc.tcl]]
set auto_index(merge_run) [list source [file join $dir vendor_merge.tcl]]
set auto_index(get_j) [list source [file join $dir vendor_merge.tcl]]
set auto_index(put_rev_tags) [list source [file join $dir vendor_merge.tcl]]
set auto_index(do_merge) [list source [file join $dir vendor_merge.tcl]]
set auto_index(unpack_tag_word) [list source [file join $dir vendor_merge.tcl]]
set auto_index(get_rv_tags) [list source [file join $dir vendor_merge.tcl]]
set auto_index(merge_taglist) [list source [file join $dir vendor_merge.tcl]]
set auto_index(vendorDialog) [list source [file join $dir vendor_merge.tcl]]
set auto_index(workdir_setup) [list source [file join $dir workdir.tcl]]
set auto_index(workdir_list_files) [list source [file join $dir workdir.tcl]]
set auto_index(workdir_edit_command) [list source [file join $dir workdir.tcl]]
set auto_index(workdir_newdir) [list source [file join $dir workdir.tcl]]
set auto_index(workdir_edit_file) [list source [file join $dir workdir.tcl]]
set auto_index(workdir_view_file) [list source [file join $dir workdir.tcl]]
set auto_index(add_bookmark) [list source [file join $dir workdir.tcl]]
set auto_index(delete_bookmark_dialog) [list source [file join $dir workdir.tcl]]
set auto_index(delete_bookmark) [list source [file join $dir workdir.tcl]]
set auto_index(auto_setup_dir) [list source [file join $dir workdir.tcl]]
set auto_index(setup_dir) [list source [file join $dir workdir.tcl]]
set auto_index(directory_list) [list source [file join $dir workdir.tcl]]
set auto_index(workdir_cleanup) [list source [file join $dir workdir.tcl]]
set auto_index(workdir_delete_file) [list source [file join $dir workdir.tcl]]
set auto_index(are_you_sure) [list source [file join $dir workdir.tcl]]
set auto_index(workdir_print_file) [list source [file join $dir workdir.tcl]]
set auto_index(incvs_detect) [list source [file join $dir workdir.tcl]]
set auto_index(insvn_detect) [list source [file join $dir workdir.tcl]]
set auto_index(ingit_detect) [list source [file join $dir workdir.tcl]]
set auto_index(inrcs_detect) [list source [file join $dir workdir.tcl]]
set auto_index(vcs_detect) [list source [file join $dir workdir.tcl]]
set auto_index(isCmDirectory) [list source [file join $dir workdir.tcl]]
set auto_index(getFiles) [list source [file join $dir workdir.tcl]]
set auto_index(log_toggle) [list source [file join $dir workdir.tcl]]
set auto_index(exit_cleanup) [list source [file join $dir workdir.tcl]]
set auto_index(save_options) [list source [file join $dir workdir.tcl]]
tkrev_9.6.1/tkrev/git.tcl 0000664 0001750 0001750 00000232451 15033645673 015721 0 ustar dorothyr dorothyr # Find where we are in path
proc read_git_dir {dirname} {
global cvsglb
global current_tagname
# See what branch we're on
set cmd(git_branch) [exec::new "git branch --no-color"]
set branch_lines [split [$cmd(git_branch)\::output] "\n"]
foreach line $branch_lines {
if {[string match {\* *} $line]} {
# Could be something like (HEAD detached at 960c171)
set current_tagname [join [lrange $line 1 end]]
gen_log:log D "current_tagname=$current_tagname"
}
}
# What's the top level, and where are we relative to it?
set cmd(find_top) [exec::new "git rev-parse --show-toplevel"]
set cvsglb(repos_top) [lindex [$cmd(find_top)\::output] 0]
set wd [pwd]
set l [string length $cvsglb(repos_top)]
set cvsglb(relpath) [string range $wd [expr {$l+1}] end]
gen_log:log D "Relative path: $cvsglb(relpath)"
}
proc git_workdir_status {showfiles} {
global cvscfg
global cvsglb
global Filelist
global current_tagname
global module_dir
gen_log:log T "ENTER ($showfiles)"
read_git_dir [pwd]
set module_dir $cvsglb(relpath)
# git status ignores unchanged files, so we use ls-tree to list the
# files in the current directory that git is tracking.
set cmd(git_list) [exec::new "git ls-tree $current_tagname"]
set list_lines [split [$cmd(git_list)\::output] "\n"]
foreach l $list_lines {
if {$l eq ""} {continue}
set fname [join [lrange $l 3 end]]
set type [lindex $l 1]
if {$fname ni $showfiles} {continue}
if {$type eq "tree"} {
set Filelist($fname:status) ""
} else {
# preliminary, may be corrected
set Filelist($fname:status) "Up-to-date"
}
}
if {[info exists cmd(git_list)]} {
$cmd(git_list)\::destroy
catch {unset cmd(git_list)}
}
# Read git's status of the files. Always recursive below current level, and
# also the filename contains the path from the top. If they're up-to-date,
# git status is mute about them.
set cmd(git_status) [exec::new "git status -u --porcelain ."]
set status_lines [split [$cmd(git_status)\::output] "\n"]
if {[info exists cmd(git_status)]} {
$cmd(git_status)\::destroy
catch {unset cmd(git_status)}
}
foreach statline $status_lines {
if {[string length $statline] < 1} {
continue
}
# MM "Dir1/F 3.txt"
# M Dir2/F2.txt
# R Dir1/F1.txt -> Dir1/F1mv.txt
set status [string range $statline 0 1]
# Strip quotes
set f [string trim [join [lrange $statline 1 end]] "\""]
# Trim dirname from path. Renamed ones need to be handled now
if {[string match {R*} $status]} {
if {[regexp {(^\S+) -> (\S+)$} $f all f1 f2]} {
set dirname [file dirname $f1]
if {$dirname eq "."} {set dirname ""}
if {$dirname eq $module_dir} {
set t1 [file tail $f1]
set t2 [file tail $f2]
set Filelist($t1:status) "Renamed, moved to $t2"
set Filelist($t2:status) "Renamed, moved from $t1"
if {$status eq "RM"} {
set Filelist($t1:status) "Renamed, moved to $t2, Modified"
}
}
}
} else {
regsub "^$module_dir/" $f "" f
}
if {[regexp {/} $f]} {
gen_log:log D "$statline -> SKIP"
continue
}
switch -glob -- $status {
{M } {
set Filelist($f:status) "Modified, staged"
gen_log:log D "$statline -> $Filelist($f:status)"
}
{ M} -
{MM} {
set Filelist($f:status) "Modified, unstaged"
gen_log:log D "$statline -> $Filelist($f:status)"
}
{A } {
set Filelist($f:status) "Added"
gen_log:log D "$statline -> $Filelist($f:status)"
}
{AD} {
set Filelist($f:status) "Added, missing"
gen_log:log D "$statline -> $Filelist($f:status)"
}
{D } {
set Filelist($f:status) "Removed"
gen_log:log D "$statline -> $Filelist($f:status)"
}
{ D} {
set Filelist($f:status) "Missing"
gen_log:log D "$statline -> $Filelist($f:status)"
}
{C*} {
set Filelist($f:status) "Copied"
gen_log:log D "$statline -> $Filelist($f:status)"
}
{AA} -
{AU} -
{DD} -
{DU} -
{UA} -
{UD} -
{UU} {
set Filelist($f:status) "Conflict"
gen_log:log D "$statline -> $Filelist($f:status)"
}
{??} {
if {[string match {.*} $f] && ! $cvscfg(allfiles)} {continue}
if {$f ni $showfiles} {continue}
set Filelist($f:status) "Not managed by Git"
gen_log:log D "$statline -> $Filelist($f:status)"
}
}
}
# So they're not undefined
catch {set Filelist($f:date) \
[clock format [file mtime ./$i] -format $cvscfg(dateformat)]}
if {$cvscfg(gitdetail)} {
# This log-each-file op is time consuming, so it's enabled or disabled in ~/.tkrev
# by the gitdetail variable
foreach i [array names Filelist *:status] {
regsub {:status$} $i {} f
gen_log:log D "$f $Filelist($f:status)"
if {$Filelist($f:status) eq "Not managed by Git"} { continue }
if {$Filelist($f:status) eq ""} { continue }
# --porcelain=1 out: XY , where X is the modification state of the index
# and Y is the state of the work tree. ' ' = unmodified.
# --porcelain=2 out has an extra integer field before the status and 6 extra
# fields before the filename.
# XY, now the second field, has "." for unmodified.
set good_line ""
# Format: short hash, commit time, committer, author
set command "git log -n 1 --format=%h|%ct|%cn|%an -- \"$f\""
set cmd(git_log) [exec::new "$command"]
set log_out [$cmd(git_log)\::output]
foreach log_line [split $log_out "\n"] {
if {[string length $log_line] > 0} {
set good_line $log_line
}
}
$cmd(git_log)\::destroy
set items [split $good_line "|"]
set hash [string trim [lindex $items 0] "\""]
set wdate [string trim [lindex $items 1] "\""]
set committer [string trim [lindex $items 2] "\""]
set author [string trim [lindex $items 3] "\""]
set Filelist($f:stickytag) $hash
catch {set Filelist($f:date) [clock format $wdate -format $cvscfg(dateformat)]}
set Filelist($f:editors) "$committer"
if {$author ne $committer} {
append Filelist($f:editors) " for $author"
}
if {[file isdirectory $f]} {
if {[string length $log_out] > 0} {
set Filelist($f:status) ""
} else {
set Filelist($f:status) ""
}
}
}
}
gen_log:log T "LEAVE"
}
proc find_git_remote {dirname} {
global cvscfg
global cvsglb
gen_log:log T "ENTER ($dirname)"
if {! [info exists cvscfg(url)] } {
set cvscfg(url) ""
set cvscfg(origin) ""
set cvsglb(fetch_url) ""
}
if {! [info exists cvscfg(origin)] } {
set cvscfg(origin) ""
}
set cmd(git_config) [exec::new "git remote -v"]
set lines [split [$cmd(git_config)\::output] "\n"]
set i 0
foreach line $lines {
if {$i == 0} {
# Take the first line, whatever it is, to fill basic info
set cvscfg(origin) [lindex $line 0]
set cvscfg(url) [lindex $line 1]
# In case fetch and push keywords aren't found
set cvsglb(fetch_origin) $cvscfg(origin)
set cvsglb(fetch_url) $cvscfg(url)
set cvsglb(push_origin) $cvscfg(origin)
set cvsglb(push_url) $cvscfg(url)
}
# Then, in case fetch and push urls are different
if {[string match {*(fetch)} $line]} {
set cvsglb(fetch_origin) [lindex $line 0]
set cvsglb(fetch_url) [lindex $line 1]
} elseif {[string match {*(push)} $line]} {
set cvsglb(push_origin) [lindex $line 0]
set cvsglb(push_url) [lindex $line 1]
}
incr i
}
set cvsglb(root) $cvscfg(url)
set cvsglb(vcs) git
gen_log:log T "LEAVE"
}
# For module browser.
proc parse_gitlist {gitroot} {
global cvsglb
global modval
global modtitle
gen_log:log T "ENTER ($gitroot)"
# Clear the arrays
catch {unset modval}
catch {unset modtitle}
set tv .modbrowse.treeframe.pw
set command "git ls-remote \"$cvsglb(root)\""
gen_log:log C "$command"
set rem_cmd [exec::new $command]
set remote_output [$rem_cmd\::output]
foreach line [split $remote_output "\n"] {
if {$line eq ""} {continue}
set dname [lindex $line 1]
gen_log:log D "dname=$dname"
# This is the hash
set modval($dname) [lindex $line 0]
gen_log:log D "modval($dname)=$modval($dname)"
gen_log:log D "$tv insert {} end -id $dname -values [list $dname $modval($dname)]"
$tv insert {} end -id "$dname" -values [list "$dname" $modval($dname)]
}
update idletasks
# Then you can do something like this to list the files
# git ls-tree -r refs/heads/master --name-only
gen_log:log T "LEAVE"
}
proc git_push {} {
global cvsglb
gen_log:log T "ENTER"
set command "git push --dry-run . HEAD"
gen_log:log C "$command"
set ret [catch {exec {*}$command} dryrun_output]
gen_log:log S "$dryrun_output"
# push will return "Everything up-to-date" if it is
if {! [string match "Everyt*" $dryrun_output]} {
set mess "This will push your committed changes to\
$cvsglb(push_origin) $cvsglb(push_url).\n"
append mess "\n$dryrun_output"
append mess "\n\n Are you sure?"
set title {Confirm!}
set answer [tk_messageBox \
-icon question \
-title $title \
-message $mess \
-parent .workdir \
-type okcancel]
if {$answer == {ok}} {
set commandline "git push . HEAD"
set v [viewer::new "Push"]
$v\::do "$commandline"
$v\::wait
$v\::clean_exec
}
} else {
cvsok "$dryrun_output" .workdir
}
gen_log:log T "LEAVE"
}
proc git_fetch {} {
global cvsglb
gen_log:log T "ENTER"
set command "git fetch --dry-run"
gen_log:log C "$command"
set ret [catch {exec {*}$command} dryrun_output]
gen_log:log S "$dryrun_output"
# Fetch is just quiet if it's up to date
if {[llength $dryrun_output] > 1} {
set mess "This will fetch changes from\
$cvsglb(fetch_origin) $cvsglb(fetch_url).\n"
append mess "\n$dryrun_output"
append mess "\n\n Are you sure?"
set title {Confirm!}
set answer [tk_messageBox \
-icon question \
-title $title \
-message $mess \
-parent .workdir \
-type okcancel]
if {$answer == {ok}} {
set commandline "git fetch"
set v [viewer::new "Fetch"]
$v\::do "$commandline"
$v\::wait
$v\::clean_exec
}
} else {
cvsok "Everything up to date" .workdir
}
gen_log:log T "LEAVE"
}
proc git_list_tags {} {
gen_log:log T "ENTER"
set commandline "git tag --list"
set v [viewer::new "Tags"]
$v\::do "$commandline"
$v\::wait
$v\::clean_exec
gen_log:log T "LEAVE"
}
# Called from "Log" in Reports menu
proc git_log {detail args} {
gen_log:log T "ENTER ($detail $args)"
busy_start .workdir.main
set flags ""
set filter ""
set filelist [join $args]
if {$filelist eq ""} {
set filelist {.}
}
set title "Git Log $filelist ($detail)"
set commandline "git log"
switch -- $detail {
latest {
append flags " --max-count=1"
set filter patch_colortags
}
summary {
append flags " --pretty=oneline"
#set filter patch_colortags
}
verbose {
# medium has the date, but full doesn't
append flags " --pretty=medium --all"
set filter patch_colortags
}
}
set v [viewer::new "$title"]
foreach file $filelist {
if {[llength $filelist] > 1} {
$v\::log "-- $file -------------------------------\n" invert
}
set command "git log --no-color $flags -- \"$file\""
$v\::do "$command" 1 $filter
$v\::wait
# If we're doing the graph, make the window wider
}
busy_done .workdir.main
gen_log:log T "LEAVE"
}
# does git rm from workdir browser
proc git_rm {args} {
gen_log:log T "ENTER ($args)"
set filelist [join $args]
# Unix-remove the files
set success 1
foreach file $filelist {
file delete -force -- $file
gen_log:log F "DELETE $file"
if {[file exists $file]} {
set success 0
}
}
if {$success == 0} {
cvsfail "Remove $file failed" .workdir
return
}
# git-rm them
set command "git rm"
foreach f $filelist {
append command " \"$f\""
}
set exec_cmd [exec::new "$command"]
auto_setup_dir $exec_cmd
gen_log:log T "LEAVE"
}
# does git rm -r from workdir browser popup menu
proc git_remove_dir {args} {
gen_log:log T "ENTER ($args)"
set filelist [join $args]
set command "git rm -r"
foreach f $filelist {
append command " \"$f\""
}
set exec_cmd [exec::new "$command"]
auto_setup_dir $exec_cmd
gen_log:log T "LEAVE"
}
# does git add from workdir browser
proc git_add {args} {
global cvscfg
gen_log:log T "ENTER ($args)"
set filelist [join $args]
if {$filelist == ""} {
set mess "This will add all new files"
} else {
set mess "This will add these files:\n\n"
foreach file $filelist {
append mess " $file\n"
}
}
set command "git add"
if {$filelist == ""} {
append command [glob -nocomplain $cvscfg(aster) .??*]
} else {
foreach f $filelist {
append command " \"$f\""
}
}
set addcmd [exec::new "$command"]
auto_setup_dir $addcmd
gen_log:log T "LEAVE"
}
# Called from workdir browser popup
proc git_rename_ask {args} {
gen_log:log T "ENTER ($args)"
set file [lindex $args 0]
if {$file eq ""} {
cvsfail "Rename:\nPlease select a file !" .workdir
return
}
# Send it to the dialog to ask for the filename
file_input_and_do "Git Rename" "git_rename \"$file\""
gen_log:log T "LEAVE"
}
# The callback for git_rename_ask and file_input_and_do
proc git_rename {args} {
global cvscfg
gen_log:log T "ENTER ($args)"
set oldname [lindex $args 0]
set newname [lindex $args 1]
set v [viewer::new "SVN rename"]
set command "git mv $oldname $newname"
$v\::do "$command"
# don't do this, or you'll get an error from git
#catch {file delete $oldname}
if {$cvscfg(auto_status)} {
setup_dir
}
gen_log:log T "LEAVE"
}
# Revert. Called from workdir browser
proc git_reset {args} {
global cvscfg
gen_log:log T "ENTER ($args)"
set filelist [join $args]
set commandline "git reset"
foreach f $filelist {
append commandline " \"$f\""
}
gen_log:log D "Reverting $filelist"
set v [viewer::new "Git Reset"]
$v\::do "$commandline"
$v\::wait
$v\::clean_exec
if {$cvscfg(auto_status)} {
setup_dir
}
gen_log:log T "LEAVE"
}
# called by "Status" in the Reports menu. Uses status_filter.
proc git_status {detail args} {
global cvscfg
gen_log:log T "ENTER ($detail $args)"
busy_start .workdir.main
set filelist [join $args]
set flags ""
set title "Git Status ($detail)"
# Hide unknown files if desired
if {$cvscfg(status_filter)} {
append flags " -uno"
}
switch -- $detail {
terse {
append flags " --porcelain"
}
summary {
append flags " --long"
}
verbose {
append flags " --verbose"
}
}
set commandline "git status $flags"
# There doesn't seem to be a way to suppress color. This option is invalid.
#append flags " --no-color"
foreach f $filelist {
append commandline " \"$f\""
}
set stat_cmd [viewer::new $title]
$stat_cmd\::do "$commandline" 0
busy_done .workdir.main
gen_log:log T "LEAVE"
}
# called from the branch browser
proc git_log_rev {rev filename} {
global cvscfg
gen_log:log T "ENTER ($rev $filename)"
set title "Git log"
set commandline "git log"
if {$rev ne ""} {
append commandline " $rev"
append title " $rev"
} else {
append commandline " $cvscfg(gitlog_opts)"
append title " $cvscfg(gitlog_opts)"
}
append commandline " \"$filename\""
append title " $filename"
set v_log [viewer::new "$title"]
#$v_log\::width 120
$v_log\::do $commandline 1 patch_colortags
gen_log:log T "LEAVE"
}
# Shows which files changed in a commit
# called from the branch browser
proc git_show {rev} {
gen_log:log T "ENTER ($rev)"
set show_command "git show --stat --no-color $rev"
set title "Git show $rev"
set v_show [viewer::new "$title"]
$v_show\::do $show_command 1
$v_show\::wait
gen_log:log T "LEAVE"
}
# Shows changes between commits
# called from the workdir browser
proc git_patch { filename {rev1 {}} {rev2 {}} } {
gen_log:log T "ENTER (\"$rev1\" \"$rev2\")"
set command "git diff --no-color"
set args ""
if {$rev1 != {} && $rev2 != {} } {
set args "$rev1 $rev2"
} elseif {$rev1 != {} } {
set args "$rev1^ $rev1"
} elseif {$rev2 != {} } {
set args "$rev2^ $rev2"
}
if {$filename != ""} {
append args " \"$filename\""
}
set title "SVN diff $args"
set title "Git diff $args"
set v_show [viewer::new "$title"]
#$v_show\::width 120
$v_show\::do "$command $args" 1 patch_colortags
$v_show\::wait
gen_log:log T "LEAVE"
}
# called from the "Check Directory" button in the workdir and Reports menu
proc git_check {} {
global cvscfg
gen_log:log T "ENTER ()"
busy_start .workdir.main
set title "Git Directory Check"
# I know we use a short report for other VCSs, but for Git you really
# need the full report to know what's staged and what's not
set flags "--porcelain"
# Show unknown files if desired
if {$cvscfg(status_filter)} {
append flags " -uno"
}
set command "git status $flags ."
set check_cmd [viewer::new $title]
$check_cmd\::do "$command" 0
busy_done .workdir.main
gen_log:log T "LEAVE"
}
# dialog for git commit - called from workdir browser
proc git_commit_dialog {} {
global cvsglb
global cvscfg
global colorglb
# If marked files, commit these. If no marked files, then
# commit any files selected via listbox selection mechanism.
# The cvsglb(commit_list) list remembers the list of files
# to be committed.
set cvsglb(commit_list) [workdir_list_files]
# If we want to use an external editor, just do it
if {$cvscfg(use_cvseditor)} {
git_commit "" "" $cvsglb(commit_list)
return
}
if {[winfo exists .commit]} {
destroy .commit
}
toplevel .commit
#grab set .commit
frame .commit.top -borderwidth 8
frame .commit.down -relief groove -borderwidth 2
pack .commit.top -side top -fill x
pack .commit.down -side bottom -fill x
frame .commit.comment
pack .commit.comment -side top -fill both -expand 1
label .commit.comment.lcomment -text "Your log message" -anchor w
button .commit.comment.history -text "Log History" \
-command history_browser
text .commit.comment.tcomment -relief sunken -width 70 -height 10 \
-bg $colorglb(textbg) -exportselection 1 \
-wrap word -borderwidth 2 -setgrid yes
# Explain what it means to "commit" files
message .commit.message -justify left -aspect 800 \
-text "This will commit changes from your local, working directory
into the local repository, recursively."
pack .commit.message -in .commit.top -padx 2 -pady 5
button .commit.ok -text "OK" \
-command {
#grab release .commit
wm withdraw .commit
set cvsglb(commit_comment) [.commit.comment.tcomment get 1.0 end]
git_commit $cvsglb(commit_comment) $cvsglb(commit_list)
commit_history $cvsglb(commit_comment)
}
button .commit.apply -text "Apply" \
-command {
set cvsglb(commit_comment) [.commit.comment.tcomment get 1.0 end]
git_commit $cvsglb(commit_comment) $cvsglb(commit_list)
commit_history $cvsglb(commit_comment)
}
button .commit.clear -text "ClearAll" \
-command {
set version ""
.commit.comment.tcomment delete 1.0 end
}
button .commit.quit \
-command {
#grab release .commit
wm withdraw .commit
}
.commit.ok configure -text "OK"
.commit.quit configure -text "Close"
grid columnconf .commit.comment 1 -weight 1
grid rowconf .commit.comment 1 -weight 1
grid .commit.comment.lcomment -column 0 -row 0
grid .commit.comment.tcomment -column 1 -row 0 -rowspan 2 -padx 4 -pady 4 -sticky nsew
grid .commit.comment.history -column 0 -row 1
pack .commit.ok .commit.apply .commit.clear .commit.quit -in .commit.down \
-side left -ipadx 2 -ipady 2 -padx 4 -pady 4 -fill both -expand 1
# Fill in the most recent commit message
.commit.comment.tcomment insert end $cvsglb(commit_comment)
wm title .commit "Commit Changes"
wm minsize .commit 1 1
gen_log:log T "LEAVE"
}
# git commit - called from commit dialog
proc git_commit {comment args} {
global cvscfg
gen_log:log T "ENTER ($comment $args)"
set filelist [join $args]
set commit_output ""
if {$filelist == ""} {
set mess "This will commit your changes to ** ALL ** files in"
append mess " and under this directory."
} else {
foreach file $filelist {
append commit_output "\n$file"
}
set mess "This will commit your changes to:$commit_output"
}
append mess "\n\nAre you sure?"
set commit_output ""
if {[cvsconfirm $mess .workdir] != "ok"} {
return 1
}
if {$cvscfg(use_cvseditor)} {
# Starts text editor of your choice to enter the log message.
update idletasks
set command "$cvscfg(terminal) git commit"
foreach f $filelist {
append command " \"$f\""
}
gen_log:log C "$command"
set ret [catch {exec {*}$command} view_this]
if {$ret} {
cvsfail $view_this .workdir
gen_log:log T "LEAVE ERROR ($view_this)"
return
}
} else {
if {$comment == ""} {
cvsfail "You must enter a comment!" .commit
return 1
}
set v [viewer::new "Git Commit"]
regsub -all "\"" $comment "\\\"" comment
set commandline "git commit -m \"$comment\""
foreach f $filelist {
append commandline " \"$f\""
}
$v\::do "$commandline" 1
$v\::wait
}
if {$cvscfg(auto_status)} {
setup_dir
}
gen_log:log T "LEAVE"
}
# git tag - called from tag dialog
proc git_tag {tagname annotate comment args} {
global cvscfg
gen_log:log T "ENTER ($tagname $annotate $comment $args)"
if {$tagname == ""} {
cvsfail "You must enter a tag name!" .workdir
return 1
}
set filelist [join $args]
set command "git tag "
if {$annotate == "yes"} {
append command "-a -m \"$comment\""
}
append command " $tagname"
foreach f $filelist {
append command " \"$f\""
}
set v [viewer::new "Git Tag"]
$v\::do "$command" 1
$v\::wait
if {$cvscfg(auto_status)} {
setup_dir
}
gen_log:log T "LEAVE"
}
# git branch - called from branch dialog
proc git_branch {branchname updflag args} {
global cvscfg
gen_log:log T "ENTER ($branchname $args)"
if {$branchname == ""} {
cvsfail "You must enter a branch name!" .workdir
return 1
}
set filelist [join $args]
set command "git branch $branchname"
foreach f $filelist {
append command " \"$f\""
}
set v [viewer::new "Git Branch"]
$v\::do "$command" 1"
$v\::wait
if {$updflag == "yes"} {
set command "git checkout $branchname"
foreach f $filelist {
append command " \"$f\""
}
$v\::log "$command"
$v\::do "$command" 0
$v\::wait
}
if {$cvscfg(auto_status)} {
setup_dir
}
gen_log:log T "LEAVE"
}
# git checkout with options - called from Update with Options in workdir browser
proc git_opt_update {} {
global cvsglb
switch -exact -- $cvsglb(tagmode_selection) {
"Keep" {
set command "git checkout"
}
"Trunk" {
set command "git checkout master"
}
"Branch" {
set command "git checkout $cvsglb(branchname)"
}
"Tag" {
set command "git checkout $cvsglb(tagname)"
}
"Commit" {
set command "git checkout $cvsglb(revnumber)"
}
}
set upd_cmd [viewer::new "Git Checkout"]
$upd_cmd\::do "$command" 0 status_colortags
auto_setup_dir $upd_cmd
}
# git checkout - called from Update in workdir browser
proc git_checkout {args} {
gen_log:log T "ENTER ($args)"
set filelist [join $args]
if {$filelist == ""} {
append mess "\nThis will download from"
append mess " the repository to your local"
append mess " filespace ** ALL ** files which"
append mess " have changed in it."
} else {
append mess "\nThis will download from"
append mess " the repository to your local"
append mess " filespace these files which"
append mess " have changed:\n"
}
foreach file $filelist {
append mess "\n\t$file"
}
append mess "\n\nAre you sure?"
set command "git checkout"
if {[cvsconfirm $mess .workdir] == "ok"} {
foreach file $filelist {
append command " \"$file\""
}
} else {
return;
}
set co_cmd [viewer::new "Git Update"]
$co_cmd\::do "$command" 1
auto_setup_dir $co_cmd
gen_log:log T "LEAVE"
}
# Make a clone using the Module Browser
proc git_clone {root tag target} {
global incvs insvn inrcs ingit
gen_log:log T "ENTER ($root $tag $target)"
set dir [pwd]
if {[file pathtype $target] eq "absolute"} {
set tgt $target
} else {
set tgt "$dir/$target"
}
set mess "This will clone\n\
$root $tag\n\
to directory\n\
$tgt\n\
Are you sure?"
if {[cvsconfirm $mess .modbrowse] == "ok"} {
set command "git clone"
if {$tag ne "HEAD"} {
append command " -b \"$tag\""
}
append command " \"$root\" \"$target\""
set v [viewer::new "Git Clone"]
$v\::do "$command"
}
gen_log:log T "LEAVE"
return
}
proc git_reconcile_conflict {args} {
global cvscfg
global tcl_version
gen_log:log T "ENTER ($args)"
if {[llength $args] != 1} {
cvsfail "Please select one file." .workdir
return
}
set filelist [join $args]
# See if it's really a conflict file
foreach file $filelist {
gen_log:log F "OPEN $file"
set f [open $file]
if {$tcl_version >= 9.0} {chan configure $f -profile tcl8}
set match 0
while { [eof $f] == 0 } {
gets $f line
if { [string match "<<<<<<< *" $line] } {
set match 1
break
}
}
gen_log:log F "CLOSE $file"
close $f
if { $match != 1 } {
cvsfail "$file does not appear to have a conflict." .workdir
continue foreach f $filelist {
append commandline " \"$f\""
}
}
set tkdiff_command "$cvscfg(tkdiff) -conflict -o \"$file\" \"$file\""
gen_log:log C "$tkdiff_command"
set ret [catch {exec {*}$tkdiff_command &} view_this]
}
gen_log:log T "LEAVE"
}
# annotate/blame. Called from workdir.
proc git_annotate {revision args} {
gen_log:log T "ENTER ($revision $args)"
set filelist [join $args]
if {$revision != ""} {
set revflag "$revision"
} else {
set revflag ""
}
if {$filelist == ""} {
cvsfail "Annotate:\nPlease select one or more files !" .workdir
gen_log:log T "LEAVE (Unselected files)"
return
}
foreach file $filelist {
annotate::new $revflag "$file" "git"
}
gen_log:log T "LEAVE"
}
# Called from branch browser annotate button
proc git_annotate_r {revision filepath} {
gen_log:log T "ENTER ($revision $filepath)"
if {$revision != ""} {
# We were given a revision
set revflag "$revision"
} else {
set revflag ""
}
annotate::new $revflag "$filepath" "git_r"
gen_log:log T "LEAVE"
}
# Called from file viewer annotate button
proc git_annotate_range {v_w revision filename} {
gen_log:log T "ENTER ($v_w $revision $filename)"
if {$revision != ""} {
# We were given a revision
set revflag "$revision"
} else {
set revflag ""
}
set range [get_textlines $v_w]
set firstline [lindex $range 0]
set lastline [lindex $range 1]
if {$firstline eq "" || $lastline eq ""} {
cvsfail "Plesae select a range of lines" $v_w
return
}
annotate::new $revision "$filename" "git_range" $firstline $lastline
gen_log:log T "LEAVE"
}
# View a specific revision of a file.
# Called from branch browser
proc git_fileview {revision path filename} {
gen_log:log T "ENTER ($revision $path $filename)"
if {$path ne ""} {
set filepath "$path/$filename"
} else {
set filepath "$filename"
}
set command "git show \"$revision:$filepath\""
set v [viewer::new "$filepath Revision $revision"]
$v\::do "$command"
# Get the viewer window
set v_w [namespace inscope $v {set w}]
frame $v_w.blamefm
button $v_w.blamefm.blame -text "Annotate selection" \
-command "git_annotate_range $v_w $revision \"$filename\""
pack $v_w.blamefm -in $v_w.bottom -side left
pack $v_w.blamefm.blame
}
# Sends files to the branch browser one at a time
proc git_branches {files} {
global cvsglb
gen_log:log T "ENTER ($files)"
set cvsglb(lightning) 0
read_git_dir [pwd]
gen_log:log D "Relative Path: $cvsglb(relpath)"
if {$files == {}} {
::git_branchlog::new $cvsglb(relpath) .
} else {
foreach file $files {
::git_branchlog::new $cvsglb(relpath) $file
}
}
gen_log:log T "LEAVE"
}
# Sends files to the branch browser one at a time
proc git_fast_diagram {files} {
global cvscfg
global cvsglb
gen_log:log T "ENTER ($files)"
set cvsglb(lightning) 1
read_git_dir [pwd]
gen_log:log D "Relative Path: $cvsglb(relpath)"
if {$files == {}} {
::git_branchlog::new $cvsglb(relpath) .
} else {
foreach file $files {
::git_branchlog::new $cvsglb(relpath) $file
}
}
gen_log:log T "LEAVE"
}
namespace eval ::git_branchlog {
variable instance 0
proc new {relpath filename {directory_merge {0}} } {
variable instance
set my_idx $instance
incr instance
namespace eval $my_idx {
global logcfg
global cvsglb
set my_idx [uplevel {concat $my_idx}]
set filename [uplevel {concat $filename}]
set relpath [uplevel {concat $relpath}]
set directory_merge [uplevel {concat $directory_merge}]
variable cmd_log
variable lc
variable ln
variable revwho
variable revdate
variable revtime
variable revlines
variable revstate
variable revcomment
variable revparent
variable tags
variable revbranches
variable branchrevs
variable logstate
gen_log:log T "ENTER [namespace current]"
set newlc [branch_diagram::new $filename "GIT,loc" [namespace current]]
set ln [lindex $newlc 0]
set lc [lindex $newlc 1]
if {![info exists cvsglb(lightning)]} {
set cvsglb(lightning) 0
}
if {$cvsglb(lightning)} {
$lc.refresh configure -state disabled
}
proc abortLog { } {
variable cmd_log
variable lc
if {[info exists cmd_log]} {
catch {$cmd_log\::abort}
}
busy_done $lc
pack forget $lc.stop
pack $lc.close -in $lc.down.closefm -side right
$lc.close configure -state normal
}
proc reloadLog { } {
global cvscfg
global cvsglb
global logcfg
global current_tagname
variable filename
variable cmd_log
variable lc
variable ln
variable allrevs
variable branch_matches
variable branchtip
variable branchroot
variable branchrevs
variable branchparent
variable family
variable raw_revs
variable revwho
variable revdate
variable revtime
variable revcomment
variable revkind
variable revparent
variable revpath
variable revstate
variable revtags
variable revbtags
variable revmergefrom
variable rootrev
variable rootrevs
variable oldest_rev
variable revbranches
variable logstate
variable relpath
variable filename
gen_log:log T "ENTER"
catch { $lc.canvas delete all }
catch { unset branch_matches }
catch { unset branchtip }
catch { unset branchroot }
catch { unset branchrevs }
catch { unset branchparent }
catch { unset raw_revs }
catch { unset revwho }
catch { unset revdate }
catch { unset revstate }
catch { unset revtime }
catch { unset revcomment }
catch { unset revtags }
catch { unset revbtags }
catch { unset revbranches }
catch { unset revkind }
catch { unset revmergefrom }
catch { unset revpath }
catch { unset revparent }
catch { unset rootrev }
catch { unset rootrevs }
catch { unset trunk }
catch { unset trunks }
catch { unset family }
catch { unset fam_trunk }
pack forget $lc.close
pack $lc.stop -in $lc.down.closefm -side right
$lc.stop configure -state normal
busy_start $lc
# Start collecting information and initializing the
# browser
$ln\::ConfigureButtons $filename
# in case we got here straight from the command line
if {! [info exists current_tagname]} {
set command "git rev-parse --abbrev-ref HEAD"
set cmd_curbranch [exec::new $command {} 0 {} 1]
set branch_output [$cmd_curbranch\::output]
$cmd_curbranch\::destroy
set current_tagname [string trim $branch_output "\n"]
}
gen_log:log D "current_tagname $current_tagname"
set current_revnum [set $ln\::current_revnum]
gen_log:log D "current_revnum $current_revnum"
# Start collecting the branches
catch {unset branches}
catch {unset logged_branches}
catch {unset local_branches}
catch {unset remote_branches}
# Prepare to draw something on the canvas so user knows we're working
set cnv_y 20
set yspc 15
set cnv_h [winfo height $lc.canvas]
set cnv_w [winfo width $lc.canvas]
set cnv_x [expr {$cnv_w / 2- 8}]
# subtract scrollbars etc
incr cnv_h -20
incr cnv_w -20
$lc.canvas create text $cnv_x $cnv_y -text "Collecting the LOG" -tags {temporary}
incr cnv_y $yspc
$lc.canvas configure -scrollregion [list 0 0 $cnv_w $cnv_y]
$lc.canvas yview moveto 1
update idletasks
if {! $logcfg(show_branches)} {
set cvsglb(lightning) 1
}
# Gets all the commit information at once, including the branch, tag,
# merge, and parent information. Doesn't necessarily pick up all of the
# locally reachable branches
set command "git log --all"
if {$cvsglb(lightning)} {
# For the fast no-branches mode, it's best with no options but in date order
append command " --date-order"
} else {
append command " $cvscfg(gitlog_opts)"
if {$cvscfg(gitmaxhist) != ""} {
append command " -$cvscfg(gitmaxhist)"
}
if {$cvscfg(gitlog_since) != ""} {
set sinceflag "--since=\"$cvscfg(gitlog_since)\""
regsub -all {\s+} $sinceflag {\\ } sinceflag
append command " $sinceflag"
}
}
if {$logcfg(show_tags)} {
append command " --tags"
}
append command " --abbrev-commit --parents --format=fuller --date=iso --decorate=short --no-color -- \"$filename\""
set cmd_log [exec::new $command {} 0 {} 1]
set log_output [$cmd_log\::output]
$cmd_log\::destroy
set log_lines [split $log_output "\n"]
set logged_branches [parse_gitlog $log_lines]
catch {unset log_output}
catch {unset log_lines}
if {! [info exists allrevs]} {
set msg "No revisions found for $filename"
if {$cvscfg(gitlog_since) != ""} {
set sinceflag "--since=\"$cvscfg(gitlog_since)\""
regsub -all {\s+} $sinceflag {\\ } sinceflag
append msg " $sinceflag"
}
cvsfail $msg $lc
return;
}
gen_log:log D "[llength $allrevs] REVISIONS picked up by git log --all"
# If we've found parentless revisions, rootrev is set to the first parentless
# one we found
gen_log:log D "Parentless revs $rootrevs"
gen_log:log D "Last rootrev $rootrev"
set oldest_rev [lindex $allrevs end]
gen_log:log D "Oldest rev $oldest_rev $revdate($oldest_rev)"
set raw_all [lreverse $allrevs]
# Branches that were in the log decorations
if {$logged_branches != {}} {
set logged_branches [prune_branchlist $logged_branches]
}
if {! $cvsglb(lightning)} {
# This gets all the locally reachable branches. We only use all of them if asked,
# but their order is important. Also if "master" is in there, we want it.
set cmd(git_branch) [exec::new "git branch --no-color"]
set branch_lines [split [$cmd(git_branch)\::output] "\n"]
# If we're in a detached head state, one of these can be like (HEAD detached at 9d24194)
# but we can just filter it out
foreach line $branch_lines {
if {[string length $line] < 1} continue
if {[regexp {detached} $line]} continue
regsub {\*\s+} $line {} line
lappend local_branches [lindex $line 0]
}
catch {unset branch_lines}
# We always want the current branch, though
if {($current_tagname != "") && ($current_tagname ni $logged_branches)} {
lappend logged_branches $current_tagname
}
if {("master" in $local_branches) && ("master" ni $logged_branches)} {
lappend logged_branches {master}
}
# Don't get the remote branches unless asked to
if { ! $cvsglb(lightning) && [regexp {R} $cvscfg(gitbranchgroups)] } {
set cmd(git_rbranch) [exec::new "git branch -r"]
set branch_lines [split [$cmd(git_rbranch)\::output] "\n"]
foreach line $branch_lines {
if {[string length $line] < 1} continue
if {[string match {*/HEAD} $line]} continue
lappend remote_branches [lindex $line 0]
}
catch {unset branch_lines}
}
if {![info exists logged_branches]} { set logged_branches {} }
if {![info exists local_branches]} { set local_branches {} }
if {![info exists remote_branches]} { set remote_branches {} }
gen_log:log D "File-log branches ([llength $logged_branches]): $logged_branches"
gen_log:log D "Local branches ([llength $local_branches]): $local_branches"
gen_log:log D "Remote branches ([llength $remote_branches]): $remote_branches"
# Collect and de-duplicate the branch list
# First, add the logged branches. We always need those, you can't opt out
set branches $logged_branches
# The local branch list usually preserves the order the best. So
# we try to preserve that order when we blend them, even if we don't add ones
# that aren't already in the logged branches
set ovlp_list ""
set fb_only ""
set lb_only ""
if {[llength $local_branches] > 0} {
foreach lb $local_branches {
if {$lb in $logged_branches} {
lappend ovlp_list $lb
} else {
lappend lb_only $lb
}
}
foreach fb $logged_branches {
if {$fb ni $local_branches} {
lappend fb_only $fb
}
}
}
# Then add the local branches that weren't in the logged branches, if desired
if { [regexp {L|R} $cvscfg(gitbranchgroups)] } {
set branches [concat $ovlp_list $fb_only $lb_only ]
} else {
set branches [concat $ovlp_list $fb_only ]
}
# Then add the remote branches, if desired
if { [regexp {R} $cvscfg(gitbranchgroups)] } {
foreach remb $remote_branches {
if {$remb ni $branches} {
lappend branches $remb
}
}
}
set branches [lrange $branches 0 $cvscfg(gitmaxbranch)]
set branches [prune_branchlist $branches]
# Move master to the front
set idx [lsearch -regexp $branches {master|.*/master}]
set mstr [lindex $branches $idx]
set branches [lreplace $branches $idx $idx]
set branches [concat $mstr $branches]
catch {unset logged_branches}
catch {unset local_branches}
gen_log:log D "Overlap: $ovlp_list"
gen_log:log D "File only: $fb_only"
gen_log:log D "Local only: $lb_only"
gen_log:log D "Combined branches ([llength $branches]): $branches"
# De-duplicate the tags, while we're thinking of it.
foreach a [array names revtags] {
if {[llength $revtags($a)] > 1} {
set revtags($a) [prune_branchlist $revtags($a)]
}
}
# Filter the branches
# We got the master above
set filtered_branches $mstr
if {$current_tagname ne $mstr} {
lappend filtered_branches $current_tagname
}
if {$cvscfg(gitbranchregex) ne ""} {
gen_log:log D "regexp \{$cvscfg(gitbranchregex)\}"
foreach b $branches {
#gen_log:log D "regexp $cvscfg(gitbranchregex) $b"
if {[catch { regexp "$cvscfg(gitbranchregex)" $b} reg_out]} {
gen_log:log E "$reg_out"
cvsfail "$reg_out"
break
} else {
if {$reg_out} {
lappend filtered_branches $b
}
}
}
if {[llength $filtered_branches] < 1} {
gen_log:log E "filter \{$cvscfg(gitbranchregex)\} didn't match any branches!"
#cvsfail "filter \{$cvscfg(gitbranchregex)\} didn't match any branches!"
} else {
gen_log:log D "Filtered branches: $filtered_branches"
set branches $filtered_branches
}
}
set current_branches ""
} else {
set branches $current_tagname
set current_branches $current_tagname
set trunk $current_tagname
set trunks $current_tagname
set branchrevs($trunk) $allrevs
set branchtip($trunk) [lindex $allrevs 0]
set branchroot($trunk) [lindex $allrevs end]
set branchrevs($branchroot($trunk)) $branchrevs($trunk)
}
# We need to query each branch to know if it's empty, so we collect the
# revision list while we're at it. We collect the branches into
# families having the same root, and detect identical ones.
set empty_branches ""
set root_branches ""
set branchtips ""
list ident_matches
list family
if {! $cvsglb(lightning)} {
# This is necessary to reset the view after clearing the canvas
$lc.canvas configure -scrollregion [list 0 0 $cnv_w $cnv_h]
set cnv_y [expr {$cnv_y + $yspc}]
set cnv_x [expr {$cnv_w / 2- 8}]
$lc.canvas create text $cnv_x $cnv_y -text "Getting BRANCHES" -tags {temporary}
incr cnv_y $yspc
$lc.canvas configure -scrollregion [list 0 0 $cnv_w $cnv_y]
$lc.canvas yview moveto 1
update idletasks
foreach br $branches {
# Draw something on the canvas so the user knows we're working
$lc.canvas create text $cnv_x $cnv_y -text $br -tags {temporary} -fill $cvscfg(colourB)
incr cnv_y $yspc
$lc.canvas configure -scrollregion [list 0 0 $cnv_w $cnv_y]
$lc.canvas yview moveto 1
update idletasks
set command "git rev-list"
if {$cvscfg(gitmaxhist) != ""} {
append command " -$cvscfg(gitmaxhist)"
}
# If since time is set, use that. Otherwise, use the time of the
# oldest rev we found in log --all
if {$cvscfg(gitlog_since) != ""} {
set sinceflag "--since=\"$cvscfg(gitlog_since)\""
regsub -all {\s+} $sinceflag {\\ } sinceflag
set since_time $sinceflag
} else {
set seconds [clock scan $revdate($oldest_rev) -gmt yes]
set since_time [clock add $seconds -1 hour]
}
set command "$command --reverse --abbrev-commit $cvscfg(gitlog_opts) --since=\"$since_time\" $br -- \"$filename\""
set cmd_revlist [exec::new $command {} 0 {} 1]
set revlist_output [$cmd_revlist\::output]
$cmd_revlist\::destroy
set revlist_lines [split $revlist_output "\n"]
if {[llength $revlist_lines] < 1} {
gen_log:log D "branch $br is EMPTY. Removing from consideration"
# If it's empty, remove this branch from the list
set idx [lsearch $branches $br]
set branches [lreplace $branches $idx $idx]
lappend empty_branches $br
continue
}
if {[llength $revlist_lines]} {
foreach ro $revlist_lines {
if {[string length $ro] > 0} {
lappend raw_revs($br) $ro
set revpath($ro) $relpath
set revkind($ro) "revision"
}
}
catch {unset revlist_output}
catch {unset revlist_lines}
set branchtip($br) [lindex $raw_revs($br) end]
lappend branchtips $branchtip($br)
lappend ident_matches($branchtip($br)) $br
if {[llength $ident_matches($branchtip($br))] > 1} {
gen_log:log D "$br identical to another branch. Setting aside"
continue
}
lassign [list_within_list $raw_all $raw_revs($br)] start n_overlap
# If there is orphaned stuff in here, some branches are disjunct with
# with our root. Don't process these further now.
if {$n_overlap == 0} {
gen_log:log D "branch $br is DISJUNCT with our root"
#set idx [lsearch $branches $br]
#set branches [lreplace $branches $idx $idx]
}
set overlap_len($br) $n_overlap
set overlap_start($br) $start
set branchroot($br) [lindex $raw_revs($br) 0]
gen_log:log D "$br root is $branchroot($br)"
if {$branchroot($br) ni $rootrevs} {
lappend rootrevs $branchroot($br)
}
if {$current_revnum in $raw_revs($br)} {
gen_log:log D "$br contains current_revnum $current_revnum"
lappend current_branches $br
}
foreach r $rootrevs {
if {$r in $raw_revs($br)} {
gen_log:log D "$br contains ROOT $r"
if {[lindex $raw_revs($br) 0] eq $r} {
lappend family($r) $br
}
}
}
}
}
# Finished collecting the branches from the repository
# It's easier to compare the branches if we put identical ones aside.
# Here we are saving lists of two or more identical branches.
foreach i [array names ident_matches] {
if {[llength $ident_matches($i)] < 2} {
catch {unset ident_matches($i)}
}
}
}
# Get the branches in each family back in order
foreach f [array names family] {
set ofam [list]
foreach ob $branches {
if {$ob in $family($f)} {
lappend ofam $ob
}
}
set family($f) $ofam
gen_log:log D "FAMILY ($f): $family($f)"
}
gen_log:log D "Empty branches: $empty_branches"
gen_log:log D "You are Here: $current_branches"
gen_log:log D "Branches: $branches"
if {[llength $branches] < 1} {
cvsfail "Nothing found by git log $cvscfg(gitlog_opts)"
busy_done $lc
return
}
# Decide what to use for the trunk. Consider only non-empty,
# non-disjunct branches.
foreach f [array names family] {
set fam_branches $family($f)
set fam_trunk($f) ""
set trunk_found 0
gen_log:log D "Deciding on a trunk for the ($f) $family($f) family"
if {[llength $fam_branches] == 1} {
# If there's only one choice, don't waste time looking
set fam_trunk($f) [lindex $fam_branches 0]
set trunk_found 1
gen_log:log D " Only one branch to begin with! That was easy! trunk=$fam_trunk($f)"
}
if {! $trunk_found} {
# If only one branch begins at the beginning, that's a good one
set os_z ""
foreach b $fam_branches {
if {$overlap_start($b) == 0} {
lappend os_z $b
}
}
if {[llength $os_z] == 1} {
gen_log:log D " Only one branch begins at the root. trunk=$b"
set trunk_found 1
}
}
if {! $trunk_found} {
# Do we have revisions on master?
set m [lsearch -exact $fam_branches {master}]
if {$m > -1} {
gen_log:log D "master is in our branches"
set fam_trunk($f) "master"
set trunk_found 1
}
}
if {! $trunk_found} {
# how about origin/master
set m [lsearch -glob $fam_branches {*/master}]
if {$m > -1} {
set match [lindex $fam_branches $m]
gen_log:log D "$match is in branches"
set fam_trunk($f) $match
set trunk_found 1
}
}
if {! $trunk_found} {
if {[llength $fam_branches] > 0} {
set fam_trunk($f) [lindex $fam_branches 0]
set trunk_found 1
gen_log:log D " Using first branch as trunk"
}
set trunk_found 1
}
if {! $trunk_found} {
gen_log:log D "No named TRUNK found!"
set fam_trunk($f) ""
}
gen_log:log D "TRUNK for FAMILY $f: $fam_trunk($f)"
# Make sure the trunk is the first in the branchlist
set idx [lsearch $fam_branches $fam_trunk($f)]
set fam_branches [lreplace $fam_branches $idx $idx]
set fam_branches [linsert $fam_branches 0 $fam_trunk($f)]
set family($f) $fam_branches
# Get rev lists for the branches
catch {unset branch_matches}
# Draw something on the canvas so the user knows we're working
set empty_branches ""
gen_log:log D "========================"
gen_log:log D "FINDING THE MAJOR BRANCHES for family($f)"
foreach branch $family($f) {
$lc.canvas create text $cnv_x $cnv_y -text "$branch" -tags {temporary} -fill green
incr cnv_y $yspc
$lc.canvas configure -scrollregion [list 0 0 $cnv_w $cnv_y]
$lc.canvas yview moveto 1
update
gen_log:log D "========= $branch =========="
if {$branch eq $fam_trunk($f)} {
# sometimes we don't have raw_revs($fam_trunk($f)) if the file is added on branch,
# but we should have guessed at a rootrev by now
if {! [info exists raw_revs($fam_trunk($f))]} {
set raw_revs($fam_trunk($f)) $rootrev
}
set branchrevs($f) [lreverse $raw_revs($fam_trunk($f))]
set branchrevs($fam_trunk($f)) $branchrevs($f)
set branchtip($fam_trunk($f)) [lindex $branchrevs($fam_trunk($f)) 0]
set branchroot($fam_trunk($f)) [lindex $branchrevs($fam_trunk($f)) end]
if {! [info exists rootrev]} {
set rootrev $branchroot($fam_trunk($f))
gen_log:log D "USING ROOT $rootrev"
}
# Move the trunk's tags from the tip to the base
# But if there's only one rev, those are the same, so don't do it
if {[info exists revbtags($branchroot($branch)] && $branch in $revbtags($branchroot($branch))} {
gen_log:log D "$branch is already in $branchroot($branch)"
} else {
gen_log:log D "Adding $branch to revbtags for $branchroot($branch)"
lappend revbtags($branchroot($branch)) $branch
}
if {$branchtip($branch) ne $branchroot($branch)} {
if {[info exists revbtags($branchtip($branch))]} {
gen_log:log D " and removing it from tip"
set idx [lsearch $revbtags($branchtip($branch)) $branch]
set revbtags($branchtip($branch)) [lreplace $revbtags($branchtip($branch)) $idx $idx]
}
}
gen_log:log D "BASE of trunk $branch is $branchroot($branch)"
continue
}
# The root for a branch is the first one we get back that's only in the branch
# and not in master
if {[info exists raw_revs($branch)]} {
set raw_revs($branch) [lreverse $raw_revs($branch)]
# Here, we are establishing the first-level branches off the trunk
compare_branches $branch $fam_trunk($f)
set parent_ok 0
set base $branchroot($branch)
if {[info exists branchparent($branch)]} {
gen_log:log D "Using branchparent($branch) $branchparent($branch)"
set revparent($base) $branchparent($branch)
set parent_ok 1
}
if {! $parent_ok} {
# Was it merged from our root?
# Just testing this, don't set parent_ok
if {[info exists revmergefrom($base)]} {
set revparent($base) $revmergefrom($base)
gen_log:log D "$base was MERGED FROM $revparent($base)"
}
}
# NOPE NOPE NOPE prevent recursion
if {[info exists revparent($base)] && ($revparent($base) in $branchrevs($branch))} {
gen_log:log D "PARENT $revparent($base) is in the revision list of $branch!"
set parent_ok 0
}
if {! $parent_ok} {
gen_log:log D "Ignoring branch $branch"
catch {unset revparent($base)}
# Withdraw this branch from the proceedings
set idx [lsearch $family($f) $branch]
set branches [lreplace $family($f) $idx $idx]
continue
}
gen_log:log D " $branch: BASE $base PARENT $revparent($base)"
# Sometimes we get back a parent that our log --all didn't pick
# up. This may happen if the directory had checkins that didn't
# affect the file or the file is newly added
if {! [info exists revdate($revparent($base))] } {
# Draw it differently because it may not be reachable
set revpath($revparent($base)) $relpath
set revstate($revparent($base)) "ghost"
}
# We got the parent settled one way or another
# Add it to revbranches(parent)
if {! [info exists revbranches($revparent($base))] || $branchroot($branch) ni $revbranches($revparent($base))} {
lappend revbranches($revparent($base)) $branchroot($branch)
}
if {$branchtip($branch) ne $branchroot($branch)} {
if {[info exists revbtags($branchtip($branch))]} {
gen_log:log D " and removing it from tip"
set idx [lsearch $revbtags($branchtip($branch)) $branch]
set revbtags($branchtip($branch)) [lreplace $revbtags($branchtip($branch)) $idx $idx]
}
}
}
}
gen_log:log D "========================"
# If two branches have the same root, one is likely
# a sub-branch of the other. Let's see if we can disambiguate
foreach t [array names branchroot] {
if {$t eq $branch} continue
if {! [info exists branchroot($branch)]} continue
# Maybe we took it out in the first comparison
if {$branch ni $family($f)} continue
if {$branchroot($branch) eq $branchroot($t)} {
#gen_log:log D "$branch and $t have the same root $branchroot($branch)"
# Save the duplicates in a list to deal with next
lappend branch_matches($branch) $t
}
}
if {[info exists branch_matches]} {
gen_log:log D "SORTING OUT SUB-BRANCHES for FAMILY $f"
} else {
gen_log:log D "NO SUB-BRANCHES FOUND for FAMILY $f"
}
# Now that we've got sets of matches, process each set
foreach m [array names branch_matches] {
set family_base($m) $branchroot($m)
set peers [concat $m $branch_matches($m)]
gen_log:log D "FAMILY $peers"
set limit [llength $peers]
for {set i 0} {$i < $limit} {incr i} {
set j [expr {$i+1}]
if {$j == $limit} {set j 0}
set peer1 [lindex $peers $i]
set peer2 [lindex $peers $j]
# If the next one has been taken out for identity or something, skip it
if {$peer2 ni $family($f)} continue
compare_branches $peer1 $peer2
}
}
}
# Finished finding major branches
gen_log:log D "========================"
# Put back the identical branches
foreach i [array names ident_matches] {
gen_log:log D "$i IDENTICAL $ident_matches($i)"
set first [lindex $ident_matches($i) 0]
foreach next [lrange $ident_matches($i) 1 end] {
if {! [info exists branchrevs($first)]} {
gen_log:log E "branchrevs($first) doesn't exist!"
}
set branchrevs($next) $branchrevs($first)
set branchroot($next) $branchroot($first)
set branchtip($next) $branchtip($first)
if {$next ni $revbtags($branchroot($first))} {
lappend revbtags($branchroot($first)) $next
}
}
}
gen_log:log D "Deciding which family to draw"
gen_log:log D "CURRENT BRANCH: $current_tagname"
foreach ft [array names fam_trunk] {
lappend trunks $fam_trunk($ft)
}
gen_log:log D "TRUNK(s) $trunks"
set trunk_ok 0
set idx [lsearch -regexp $trunks {master|.*/master}]
if {$idx > -1} {
set mstr [lindex $trunks $idx]
gen_log:log D "Found $mstr in ($trunks)"
set trunk $mstr
set trunk_ok 1
}
if {! $trunk_ok} {
foreach t $trunks {
if {$t in $current_branches} {
gen_log:log D "Found $t in Current branches"
set trunk $t
set trunk_ok 1
}
}
}
if {! $trunk_ok} {
foreach t $trunks {
if {$t eq $current_tagname} {
gen_log:log D " Using current_tagname $current_tagname"
set trunk $t
set trunk_ok 1
}
}
}
if {! $trunk_ok} {
gen_log:log D " Using first trunk in list"
set trunk [lindex $trunks 0]
set trunk_ok 1
}
if {! $trunk_ok} {
cvsfail "Can't find a trunk for this file" $lc
}
foreach f [array names fam_trunk] {
if {$fam_trunk($f) eq "$trunk"} {
set rootrev $f
}
}
if {$rootrev eq ""} {
set rootrev $oldest_rev
}
set revkind($rootrev) "root"
gen_log:log D "USING TRUNK $trunk (rootrev $rootrev)"
# Little flourish here if we can do it. If the master arises from a merged
# branch, and we might draw the branch, try to show the merge
if {[info exists revparent($rootrev)] && $revparent($rootrev) ne ""} {
set revmergefrom($rootrev) $revparent($rootrev)
}
# Make sure we know where we're rooted. Sometimes the initial parent detection went
# one too far, which would put us on a different branch that's not visible from here.
gen_log:log D "branchrevs($trunk) $branchrevs($trunk)"
# Position the the You are Here icon and top up final variables
gen_log:log D "Looking for current_revnum $current_revnum in branches"
foreach branch $current_branches {
if {$branchtip($branch) eq $current_revnum} {
gen_log:log D "Currently at top of $branch"
set branchrevs($branch) [linsert $branchrevs($branch) 0 {current}]
} else {
# But maybe we're not at the tip
foreach r $branchrevs($branch) {
if {$r == $current_revnum} {
# We need to make a new artificial branch off of $r
gen_log:log D "appending current to revbranches($r)"
lappend revbranches($r) {current}
set revbtags(current) {current}
}
}
}
if {[info exists branchroot($branch)]} {
if {[info exists branchrevs($branch)]} {
set branchrevs($branchroot($branch)) $branchrevs($branch)
} else {
gen_log:log D "branchrevs($branch) doesn't exist!"
}
} else {
gen_log:log D "branchroot($branch) doesn't exist!"
}
}
# This causes recursion
foreach rb [array names revbranches] {
#gen_log:log D "revbranches($rb) $revbranches($rb)"
foreach r $revbranches($rb) {
foreach rb2 [array names revbranches] {
if {$rb eq $rb2} continue
if {$r in $revbranches($rb2)} {
gen_log:log D "$r is in both $rb and $rb2"
gen_log:log D " revbranches($rb) $revbranches($rb)"
gen_log:log D " revbranches($rb2) $revbranches($rb2)"
# Take it out of the longer one?
if {[llength $revbranches($rb)] > [llength $revbranches($rb2)]} {
set idx [lsearch $revbranches($rb) $r]
set revbranches($rb) [lreplace $revbranches($rb) $idx $idx]
} else {
set idx [lsearch $revbranches($rb2) $r]
set revbranches($rb2) [lreplace $revbranches($rb2) $idx $idx]
}
}
}
}
}
# We may have added a "current" branch. We have to set all its
# stuff or we'll get errors
foreach {revwho(current) revdate(current) revtime(current)
revlines(current) revcomment(current)
branchrevs(current) revbtags(current)}\
{{} {} {} {} {} {} {}} \
{ break }
pack forget $lc.stop
pack $lc.close -in $lc.down.closefm -side right
$lc.close configure -state normal
[namespace current]::git_sort_it_all_out
# Little pause before erasing the list of branches we temporarily drew
after 500
set new_x [$ln\::DrawTree now]
# Draw unrooted branches
gen_log:log D "ROOTREV $rootrev"
gen_log:log D "ROOTREVS $rootrevs"
set idx [lsearch $rootrevs $rootrev]
set rootrevs [lreplace $rootrevs $idx $idx]
set sidetree_x [expr {$new_x + 2}]
foreach rv $rootrevs {
if {[info exists revbtags($rv)]} {
set broot [lindex $revbtags($rv) 0]
} else {
continue
}
gen_log:log D "UNROOTED branch $rv: $broot"
catch {unset revkind}
set revkind($broot) "root"
gen_log:log D "revbtags($rv) $revbtags($rv)"
set new_x [$ln\::DrawSideTree $sidetree_x 0 $rv]
set sidetree_x [expr {$new_x + 2}]
}
gen_log:log T "LEAVE"
return
}
proc parse_gitlog {lines} {
global logcfg
global cvsglb
variable allrevs
variable relpath
variable revwho
variable revdate
variable revparent
variable revpath
variable revtime
variable revcomment
variable revtags
variable revbtags
variable revmergefrom
variable revstate
variable rootrev
variable rootrevs
gen_log:log T "ENTER (<...>)"
set revnum ""
set i 0
set l [llength $lines]
set last ""
set logged_branches ""
catch {unset allrevs}
set rootrev ""
set rootrevs ""
while {$i < $l} {
set line [lindex $lines $i]
#gen_log:log D "$line"
if { [ regexp {^\s*$} $last ] && [ string match {commit *} $line] } {
# ^ the last line was empty and this one starts with commit
# The commit line is complex. It can contain parents, tags, and branch tags.
# It can look like this:
# commit aad218525 3590769e6 (tag: tclpro-1-5-0, origin/tclpro-1-5-0-synthetic)
if {[expr {$l - $i}] < 0} {break}
# ^ we came to the last line!
set line [lindex $lines $i]
set commits ""
set parenthetical ""
regexp {^commit ([\w\s]*)} $line nil commits
regexp {^commit .*(\(.*\))} $line nil parenthetical
set revnum [lindex $commits 0]
lappend allrevs $revnum
# If it's a merge, there's more than one parent. But for this, we only want
# the first one
set parentlist [lindex $commits 1]
set parent [lindex $parentlist 0]
set revparent($revnum) $parent
if {$parent == ""} {
set rootrev $revnum
gen_log:log D "FOUND PARENTLESS ROOT $rootrev"
lappend rootrevs $rootrev
}
#strip off the parentheses
set in_parens [string range $parenthetical 1 end-1]
set items [split $in_parens " "]
set p 0
while {$p < [llength $items]} {
# First, see if there are tags and peel them off
if {[lindex $items $p] eq "tag:"} {
incr p
lappend revtags($revnum) [string trimright [lindex $items $p] ","]
incr p
} else {
# what's left are branches. This is the tip, not the root, usually
set raw_btag [string trimright [lindex $items $p] ","]
if {(! [regexp {HEAD} $raw_btag]) && ($raw_btag ne "->")} {
if {$cvsglb(lightning)} {
set revbtags($revnum) $raw_btag
} else {
lappend logged_branches $raw_btag
}
}
incr p
}
}
incr i
set line [lindex $lines $i]
# a line like "Merge: 7ee40c3 d6b18a7" could be next
if { [string match {Merge:*} $line] } {
set revmergefrom($revnum) [lindex $line end]
incr i
}
set line [lindex $lines $i]
# Author: dorothy rob
if { [string match {Author:*} $line] } {
set remainder [join [lrange $line 1 end]]
regsub { <.*>} $remainder {} revwho($revnum)
}
incr i 3
set line [lindex $lines $i]
# Date: 2018-08-17 20:10:15 -0700
if { [string match {CommitDate:*} $line] } {
set revdate($revnum) [lindex $line 1]
set revtime($revnum) [lindex $line 2]
}
set last [lindex $lines $i]
incr i
set line [lindex $lines $i]
# Blank line precedes comment
set revcomment($revnum) ""
if { [ regexp {^\s*$} $line ] } {
set last $line
set j $i
set c [expr {$i + 1}]
set line [lindex $lines $c]
while { ! [string match {commit *} $line] } {
incr c
set line [lindex $lines $c]
if {$c > $l} {break}
}
# The comment lines have leading whitespace (4 spaces)
foreach commentline [lrange $lines [expr {$j + 1}] [expr {$c - 2}]] {
set commentline [string range $commentline 4 end]
append revcomment($revnum) "$commentline\n"
}
set i [expr {$c - 1}]
}
incr i
set revpath($revnum) $relpath
}
}
gen_log:log T "LEAVE ($logged_branches)"
return $logged_branches
}
proc compare_branches {A B} {
variable branchrevs
variable branchroot
variable branchtip
variable branchparent
variable raw_revs
variable revbranches
variable revbtags
variable branch_matches
variable family
gen_log:log D " COMPARING $A VS $B"
# For the main comparisons, we don't have branchrevs yet
if {! [info exists branchrevs($A)]} {
set branchrevs($A) $raw_revs($A)
}
#gen_log:log D " branchrevs($A) $branchrevs($A)"
if {! [info exists branchrevs($B)]} {
set branchrevs($B) $raw_revs($B)
}
#gen_log:log D " branchrevs($B) $branchrevs($B)"
lassign [list_comm $branchrevs($B) $branchrevs($A)] inAonly inBonly inBoth
gen_log:log D " == ONLY IN $A: $inBonly"
gen_log:log D " == ONLY IN $B: $inAonly"
if {$inBonly eq "IDENTICAL"} {
gen_log:log D " BRANCHES $A and $B are IDENTICAL"
set branchrevs($A) $branchrevs($B)
set branchroot($A) $branchroot($B)
set branchtip($branch) $branchtip($B)
# Add its tag to the branchroot for the other
foreach z [list $A $B] {
if {$z ni $revbtags($branchroot($z))} {
gen_log:log D "Adding $z to revbtags for ($branchroot($z))"
lappend revbtags($branchroot($z)) $z
}
}
gen_log:log D "Removing $A as an independent entity"
set idx [lsearch $branch_matches($m) $A]
set branch_matches($m) [lreplace $branch_matches($m) $idx $idx]
set idx [lsearch $family($f) $branch]
set family($f) [lreplace $family($f) $idx $idx]
return
}
if {$inBonly ne {}} {
set branchrevs($A) $inBonly
set branchroot($A) [lindex $branchrevs($A) end]
set branchtip($A) [lindex $branchrevs($A) 0]
set new_base $branchroot($A)
set branchrevs($new_base) $inBonly
set fork [lindex $inBoth 0]
if {$fork eq ""} {
gen_log:log D " $A and $B are now non-overlapping"
return
}
gen_log:log D " NEW PARENT $fork and BASE $new_base of $A"
set branchparent($A) $fork
set old_base [lindex $inBoth end]
set revkind($new_base) "branch"
# Move revbtags
if {! [info exists revbtags($new_base)] || ($A ni $revbtags($new_base))} {
gen_log:log D "Adding $A to revbtags($new_base)"
lappend revbtags($new_base) $A
}
if {[info exists revbtags($old_base)]} {
gen_log:log D " and removing it from old base $old_base"
set idx [lsearch $revbtags($old_base) $A]
set revbtags($old_base) [lreplace $revbtags($old_base) $idx $idx]
}
# Move revbranches
if {! [info exists revbranches($fork)] || ($new_base ni $revbranches($fork))} {
lappend revbranches($fork) $new_base
}
} elseif {$inAonly ne {} && ! [regexp $B {master|.*/master}]} {
set branchrevs($B) $inAonly
set branchroot($B) [lindex $branchrevs($B) end]
set branchtip($B) [lindex $branchrevs($B) 0]
set new_base $branchroot($B)
set branchrevs($new_base) $inAonly
set fork [lindex $inBoth 0]
if {$fork eq ""} {
gen_log:log D " $A and $B are now non-overlapping"
return
}
gen_log:log D " NEW PARENT $fork and BASE $new_base of $B"
set branchparent($B) $fork
set old_base [lindex $inBoth end]
set revkind($new_base) "branch"
# Move revbtags
if {! [info exists revbtags($new_base)] || ($A ni $revbtags($new_base))} {
gen_log:log D "Adding $B to revbtags($new_base)"
lappend revbtags($new_base) $B
}
if {[info exists revbtags($old_base)]} {
gen_log:log D " and removing it from old base $old_base"
set idx [lsearch $revbtags($old_base) $B]
set revbtags($old_base) [lreplace $revbtags($old_base) $idx $idx]
}
# Move revbranches
if {! [info exists revbranches($fork)] || ($new_base ni $revbranches($fork))} {
lappend revbranches($fork) $new_base
}
} else {
set fork [lindex $inBoth 0]
set old_base [lindex $inBoth end]
if {[info exists family($old_base)]} {
set idx [lsearch $family($old_base) $A]
set family($old_base) [lreplace $family($old_base) $idx $idx]
gen_log:log D " removing $old_base from family($old_base)"
}
}
}
proc git_sort_it_all_out {} {
global cvscfg
global current_tagname
variable filename
variable lc
variable ln
variable revwho
variable revdate
variable revtime
variable revcomment
variable revkind
variable revpath
variable revtags
variable revbtags
variable branchrevs
variable revbranches
variable revstate
variable revmergefrom
variable logstate
variable revnum
variable rootbranch
variable revbranch
variable rootrev
variable rootrevs
variable oldest_rev
gen_log:log T "ENTER"
# Sort the revision and branch lists and remove duplicates
foreach r [lsort -dictionary [array names revkind]] {
if {$revkind($r) eq "root"} {
gen_log:log D "revkind($r) $revkind($r)"
}
}
gen_log:log D ""
foreach a [lsort -dictionary [array names revtags]] {
gen_log:log D "revtags($a) $revtags($a)"
}
gen_log:log D ""
foreach a [lsort -dictionary [array names revbtags]] {
gen_log:log D "revbtags($a) $revbtags($a)"
}
gen_log:log D ""
foreach a [lsort -dictionary [array names revbranches]] {
gen_log:log D "revbranches($a) $revbranches($a)"
}
gen_log:log D ""
foreach a [lsort -dictionary [array names branchrevs]] {
gen_log:log D "branchrevs($a) $branchrevs($a)"
}
gen_log:log D ""
foreach a [lsort -dictionary [array names revmergefrom]] {
# Only take one from the list that you might have here
#set revmergefrom($a) [lindex $revmergefrom($a) end]
gen_log:log D "revmergefrom($a) $revmergefrom($a)"
}
gen_log:log D ""
foreach a [lsort -dictionary [array names revstate]] {
gen_log:log D "revstate($a) $revstate($a)"
}
# We only needed these to place the you-are-here box.
catch {unset rootbranch revbranch}
gen_log:log T "LEAVE"
}
[namespace current]::reloadLog
return [namespace current]
}
}
}
# Expect two lists. We look for the second one inside the
# first one.
# Return the length of the matching part and the first
# item, if any, that's only in listB.
proc list_within_list {listA listB} {
set lA [llength $listA]
set lB [llength $listB]
# The lists may not actually be the same, but we can
# look for where B might start in A
set firstB [lindex $listB 0]
set idx [lsearch $listA $firstB]
if {$idx > -1} {
set listA [lrange $listA $idx end]
}
# Find shorter list, end there
set n_items [expr {$listA < $listB} ? {$lA} : {$lB}]
for {set i 0} {$i < $n_items} {incr i} {
set iA [lindex $listA $i]
set iB [lindex $listB $i]
if {$iA ne $iB} {
break
}
}
return [list $idx $i]
}
# Expect two lists that are the same after some point.
# Collect the items that are different, and the first
# one that's the same
proc list_comm {listA listB} {
gen_log:log T "listA: ([llength $listA]) $listA"
gen_log:log T "listB: ([llength $listB]) $listB"
set inA ""
set inB ""
set inBoth ""
# Shortcut if lists are identical
if { $listA == $listB } {
set inA ""
set inB ""
set inBoth $listA
#gen_log:log D "lists are IDENTICAL"
return [list {IDENTICAL} $listA]
} else {
foreach B $listB {
if {$B in $listA} {
lappend inBoth $B
} else {
lappend inB $B
}
}
foreach A $listA {
if {$A ni $listB} {
lappend inA $A
}
}
}
gen_log:log T "LEAVE A only: ([llength $inA]) $inA"
gen_log:log T "LEAVE B only: ([llength $inB]) $inB"
gen_log:log T "LEAVE in Both: ([llength $inBoth]) $inBoth"
return [list $inA $inB $inBoth]
}
# We have both remote and local names of the same branch.
# For duplicated ones, keep only the local
proc prune_branchlist {branchlist} {
gen_log:log T "ENTER ($branchlist)"
set filtered_branchlist ""
foreach r $branchlist {
if {$r in $filtered_branchlist} {continue}
if {[string match {*/HEAD} $r]} {continue}
if {[regexp {/} $r]} {
regsub {.*/} $r {} rtail
if {$rtail ni $branchlist} {
lappend filtered_branchlist $r
}
} else {
if {$r ni $filtered_branchlist} {
lappend filtered_branchlist $r
}
}
}
gen_log:log T "LEAVE ($filtered_branchlist)"
return $filtered_branchlist
}
tkrev_9.6.1/tkrev/diff.tcl 0000664 0001750 0001750 00000004704 13765056474 016051 0 ustar dorothyr dorothyr # NOTE: tkdiff exit status is nonzero if there are differences, so we
# can't take it to mean failure
proc comparediff {args} {
#
# This diffs a file with the repository (tkdiff )
#
global cvscfg
gen_log:log T "ENTER ($args)"
set filelist [join $args]
if {$filelist == ""} {
cvsfail "Please select one or more files to compare!" .workdir
} else {
foreach file $filelist {
regsub -all {\$} $file {\$} file
gen_log:log C "$cvscfg(tkdiff) \"$file\""
set ret [catch {exec {*}$cvscfg(tkdiff) "$file" &} view_this]
if {$ret} { cvsfail $view_this .workdir }
}
}
gen_log:log T "LEAVE"
}
# Two files
proc comparediff_files {parent file1 file2} {
global cvscfg
gen_log:log T "ENTER ($file1 $file2)"
gen_log:log C "$cvscfg(tkdiff) \"$file1\" \"$file2\""
set ret [catch {exec {*}$cvscfg(tkdiff) "$file1" "$file2" &} view_this]
if {$ret} { cvsfail $view_this $parent }
gen_log:log T "LEAVE"
}
proc comparediff_r {rev1 rev2 parent filename} {
#
# This diffs versions of a file, using one or two revisions (tkdiff -r1 [-r2] file)
#
global cvscfg
global insvn
gen_log:log T "ENTER (\"$rev1\" \"$rev2\" $filename)"
if {$rev1 == {} && $rev2 == {}} {
cvsfail "Must have at least one revision number or tag for this function!" $parent
return 1
}
if {$rev1 != {}} {
if {$insvn} {
set rev1 [string trimleft $rev1 {r}]
}
set rev1 "-r $rev1"
}
if {$rev2 != {}} {
if {$insvn} {
set rev2 [string trimleft $rev2 {r}]
}
set rev2 "-r $rev2"
}
set commandline "$cvscfg(tkdiff) $rev1 $rev2 \"$filename\""
gen_log:log C "$commandline"
set ret [catch {exec {*}$commandline &} view_this]
if {$ret} { cvsfail $view_this $parent }
gen_log:log T "LEAVE"
}
proc comparediff_sandbox {rev1 rev2 parent filename} {
#
# This diffs two revisions of a file that's not checked out
#
global cvscfg
gen_log:log T "ENTER (\"$rev1\" \"$rev2\" $filename)"
if {$rev1 == {} && $rev2 == {}} {
cvsfail "Must have at least one revision number or tag for this function!" $parent
return 1
}
if {$rev1 != {}} {
set rev1 [string trimleft $rev1 {r}]
set rev1 "-r \"$rev1\""
}
if {$rev2 != {}} {
set rev2 [string trimleft $rev2 {r}]
set rev2 "-r \"$rev2\""
}
set commandline "$cvscfg(tkdiff) $rev1 $rev2 \"$filename\""
gen_log:log C "$commandline"
cvs_sandbox_runcmd $commandline view_this
gen_log:log T "LEAVE"
}
tkrev_9.6.1/tkrev/branch_diagram.tcl 0000664 0001750 0001750 00000272771 15015446517 020064 0 ustar dorothyr dorothyr #
# Tcl Library for TkRev
#
# This is a major rewrite over the original version. It uses a
# top down, recursive, branch-at-a-time, latest-revision-first
# algorithm to layout the graph sensibly.
# -- Mike Jagdis
#
namespace eval ::branch_diagram {
variable instance 0
proc new {filename how scope} {
#
# Creates a new log canvas.
#
variable instance
set my_idx $instance
incr instance
global current_tagname
global module_dir
variable sys
variable loc
namespace eval $my_idx {
set my_idx [uplevel {concat $my_idx}]
set how [uplevel {concat $how}]
set filename [uplevel {concat $filename}]
set scope [uplevel {concat $scope}]
variable branchwin
#variable cmd_log
# Global constants scaled by current scaling factor for this instance
variable curr
upvar ::cvscfg cvscfg
upvar ::cvsglb cvsglb
upvar ::colorglb colorglb
upvar ::logcfg logcfg
upvar ::ingit in_git
upvar ::insvn in_svn
global tcl_platform
# User options for info display for this instance
variable revwho
variable revdate
variable revtime
variable revstate
variable revbranches
variable branchrevs
variable revcomment
variable revtags
variable revbtags
variable revpath
variable sel_tag
set sel_tag(A) ""
set sel_tag(B) ""
variable sel_rev
variable current_revnum
set sel_rev(A) ""
set sel_rev(B) ""
variable search_lastpattern ""
variable search_elements [list]
variable search_index 0
variable search_lastcase 0
variable search_nocase 0
set branchwin ".branch_diagram$my_idx"
gen_log:log T "ENTER [namespace current]"
set sys_loc [split $how {,}]
set sys [lindex $sys_loc 0]
set loc [lindex $sys_loc 1]
proc ClearSelection {AorB} {
variable sel_tag
variable sel_rev
set branchwin [namespace inscope [namespace current] {set branchwin}]
catch {$branchwin.canvas itemconfigure Sel$AorB -fill gray90}
$branchwin.canvas dtag Sel$AorB
$branchwin.up.rev${AorB}_rvers configure -state normal
$branchwin.up.rev${AorB}_rvers delete 0 end
$branchwin.up.rev${AorB}_rvers configure -state readonly
$branchwin.up.log${AorB}_rlogfm.rcomment configure -state normal
$branchwin.up.log${AorB}_rlogfm.rcomment delete 1.0 end
$branchwin.up.log${AorB}_rlogfm.rcomment configure -state disabled
$branchwin.up.rev${AorB}_rwho configure -text {}
$branchwin.up.rev${AorB}_rdate configure -text {}
set sel_tag($AorB) ""
set sel_rev($AorB) ""
return
}
proc SetSelection {AorB tag rev} {
global cvscfg
variable revdate
variable revtime
variable revwho
variable revcomment
variable sel_tag
variable sel_rev
set branchwin [namespace inscope [namespace current] {set branchwin}]
ClearSelection $AorB
set other [expr {$AorB == "A" ? {B} : {A}}]
if {$rev == $sel_rev($other)} { ClearSelection $other }
if {! [info exists revcomment($rev)]} {
set revcomment($rev) "*** empty log message ***"
}
if {$tag != {}} {
$branchwin.up.rev${AorB}_rvers configure -state normal
$branchwin.up.rev${AorB}_rvers delete 0 end
$branchwin.up.rev${AorB}_rvers insert end "$tag"
$branchwin.up.rev${AorB}_rvers configure -state readonly
} else {
$branchwin.up.rev${AorB}_rvers configure -state normal
$branchwin.up.rev${AorB}_rvers delete 0 end
$branchwin.up.rev${AorB}_rvers insert end "$rev"
$branchwin.up.rev${AorB}_rvers configure -state readonly
}
if {$rev != {} && [info exists revwho($rev)]} {
$branchwin.up.rev${AorB}_rwho configure -text $revwho($rev)
$branchwin.up.rev${AorB}_rdate configure -text\
"$revdate($rev) $revtime($rev)"
$branchwin.up.log${AorB}_rlogfm.rcomment configure -state normal
$branchwin.up.log${AorB}_rlogfm.rcomment insert end $revcomment($rev)
$branchwin.up.log${AorB}_rlogfm.rcomment configure -state disabled
}
$branchwin.canvas addtag Sel$AorB withtag rect$rev
$branchwin.canvas itemconfigure SelA -fill $cvscfg(colourA)
$branchwin.canvas itemconfigure SelB -fill $cvscfg(colourB)
set sel_tag($AorB) $tag
set sel_rev($AorB) $rev
return
}
proc RevSelect {AorB} {
set branchwin [namespace inscope [namespace current] {set branchwin}]
set t [$branchwin.canvas gettags current]
SetSelection $AorB \
[string range [lindex $t [lsearch -glob $t {T*}]] 1 end] \
[string range [lindex $t [lsearch -glob $t {R*}]] 1 end]
return
}
proc Unselect {AorB} {
set branchwin [namespace inscope [namespace current] {set branchwin}]
set t [$branchwin.canvas gettags current]
if {$t != {} } {return}
ClearSelection $AorB
}
proc EitherOrHead {} {
variable sys
set branchwin [namespace inscope [namespace current] {set branchwin}]
set revA [$branchwin.up.revA_rvers get]
set revB [$branchwin.up.revB_rvers get]
if {$revA ne ""} {
set rev $revA
} elseif {$revB ne ""} {
set rev $revB
} else {
if {$sys eq "SVN"} {set rev rHEAD} else {set rev HEAD}
}
return $rev
}
# This proc is called from the cvs, svn, or git modules
proc ConfigureButtons {fname} {
global cvsglb
global module_dir
variable sys
variable loc
variable current_revnum
set branchwin [namespace inscope [namespace current] {set branchwin}]
switch -- $sys {
"SVN" {
# Find out current rev and if it's a directory, if we can
set kind ""
set info_cmd [exec::new "svn info \"[file tail $fname]\""]
set info_lines [split [$info_cmd\::output] "\n"]
foreach infoline $info_lines {
if {[string match "Node Kind:*" $infoline]} {
gen_log:log D "$infoline"
set kind [lindex $infoline end]
} elseif {[string match "Last Changed Rev:*" $infoline]} {
gen_log:log D "$infoline"
set current_revnum [lindex $infoline end]
}
}
if {! [info exists current_revnum]} {
gen_log:log E "Warning: couldn't find current revision number!"
}
$branchwin.up.bmodbrowse configure -command modbrowse_run \
-image Modules_svn -state normal
$branchwin.up.lfname configure -text "SVN Path"
$branchwin.up.rfname configure -state normal
$branchwin.up.rfname delete 0 end
$branchwin.up.rfname insert end "$module_dir/$fname"
$branchwin.up.rfname configure -state readonly
$branchwin.view configure -state normal \
-command [namespace code {
set rev [EitherOrHead]
svn_fileview $rev $filename "file"
}]
$branchwin.log configure -state normal \
-command [namespace code {
svn_log_rev [EitherOrHead] $filename
}]
$branchwin.annotate configure \
-command [namespace code {
set rev [EitherOrHead]
if {$rev eq "rHEAD"} {set revpath($rev) "$filename"}
svn_annotate_r $rev "$revpath($rev)"
}]
$branchwin.diff configure \
-command [namespace code {
set revA [$branchwin.up.revA_rvers get]
set revB [$branchwin.up.revB_rvers get]
if {$revA eq "" || $revB eq ""} {
set rev [EitherOrHead]
comparediff_r $rev "" $branchwin $filename
} else {
comparediff_r $revA $revB $branchwin $filename
}
}]
$branchwin.patchdiff configure -state normal \
-command [namespace code {
set rev [EitherOrHead]
svn_difflog_rev $rev "$revpath($rev)"
}]
$branchwin.ddiff configure -state normal \
-command [namespace code {
set revA [$branchwin.up.revA_rvers get]
set revB [$branchwin.up.revB_rvers get]
if {$revA eq "" && $revB eq ""} {
cvsfail "Please select a revision!" $branchwin
return
}
set rev [EitherOrHead]
svn_show_rev $rev "$revpath($rev)"
}]
$branchwin.merge configure \
-command [namespace code {
set currentrevpath "$revpath(r$current_revnum)@$current_revnum"
set fromrev [$branchwin.up.revA_rvers get]
if {$fromrev == ""} {
cvsfail "Please select a revision to merge from!" $branchwin
return
}
set fromrevpath "$revpath($fromrev)@[string trimleft $fromrev {r}]"
set sincerev [$branchwin.up.revB_rvers get]
set fromtag ""
if {[info exists revbtags($sincerev)]} {
set fromtag [lindex $revbtags($sincerev) 0]
}
if {$fromtag == ""} {
foreach brev [array names revbtags] {
set b $revbtags($brev)
if {$b == ""} continue
foreach r $branchrevs($b) {
if {$r == $fromrev} {
set fromtag $b
}
}
}
}
if {$sincerev == ""} {
svn_merge $branchwin $fromrevpath "" $currentrevpath $fromtag $filename
} else {
set sincerevpath "$revpath($sincerev)@[string trimleft $sincerev {r}]"
svn_merge $branchwin $fromrevpath $sincerev $sincerevpath $fromtag $filename
}
}]
if {$kind == "directory"} {
$branchwin.view configure \
-command [namespace code {
set rev [EitherOrHead]
svn_fileview $rev $filename "directory"
}]
$branchwin.annotate configure -state disabled
$branchwin.diff configure -state disabled
$branchwin.patchdiff configure -state disabled
$branchwin.ddiff configure -state disabled
}
}
"CVS" {
$branchwin.up.bmodbrowse configure -command modbrowse_run \
-image Modules_cvs -state normal
$branchwin.up.lfname configure -text "RCS file"
$branchwin.up.rfname configure -state normal
$branchwin.up.rfname delete 0 end
$branchwin.up.rfname insert end "$fname,v"
$branchwin.up.rfname configure -state readonly
if {$loc == "rep"} {
# Working on repository files, not checked out
$branchwin.view configure -state normal \
-command [namespace code {
set rev [EitherOrHead]
cvs_fileview_checkout $rev $filename
}]
$branchwin.log configure -state disabled
$branchwin.annotate configure -state disabled
$branchwin.diff configure -state disabled
$branchwin.merge configure -state disabled
} else {
# We have a checked-out local file
$branchwin.view configure \
-command [namespace code {
set rev [EitherOrHead]
cvs_fileview_update $rev $filename
}]
$branchwin.log configure -state normal \
-command [namespace code {
set rev [EitherOrHead]
cvs_log_rev $rev $filename
}]
$branchwin.annotate configure \
-command [namespace code {
set rev [EitherOrHead]
cvs_annotate_r $rev "$module_dir/$filename"
}]
$branchwin.diff configure -state normal \
-command [namespace code {
set revA [$branchwin.up.revA_rvers get]
set revB [$branchwin.up.revB_rvers get]
if {$revA eq "" || $revB eq ""} {
set rev [EitherOrHead]
comparediff_r $rev "" $branchwin $filename
} else {
comparediff_r $revA $revB $branchwin $filename
}
}]
$branchwin.merge configure \
-command [namespace code {
set fromrev [$branchwin.up.revA_rvers get]
set sincerev [$branchwin.up.revB_rvers get]
if {$fromrev eq ""} {
cvsfail "Please select a revision to merge from!" $branchwin
return
}
set fromtag ""
set fromrev_root [join [lrange [split $fromrev {.}] 0 end-1] {.}]
if {[info exists revbtags($fromrev_root)]} {
set fromtag [lindex $revbtags($fromrev_root) 0]
} else {
# Just a rev number will do
set fromtag $fromrev_root
}
cvs_merge $branchwin $fromrev $sincerev $fromtag [list $filename]
}]
}
}
"GIT" {
$branchwin.up.bmodbrowse configure -command modbrowse_run \
-image Modules_git -state normal
$branchwin.up.lfname configure -text "GIT Path"
$branchwin.up.rfname configure -state normal
$branchwin.up.rfname delete 0 end
$branchwin.up.rfname insert end "$cvsglb(relpath)/$fname"
$branchwin.up.rfname configure -state readonly
set info_cmd [exec::new "git log --abbrev-commit --pretty=oneline --max-count=1 --no-color -- \"$fname\""]
set infoline [$info_cmd\::output]
gen_log:log D "$infoline"
# don't split infoline because comments like this break it:
#f6c73a2 Reinstate debug command. Apparently "$1"x != x works differently in bash 4.2
regsub { .*$} $infoline {} current_revnum
#gen_log:log D "current_revnum $current_revnum"
if {! [info exists current_revnum]} {
gen_log:log E "Warning: couldn't find current revision number!"
}
$branchwin.view configure -state normal \
-command [namespace code {
set rev [EitherOrHead]
git_fileview $rev $cvsglb(relpath) "$filename"
}]
$branchwin.log configure \
-command [namespace code {
set rev [EitherOrHead]
git_log_rev $rev "$filename"
}]
$branchwin.annotate configure -state normal \
-command [namespace code {
set rev [EitherOrHead]
git_annotate_r $rev "$filename"
}]
$branchwin.diff configure \
-command [namespace code {
set revA [$branchwin.up.revA_rvers get]
set revB [$branchwin.up.revB_rvers get]
if {$revA eq "" || $revB eq ""} {
set rev [EitherOrHead]
comparediff_r $rev "" $branchwin $filename
} else {
comparediff_r $revA $revB $branchwin $filename
}
}]
$branchwin.patchdiff configure -state normal \
-command [namespace code {
set revA [$branchwin.up.revA_rvers get]
set revB [$branchwin.up.revB_rvers get]
git_patch "$filename" $revA $revB
}]
$branchwin.ddiff configure -state normal \
-command [namespace code {
set rev [EitherOrHead]
git_show $rev
}]
$branchwin.merge configure -state disabled
$branchwin.viewtags configure -state normal \
-command {git_list_tags}
if {[file isdirectory $fname]} {
$branchwin.view configure -state disabled
$branchwin.annotate configure -state disabled
$branchwin.diff configure -state disabled
$branchwin.patchdiff configure -state disabled
$branchwin.merge configure -state disabled
}
}
"RCS" {
$branchwin.up.bmodbrowse configure -command modbrowse_run \
-image Modules -state normal
$branchwin.up.lfname configure -text "RCS file"
$branchwin.up.rfname configure -state normal
$branchwin.up.rfname delete 0 end
$branchwin.up.rfname insert end "$fname"
$branchwin.up.rfname configure -state readonly
$branchwin.view configure \
-command [namespace code {
set revA [$branchwin.up.revA_rvers get]
set revB [$branchwin.up.revB_rvers get]
if {$revA ne ""} {
set rev $revA
} elseif {$revB ne ""} {
set rev $revB
} else {
set rev ""
}
rcs_fileview_checkout $rev $filename
}]
$branchwin.log configure -state normal \
-command [namespace code {
set revA [$branchwin.up.revA_rvers get]
set revB [$branchwin.up.revB_rvers get]
if {$revA ne ""} {
set rev $revA
} elseif {$revB ne ""} {
set rev $revB
} else {
set rev ""
}
rcs_log_rev $rev $filename
}]
$branchwin.annotate configure -state disabled
$branchwin.diff configure -state normal \
-command [namespace code {
set revA [$branchwin.up.revA_rvers get]
set revB [$branchwin.up.revB_rvers get]
if {$revA eq "" || $revB eq ""} {
set rev [EitherOrHead]
comparediff_r $rev "" $branchwin $filename
} else {
comparediff_r $revA $revB $branchwin $filename
}
}]
$branchwin.merge configure -state disabled
}
}
}
# Pop up a transient window with a listbox of the tags for a specific
# revision
proc PopupTags { x y } {
global colorglb
set branchwin [namespace inscope [namespace current] {set branchwin}]
variable revtags
gen_log:log T "ENTER ($x $y)"
# We tagged the "more..." text with R$revision
foreach tag [$branchwin.canvas gettags current] {
if {[string index $tag 0] == {R}} {
set rev [string range $tag 1 end]
lassign [$branchwin.canvas coords $tag] rev_x rev_y
gen_log:log D "item $tag coords: $rev_x $rev_y"
break
}
}
set mname "$branchwin.canvas.[join [split $rev {.}] {_}]"
set ntags [llength $revtags($rev)]
incr ntags
if {$ntags > 20} {set ntags 20}
set line_h [font metrics $colorglb(listboxfont) -displayof $branchwin -linespace]
gen_log:log D "line height: $line_h"
set h [expr {$ntags * $line_h}]
gen_log:log D "height for $ntags tags: $h"
incr h $line_h
set maxlen 0
foreach t $revtags($rev) {
set len [string length $t]
if {$len > $maxlen} {
set maxlen $len
set maxtag $t
}
}
set maxtag "mm$maxtag"
set w [font measure $colorglb(listboxfont) -displayof $branchwin "$maxtag"]
if {! [winfo exists $mname]} {
gen_log:log D "width from $maxtag: $w"
frame $mname -relief raised -bd 2 -bg $colorglb(hlbg)
listbox $mname.lbx -font $colorglb(listboxfont) \
-yscrollcommand "$mname.yscr set" \
-listvariable [namespace current]::revtags($rev)
ttk::scrollbar $mname.yscr -orient vertical -command "$mname.lbx yview"
frame $mname.bot
button $mname.but -text "Close" -command "$branchwin.canvas delete lbx"
button $mname.arr -image arr_dn -command [namespace code "sort_tag_lbx $mname"]
incr w [winfo reqwidth $mname.yscr]
incr h [winfo reqheight $mname.but]
$branchwin.canvas create window $rev_x $rev_y -anchor w \
-height $h -width $w -window $mname -tags lbx
pack $mname.bot -in $mname -side bottom -expand 0 -fill x
pack $mname.arr -in $mname.bot -side left -anchor w
pack $mname.but -in $mname.bot -side right -anchor e -ipady 0
pack $mname.yscr -in $mname -side right -fill y
pack $mname.lbx -in $mname -side left -expand yes -fill both
bind $mname.lbx [namespace code "
variable revtags
set i \[$mname.lbx nearest %y\]
SetSelection A \[lindex \$revtags($rev) \$i\] $rev
$mname.lbx selection clear 0 end
$mname.lbx selection set \$i"]
bind $mname.lbx [namespace code "
variable revtags
set i \[$mname.lbx nearest %y\]
SetSelection A \[lindex \$revtags($rev) \$i\] $rev
$mname.lbx selection clear 0 end
$mname.lbx selection set \$i"]
bind $mname.lbx [namespace code "
variable revtags
set i \[$mname.lbx nearest %y\]
SetSelection B \[lindex \$revtags($rev) \$i\] $rev
$mname.lbx selection clear 0 end
$mname.lbx selection set \$i"]
} else {
gen_log:log D "$mname already exists"
$branchwin.canvas create window $rev_x $rev_y -anchor w \
-height $h -width $w -window $mname -tags lbx
}
gen_log:log T "LEAVE"
return
}
# Sort the tags popup listbox
proc sort_tag_lbx {mname} {
set arr [$mname.arr cget -image]
set tagvar [$mname.lbx cget -listvar]
set taglist [set [$mname.lbx cget -listvar]]
if {$arr eq {arr_up}} {
set direction "-decreasing"
$mname.arr configure -image "arr_dn"
} else {
set direction "-increasing"
$mname.arr configure -image "arr_up"
}
set new_taglist [lsort -dictionary $direction $taglist]
$mname.lbx delete 0 end
foreach t $new_taglist {
$mname.lbx insert end $t
}
}
# Calculate size of the You are Here box
proc CalcCurrent { revision } {
variable curr
variable font_bold
variable font_bold_h
set branchwin [namespace inscope [namespace current] {set branchwin}]
#gen_log:log T "ENTER ($revision)"
set redbox_width \
[expr {[image width Man] \
+ $curr(padx) \
+ [font measure $font_bold \
-displayof $branchwin.canvas {You are}] \
+ $curr(padx,2)}]
set redbox_height [image height Man]
set h [expr {2 * $font_bold_h}]
if {$h > $redbox_height} {
set redbox_height $h
}
incr redbox_height $curr(pady,2)
#gen_log:log T "LEAVE box sixe ($redbox_width x $redbox_height)"
return [list $redbox_width $redbox_height]
}
# Draw You are Here box
proc DrawCurrent { x y width height revision } {
variable curr
variable revstate
variable font_bold
variable curr_x
variable curr_y
set branchwin [namespace inscope [namespace current] {set branchwin}]
#gen_log:log T "ENTER ($x $y $width $height $revision)"
set curr_x $x
set curr_y $y
# draw the box
set tx [expr {$x + $width}]
set ty [expr {$y - $height}]
$branchwin.canvas create rectangle \
$x $y $tx $ty \
-width $curr(width) -fill gray90 -outline red3
if {[info exists revstate(current)]} {
if {$revstate(current) == {dead}} {
$branchwin.canvas create line \
$x $y $tx $ty -fill red -width $curr(width)
$branchwin.canvas create line \
$tx $y $x $ty -fill red -width $curr(width)
}
}
set pad \
[expr {($width - [image width Man] - \
[font measure $font_bold -displayof $branchwin.canvas {You are}]) \
/ 3}]
set ty [expr {$y - [expr {$height/2}]}]
# add the contents
$branchwin.canvas create image \
[expr {$x + $pad}] $ty \
-image Man -anchor w
$branchwin.canvas create text \
[expr {$x + $width - $pad}] $ty \
-text "You are\nhere" -anchor e \
-fill red3 \
-font $font_bold
#gen_log:log T "LEAVE ()"
return
}
# Finds the dimensions including tags, but not the location, for the blue
# root box. That (tags on the root) can only happen in CVS, I think
proc CalcRoot { root_rev } {
global cvscfg
upvar ::logcfg logcfg
variable curr
variable box_height
variable font_bold
variable font_norm
variable font_norm_h
variable root_info
variable revtags
variable revbtags
variable tlist
set branchwin [namespace inscope [namespace current] {set branchwin}]
#gen_log:log T "ENTER ($root_rev)"
set height $box_height
set root_width 0
set tag_width 0
set tlist($root_rev) ""
if {[info exists revtags($root_rev)]} {
# We want to show all the coloured tags plus others to take
# the total to at least cvscfg(tagdepth)
set tag_colour ""
set tag_black ""
foreach tag $revtags($root_rev) {
if {[info exists cvscfg(tagcolour,$tag)]} {
lappend tag_colour $tag
} else {
lappend tag_black $tag
}
}
set tlist($root_rev) [concat $tag_colour $tag_black]
if {$logcfg(show_tags)} {
if {[info exists cvscfg(tagdepth)] && $cvscfg(tagdepth) != 0} {
set n [expr {$cvscfg(tagdepth) - [llength $tag_colour]}]
if {$n < [llength $tag_black]} {
set tag_black [concat [lrange $tag_black 0 [expr {$n-1}]] {more...}]
}
}
set my_font $font_bold
foreach tag $tlist($root_rev) {
set w [font measure $my_font -displayof $branchwin.canvas $tag]
if {$w > $tag_width} {
set tag_width $w
}
}
incr tag_width $curr(tspcb,2)
set h [expr {[llength $tlist($root_rev)] * $font_norm_h}]
if {$h > $height} {
set height $h
}
}
}
if {![info exists revbtags($root_rev)]} {set revbtags($root_rev) {}}
foreach s [subst $root_info] {
set w [font measure $font_norm -displayof $branchwin.canvas " $s "]
if {$w > $root_width} {
set root_width $w
}
}
incr width $curr(padx,2)
set height [expr {$curr(pady,2) + \
[llength [subst $root_info]] * $font_norm_h}]
gen_log:log T "LEAVE (tag_width $tag_width root_width $root_width height $height)"
return [list $tag_width $root_width $height]
}
proc DrawRoot { x y rbox_width rbox_height cur_rev root_rev } {
variable curr
variable font_norm
variable font_norm_h
variable font_bold
variable root_info
variable revbtags
variable revbranches
variable tlist
set branchwin [namespace inscope [namespace current] {set branchwin}]
#gen_log:log T "ENTER ($x $y $rbox_width $rbox_height $cur_rev $root_rev)"
if {[info exists revbtags($root_rev)]} {
#gen_log:log D "revbtags($root_rev) $revbtags($root_rev)"
gen_log:log D "Drawing root for $revbtags($root_rev) $root_rev"
} else {
gen_log:log D "Drawing nameless root for $root_rev"
set revbtags() ""
}
# draw the box
$branchwin.canvas create rectangle \
$x $y \
[expr {$x + $rbox_width}] [expr {$y - $rbox_height}] \
-width $curr(width) \
-tags box \
-fill gray90 -outline blue
set tx [expr {$x + $rbox_width/2}]
set ty [expr {$y - $curr(pady)}]
#gen_log:log D "[subst $root_info]"
foreach s [subst $root_info] {
$branchwin.canvas create text \
$tx $ty \
-text $s \
-anchor s \
-font $font_norm -fill navy \
-tags "R$root_rev"
incr ty -$font_norm_h
}
#gen_log:log T "LEAVE ()"
return
}
# Finds the dimensions including tags, but not the location, of each revision box
proc CalcRevision { revision } {
global cvscfg
global cvsglb
upvar ::logcfg logcfg
variable in_git
variable curr
variable box_height
variable rev_info
variable revdate
variable revtime
variable revwho
variable font_norm
variable font_norm_h
variable font_bold
variable revtags
variable revbtags
variable tlist
variable btlist
set branchwin [namespace inscope [namespace current] {set branchwin}]
#gen_log:log T "ENTER ($revision)"
set height $box_height
set width 0
set tag_width 0
set tlist($revision) ""
if {[info exists revtags($revision)]} {
# We want to show all the coloured tags plus others to take
# the total to at least cvscfg(tagdepth)
set tag_colour ""
set tag_black ""
foreach tag $revtags($revision) {
if {[info exists cvscfg(tagcolour,$tag)]} {
lappend tag_colour $tag
} else {
lappend tag_black $tag
}
}
if {[info exists cvscfg(tagdepth)] && $cvscfg(tagdepth) != 0} {
set n [expr {$cvscfg(tagdepth) - [llength $tag_colour]}]
if {$n < [llength $tag_black]} {
set tag_black [concat [lrange $tag_black 0 [expr {$n-1}]] {more...}]
}
}
set tlist($revision) [concat $tag_colour $tag_black]
if {$logcfg(show_tags)} {
foreach tag $tlist($revision) {
if {$tag == {more...}} {
set my_font $font_bold
} else {
set my_font $font_norm
}
set w [font measure $my_font -displayof $branchwin.canvas $tag]
if {$w > $tag_width} {
set tag_width $w
}
}
incr tag_width $curr(tspcb,2)
set h [expr {[llength $tlist($revision)] * $font_norm_h}]
if {$h > $height} {
set height $h
}
}
}
if {$in_git && $logcfg(show_tags) && (! $logcfg(show_branches) || $cvsglb(lightning))} {
# If show_branches is off but we're in git, it doesn't cost anything to
# get branch tags, so we can show them like tags
set btlist($revision) ""
set btag_colour ""
set btag_black ""
if {[info exists revbtags($revision)]} {
foreach btag $revbtags($revision) {
lappend btag_colour $btag
}
if {[info exists cvscfg(tagdepth)] && $cvscfg(tagdepth) != 0} {
set n [expr {$cvscfg(tagdepth) - [llength $btag_colour]}]
if {$n < [llength $btag_black]} {
set btag_black [concat [lrange $btag_black 0 [expr {$n-1}]] {more...}]
}
}
set btlist($revision) [concat $btag_colour $btag_black]
set my_font $font_bold
foreach rbt $revbtags($revision) {
set w [font measure $my_font -displayof $branchwin.canvas $rbt]
if {$w > $tag_width} {
set tag_width $w
}
}
incr tag_width $curr(tspcb,2)
set h [expr {[llength $btlist($revision)] * $font_norm_h}]
if {$h > $height} {
set height $h
}
}
}
if {![info exists revtime($revision)]} {set revtime($revision) {}}
if {![info exists revdate($revision)]} {set revdate($revision) {}}
if {![info exists revinfo($revision)]} {set revinfo($revision) {}}
if {![info exists revwho($revision)]} {set revwho($revision) {}}
foreach s [subst $rev_info] {
set w [font measure $font_norm -displayof $branchwin.canvas $s]
if {$w > $width} {
set width $w
}
}
incr width $curr(padx,2)
#gen_log:log T "LEAVE (tag_width $tag_width width $width height $height)"
return [list $tag_width $width $height]
}
proc DrawRevision { x y width height revision} {
global cvscfg
global cvsglb
upvar ::logcfg logcfg
variable in_git
global colorglb
variable curr
variable rev_info
variable revdate
variable revtime
variable revwho
variable revstate
variable revkind
variable revtags
variable revbtags
variable font_norm
variable font_norm_h
variable font_bold
variable btlist
variable tlist
variable match
variable fromtags
variable totags
variable xyw
variable boxwidth
variable fromprefix
variable toprefix
variable mrev
variable drawn_revs
upvar branch branch
set branchwin [namespace inscope [namespace current] {set branchwin}]
#gen_log:log T "ENTER ($x $y $width $height $revision)"
if {! [info exists drawn_revs]} {
set drawn_revs ""
}
if {{$branch,$revision} in $drawn_revs} {
gen_log:log E "$revision is already drawn!"
return
}
set xyw($revision) [list $x [expr {$y - ($height / 4)}] $width ]
# Draw the list of tags
set tx [expr {$x - $curr(tspcb)}]
set ty $y
set revbtag $revbtags($branch)
if {$in_git && $logcfg(show_tags) && (! $logcfg(show_branches) || $cvsglb(lightning))} {
# This is a git-only thing. Treat branches as tags
foreach btag $btlist($revision) {
gen_log:log D "$revision: btag $btag"
set my_font $font_bold
set btagcolour blue
set btaglist ""
if {$btag == {more...}} {
set my_font $font_bold
set btaglist [list R$revision tag active]
set tagcolour $cvscfg(tagcolour,$btag)
}
$branchwin.canvas create text \
$tx $ty \
-text $btag \
-anchor se -fill $btagcolour \
-font $my_font \
-tags $btaglist
incr ty -$font_norm_h
}
}
foreach tag $tlist($revision) {
gen_log:log D "$revision: tag $tag"
if {[string match "${fromprefix}_*" $tag]} {
set mrev($tag) $revision
lappend fromtags $tag
regsub {.*_(.*$)} $tag {\1} tagend
gen_log:log D " $tag is a FROM TAG"
gen_log:log D " will need a TO TAG ${toprefix}_${revbtag}_$tagend"
set match($tag) ${toprefix}_${revbtag}_$tagend
}
if {[string match "${toprefix}_*" $tag]} {
set mrev($tag) $revision
lappend totags $tag
}
if {$logcfg(show_tags)} {
set my_font $font_norm
set tagcolour $colorglb(canvfg)
set taglist ""
if {$tag == {more...}} {
set my_font $font_bold
set taglist [list R$revision tag active]
} elseif {[info exists cvscfg(tagcolour,$tag)]} {
set tagcolour $cvscfg(tagcolour,$tag)
}
$branchwin.canvas create text \
$tx $ty \
-text $tag \
-anchor se -fill $tagcolour \
-font $my_font \
-tags $taglist
incr ty -$font_norm_h
}
}
# draw the box...
set tx [expr {$x + $width}]
set ty [expr {$y - $height}]
$branchwin.canvas create rectangle \
$x $y $tx $ty \
-width $curr(width) -fill gray90 -outline black \
-tags [list box selectable R$revision rect$revision active]
# ...and add the contents
if {[info exists revstate($revision)]} {
if {$revstate($revision) == {dead}} {
# in CVS, a "dead" revision, which is often present if a file was
# added on a branch
$branchwin.canvas create line \
$x $y $tx $ty -fill red -width $curr(width)
$branchwin.canvas create line \
$tx $y $x $ty -fill red -width $curr(width)
} elseif {$revstate($revision) == {ghost}} {
# In GIT, a similar thing happens if a file was added on a branch.
# It's not dead, it's just not reachable from the current branch.
$branchwin.canvas create line \
$x $y $tx $ty -fill gray -width $curr(width)
$branchwin.canvas create line \
$tx $y $x $ty -fill gray -width $curr(width)
}
}
set tx [expr {$x + $width/2}]
set ty [expr {$y - $curr(pady)}]
foreach s [subst $rev_info] {
$branchwin.canvas create text \
$tx $ty \
-text $s \
-anchor s \
-font $font_norm \
-fill black \
-tags [list selectable R$revision active]
incr ty -$font_norm_h
}
lappend drawn_revs $branch,$revision
#gen_log:log T "LEAVE ()"
return
}
proc DrawBranch { x y root_rev branch } {
global cvsglb
global colorglb
upvar ::logcfg logcfg
upvar ::ingit in_git
variable curr
variable box_height
variable bot_height
variable tip_height
variable lbl_height
variable cur_height
variable revkind
variable branchrevs
variable revbranches
variable revbtags
variable drawn_revs
set branchwin [namespace inscope [namespace current] {set branchwin}]
gen_log:log T "ENTER ($x $y $root_rev $branch)"
gen_log:log T "level [info level]"
if {! [info exists drawn_revs]} {
set drawn_revs ""
}
if {[info exists revbtags($branch)]} {
gen_log:log D "Drawing $revbtags($branch) $branch rooted at $root_rev ($x $y)"
} else {
gen_log:log D "Drawing nameless branch rooted at $root_rev ($x $y)"
}
# What revisions to show on this branch? Options may hide some
if {![info exists branchrevs($branch)]} {set branchrevs($branch) {}}
foreach r $drawn_revs {
if {$r in $branchrevs($branch)} {
gen_log:log E "Revision $r already drawn!"
return [list $x $y 200 18 $y]
}
}
if {$branchrevs($branch) == {}} {
set revlist ""
} else {
# Always have the head revision
set revlist [lindex $branchrevs($branch) 0]
foreach r [lrange $branchrevs($branch) 1 end-1] {
if {![info exists revbranches($r)]} {set revbranches($r) {}}
if {$logcfg(show_inter_revs) || $logcfg(show_empty_branches) \
&& $revbranches($r) != {}} {
lappend revlist $r
} else {
# Only if there are non-empty branches off this revision
foreach b $revbranches($r) {
if {![info exists branchrevs($b)]} {set branchrevs($b) {}}
if {$branchrevs($b) != {}} {
lappend revlist $r
break
}
}
}
}
if {[llength $branchrevs($branch)] > 1} {
# Always have the first revision on a branch
lappend revlist [lindex $branchrevs($branch) end]
}
}
# Work out width and height of this limb, saving sizes of revisions
set tag_width 0
set rdata ""
# On encountering a branch, it may be just a You are Here, which
# has a simplified special procedure. Otherwise, kick off a new
# branch.
if {$branch == {current}} {
set rtw 0
lassign [CalcCurrent $branch] box_width cur_height
set lbl_height(current) $cur_height
} else {
lassign [CalcRoot $branch] rtw box_width bot_height
set tip_height 0
if {$in_git} {
set tip_height $bot_height
set bot_height 0
}
set lbl_height($branch) $bot_height
gen_log:log D "set lbl_height($branch) ($lbl_height($branch))"
#set tip_height $lbl_height($branch)
if {$rtw > $tag_width} {
set tag_width $rtw
}
}
set height [expr {$lbl_height($branch) + $curr(spcy)}]
# calculate the size of each revision in the branch, and keep
# track of the largest x and y dimensions, which we will use
# for all when drawing
set rev_height 0
foreach revision $revlist {
if {$revision == {current}} {
set rtw 0
lassign [CalcCurrent $revision] rbw cur_height
set lbl_height(current) $cur_height
} else {
lassign [CalcRevision $revision] rtw rbw rev_height
}
if {$rev_height != 0} {
set rh $rev_height
} else {
set rh $cur_height
}
lappend rdata $rtw $rh
if {$rtw > $tag_width} {
set tag_width $rtw
}
if {$rbw > $box_width} {
set box_width $rbw
}
incr height $curr(spcy)
incr height $rh
}
# At the end, we've saved the height and width of the whole column
# Position branch. Query the canvas to look for overlaps, using the
# lower-left x and y that were passed in, and the measured width and
# accumulated height. Use tk's canvas overlap command to find and tag
# any overlapping objects within the rectangle. We haven't drawn
# anything yet, this is still just in memory
# Look for overlap horizontally
while {1} {
set overlap_llx [expr {$x - $curr(spcx)}]
set overlap_lly [expr {$y - $height + $curr(yfudge)}]
set overlap_urx [expr {$x + $tag_width + $box_width}]
set overlap_ury $y
$branchwin.canvas addtag ol_x overlapping \
$overlap_llx $overlap_lly $overlap_urx $overlap_ury
set bbox [$branchwin.canvas bbox ol_x]
$branchwin.canvas dtag ol_x
if {$bbox == {}} {
break
}
gen_log:log D "horizontal overlap with $bbox"
# Move branch to rightmost point of overlapped objects plus some space
# N.B. +1 because exactly equal counts as an overlap
set x [expr {[lindex $bbox 2] + $curr(spcx) + 1}]
}
# Look for overlap vertically
set overlap_llx $x
set overlap_lly [expr {$y - $height}]
set overlap_urx [expr {$x + $tag_width + $box_width}]
set overlap_ury [expr {$y - $height + $curr(yfudge)}]
$branchwin.canvas addtag ol_y overlapping \
$overlap_llx $overlap_lly $overlap_urx $overlap_ury
set bbox [$branchwin.canvas bbox ol_y]
$branchwin.canvas dtag ol_y
if {$bbox != {}} {
# Move down to make space
gen_log:log D "vertical overlap with $bbox"
incr y [expr {[lindex $bbox 3] - ($y - $height) + $curr(spcy) + $tip_height}]
}
# Now we're ready to start drawing
# Position to top of branch
incr x $tag_width
set top_y $y
incr y -$height
# Draw this branch
set midx [expr {$x + $box_width/2}]
set last_y ""
foreach revision $revlist {rtag_width rheight} $rdata {
incr y $curr(spcy)
incr y $rheight
# For each branch off this revision, draw it to the right of this
# revision box and a little above the centre line of this box.
set x2 [expr {$x + $box_width + $curr(spcx)}]
set y2 [expr {$y - $box_height/2 - $curr(boff)}]
set brevs ""
set bxys ""
if {[info exists revbranches($revision)]} {
# Here we recurse into branches off of the current branch
foreach r2 $revbranches($revision) {
if {![info exists branchrevs($r2)] } { set branchrevs($r2) {} }
# Don't display the branch if it is empty unless
# logcfg(show_empty_branches) is set. Except for You are Here,
# which is a special case
if {$branchrevs($r2) == {} && $r2 != {current} && !\
$logcfg(show_empty_branches)} {
continue
}
lappend brevs $r2
foreach {lx y2 lbw rh lly} [DrawBranch $x2 $y2 $revision $r2] {
lappend bxys $lx $lbw $rh $lly
break
}
set x2 [expr {$lx + $lbw + $curr(spcx)}]
}
}
# y2 may have changed to accomodate a long branch. If so we need
# to figure out what our y should be
set y [expr {$y2 + $box_height/2 + $curr(boff)}]
set rx [expr {$x + $box_width}]
set ry [expr {$y - $box_height/2}]
set by [expr {$ry - $curr(boff)}]
# If it has brevs, it's the root of a branch
# Draw the arrows before the boxes, leaving box-high spaces between them
foreach b $brevs {bx bw rh ly} $bxys {
set mx [expr {$bx + $bw/2}]
if {$ly != {} && ! $in_git} {
# The up-pointing arrow below the bottom revision, if that has been raised
$branchwin.canvas create line \
$mx $ly $mx [expr {$by - $rh}] \
-fill $colorglb(canvfg) \
-arrow first -arrowshape $curr(arrowshape) -width $curr(width)
}
if {$in_git && $ly != {}} {
set ny [expr {$ly + $curr(boff)}]
if {$ny != $by} {
# The up-pointing arrow below the bottom revision, if that has been raised
$branchwin.canvas create line \
$mx $ly $mx [expr {$by - $curr(boff)}] \
-fill $colorglb(canvfg) \
-arrow first -arrowshape $curr(arrowshape) -width 1
}
}
if {$b == {current}} {
# treat this "current" as a branch. The arrow points sideways to it
DrawCurrent $bx $by $bw $cur_height $revision
$branchwin.canvas lower [ \
$branchwin.canvas create line \
$rx $ry $mx $ry $mx $by \
-fill $colorglb(canvfg) \
-arrow last -arrowshape $curr(arrowshape) -width $curr(width)
]
# And we're done, no arrows or boxes above it
continue
} else {
# if the last (top) revision is current, we don't draw that one now.
# We save it for when we draw the regular revboxes, below
set last_rev [lindex $branchrevs($b) 0]
if {$last_rev == {current}} {
set last_rev [lindex $branchrevs($b) 1]
}
}
if {!$in_git } {
# The blue box at the base of each branch
DrawRoot $bx $by $bw $lbl_height($b) $revision $b
#if {$ly == {} } {
#$branchwin.canvas create line \
#$mx [expr {$by - $rh}] $mx [expr {$by - $rh - $curr(boff)}] \
#-arrow last -arrowshape $curr(arrowshape) \
#-width $curr(width) -fill brown
#}
}
# Arrow connecting the branch root box to its parent
if {$in_git} {
# Curved line.
#set ay [expr {$by - $tip_height - $curr(boff)}]
set ay [expr {$by - $curr(boff)}]
$branchwin.canvas lower [ \
$branchwin.canvas create line \
$rx $ry $mx $ry $mx $ay \
-fill $colorglb(canvfg) \
-arrow last -arrowshape $curr(arrowshape) -smooth 1
]
} else {
# Blue elbow
$branchwin.canvas lower [ \
$branchwin.canvas create line \
$rx $ry $mx $ry $mx $by \
-arrow last -arrowshape $curr(arrowshape) -width $curr(width) \
-fill blue
]
}
if {$logcfg(update_drawing) < 1} {
UpdateBndBox
}
}
# finised drawing special items for sub-branches
if {$last_y != {}} {
# This is a regular between-revisions arrow
$branchwin.canvas create line \
$midx $last_y $midx [expr {$y - $box_height}] \
-fill $colorglb(canvfg) \
-arrow first -arrowshape $curr(arrowshape) -width $curr(width)
}
# Start drawing the boxes.
# First, the top one may well be "current" which is
# a special case.
if {$revision == {current}} {
DrawCurrent $x $y $box_width $rheight $revision
} else {
# Otherwise, draw normal revision
DrawRevision $x $y $box_width $rheight $revision
}
if {$logcfg(update_drawing) < 1} {
UpdateBndBox
}
set last_y $y
set last_rev $revision
}
# Finished individual revisions and their branches
if {$in_git && ! $cvsglb(lightning)} {
# For Git, now we draw the root box at the top
lassign [CalcRoot $branch] rtw ignore bot_height
if {$last_y != {} } {
set gy [expr {$top_y - $height}]
DrawRoot [expr {$midx - ($box_width/2)}] $gy $box_width $bot_height [lindex $branchrevs($branch) end] $branch
$branchwin.canvas lower [ \
$branchwin.canvas create line \
$midx $gy $midx [expr {$gy + $curr(spcy)}] \
-fill blue \
-arrow first -arrowshape $curr(arrowshape) -width $curr(width)
]
}
}
if {$logcfg(update_drawing) < 2} {
UpdateBndBox
}
set new_y [expr {$y + $lbl_height($branch) + $curr(spcy)}]
gen_log:log T "LEAVE ($x $new_y $box_width $lbl_height($branch) $last_y)"
return [list $x $new_y $box_width $lbl_height($branch) $last_y]
}
proc DrawSideTree { x y root_rev } {
variable in_git
global colorglb
variable curr
variable lbl_height
variable branchrevs
variable revmergefrom
variable xyw
set branchwin [namespace inscope [namespace current] {set branchwin}]
gen_log:log T "ENTER: ($x $y $root_rev)"
gen_log:log D "Drawing SideTree branch at $root_rev"
foreach {lx y2 lbw rh lly} [DrawBranch $x $y $root_rev $root_rev] {
lappend bxys $lx $lbw $rh $lly
break
}
gen_log:log D "Drawing root for $root_rev SideTree"
lassign [CalcRoot $root_rev] rtw box_width box_height
set x2 [expr {$lx + $lbw + $curr(spcx)}]
set mx [expr {$lx + $lbw/2}]
set ry [expr {$y2 - $rh/4 - $curr(spcy)}]
set by [expr {$y2 - $curr(boff)}]
lassign [CalcRoot $root_rev] rtw box_width ignore
if {! $in_git } {
# This is the blue box at the bottom of the side branch for a rootless tree
DrawRoot $lx $y2 $lbw $lbl_height($root_rev) $root_rev $root_rev
# This is the arrow at the base of the side branch
$branchwin.canvas lower [\
$branchwin.canvas create line \
$mx $ry $mx [expr {$by - $rh}] \
-fill $colorglb(canvfg) \
-arrow last -arrowshape $curr(arrowshape) \
-width $curr(width)
]
}
# See if any merges were from this branch back to one we've already drawn
foreach to [array names revmergefrom] {
if {$revmergefrom($to) ni $branchrevs($root_rev)} continue
#gen_log:log D "revmergefrom($to) $revmergefrom($to)"
set from $revmergefrom($to)
if {[info exists xyw($from)]} {
#gen_log:log D " xyw($from) $xyw($from)"
} else {
#gen_log:log D " xyw($from) doesn't exist"
continue
}
if {[info exists xyw($to)]} {
gen_log:log D " xyw($to) $xyw($to)"
} else {
#gen_log:log D " xyw($to) doesn't exist"
continue
}
set xto [lindex $xyw($from) 0]
set yto [lindex $xyw($from) 1]
set bwto [lindex $xyw($from) 2]
set xfrom [lindex $xyw($to) 0]
set yfrom [lindex $xyw($to) 1]
set bwfrom [lindex $xyw($to) 2]
set xmid $xto
set ymid $yto
if {$xto > $xfrom} {
set xfrom [expr {$xfrom + $bwfrom}]
set yfrom [expr {$yfrom - ($box_height / 2)}]
set yto [expr {$yto - ($box_height / 2)}]
set xmid [expr {$xfrom + (($xto - $xfrom) / 2)}]
set ymid [expr {$yto - $box_height}]
} elseif {$xfrom > $xto} {
set xto [expr {$xto + $bwto}]
set xmid [expr {$xto + (($xfrom - $xto) / 2)}]
set ymid [expr {$yto + ($box_height / 2)}]
} elseif {$xto == $xfrom} {
set xmid [expr {$xto - ($bwfrom / 2)}]
set ymid [expr {$yfrom - (($yfrom - $yto) / 2)}]
}
$branchwin.canvas create line \
$xfrom $yfrom $xmid $ymid $xto $yto \
-fill $colorglb(canvfg) \
-arrow first -smooth 1
}
UpdateBndBox
gen_log:log T "LEAVE"
return $x2
}
proc UpdateBndBox {} {
variable in_git
variable font_bold
variable view_xoff
variable view_yoff
variable curr_x
variable curr_y
set branchwin [namespace inscope [namespace current] {set branchwin}]
#gen_log:log T "ENTER ()"
lassign [$branchwin.canvas bbox all] x1 y1 x2 y2
if {$x1 == ""} {
gen_log:log D "No BBOX"
return
}
if {! $in_git} {
$branchwin.canvas configure \
-scrollregion [list \
[expr {$x1 - 5}] [expr {$y1 - 5}] \
[expr {$x2 + 5}] [expr {$y2 + 5}]
]
} else {
# In git, we may have merge arrows to the left of the first column.
# tk doesn't include these in the bounding box, for some reason
$branchwin.canvas configure \
-scrollregion [list \
[expr {$x1 - 25}] [expr {$y1 - 5}] \
[expr {$x2 + 5}] [expr {$y2 + 5}]
]
}
if {[info exists curr_x]} {
set bbox [$branchwin.canvas bbox all]
set llx [lindex $bbox 0]
set lly [lindex $bbox 1]
set urx [lindex $bbox 2]
set ury [lindex $bbox 3]
set bbox_width [expr {$urx - $llx}]
set bbox_height [expr {$ury - $lly}]
gen_log:log D "diagram bbox: $bbox_width x $bbox_height"
set xvw [$branchwin.canvas xview]
set yvw [$branchwin.canvas yview]
set xvl_frac [lindex $xvw 0]
set xvr_frac [lindex $xvw 1]
set yvt_frac [lindex $yvw 0]
set yvb_frac [lindex $yvw 1]
set canvas_l [expr {int($bbox_width * $xvl_frac)}]
set canvas_r [expr {int($bbox_width * $xvr_frac)}]
set canvas_t [expr {int($bbox_height * $yvt_frac)}]
set canvas_b [expr {int($bbox_height * $yvb_frac)}]
set canv_width [expr {$canvas_r - $canvas_l}]
set canv_height [expr {$canvas_b - $canvas_t}]
gen_log:log D "canvas xrange $canvas_l $canvas_r ($canv_width)"
gen_log:log D "canvas yrange $canvas_b $canvas_t ($canv_height)"
gen_log:log D "calculated canvas: $canv_width x $canv_height"
set view_y -$canv_height
if {$curr_x > $canv_width} {
set dist_x [expr {$curr_x - $canv_width/2}]
set dist_x [expr {$dist_x - 3 * [font measure $font_bold \
-displayof $branchwin.canvas {You are}]}]
#gen_log:log D "positioning x: new x $dist_x"
} else {
#gen_log:log D "not re-positioning x"
set dist_x 0
}
#gen_log:log D "y: (curr_y $curr_y) (view_y $view_y)"
if {$curr_y < $view_y} {
set dist_y [expr {$curr_y - $lly}]
#gen_log:log D " $curr_y is $dist_y pixels from the top"
set dist_y [expr {$dist_y - 2 * [image height Man]}]
#gen_log:log D "positioning y: new y $dist_y"
} else {
#gen_log:log D "not re-positioning y"
set dist_y 0
}
# Multiplying by 1.0 keeps it from being rounded to an int
set x_proportion [expr {($dist_x * 1.0) / ($bbox_width * 1.0)}]
set view_xoff $x_proportion
set y_proportion [expr {($dist_y * 1.0) / ($bbox_height * 1.0)}]
set view_yoff $y_proportion
}
#gen_log:log D "set offset $view_xoff $view_yoff"
$branchwin.canvas xview moveto $view_xoff
$branchwin.canvas yview moveto $view_yoff
update
#gen_log:log T "LEAVE ()"
return
}
proc DrawTree { {now {}} } {
global cvscfg
global colorglb
upvar ::logcfg logcfg
variable in_git
variable scope
variable after_id_draw
variable box_height
variable bot_height
variable tip_height
variable lbl_height
variable cur_height
variable root_info
variable fromtags {}
variable totags {}
variable toprefix
variable fromprefix
variable xyw
variable boxwidth
variable view_xoff
variable view_yoff
variable curr
variable rev_info
variable scale
variable font_norm
variable font_norm_h
variable font_bold
variable font_bold_h
variable sys
variable revwho
variable revdate
variable revtime
variable revcomment
variable revstate
variable revtags
variable revbtags
variable revpath
variable revkind
variable revbranches
variable revmergefrom
variable branchrevs
variable mrev
variable match
variable drawn_revs
set branchwin [namespace inscope [namespace current] {set branchwin}]
gen_log:log D "=================================="
gen_log:log T "ENTER ($now)"
catch {unset drawn_revs}
catch {unset xyw}
catch { unset revwho }
foreach a [array names $scope\::revwho] {
set revwho($a) [set $scope\::revwho($a)]
}
catch { unset revdate }
foreach a [array names $scope\::revdate] {
set revdate($a) [set $scope\::revdate($a)]
}
catch { unset revtime }
foreach a [array names $scope\::revtime] {
set revtime($a) [set $scope\::revtime($a)]
}
catch { unset revcomment }
foreach a [array names $scope\::revcomment] {
set revcomment($a) [set $scope\::revcomment($a)]
}
catch { unset revstate }
foreach a [array names $scope\::revstate] {
set revstate($a) [set $scope\::revstate($a)]
}
catch { unset revtags }
foreach a [array names $scope\::revtags] {
set revtags($a) [set $scope\::revtags($a)]
}
catch { unset revbtags }
foreach a [array names $scope\::revbtags] {
set revbtags($a) [set $scope\::revbtags($a)]
}
catch { unset revpath }
foreach a [array names $scope\::revpath] {
set revpath($a) [set $scope\::revpath($a)]
}
catch { unset revbranches }
foreach a [array names $scope\::revbranches] {
set revbranches($a) [set $scope\::revbranches($a)]
}
catch { unset revmergefrom }
foreach a [array names $scope\::revmergefrom] {
set revmergefrom($a) [set $scope\::revmergefrom($a)]
}
catch { unset revkind }
foreach a [array names $scope\::revkind] {
set revkind($a) [set $scope\::revkind($a)]
}
catch { unset branchrevs }
foreach a [array names $scope\::branchrevs] {
set branchrevs($a) [set $scope\::branchrevs($a)]
}
set totagbegin [string first "_BRANCH_" $cvscfg(mergetoformat) ]
set fromtagbegin [string first "_BRANCH_" $cvscfg(mergefromformat) ]
set fromprefix [string range $cvscfg(mergefromformat) 0 [expr {$fromtagbegin -1}]]
set toprefix [string range $cvscfg(mergetoformat) 0 [expr {$totagbegin - 1}]]
catch {after cancel $after_id_draw}
busy_start $branchwin
if {$now != {now} && [info exists logcfg(draw_delay)]} {
set after_id_draw \
[after $logcfg(draw_delay) [namespace code {DrawTree now}]]
} else {
set view_xoff [lindex [$branchwin.canvas xview] 0]
set view_yoff [lindex [$branchwin.canvas yview] 0]
$branchwin.canvas delete all
# These put the names of variables into one variable to be passed.
# Because they're in braces, we don't need to know about the
# variables here. But the proc they're evaluated in has to know
# about them.
set root_info ""
if {$logcfg(show_root_tags)} {
append root_info {$revbtags($root_rev) }
}
if {$logcfg(show_box_rev)} {
if {$sys eq "CVS" || $sys eq "RCS"} {
append root_info {$root_rev}
}
}
set rev_info ""
if {$logcfg(show_box_revtime)} {
append rev_info {$revtime($revision) }
}
if {$logcfg(show_box_revdate)} {
append rev_info {$revdate($revision) }
}
if {$logcfg(show_box_revwho)} {
append rev_info {"$revwho($revision)" }
}
if {$logcfg(show_box_rev)} {
append rev_info {$revision}
}
# Note: the boxes and tag lists are sized according to the font
# so do not need to be scaled.
set my_size [expr {round($logcfg(font_size) * $logcfg(scale))}]
set font_norm [font create \
-family Helvetica -size $my_size]
set font_norm_h [font metrics \
$font_norm -displayof $branchwin -linespace]
set font_bold [font create \
-family Helvetica -size $my_size -weight bold]
set font_bold_h [font metrics \
$font_bold -displayof $branchwin -linespace]
# Scale the layout constants
foreach x {spcx spcy yfudge boff} {
set curr($x) [expr {round($logcfg($x) * $font_norm_h * $logcfg(scale))}]
if {$curr($x) < 1} {
set curr($x) 1
}
}
foreach x {padx pady tspcb width} {
set curr($x) [expr {round($logcfg($x) * $logcfg(scale))}]
set curr($x,2) [expr {$curr($x) << 1}]
}
set curr(arrowshape) ""
foreach x $logcfg(arrowshape) {
lappend curr(arrowshape) [expr {$x * $logcfg(scale)}]
}
set box_height [expr {$curr(pady,2) + [llength $rev_info]*$font_norm_h}]
# Find the root. (needed for SVN and GIT). If there's a trunk, use that
foreach a [array names revkind] {
if {$revkind($a) == "root"} {
set trunkrev $a
break
}
}
# If there's no trunk, find the beginning of a branch
if {! [info exists trunkrev] || $trunkrev == ""} {
gen_log:log D "No trunk found!"
set min 999999
foreach a [array names revbtags] {
if {$a == "" } {continue}
foreach tag $revbtags($a) {
if {$revbtags($a) != {} } {
set rnum [string trimleft $a {r}]
if {$rnum < $min} {set min $rnum}
}
}
}
if {$min != 999999} {
set basebranch "r$min"
gen_log:log D "No trunk, starting with basebranch $basebranch"
}
}
# Start drawing, beginning with the trunk or the lowest branch
if {[info exists trunkrev] && $trunkrev != ""} {
gen_log:log D "Drawing trunkrev $trunkrev"
foreach {lx y2 lbw rh lly} [DrawBranch 0 0 {} $trunkrev] {
lappend bxys $lx $lbw $rh $lly
break
}
set x2 [expr {$lx + $lbw + $curr(spcx)}]
set mx [expr {$lx + $lbw/2}]
set ry [expr {$y2 - $rh/4 - $curr(spcy)}]
set by [expr {$y2 - $curr(boff)}]
lassign [CalcRoot $trunkrev] rtw box_width ignore
if {! $in_git} {
# This is the blue box at the bottom of the trunk
DrawRoot $lx $y2 $lbw $lbl_height($trunkrev) $trunkrev $trunkrev
# This is the arrow at the base of the trunk
$branchwin.canvas lower [ \
$branchwin.canvas create line \
$mx $ry $mx [expr {$by - $rh}] \
-fill $colorglb(canvfg) \
-arrow last -arrowshape $curr(arrowshape) \
-width $curr(width)
]
}
UpdateBndBox
} elseif {[info exists basebranch]} {
gen_log:log D "Drawing basebranch $basebranch"
foreach {lx y2 lbw rh lly} [DrawBranch 0 0 {} $basebranch] {
lappend bxys $lx $lbw $rh $lly
break
}
set x2 [expr {$lx + $lbw + $curr(spcx)}]
set mx [expr {$lx + $lbw/2}]
set ry [expr {$y2 - $rh/2 - $curr(spcy)}]
set by [expr {$y2 - $curr(boff)}]
lassign [CalcRoot $basebranch] rtw box_width bot_height
if {! $in_git } {
$branchwin.canvas create line \
$mx $by $mx [expr {$by - $rh}] \
-fill $colorglb(canvfg) \
-arrow last -arrowshape $curr(arrowshape) \
-width $curr(width)
DrawRoot $lx $y2 $lbw $lbl_height($basebranch) $basebranch $basebranch
}
UpdateBndBox
}
gen_log:log D "fromtags: $fromtags"
gen_log:log D "totags: $totags"
if {$logcfg(show_merges)} {
# Draw merge arrows derived from tags
foreach from $fromtags {
gen_log:log D " $from on $mrev($from)"
if {! [info exists match($from)]} {
gen_log:log D " No match for $match($from)"
continue
}
foreach to $totags {
if {[string equal $to $match($from)]} {
gen_log:log D " $to on $mrev($to)"
if {! [info exists revmergefrom($mrev($from))]} {
set revmergefrom($mrev($from)) $mrev($to)
gen_log:log D "Set revmergefrom($mrev($from)) = $mrev($to)"
} else {
gen_log:log D "revmergefrom($mrev($from)) exists. Not changing"
}
}
}
}
# Draw merge arrows derived from cvsnt mergepoint, svn mergeinfo, or git
foreach to [array names revmergefrom] {
#gen_log:log D "revmergefrom($to) $revmergefrom($to)"
set from $revmergefrom($to)
if {[info exists xyw($from)]} {
gen_log:log D " xyw($from) $xyw($from)"
} else {
#gen_log:log D " xyw($from) doesn't exist"
continue
}
if {[info exists xyw($to)]} {
gen_log:log D " xyw($to) $xyw($to)"
} else {
#gen_log:log D " xyw($to) doesn't exist"
continue
}
set xto [lindex $xyw($from) 0]
set yto [lindex $xyw($from) 1]
set bwto [lindex $xyw($from) 2]
set xfrom [lindex $xyw($to) 0]
set yfrom [lindex $xyw($to) 1]
set bwfrom [lindex $xyw($to) 2]
set xmid $xto
set ymid $yto
if {$xto > $xfrom} {
set xfrom [expr {$xfrom + $bwfrom}]
set yfrom [expr {$yfrom - ($box_height / 2)}]
set yto [expr {$yto - ($box_height / 2)}]
set xmid [expr {$xfrom + (($xto - $xfrom) / 2)}]
set ymid [expr {$yto - $box_height}]
} elseif {$xfrom > $xto} {
set xto [expr {$xto + $bwto}]
set xmid [expr {$xto + (($xfrom - $xto) / 2)}]
set ymid [expr {$yto + ($box_height / 2)}]
} elseif {$xto == $xfrom} {
set xmid [expr {$xto - ($bwfrom / 2)}]
set ymid [expr {$yfrom - (($yfrom - $yto) / 2)}]
}
$branchwin.canvas create line \
$xfrom $yfrom $xmid $ymid $xto $yto \
-fill $colorglb(canvfg) \
-arrow first -smooth 1
}
}
# Reselect the previously selected revisions
variable sel_tag
variable sel_rev
foreach AorB {A B} {
SetSelection $AorB $sel_tag($AorB) $sel_rev($AorB)
}
busy_done $branchwin
}
gen_log:log T "LEAVE ()"
if {[info exists x2]} {
return $x2
} else {
return 0
}
}
proc SaveOptions {} {
upvar ::logcfg logcfg
variable loc
# Save the options to the global set
set logcfg(update_drawing) $logcfg(update_drawing)
foreach {key value} [array get opt] {
gen_log:log D "logcfg($key) $value"
set logcfg($key) $value
}
save_options
}
# Search functionality for log viewer that searches for strings in the
# log windows. It will create a new button and an entry box below the logs. You
# can enter a glob-style search pattern in the entry field and click the search
# button. With every click (or pressing enter), the log viewer jumps from one
# occurrence of the pattern to the next, highlighting it in red.
#
# The following special characters are used in the search pattern:
#
# * Matches any sequence of characters in string, including a null string.
#
# ? Matches any single character in string.
#
# [chars] Matches any character in the set given by chars. If a sequence of the
# form x-y appears in chars, then any character between x and y, inclusive, will
# match.
#
# \x Matches the single character x. This provides a way of avoiding the
# special interpretation of the characters *?[]\ in pattern.
#
# If you only enter "FOO" (without the ") in the entry box, it searches the exact
# string "FOO". If you want to search all strings starting with "FOO", you have
# to put "FOO*". For all strings containing "FOO", you must put "*FOO*".
proc Search {} {
global cvscfg
global colorglb
variable font_bold
variable search_elements
variable search_index
variable search_lastpattern
variable search_lastcase
variable search_nocase
variable revwho
variable revdate
variable revtime
variable revcomment
variable revtags
variable revbtags
set branchwin [namespace inscope [namespace current] {set branchwin}]
gen_log:log T "ENTER search_index $search_index, search_elements $search_elements"
# Read search pattern from entry box
set pattern [string trim [$branchwin.down.search.e get]]
# Check if search pattern or nocase flag have been changed since the
# last call
if {([string equal $pattern $search_lastpattern] == 0) \
||($search_lastcase != $search_nocase)} {
# Restore box colors
foreach item [$branchwin.canvas find withtag box] {
$branchwin.canvas itemconfigure $item -fill $colorglb(textbg)
}
$branchwin.canvas itemconfigure SelA -fill $cvscfg(colourA)
$branchwin.canvas itemconfigure SelB -fill $cvscfg(colourB)
# Rebuild matching element list
set search_lastpattern $pattern
set search_lastcase $search_nocase
set search_elements [list]
# Ignore empty patterns
if {[string length $pattern] != 0} {
# Collect all the revision data
foreach r [array names revdate] {
set data "$r "
catch {append data "$revwho($r) "}
catch {append data "$revdate($r) "}
catch {append data "$revtime($r) "}
catch {append data "$revcomment($r) "}
catch {append data "$revtags($r) "}
catch {append data "$revbtags($r) "}
# Check if text element matches search pattern
if {$search_nocase} {
if {[string match -nocase "*$pattern*" $data]} {
# Add element to list of matching elements
lappend search_elements $r
gen_log:log D "$pattern MATCHED $data"
}
} else {
if {[string match "*$pattern*" $data]} {
# Add element to list of matching elements
lappend search_elements $r
gen_log:log D " $pattern MATCHED $data"
}
}
}
}
# Reset highlight index
set search_index 0
# Pattern has not been changed since last call and there have been
# matching elements found in the last call
} elseif {[llength $search_elements] != 0} {
# Select next matching element (restart if last one has been passed)
incr search_index
if {$search_index >= [llength $search_elements]} {
set search_index 0
}
set rev [lindex $search_elements $search_index]
gen_log:log D " $rev"
}
# Check if there are matching elements
set length [llength $search_elements]
if {$length > 0} {
foreach rev $search_elements {
# This is the counter in the status bar
$branchwin.down.search.l configure -text "[expr {$search_index + 1}] / $length"
# Find canvas items with tag rect$r
foreach item [$branchwin.canvas find withtag "box&&rect$rev"] {
# Color the rectangle
$branchwin.canvas itemconfigure $item -fill lightsalmon
}
}
set rev [lindex $search_elements $search_index]
# There should only be one match but things go wrong
set items [$branchwin.canvas find withtag "box&&rect$rev"]
set il [llength $items]
if { $il > 1} {
gen_log:log D "$il ITEMS MATCH the tag rect$rev"
}
set item [lindex $items 0]
# There may be a data item for $rev but it isn't drawn
if {$item != {}} {
$branchwin.canvas itemconfigure $item -fill orangered
# Scroll to next matching item
set scrollregion [$branchwin.canvas cget -scrollregion]
set coords [$branchwin.canvas bbox $item]
set sx1 [lindex $scrollregion 0]
set sy1 [lindex $scrollregion 1]
set sx2 [lindex $scrollregion 2]
set sy2 [lindex $scrollregion 3]
set ix1 [lindex $coords 0]
set iy1 [lindex $coords 1]
set ix2 [lindex $coords 2]
set iy2 [lindex $coords 3]
set xview [$branchwin.canvas xview]
set yview [$branchwin.canvas yview]
set vx1 [lindex $xview 0]
set vx2 [lindex $xview 1]
set vy1 [lindex $yview 0]
set vy2 [lindex $yview 1]
set x [expr {(double($ix1 - $sx1) / double($sx2 - $sx1)) -(($vx2 - $vx1) / 2)}]
set y [expr {(double($iy1 - $sy1) / double($sy2 - $sy1)) -(($vy2 - $vy1) / 2)}]
$branchwin.canvas xview moveto $x
$branchwin.canvas yview moveto $y
if {! [info exists revcomment($rev)]} {
set revcomment($rev) "*** empty log message ***"
}
}
$branchwin.up.revA_rvers configure -state normal
$branchwin.up.revA_rvers delete 0 end
$branchwin.up.revA_rvers insert end "$rev"
$branchwin.up.revA_rvers configure -state readonly
if {$rev != {} && [info exists revwho($rev)]} {
$branchwin.up.revA_rwho configure -text $revwho($rev)
$branchwin.up.revA_rdate configure -text "$revdate($rev) $revtime($rev)"
$branchwin.up.logA_rlogfm.rcomment configure -state normal
$branchwin.up.logA_rlogfm.rcomment delete 1.0 end
if {$item == {}} {
$branchwin.up.logA_rlogfm.rcomment insert end "*** not drawn ***\n"
}
$branchwin.up.logA_rlogfm.rcomment insert end $revcomment($rev)
$branchwin.up.logA_rlogfm.rcomment configure -state disabled
}
} else {
$branchwin.down.search.l configure -text "Not found"
}
} ;# End of Search proc
toplevel $branchwin
wm title $branchwin "TkRev Branches $filename"
menubar_menus $branchwin
set filemenu_idx [$branchwin.menubar index "File"]
$branchwin.menubar insert [expr {$filemenu_idx + 1}] cascade -label "Diagram"\
-menu [menu $branchwin.menubar.view] -underline 0
help_menu $branchwin
# Diagram
menu $branchwin.menubar.view.update
$branchwin.menubar.view.update add radiobutton -label "Every Revision" \
-variable logcfg(update_drawing) -value 0
$branchwin.menubar.view.update add radiobutton -label "Every Branch" \
-variable logcfg(update_drawing) -value 1
$branchwin.menubar.view.update add radiobutton -label "When Finished" \
-variable logcfg(update_drawing) -value 2
$branchwin.menubar.view add separator
$branchwin.menubar.view add cascade -label "Tree Layout" \
-menu $branchwin.menubar.view.tree
menu $branchwin.menubar.view.tree
$branchwin.menubar.view.tree add checkbutton -label \
"Show tags" \
-variable logcfg(show_tags) \
-onvalue 1 -offvalue 0 \
-command [namespace code { DrawTree }]
$branchwin.menubar.view.tree add checkbutton -label \
"Show branches" \
-variable logcfg(show_branches) \
-onvalue 1 -offvalue 0 \
-command [namespace code { DrawTree }]
$branchwin.menubar.view.tree add checkbutton -label \
"Show empty branches" \
-variable logcfg(show_empty_branches) \
-onvalue 1 -offvalue 0 \
-command [namespace code { DrawTree }]
$branchwin.menubar.view.tree add checkbutton -label \
"Show intermediate revisions" \
-variable logcfg(show_inter_revs) \
-onvalue 1 -offvalue 0 \
-command [namespace code { DrawTree }]
$branchwin.menubar.view.tree add checkbutton -label \
"Show merges" \
-variable logcfg(show_merges) \
-onvalue 1 -offvalue 0 \
-command [namespace code { DrawTree }]
$branchwin.menubar.view add cascade -label "Branch Layout" \
-menu $branchwin.menubar.view.branch
menu $branchwin.menubar.view.branch
$branchwin.menubar.view.branch add command -label "Turn all options on" \
-command [namespace code {
set logcfg(show_root_tags) 1
DrawTree
}]
$branchwin.menubar.view.branch add command -label "Turn all options off" \
-command [namespace code {
set logcfg(show_root_tags) 0
DrawTree
}]
$branchwin.menubar.view.branch add separator
$branchwin.menubar.view.branch add checkbutton -label "Show label" \
-variable logcfg(show_root_tags) \
-onvalue 1 -offvalue 0 \
-command [namespace code { DrawTree }]
$branchwin.menubar.view add cascade -label "Revision Layout" \
-menu $branchwin.menubar.view.rev
menu $branchwin.menubar.view.rev
$branchwin.menubar.view.rev add command -label "Turn all options on" \
-command [namespace code {
set logcfg(show_tags) 1
set logcfg(show_branches) 1
set logcfg(show_box_rev) 1
set logcfg(show_box_revwho) 1
set logcfg(show_box_revdate) 1
set logcfg(show_box_revtime) 1
DrawTree
}]
$branchwin.menubar.view.rev add command -label "Turn all options off" \
-command [namespace code {
set logcfg(show_tags) 0
set logcfg(show_branches) 0
set logcfg(show_box_rev) 0
set logcfg(show_box_revwho) 0
set logcfg(show_box_revdate) 0
set logcfg(show_box_revtime) 0
DrawTree
}]
$branchwin.menubar.view.rev add separator
$branchwin.menubar.view.rev add checkbutton -label "Show revision" \
-variable logcfg(show_box_rev) \
-onvalue 1 -offvalue 0 \
-command [namespace code { DrawTree }]
$branchwin.menubar.view.rev add checkbutton -label "Show author" \
-variable logcfg(show_box_revwho) \
-onvalue 1 -offvalue 0 \
-command [namespace code { DrawTree }]
$branchwin.menubar.view.rev add checkbutton -label "Show date" \
-variable logcfg(show_box_revdate) \
-onvalue 1 -offvalue 0 \
-command [namespace code { DrawTree }]
$branchwin.menubar.view.rev add checkbutton -label "Show time" \
-variable logcfg(show_box_revtime) \
-onvalue 1 -offvalue 0 \
-command [namespace code { DrawTree }]
$branchwin.menubar.view add separator
$branchwin.menubar.view add cascade -label "Size" \
-menu $branchwin.menubar.view.size
menu $branchwin.menubar.view.size
foreach {label factor} $logcfg(scaling_options) {
$branchwin.menubar.view.size add radiobutton -label $label \
-variable logcfg(scale) -value $factor \
-command [namespace code { DrawTree }]
}
$branchwin.menubar.view add separator
$branchwin.menubar.view add command -label "Save options" \
-command [namespace code {
SaveOptions
}]
if {$in_git} {
# The git options menu
git_branch_menu $branchwin $filename
}
if { [tk windowingsystem] eq "x11" } {
wm iconphoto $branchwin Branch
} else {
wm iconphoto $branchwin -default AppIcon
}
wm protocol $branchwin WM_DELETE_WINDOW \
[namespace code {$branchwin.close invoke}]
frame $branchwin.up -relief groove -borderwidth 2
set textfont $colorglb(listboxfont)
set disbg [lindex [$branchwin.up configure -background] 4]
label $branchwin.up.lfname -width 12 -anchor w
entry $branchwin.up.rfname -font $textfont -relief groove \
-bd 1 -relief sunk -state readonly
button $branchwin.up.bmodbrowse -image Modules \
-command modbrowse_run
button $branchwin.up.bworkdir -image Workdir \
-command { workdir_setup }
pack $branchwin.up -side top -fill x
foreach fm {A B} {
label $branchwin.up.rev${fm}_lvers -text "Revision $fm"
entry $branchwin.up.rev${fm}_rvers -textvariable {} \
-width 8 -bd 1 -relief sunk -state readonly
label $branchwin.up.rev${fm}_ldate -text "Committed"
label $branchwin.up.rev${fm}_rdate -text {} \
-anchor w -font $textfont
label $branchwin.up.rev${fm}_lwho -text " by "
label $branchwin.up.rev${fm}_rwho -text {} \
-anchor w -font $textfont
label $branchwin.up.log${fm}_lcomment -text "Log $fm"
frame $branchwin.up.log${fm}_rlogfm -bd 3 -bg $cvscfg(colour$fm)
text $branchwin.up.log${fm}_rlogfm.rcomment -height 5 \
-fg $colorglb(textfg) -bg $colorglb(textbg) -state disabled \
-yscrollcommand [namespace code\
"$branchwin.up.log${fm}_rlogfm.yscroll set"]
ttk::scrollbar $branchwin.up.log${fm}_rlogfm.yscroll \
-command [namespace code\
"$branchwin.up.log${fm}_rlogfm.rcomment yview"]
}
grid columnconf $branchwin.up 5 -weight 1
grid $branchwin.up.lfname -column 0 -row 0 -sticky nw
grid $branchwin.up.rfname -column 1 -row 0 -columnspan 5 -sticky ew
grid $branchwin.up.bworkdir -column 6 -row 0 -rowspan 2 -sticky e\
-padx 2 -pady 1
grid $branchwin.up.bmodbrowse -column 7 -row 0 -rowspan 2 -sticky e\
-padx 2 -pady 1
grid $branchwin.up.revA_lvers -column 0 -row 1 -sticky w
grid $branchwin.up.revA_rvers -column 1 -row 1 -sticky w
grid $branchwin.up.revA_ldate -column 2 -row 1 -sticky w
grid $branchwin.up.revA_rdate -column 3 -row 1 -sticky w
grid $branchwin.up.revA_lwho -column 4 -row 1 -sticky w
grid $branchwin.up.revA_rwho -column 5 -row 1 -sticky ew
grid $branchwin.up.logA_lcomment -column 0 -row 2 -sticky nw
grid $branchwin.up.logA_rlogfm -column 1 -row 2 -columnspan 7 -sticky ew
pack $branchwin.up.logA_rlogfm.yscroll -side right -fill y
pack $branchwin.up.logA_rlogfm.rcomment -side left -fill x -expand y
grid $branchwin.up.revB_lvers -column 0 -row 3 -sticky w
grid $branchwin.up.revB_rvers -column 1 -row 3 -sticky w
grid $branchwin.up.revB_ldate -column 2 -row 3 -sticky w
grid $branchwin.up.revB_rdate -column 3 -row 3 -sticky w
grid $branchwin.up.revB_lwho -column 4 -row 3 -sticky w
grid $branchwin.up.revB_rwho -column 5 -row 3 -sticky ew
grid $branchwin.up.logB_lcomment -column 0 -row 4 -sticky nw
grid $branchwin.up.logB_rlogfm -column 1 -row 4 -columnspan 7 -sticky ew
pack $branchwin.up.logB_rlogfm.yscroll -side right -fill y
pack $branchwin.up.logB_rlogfm.rcomment -side left -fill x -expand y
# Pack the bottom before the middle so it doesnt disappear if
# the window is resized smaller
frame $branchwin.down -relief groove -borderwidth 2
pack $branchwin.down -side bottom -fill x
frame $branchwin.down.search -relief sunk -bd 2
button $branchwin.down.search.b -text "Search" -command [namespace code {Search}]
entry $branchwin.down.search.e
bind $branchwin.down.search.e [namespace code {Search}]
label $branchwin.down.search.l -anchor e -width 10 -text ""
ttk::checkbutton $branchwin.down.search.c -text "Ignore case" \
-variable [namespace current]::search_nocase
pack $branchwin.down.search -side top -fill x
pack $branchwin.down.search.b -side left
pack $branchwin.down.search.e -side left
pack $branchwin.down.search.c -side left -padx 4
pack $branchwin.down.search.l -side left
# The canvas for the big picture
canvas $branchwin.canvas -relief sunken -borderwidth 2 \
-height 300 -bg $colorglb(canvbg) \
-yscrollcommand [namespace code "$branchwin.yscroll set"] \
-xscrollcommand [namespace code "$branchwin.xscroll set"]
ttk::scrollbar $branchwin.xscroll -orient horizontal \
-command [namespace code "$branchwin.canvas xview"]
ttk::scrollbar $branchwin.yscroll \
-command [namespace code "$branchwin.canvas yview"]
#
# Create buttons
#
frame $branchwin.down.btnfm
frame $branchwin.down.closefm
button $branchwin.refresh -image Refresh \
-command [namespace code {
$scope\::reloadLog
}]
button $branchwin.view -image Fileview
button $branchwin.log -image Log
button $branchwin.annotate -image Annotate
button $branchwin.diff -image Diff
button $branchwin.patchdiff -image Patches
button $branchwin.ddiff -image Difflines
button $branchwin.merge -image Mergediff
button $branchwin.viewtags -image Tags \
-command [namespace code {
variable revtags
variable revbtags
set taglist ""
foreach r [lsort -dictionary \
[concat [array names revtags] [array names revbtags]]] {
if {[info exists revtags($r)]} {
append taglist "$r: $revtags($r)\n"
} elseif {[info exists revbtags($r)]} {
append taglist "$r: $revbtags($r)\n"
}
}
view_output::new Tags $taglist
}]
button $branchwin.close -text "Close" \
-command [namespace code {
global cvscfg
variable my_idx
set cvscfg(loggeom) [wm geometry $branchwin]
destroy $branchwin
catch {namespace delete ::cvs_branchlog::$my_idx}
catch {namespace delete ::svn_branchlog::$my_idx}
namespace delete [namespace current]
exit_cleanup 0
}]
button $branchwin.stop -text "Stop" -bg red4 -fg white \
-activebackground red4 -activeforeground white \
-state [expr {$cvscfg(allow_abort) ? {normal} : {disabled}}] \
-command "$scope\::abortLog"
pack $branchwin.refresh \
-in $branchwin.down -side left \
-ipadx 4 -ipady 4
pack $branchwin.down.btnfm -side left -fill y -expand 1
pack $branchwin.view \
$branchwin.log \
$branchwin.annotate \
$branchwin.diff \
-in $branchwin.down.btnfm -side left \
-ipadx 4 -ipady 4
if {$in_svn || $in_git} {
pack $branchwin.patchdiff \
$branchwin.ddiff \
-in $branchwin.down.btnfm -side left \
-ipadx 4 -ipady 4
}
pack $branchwin.merge \
$branchwin.viewtags \
-in $branchwin.down.btnfm -side left \
-ipadx 4 -ipady 4
pack $branchwin.down.closefm -side right -expand yes -fill x
pack $branchwin.close \
-in $branchwin.down.closefm -side right -padx 15
set_tooltips $branchwin.refresh \
{"Re-read the log information"}
set_tooltips $branchwin.up.bworkdir \
{"Open the Working Directory Browser"}
set_tooltips $branchwin.up.bmodbrowse \
{"Open the Repository Browser"}
set_tooltips $branchwin.view \
{"View a version of the file"}
set_tooltips $branchwin.log \
{"Revision log of the file"}
set_tooltips $branchwin.annotate \
{"View revision where each line was modified"}
set_tooltips $branchwin.diff \
{"Side-by-side comparison of two versions of the file"}
set_tooltips $branchwin.merge \
{"Merge to current"}
set_tooltips $branchwin.viewtags \
{"List all the file\'s tags"}
set_tooltips $branchwin.patchdiff \
{"Show file changes in a commit"}
set_tooltips $branchwin.ddiff \
{"List changed files in a commit"}
#
# Put the canvas on to the display.
#
pack $branchwin.xscroll -side bottom -fill x -padx 1 -pady 1
pack $branchwin.yscroll -side right -fill y -padx 1 -pady 1
pack $branchwin.canvas -fill both -expand 1
scrollbindings $branchwin.canvas
#
# Window manager stuff.
#
wm minsize $branchwin 1 1
if {[info exists cvscfg(loggeom)]} {
wm geometry $branchwin $cvscfg(loggeom)
}
$branchwin.canvas bind active \
"$branchwin.canvas config -cursor hand2"
$branchwin.canvas bind active \
"$branchwin.canvas config -cursor {}"
$branchwin.canvas bind tag \
[namespace code "PopupTags %x %y"]
$branchwin.canvas bind selectable \
[namespace code "RevSelect A"]
# Tcl/TK for Windows doesn't do Button 3, so we duplicate it on Button 2
$branchwin.canvas bind selectable \
[namespace code "RevSelect B"]
$branchwin.canvas bind selectable \
[namespace code "RevSelect B"]
# Clicking in a blank part of the canvas unselects boxes
bind $branchwin.canvas \
[namespace code "Unselect A"]
bind $branchwin.canvas \
[namespace code "Unselect B"]
bind $branchwin.canvas \
[namespace code "Unselect B"]
focus $branchwin.canvas
# FIXME: Why isn't there a bbox when we get here?
# Then the yview moveto doesn't work, although it does in tkinter
$branchwin.canvas xview moveto 0
$branchwin.canvas yview moveto 0
return [list [namespace current] $branchwin]
}
}
}
tkrev_9.6.1/tkrev/dialog.tcl 0000664 0001750 0001750 00000175411 15024334743 016370 0 ustar dorothyr dorothyr #
# Tcl Library for TkRev
#
#
# Smallish dialogs - add, tag
#
# Creates the widgets for the dynamic forms called from the module browser
proc dialog_FormCreate { title form_data } {
global colorglb
global dynamic_dialog
global dialog_action
set font_star $colorglb(dialogfont)
set font_normal $colorglb(listboxfont)
set font_bold $colorglb(dialogfont)
set font_italic [font create -family Helvetica -size -12 -slant italic]
if {[winfo exists .dynamic_dialog]} {
destroy .dynamic_dialog
}
set w .dynamic_dialog
toplevel $w
wm attributes $w -topmost 1
frame $w.form
pack $w.form -side top -fill
set row 0
foreach {field req type labeltext data} $form_data {
# If you wanted another default, set it in the calling function
if {! [info exists dynamic_dialog($field)]} {
set dynamic_dialog($field) ""
}
if {$type == {l}} {
# Section label
frame $w.form.rule$field -relief groove -borderwidth 2 -height 4
label $w.form.l$field -font $font_bold -text $labeltext
grid $w.form.rule$field -column 0 -row [incr row] -columnspan 3 -sticky ew
grid $w.form.l$field -column 0 -row [incr row] -sticky w
} else {
# It's something else. It has a label and a req though.
label $w.form.l$field -anchor w -text " $labeltext"
label $w.form.r$field -anchor e -foreground red \
-font $font_star -text [expr {$req ? "*" : " "}]
grid $w.form.l$field -column 0 -row [incr row] -sticky w
grid $w.form.r$field -column 1 -row $row -sticky w
if {$type == {t}} {
# It's an entry
entry $w.form.e$field -width 65 \
-textvariable dynamic_dialog($field)
grid $w.form.e$field -column 2 -row $row -sticky w
} elseif {$type == {r}} {
# It's a radiobutton
frame $w.form.f$field
set k 1
foreach {text value} $data {
ttk::radiobutton $w.form.f$field$k -text $text -value $value \
-variable dynamic_dialog($field)
pack $w.form.f$field$k -in $w.form.f$field -side left -padx 4
incr k
}
grid $w.form.f$field -column 2 -row $row -sticky ew
}
}
}
incr row
label $w.form.xstar -anchor e -foreground red \
-font $font_italic -text "* = required field"
grid $w.form.xstar -column 1 -columnspan 2 -row $row -sticky w
frame $w.buttons -relief groove -bd 2
pack $w.buttons -side top -fill x
button $w.ok -text "OK" \
-command "
if {\[dialog_FormComplete $w [list $form_data]\] } {
destroy $w
$dialog_action
exit_cleanup 0
}
"
button $w.apply -text "Apply" \
-command "
if {\[dialog_FormComplete $w [list $form_data]\] } {
$dialog_action
}
"
button $w.close -text "Cancel" \
-command "
destroy $w
exit_cleanup 0
"
pack $w.close $w.apply $w.ok -in $w.buttons -side right \
-ipadx 2 -ipady 2 -padx 4 -pady 4 -fill both -expand 1
wm title $w $title
dialog_position $w .modbrowse
wm minsize $w 1 1
return
}
proc dialog_FormComplete { w form_data } {
global dynamic_dialog
gen_log:log T "ENTER ($w ...)"
foreach a [array names dynamic_dialog] {
gen_log:log D "$a $dynamic_dialog($a)"
}
set section ""
foreach {field req type labeltext data} $form_data {
if {$type == {l}} {
set section $dynamic_dialog($field)
} else {
if {$req && [set dynamic_dialog($field)] == {}} {
cvsok "$field may not be blank" $w.form
return 0
}
}
}
return 1
}
# Check out a CVS module from the module browser
proc dialog_cvs_checkout { cvsroot module {revtag {} } } {
global dynamic_dialog
global dialog_action
gen_log:log T "ENTER ($cvsroot $module $revtag)"
# Remember tags from last time
if {$revtag == {} && [info exists dynamic_dialog(revtag)]} {
set revtag $dynamic_dialog(revtag)
}
set dir [pwd]
set dynamic_dialog(cvsroot) $cvsroot
set dynamic_dialog(module) $module
set dynamic_dialog(revtag) $revtag
set dynamic_dialog(prune) {-P}
set dynamic_dialog(kflag) ""
# field req type labeltext data
set dialog_form_checkout {
1 0 l {CVS Repository} 1
cvsroot 1 t {CVSROOT} {}
2 0 l {Module} 1
module 1 t {Name/Path} {}
revtag 0 t {Revision/Tag} {}
date 0 t {Date} {}
3 0 l {Destination} 1
target 1 t {Target Directory} {}
4 0 l {Merge } 0
mtag1 0 t {Old tag} {}
mtag2 0 t {New tag} {}
5 0 l {Advanced} 0
prune 0 r {Empty Directories} {{Create} {}
{Don't Create} {-P}}
kflag 0 r {Keyword Expansion} {{Default} {}
{Keep as-is} {-ko}
{Treat files as binary} {-kb}
{Keywords only} {-kk}}
}
# Action function
set dialog_action {cvs_checkout \
$dynamic_dialog(cvsroot) \
$dynamic_dialog(prune) $dynamic_dialog(kflag) \
$dynamic_dialog(revtag) $dynamic_dialog(date) $dynamic_dialog(target) \
$dynamic_dialog(mtag1) $dynamic_dialog(mtag2) $dynamic_dialog(module)
}
set form [dialog_FormCreate "Checkout Module" $dialog_form_checkout]
gen_log:log T "LEAVE"
}
# Export a CVS module from the module browser
proc dialog_cvs_export { cvsroot module {revtag {}} } {
global dynamic_dialog
global dialog_action
gen_log:log T "ENTER ($cvsroot $module $revtag)"
# Remember tags from last time
if {$revtag == {} && [info exists dynamic_dialog(revtag)]} {
set revtag $dynamic_dialog(revtag)
}
set dir [pwd]
set dynamic_dialog(cvsroot) $cvsroot
set dynamic_dialog(module) $module
set dynamic_dialog(revtag) $revtag
# field req type labeltext data
set dialog_form_export {
1 0 l {CVS Repository} 1
cvsroot 1 t {CVSROOT} {}
2 0 l {Module} 1
module 1 t {Name/Path} {}
revtag 0 t {Revision/Tag} {}
date 0 t {Date} {}
3 0 l {Destination} 1
target 1 t {Target Directory} {}
4 0 l {Advanced} 0
kflag 0 r {Keyword Expansion} {{Default} {}
{Keep as-is} {-ko}
{Treat files as binary} {-kb}
{Keywords only} {-kk}}
}
# Action function
set dialog_action {cvs_export \
$dynamic_dialog(cvsroot) $dynamic_dialog(kflag) \
$dynamic_dialog(revtag) $dynamic_dialog(date) \
$dynamic_dialog(target) $dynamic_dialog(module)
}
set form [dialog_FormCreate "Export Module" $dialog_form_export]
gen_log:log T "LEAVE"
}
# Checkout or Export a SVN module from the module browser
proc dialog_svn_checkout { svnroot path command } {
global dynamic_dialog
global dialog_action
if {[info exists dynamic_dialog(rev)]} {
set rev $dynamic_dialog(rev)
}
set dir [pwd]
set dynamic_dialog(path) $path
set dynamic_dialog(svnroot) $svnroot
set dynamic_dialog(command) $command
# field req type labeltext data
set dialog_form_export {
1 0 l {SVN Repository} 1
svnroot 1 t {SVN URL} {}
path 1 t {Path in Repository} {}
rev 0 t {Revision/Date} {}
2 0 l {Destination} 1
target 1 t {Target Directory} {}
3 0 l {Working Copy or Unversioned Copy} {}
command 0 r {Versioning} {{Versioned (Checkout)} {checkout}
{Un-Versioned (Export)} {export}}
}
# Action function
set dialog_action {svn_checkout \
$dynamic_dialog(svnroot) $dynamic_dialog(path) \
$dynamic_dialog(rev) $dynamic_dialog(target) \
$dynamic_dialog(command)
}
set form [dialog_FormCreate "Checkout or Export" $dialog_form_export]
gen_log:log T "LEAVE"
}
# Clone a Git branch from the module browser
proc dialog_git_clone { gitroot path } {
global dynamic_dialog
global dialog_action
if {[info exists dynamic_dialog(rev)]} {
set rev $dynamic_dialog(rev)
}
set dir [pwd]
set dynamic_dialog(path) $path
set dynamic_dialog(gitroot) $gitroot
# field req type labeltext data
set dialog_form_clone {
1 0 l {Git Repository} 1
gitroot 1 t {Git URL} {}
path 0 t {Branch} {}
2 0 l {Destination} 1
target 1 t {Target Directory} {}
}
# Action function
set dialog_action {git_clone \
$dynamic_dialog(gitroot) $dynamic_dialog(path) \
$dynamic_dialog(target)
}
set form [dialog_FormCreate "Clone" $dialog_form_clone]
gen_log:log T "LEAVE"
}
# Make a branch or tag (svn copy) from the module browser
proc dialog_svn_tag { svnroot path b_or_t } {
global dynamic_dialog
global dialog_action
set dynamic_dialog(path) $path
set dynamic_dialog(svnroot) $svnroot
set dynamic_dialog(b_or_t) $b_or_t
set dynamic_dialog(frompath) "$dynamic_dialog(svnroot)/$dynamic_dialog(path)"
# field req type labeltext data
set dialog_form_tagcopy {
1 0 l {Copy Path to Tag or Branch} 1
frompath 1 t {Copy From} {}
b_or_t 0 r {Tag or Branch} {{Branch} {branches}
{Tag} {tags}}
target 1 t {New Branch/Tag} {}
}
# Action function
set dialog_action {svn_rcopy $dynamic_dialog(svnroot)/$dynamic_dialog(path) \
$dynamic_dialog(b_or_t) $dynamic_dialog(target)
}
set form [dialog_FormCreate "SVN Branch or Tag Copy" $dialog_form_tagcopy]
gen_log:log T "LEAVE"
}
# Compare two revisions of a module, from the module browser
# Can make a patch file or send a summary to the screen
proc dialog_cvs_patch { cvsroot module summary {revtagA {}} {revtagB {}} } {
global dynamic_dialog
global dialog_action
gen_log:log T "ENTER ( $cvsroot $module $summary $revtagA $revtagB )"
# Remember tags
if {$revtagA == {} && [info exists dynamic_dialog(revtagA)]} {
set revtagA $dynamic_dialog(revtagA)
}
if {$revtagB == {} && [info exists dynamic_dialog(revtagB)]} {
set revtagB $dynamic_dialog(revtagB)
}
set dynamic_dialog(cvsroot) $cvsroot
set dynamic_dialog(module) $module
set dynamic_dialog(revtagA) $revtagA
set dynamic_dialog(revtagB) $revtagB
set dynamic_dialog(outfile) "$module.patch"
if {$summary} {
set dynamic_dialog(outmode) 0
set dynamic_dialog(difffmt) {-s}
} else {
set dynamic_dialog(outmode) 1
set dynamic_dialog(difffmt) ""
}
# field req type labeltext data
set dialog_form_patch {
1 0 l {CVS Repository} 1
cvsroot 1 t {CVSROOT} {}
2 0 l {Module} 1
module 1 t {Name/Path} {}
3 0 l {Destination} 1
outmode 0 r {Output Mode} {{To Screen} 0 {To File} 1}
outfile 0 t {Output File} {outfile}
4 0 l {Old Revision} 1
revtagA 0 t {Revision/Tag} {}
dateA 0 t {Date} {}
5 0 l {New Revision} 1
revtagB 0 t {Revision/Tag} {}
dateB 0 t {Date} {}
6 0 l {Format} 1
difffmt 0 r {Diff Format} {{Default} {}
{Context diff} {-c}
{Unidiff} {-u}
{One liner} {-s}}
}
# Action function
set dialog_action {cvs_patch $dynamic_dialog(cvsroot) \
$dynamic_dialog(module) $dynamic_dialog(difffmt) \
$dynamic_dialog(revtagA) $dynamic_dialog(dateA) \
$dynamic_dialog(revtagB) $dynamic_dialog(dateB) \
$dynamic_dialog(outmode) $dynamic_dialog(outfile)
}
set form [dialog_FormCreate "Diff/Patch Module" $dialog_form_patch]
gen_log:log T "LEAVE"
}
# Compare two revisions, from the module browser
# Can make a patch file or send a summary to the screen
proc dialog_svn_patch { svn_url {pathA {}} {pathB {}} {summary {}} } {
global dynamic_dialog
global dialog_action
gen_log:log T "ENTER ( $svn_url $pathA $pathB $summary )"
set dynamic_dialog(svn_url) $svn_url
set dynamic_dialog(pathA) $pathA
set dynamic_dialog(pathB) $pathB
if {$summary} {
set dynamic_dialog(outmode) 0
} else {
set dynamic_dialog(outmode) 1
}
set dynamic_dialog(outfile) "patchfile.patch"
set dynamic_dialog(fullA) "$svn_url$pathA"
if {$pathB == ""} {
set dynamic_dialog(fullB) ""
} else {
set dynamic_dialog(fullB) "$svn_url$pathB"
}
# field req type labeltext data
set dialog_form_patch {
1 0 l {Repository Paths} 1
pathA 1 t {Path A} {}
pathB 0 t {Path B} {}
3 0 l {Destination} 1
outmode 0 r {Output Mode} {{To Screen} 0 {To File} 1}
outfile 0 t {Output File} {outfile}
4 0 l {Old Revision} 1
revA 0 t {Revision} {}
dateA 0 t {Date} {}
5 0 l {New Revision} 1
revB 0 t {Revision} {}
dateB 0 t {Date} {}
}
# Action function
set dialog_action {
# Make new fullA and fullB from the pathA and pathB entries
set dynamic_dialog(fullA) "$dynamic_dialog(svn_url)/$dynamic_dialog(pathA)"
if {$dynamic_dialog(pathB) == ""} {
set dynamic_dialog(fullB) ""
} else {
set dynamic_dialog(fullB) "$dynamic_dialog(svn_url)/$dynamic_dialog(pathB)"
}
svn_patch $dynamic_dialog(fullA) \
$dynamic_dialog(fullB) \
$dynamic_dialog(revA) $dynamic_dialog(dateA) \
$dynamic_dialog(revB) $dynamic_dialog(dateB) \
$dynamic_dialog(outmode) $dynamic_dialog(outfile)
}
set form [dialog_FormCreate "SVN Diff/Patch" $dialog_form_patch]
gen_log:log T "LEAVE"
}
# Tag a module. CVS only. Called from the module browser.
proc rtag_dialog { cvsroot module b_or_t } {
gen_log:log T "ENTER ($cvsroot $module $b_or_t)"
toplevel .modtag
wm attributes .modtag -topmost 1
grab set .modtag
frame .modtag.top
pack .modtag.top -side top -fill x
message .modtag.top.lbl -aspect 300 -relief groove \
-text "Tag the module \"$module\" with the new tag you specify.\
If you fill in \"Existing Tag\", the revisions having that tag will get\
the new tag. Otherwise, the head revision will be tagged."
label .modtag.top.olbl -text "Existing Tag" -anchor w
entry .modtag.top.oentry -textvariable otag \
-relief sunken
label .modtag.top.nlbl -text "New Tag" -anchor w
entry .modtag.top.nentry -textvariable ntag \
-relief sunken
ttk::checkbutton .modtag.top.branch -text "Branch tag (-b)" \
-variable b_or_t -onvalue "branch" -offvalue "tag"
ttk::checkbutton .modtag.top.force -text "Move existing (-F)" \
-variable force -onvalue "yes" -offvalue "no"
grid columnconf .modtag.top 1 -weight 1
grid rowconf .modtag.top 4 -weight 1
grid .modtag.top.lbl -column 0 -row 0 -columnspan 2 -pady 2 -sticky ew
grid .modtag.top.olbl -column 0 -row 1 -sticky nw
grid .modtag.top.oentry -column 1 -row 1
grid .modtag.top.nlbl -column 0 -row 2 -sticky nw
grid .modtag.top.nentry -column 1 -row 2
grid .modtag.top.branch -column 1 -row 3 -padx 4 -sticky w
grid .modtag.top.force -column 1 -row 4 -padx 4 -sticky w
frame .modtag.down -relief groove -bd 2
pack .modtag.down -side top -fill x
button .modtag.down.tag -text "Tag" \
-command "
cvs_rtag $cvsroot $module $b_or_t \$force \$otag \$ntag; \
.modtag.down.cancel invoke
"
button .modtag.down.delete -text "Remove" \
-command "
cvs_rtag $cvsroot $module tag remove \$otag \$ntag; \
.modtag.down.cancel invoke
"
button .modtag.down.cancel -text "Cancel" \
-command {
grab release .modtag
destroy .modtag
}
pack .modtag.down.tag .modtag.down.delete .modtag.down.cancel -in .modtag.down -side left \
-ipadx 2 -ipady 2 -padx 4 -pady 4 -fill both -expand 1
bind .modtag.top.nentry \
{ .modtag.down.tag invoke }
wm title .modtag "Tag Module"
dialog_position .modtag .modbrowse
wm minsize .modtag 1 1
gen_log:log T "LEAVE"
}
# Add files to the VCS. Called from workdir browser
proc add_dialog {args} {
global cvs
global incvs insvn inrcs ingit
gen_log:log T "ENTER ($args)"
set binflag ""
toplevel .add
wm attributes .add -topmost 1
grab set .add
set filelist [join $args]
if {$filelist == ""} {
set mess "This will add all new files"
} else {
set mess "This will add these files:\n\n"
foreach file $filelist {
append mess " $file\n"
}
}
message .add.top -justify left -aspect 300 -relief groove \
-text "Add a file or files to the module. The repository\
will not be changed until you do a commit."
pack .add.top -side top -fill x
message .add.middle -text $mess -aspect 200
pack .add.middle -side top -fill x
frame .add.down
button .add.down.add -text "Add"
if {$incvs} {
.add.down.add configure -command {
grab release .add
destroy .add
if {![info exists binflag]} {set binflag ""}
cvs_add $binflag [workdir_list_files]
}
ttk::checkbutton .add.binary -text "-kb (binary)" \
-variable binflag -onvalue "-kb" -offvalue ""
pack .add.binary -side top -padx 4 -fill x -expand 1
} elseif {$insvn} {
.add.down.add configure -command {
grab release .add
destroy .add
svn_add [workdir_list_files]
}
} elseif {$ingit} {
.add.down.add configure -command {
grab release .add
destroy .add
git_add [workdir_list_files]
}
}
button .add.down.cancel -text "Cancel" \
-command { grab release .add; destroy .add }
pack .add.down -side bottom -fill x -expand 1
pack .add.down.add .add.down.cancel -side left \
-ipadx 2 -ipady 2 -padx 4 -pady 4 -fill both -expand 1
wm title .add "Add Files"
dialog_position .add .workdir
wm minsize .add 1 1
gen_log:log T "LEAVE"
}
# Tag file(s) or directory. Called from the workdir browser.
proc tag_dialog {} {
global incvs insvn inrcs ingit
global tagcomment
global forceflag
gen_log:log T "ENTER"
toplevel .tag
wm attributes .tag -topmost 1
frame .tag.top
set msg ""
pack .tag.top -side top -fill x
if {$incvs || $ingit} {
set msg "Apply a new tag to the marked files\
or to the directory, recursively"
} elseif {$insvn} {
set msg "Create a new tag copy of the marked files\
or of the directory, recursively.\n\
\nAdvice: Update local directory to HEAD first."
} elseif {$inrcs} {
set msg "Apply a new tag to the marked files\
or the directory"
}
if {! [info exists forceflag]} {
set forceflag "no"
}
if {! [info exists tagcomment]} {
set tagcomment "tag copy by TkRev"
}
message .tag.top.msg -justify left -aspect 300 -relief groove \
-text $msg
label .tag.top.lbl -text "Tag Name" -anchor w
entry .tag.top.entry -relief sunken -textvariable tagname
ttk::checkbutton .tag.top.force -text "Move existing tag" \
-variable forceflag -onvalue "yes" -offvalue "no"
ttk::checkbutton .tag.top.annotate -text "Annotate" \
-variable annotateflag -onvalue "yes" -offvalue "no" \
-command {toggle_state .tag.top.comentry}
label .tag.top.comlbl -text "Comment" -anchor w
entry .tag.top.comentry -relief sunken -textvariable tagcomment
grid columnconf .tag.top 1 -weight 1
grid rowconf .tag.top 3 -weight 1
grid .tag.top.msg -column 0 -row 0 -columnspan 2 -pady 2 -sticky ew
grid .tag.top.lbl -column 0 -row 1 -sticky nw
grid .tag.top.entry -column 1 -row 1 -sticky ew
if {$incvs || $inrcs} {
# If in CVS, offer -f option (forceflag)
grid .tag.top.force -column 1 -row 3 -padx 4 -sticky w
} elseif {$insvn} {
grid .tag.top.comlbl -column 0 -row 4 -sticky nw
grid .tag.top.comentry -column 1 -row 4 -sticky ew
.tag.top.comentry configure -state normal
} elseif {$ingit} {
# If in Git, offer -a option (annotateflag) and comment entry
# Start with the comment disabled. Annotate button will toggle it
.tag.top.comentry configure -state disabled
grid .tag.top.annotate -column 1 -row 3 -padx 4 -sticky w
grid .tag.top.comlbl -column 0 -row 4 -sticky nw
grid .tag.top.comentry -column 1 -row 4 -sticky ew
}
frame .tag.down -relief groove -bd 2
pack .tag.down -side bottom -fill x -expand 1
button .tag.down.tag -text "Tag"
button .tag.down.cancel -text "Cancel" \
-command { grab release .tag; destroy .tag }
pack .tag.down.tag .tag.down.cancel -in .tag.down -side left \
-ipadx 2 -ipady 2 -padx 4 -pady 4 -fill both -expand 1
if {$incvs} {
.tag.down.tag configure -command {
cvs_tag $tagname $forceflag "tag" no [workdir_list_files]
grab release .tag; destroy .tag
}
} elseif {$insvn} {
.tag.down.tag configure -command {
svn_tag $tagname "tag" no "$tagcomment" [workdir_list_files]
grab release .tag; destroy .tag
}
} elseif {$ingit} {
.tag.down.tag configure -command {
git_tag $tagname $annotateflag "$tagcomment" [workdir_list_files]
grab release .tag; destroy .tag
}
} elseif {$inrcs} {
.tag.down.tag configure -command {
rcs_tag $tagname $forceflag [workdir_list_files]
grab release .tag; destroy .tag
}
}
wm title .tag "Tag"
dialog_position .tag .workdir
wm minsize .tag 1 1
gen_log:log T "LEAVE"
}
# Branch file(s) or directory. Called from the workdir browser.
proc branch_dialog {} {
global incvs insvn inrcs ingit
global branchcomment
gen_log:log T "ENTER"
toplevel .branch
wm attributes .branch -topmost 1
frame .branch.top
set msg ""
pack .branch.top -side top -fill x
if {$incvs} {
set msg "Apply a new branch tag to the marked files\
or to the directory, recursively"
} elseif {$insvn} {
set msg "Create a new branch copy of the marked files\
or of the directory, recursively.\n\
\nAdvice: Update local directory to HEAD first."
} elseif {$ingit} {
set msg "Branch the marked files or\
the directory, recursively"
}
if {! [info exists branchcomment]} {
set branchcomment "branch\ copy\ by\ TkRev"
}
message .branch.top.msg -justify left -aspect 300 -relief groove \
-text $msg
label .branch.top.lbl -text "Branch Name" -anchor w
entry .branch.top.entry -relief sunken -textvariable branchname
ttk::checkbutton .branch.top.upd -text "Update current directory to be on new branch" \
-variable updflag -onvalue "yes" -offvalue "no"
label .branch.top.comlbl -text "Comment" -anchor w
entry .branch.top.coment -relief sunken -textvariable branchcomment
grid columnconf .branch.top 1 -weight 1
grid rowconf .branch.top 3 -weight 1
grid .branch.top.msg -column 0 -row 0 -columnspan 2 -pady 2 -sticky ew
grid .branch.top.lbl -column 0 -row 1 -sticky nw
grid .branch.top.entry -column 1 -row 1 -sticky ew
if {$insvn} {
grid .branch.top.comlbl -column 0 -row 2 -sticky nw
grid .branch.top.coment -column 1 -row 2 -sticky ew
}
# Offer update option for all VCSs
grid .branch.top.upd -column 0 -row 3 -padx 4 -sticky w -columnspan 2
#
frame .branch.down -relief groove -bd 2
pack .branch.down -side bottom -fill x -expand 1
button .branch.down.branch -text "Branch"
button .branch.down.cancel -text "Cancel" \
-command { grab release .branch; destroy .branch }
pack .branch.down.branch .branch.down.cancel -in .branch.down -side left \
-ipadx 2 -ipady 2 -padx 4 -pady 4 -fill both -expand 1
if {$incvs} {
.branch.down.branch configure -command {
cvs_tag $branchname "no" "branch" $updflag [workdir_list_files]
grab release .branch; destroy .branch
}
} elseif {$insvn} {
.branch.down.branch configure -command {
svn_tag $branchname "branch" $updflag $branchcomment [workdir_list_files]
grab release .branch; destroy .branch
}
} elseif {$ingit} {
.branch.down.branch configure -command {
git_branch $branchname $updflag
grab release .branch; destroy .branch
}
}
wm title .branch "Branch"
dialog_position .branch .workdir
wm minsize .branch 1 1
gen_log:log T "LEAVE"
}
# Remove from VCS. Called from workdir browser
proc subtract_dialog {args} {
global incvs insvn inrcs ingit
gen_log:log T "ENTER ($args)"
set filelist [join $args]
if {$filelist == ""} {
cvsfail "Please select some files to delete first!" .workdir
return
}
foreach f $filelist {
if {$incvs && [file isdirectory $f]} {
cvsfail "$f is a directory. Try \"Remove Recursively\" instead" .workdir
return
}
}
toplevel .subtract
wm attributes .subtract -topmost 1
grab set .subtract
set mess "This will remove these files:\n\n"
foreach file $filelist {
append mess " $file\n"
}
message .subtract.top -justify left -aspect 300 -relief groove \
-text "Remove a file or files from the module. The repository\
will not be changed until you do a commit."
pack .subtract.top -side top -fill x
message .subtract.middle -text $mess -aspect 200
pack .subtract.middle -side top -fill x
frame .subtract.down
button .subtract.down.remove -text "Remove"
if {$incvs} {
.subtract.down.remove configure -command {
grab release .subtract
destroy .subtract
cvs_remove_file [workdir_list_files]
}
} elseif {$insvn} {
.subtract.down.remove configure -command {
grab release .subtract
destroy .subtract
svn_remove_file [workdir_list_files]
}
} elseif {$ingit} {
.subtract.down.remove configure -command {
grab release .subtract
destroy .subtract
git_rm [workdir_list_files]
}
}
button .subtract.down.cancel -text "Cancel" \
-command { grab release .subtract; destroy .subtract }
pack .subtract.down -side bottom -fill x -expand 1
pack .subtract.down.remove .subtract.down.cancel -side left \
-ipadx 2 -ipady 2 -padx 4 -pady 4 -fill both -expand 1
wm title .subtract "Remove Files"
dialog_position .subtract .workdir
wm minsize .subtract 1 1
gen_log:log T "LEAVE"
}
# Set the edit flag on CVS files. Called from the workdir browser.
proc edit_dialog {args} {
global incvs insvn inrcs ingit
gen_log:log T "ENTER ($args)"
if {! $incvs} {
cvs_notincvs
return 1
}
set filelist [join $args]
gen_log:log D "filelist $filelist"
if {$filelist == "." || $filelist == ""} {
cvsfail "Please select some files to edit first!" .workdir
return 1
}
toplevel .editflag
wm attributes .editflag -topmost 1
grab set .editflag
set mess "This will set the edit flag on these files:\n\n"
foreach file $filelist {
append mess " $file\n"
}
message .editflag.top -justify left -aspect 300 -relief groove \
-text "Set the edit flag on a file or files from the module"
pack .editflag.top -side top -fill x
message .editflag.middle -text $mess -aspect 200
pack .editflag.middle -side top -fill x
frame .editflag.down
button .editflag.down.remove -text "Edit" \
-command {
grab release .editflag
destroy .editflag
cvs_edit [workdir_list_files]
}
button .editflag.down.cancel -text "Cancel" \
-command { grab release .editflag; destroy .editflag }
pack .editflag.down -side bottom -fill x -expand 1
pack .editflag.down.remove .editflag.down.cancel -side left \
-ipadx 2 -ipady 2 -padx 4 -pady 4 -fill both -expand 1
wm title .editflag "Edit Files"
dialog_position .editflag .workdir
wm minsize .editflag 1 1
gen_log:log T "LEAVE"
return 0
}
# Unset the edit flag on CVS files. Called from the workdir browser.
proc unedit_dialog {args} {
global incvs insvn inrcs ingit
gen_log:log T "ENTER ($args)"
if {! $incvs} {
cvs_notincvs
return 1
}
if {$args == "." || [llength $args] == 0} {
cvsfail "Please select some files to unedit first!" .workdir
return 1
}
toplevel .uneditflag
wm attributes .uneditflag -topmost 1
grab set .uneditflag
set filelist [join $args]
set mess "This will reset the edit flag on these files:\n\n"
foreach file $filelist {
append mess " $file\n"
}
message .uneditflag.top -justify left -aspect 300 -relief groove \
-text "Reset the edit flag on a file or files from the module."
pack .uneditflag.top -side top -fill x
message .uneditflag.middle -text $mess -aspect 200
pack .uneditflag.middle -side top -fill x
frame .uneditflag.down
button .uneditflag.down.remove -text "Unedit" \
-command {
grab release .uneditflag
destroy .uneditflag
cvs_unedit [workdir_list_files]
}
button .uneditflag.down.cancel -text "Cancel" \
-command { grab release .uneditflag; destroy .uneditflag }
pack .uneditflag.down -side bottom -fill x -expand 1
pack .uneditflag.down.remove .uneditflag.down.cancel -side left \
-ipadx 2 -ipady 2 -padx 4 -pady 4 -fill both -expand 1
wm title .uneditflag "Unedit Files"
dialog_position .uneditflag .workdir
wm minsize .uneditflag 1 1
gen_log:log T "LEAVE"
}
# CVS update with options. Called from workdir browser
proc cvs_update_options {} {
global cvsglb
global colorglb
global current_tagname
gen_log:log T "ENTER"
if {[winfo exists .cvs_update]} {
wm deiconify .cvs_update
raise .cvs_update
gen_log:log T "LEAVE"
return
}
# Set defaults
if {! [info exists cvsglb(tagmode_selection)]} {
update_set_defaults
}
toplevel .cvs_update
wm attributes .cvs_update -topmost 1
grab set .cvs_update
frame .cvs_update.explaintop
# Provide an explanation of this dialog box
message .cvs_update.explaintop.explain -justify left -aspect 500 -relief groove \
-text "Update all files in local directory"
frame .cvs_update.options
frame .cvs_update.options.whichrev -relief groove -borderwidth 2
frame .cvs_update.options.diropts -relief groove -borderwidth 2
frame .cvs_update.options.normbin -relief groove -borderwidth 2
frame .cvs_update.down
# Always pack OK/Cancel first so they don't disappear
pack .cvs_update.down -side bottom -fill x
pack .cvs_update.explaintop -side top -fill x -pady 1
pack .cvs_update.explaintop.explain -side top -fill x -pady 1
pack .cvs_update.options -side top -fill x -pady 1
pack .cvs_update.options.whichrev -side top -fill x
pack .cvs_update.options.diropts -side top -fill x
pack .cvs_update.options.normbin -side top -fill x
# keep-same-tag update
ttk::radiobutton .cvs_update.options.whichrev.keep \
-text "Keep same branch or trunk" \
-variable cvsglb(tagmode_selection) -value "Keep" \
-command {.cvs_update.options.whichrev.getrev.lblentry.tname configure -state disabled
.cvs_update.options.whichrev.getrev.lblentry.dirtag configure -state disabled}
# update to the head revision
ttk::radiobutton .cvs_update.options.whichrev.trunk \
-text "Update local files to be on main trunk (-A)" \
-variable cvsglb(tagmode_selection) -value "Trunk" \
-command {.cvs_update.options.whichrev.getrev.lblentry.tname configure -state disabled
.cvs_update.options.whichrev.getrev.lblentry.dirtag configure -state disabled}
# update to different branch/tag or not
ttk::radiobutton .cvs_update.options.whichrev.tag \
-text "Update (-r) local files to be on tag/branch" \
-variable cvsglb(tagmode_selection) -value "Getrev" \
-command {.cvs_update.options.whichrev.getrev.lblentry.tname configure -state normal
.cvs_update.options.whichrev.getrev.lblentry.dirtag configure -state normal}
message .cvs_update.options.whichrev.explainkeep -font $colorglb(listboxfont) \
-justify left -width 400 \
-text "If local directory is on main trunk, get latest on main trunk.
If local directory is on a branch, get latest on that branch.
If local directory/file has \"sticky\" non-branch tag, no update."
message .cvs_update.options.whichrev.explaintrunk -font $colorglb(listboxfont) \
-justify left -width 400 \
-text "Advice: If your local directories are currently on a branch,
you may want to commit any local changes to that branch first."
pack .cvs_update.options.whichrev.keep -side top -padx 4 -fill x
pack .cvs_update.options.whichrev.explainkeep \
-side top -fill x -pady 1 -ipady 0
pack .cvs_update.options.whichrev.trunk -side top -padx 4 -fill x
pack .cvs_update.options.whichrev.explaintrunk \
-side top -fill x -pady 1 -ipady 0
pack .cvs_update.options.whichrev.tag -side top -padx 4 -fill x
frame .cvs_update.options.whichrev.getrev
frame .cvs_update.options.whichrev.getrev.lblentry
label .cvs_update.options.whichrev.getrev.lblentry.tlbl -text "Tag Name" -anchor w
entry .cvs_update.options.whichrev.getrev.lblentry.tname -relief sunken \
-textvariable cvsglb(updatename)
button .cvs_update.options.whichrev.getrev.lblentry.dirtag -text "$current_tagname" \
-command {
set cvsglb(updatename) $current_tagname
}
message .cvs_update.options.whichrev.getrev.explaintag -font $colorglb(listboxfont) \
-justify left -width 400 \
-text "Advice: Update local files to main trunk (head) first.
Note: The tag will be 'sticky' for the directory and for each file."
pack .cvs_update.options.whichrev.getrev -side top -expand 1 -fill x
pack .cvs_update.options.whichrev.getrev.lblentry -side top -expand 1 -fill x
pack .cvs_update.options.whichrev.getrev.lblentry.tlbl -side left
pack .cvs_update.options.whichrev.getrev.lblentry.tname -side left -fill x -padx 2 -pady 4
pack .cvs_update.options.whichrev.getrev.lblentry.dirtag -side left -fill x -padx 2 -pady 4
pack .cvs_update.options.whichrev.getrev.explaintag \
-side top -fill x -pady 1 -ipady 0
# Where user chooses the action to take if tag is not on a file
label .cvs_update.options.whichrev.getrev.asknotfound \
-text "If file doesn't exist on this branch/tag:" -anchor w
frame .cvs_update.options.whichrev.getrev.notfound
ttk::radiobutton .cvs_update.options.whichrev.getrev.notfound.remove \
-text "Remove file from local directory" \
-variable cvsglb(action_notag) -value "Remove"
ttk::radiobutton .cvs_update.options.whichrev.getrev.notfound.gethead \
-text "Get head revision (-f)" \
-variable cvsglb(action_notag) -value "Get_head"
pack .cvs_update.options.whichrev.getrev.asknotfound -side top -fill x
pack .cvs_update.options.whichrev.getrev.notfound -side top -expand 1 -fill x
pack .cvs_update.options.whichrev.getrev.notfound.remove -side left -padx 4
pack .cvs_update.options.whichrev.getrev.notfound.gethead -side left -padx 4
# Recurse or not.
frame .cvs_update.options.diropts.radio1
ttk::radiobutton .cvs_update.options.diropts.radio1.recurse \
-text "Recurse the subdirectories" \
-variable cvsglb(update_recurse) -value "recurse" \
-command {
.cvs_update.options.diropts.getdir configure -state normal
.cvs_update.options.diropts.prune configure -state normal
.cvs_update.options.diropts.lblentry.tdir configure -state normal
}
ttk::radiobutton .cvs_update.options.diropts.radio1.local -text "This directory only (-l)" \
-variable cvsglb(update_recurse) -value "local" \
-command {
.cvs_update.options.diropts.getdir configure -state disabled
.cvs_update.options.diropts.prune configure -state disabled
.cvs_update.options.diropts.lblentry.tdir configure -state disabled
}
pack .cvs_update.options.diropts.radio1 -side top -expand 1 -fill x
pack .cvs_update.options.diropts.radio1.recurse -side left -padx 4
pack .cvs_update.options.diropts.radio1.local -side left -padx 4
label .cvs_update.options.diropts.prunelbl \
-text "\nIf directory is here but no longer in repository:" -anchor w
ttk::checkbutton .cvs_update.options.diropts.prune -text "Prune it (-P)" \
-variable cvsglb(update_prune) -onvalue "prune" -offvalue "no-prune"
# Where user chooses whether to pick up directories not currently in local
label .cvs_update.options.diropts.getlbl \
-text "If directory is in repository but not in local:" -anchor w
ttk::checkbutton .cvs_update.options.diropts.getdir -text "Get it (-d)" \
-variable cvsglb(get_all_dirs) -onvalue "Yes" -offvalue "No" \
-command {
if {$cvsglb(get_all_dirs) != "Yes"} {
.cvs_update.options.diropts.lblentry.tdir configure -state disabled
} else {
.cvs_update.options.diropts.lblentry.tdir configure -state normal
}
}
frame .cvs_update.options.diropts.lblentry
label .cvs_update.options.diropts.lblentry.tlbl -text "Specific directory (optional)" -anchor w
entry .cvs_update.options.diropts.lblentry.tdir -relief sunken -state disabled \
-textvariable cvsglb(getdirname)
# State of top radiobuttons (keep same, main, or tag)
if {$cvsglb(tagmode_selection) != "Getrev"} {
.cvs_update.options.whichrev.getrev.lblentry.tname configure -state disabled
.cvs_update.options.whichrev.getrev.lblentry.dirtag configure -state disabled
}
# state of -l radiobuttons
if {$cvsglb(update_recurse) != "recurse"} {
.cvs_update.options.diropts.getdir configure -state disabled
.cvs_update.options.diropts.prune configure -state disabled
.cvs_update.options.diropts.lblentry.tdir configure -state disabled
}
# State of -d checkbutton
if {$cvsglb(get_all_dirs) != "Yes"} {
.cvs_update.options.diropts.lblentry.tdir configure -state disabled
}
pack .cvs_update.options.diropts.prunelbl -side top -expand 1 -fill x
pack .cvs_update.options.diropts.prune -side top -padx 4 -expand 1 -fill x
pack .cvs_update.options.diropts.getlbl -side top -expand 1 -fill x
pack .cvs_update.options.diropts.getdir -side top -padx 4 -expand 1 -fill x
pack .cvs_update.options.diropts.lblentry -side top -expand 1 -fill x
pack .cvs_update.options.diropts.lblentry.tlbl -side left
pack .cvs_update.options.diropts.lblentry.tdir -side left -fill x -padx 2 -pady 4
# normal or binary?
label .cvs_update.options.normbin.lnormbin -text "Treat files as:" -anchor w
frame .cvs_update.options.normbin.radio
ttk::radiobutton .cvs_update.options.normbin.radio.normalfile -text "Normal file" \
-variable cvsglb(norm_bin) -value "Normal"
ttk::radiobutton .cvs_update.options.normbin.radio.binaryfile -text "Binary file (-kb)" \
-variable cvsglb(norm_bin) -value "Binary"
pack .cvs_update.options.normbin.lnormbin -side top -fill both
pack .cvs_update.options.normbin.radio -side top -expand 1 -fill x
pack .cvs_update.options.normbin.radio.normalfile -side left -padx 4
pack .cvs_update.options.normbin.radio.binaryfile -side left -padx 4
# The OK/Cancel buttons
button .cvs_update.ok -text "OK" \
-command { grab release .cvs_update; wm withdraw .cvs_update; cvs_opt_update }
button .cvs_update.apply -text "Apply" \
-command cvs_opt_update
button .cvs_update.reset -text "Reset defaults" \
-command update_set_defaults
button .cvs_update.quit -text "Close" \
-command { grab release .cvs_update; wm withdraw .cvs_update }
pack .cvs_update.ok .cvs_update.apply .cvs_update.reset .cvs_update.quit -in .cvs_update.down \
-side left -ipadx 2 -ipady 2 -padx 4 -pady 4 -fill both -expand 1
# Window Manager stuff
wm title .cvs_update "Update a Module"
wm minsize .cvs_update 1 1
dialog_position .cvs_update .workdir
gen_log:log T "LEAVE"
}
# Set defaults for "Update with Options" dialog
proc update_set_defaults {} {
global cvsglb
set cvsglb(tagmode_selection) "Keep"
set cvsglb(updatename) ""
set cvsglb(update_recurse) "recurse"
set cvsglb(action_notag) "Remove"
set cvsglb(update_prune) "prune"
set cvsglb(get_all_dirs) "No"
set cvsglb(getdirname) ""
set cvsglb(norm_bin) "Normal"
}
# Recursively add directories. Called from workdir browser.
proc addir_dialog {args} {
global cvs
global incvs insvn inrcs ingit
gen_log:log T "ENTER ($args)"
if {! $incvs} {
cvs_notincvs
return 1
}
set binflag ""
toplevel .add
wm attributes .add -topmost 1
grab set .add
set filelist [join $args]
if {$filelist == ""} {
set mess "This will add all new directories"
} else {
set mess "This will add these directories:\n\n"
foreach file $filelist {
append mess " $file\n"
}
}
message .add.top -justify left -aspect 300 -relief groove \
-text "Add (recursively) a directory to the module.\
The repository will not be changed until you do a commit."
pack .add.top -side top -fill x
message .add.middle -text $mess -aspect 200
pack .add.middle -side top -fill x
ttk::checkbutton .add.binary -text "-kb (binary)" \
-variable binflag -onvalue "-kb" -offvalue ""
pack .add.binary -side top -padx 4 -expand 1 -fill x
frame .add.down
button .add.down.add -text "Add" \
-command {
grab release .add
destroy .add
foreach dir [workdir_list_files] {
cvs_add_dir $binflag $dir
}
}
button .add.down.cancel -text "Cancel" \
-command { grab release .add; destroy .add }
pack .add.down -side bottom -fill x -expand 1
pack .add.down.add .add.down.cancel -side left \
-ipadx 2 -ipady 2 -padx 4 -pady 4 -fill both -expand 1
wm title .add "Add Directories"
dialog_position .add .workdir
wm minsize .add 1 1
return 0
gen_log:log T "LEAVE"
}
# Remove directories from module. Called from workdir browser
proc subtractdir_dialog {args} {
global cvs
global incvs insvn inrcs ingit
gen_log:log T "ENTER ($args)"
set filelist [join $args]
if {$filelist == ""} {
cvsfail "Please select some directories to remove first!" .workdir
return
}
toplevel .subtract
wm attributes .subtract -topmost 1
grab set .subtract
set mess "This will remove these directories:\n\n"
foreach file $filelist {
append mess " $file\n"
}
message .subtract.top -justify left -aspect 300 -relief groove \
-text "Remove (recursively) a directory from the module. The repository\
will not be changed until you do a commit."
pack .subtract.top -side top -fill x
message .subtract.middle -text $mess -aspect 200
pack .subtract.middle -side top -fill x
frame .subtract.down
button .subtract.down.remove -text "Remove"
if {$incvs} {
.subtract.down.remove configure -command {
grab release .subtract
destroy .subtract
cvs_remove_dir [workdir_list_files]
}
} elseif {$ingit} {
.subtract.down.remove configure -command {
grab release .subtract
destroy .subtract
git_remove_dir [workdir_list_files]
}
}
button .subtract.down.cancel -text "Cancel" \
-command { grab release .subtract; destroy .subtract }
pack .subtract.down -side bottom -fill x -expand 1
pack .subtract.down.remove .subtract.down.cancel -side left \
-ipadx 2 -ipady 2 -padx 4 -pady 4 -fill both -expand 1
wm title .subtract "Remove Directories"
dialog_position .subtract .workdir
wm minsize .subtract 1 1
gen_log:log T "LEAVE"
}
# For New Directory and Edit File. Allows entry of name. Called from workdir browser.
proc file_input_and_do {title command {filearg {}}} {
global filename
gen_log:log T "ENTER ($title $command)"
toplevel .file_input_and_do
wm attributes .file_input_and_do -topmost 1
grab set .file_input_and_do
frame .file_input_and_do.top
pack .file_input_and_do.top -side top -fill both -expand 1 -pady 4 -padx 4
label .file_input_and_do.top.lbl -text "File Name" -anchor w
entry .file_input_and_do.top.entry -relief sunken -textvariable filename
bind .file_input_and_do.top.entry \
{ .file_input_and_do.ok invoke }
pack .file_input_and_do.top.lbl -side left
pack .file_input_and_do.top.entry -side left -fill x -expand 1
frame .file_input_and_do.bottom
pack .file_input_and_do.bottom -side bottom -fill x -pady 4 -padx 4
# The command has to be a tcl command, not something to be exec'd
if {$filearg != ""} {
button .file_input_and_do.ok -text "Ok" \
-command "
.file_input_and_do.close invoke
$command $filearg \\\"\$filename\\\"
"
} else {
button .file_input_and_do.ok -text "Ok" \
-command "
.file_input_and_do.close invoke
$command \"\$filename\"
"
}
button .file_input_and_do.close -text "Cancel" \
-command {
grab release .file_input_and_do
destroy .file_input_and_do
}
pack .file_input_and_do.ok .file_input_and_do.close \
-in .file_input_and_do.bottom \
-side left -fill both -expand 1
wm title .file_input_and_do $title
dialog_position .file_input_and_do .workdir
wm minsize .file_input_and_do 1 1
focus .file_input_and_do.top.entry
gen_log:log T "LEAVE"
}
# To release a CVS directory from being recorded in the history
# file as checked out. Called from workdir browser
proc release_dialog { args } {
gen_log:log T "ENTER ($args)"
set delflag ""
toplevel .release
wm attributes .release -topmost 1
grab set .release
set filelist [join $args]
message .release.top -justify left -aspect 300 -relief groove \
-text "Tell CVS that the directory is no longer being\
worked on. CVS will stop tracking it in the\
CVS history file. Optionally, delete the directory."
pack .release.top -side top -fill x
ttk::checkbutton .release.binary -text "delete (-d)" \
-variable delflag -onvalue "-d" -offvalue ""
pack .release.binary -side top -padx 4 -expand 1 -fill x
frame .release.down
button .release.down.release -text "Release" \
-command {
grab release .release
destroy .release
cvs_release $delflag [workdir_list_files]
}
button .release.down.cancel -text "Cancel" \
-command { grab release .release; destroy .release }
pack .release.down -side bottom -fill x -expand 1
pack .release.down.release .release.down.cancel -side left \
-ipadx 2 -ipady 2 -padx 4 -pady 4 -fill both -expand 1
wm title .release "Release Directories"
dialog_position .release .workdir
wm minsize .release 1 1
gen_log:log T "LEAVE"
}
# SVN update with options. Called from workdir browser
proc svn_update_options {} {
global cvsglb
global colorglb
gen_log:log T "ENTER"
if {[winfo exists .svn_update]} {
wm deiconify .svn_update
raise .svn_update
gen_log:log T "LEAVE"
return
}
# Set defaults
if {! [info exists cvsglb(tagmode_selection)]} {
update_set_defaults
}
toplevel .svn_update
wm attributes .svn_update -topmost 1
frame .svn_update.explaintop
frame .svn_update.options
frame .svn_update.down
frame .svn_update.options.keep -relief groove -borderwidth 2
frame .svn_update.options.trunk -relief groove -borderwidth 2
frame .svn_update.options.branch -relief groove -borderwidth 2
frame .svn_update.options.tag -relief groove -borderwidth 2
frame .svn_update.options.revision -relief groove -borderwidth 2
pack .svn_update.down -side bottom -fill x
pack .svn_update.explaintop -side top -fill x -pady 1
pack .svn_update.options -side top -fill x -pady 1
# Provide an explanation of this dialog box
message .svn_update.explain -justify left -aspect 500 -relief groove \
-text "Update all files in local directory"
pack .svn_update.explain \
-in .svn_update.explaintop -side top -fill x
pack .svn_update.options.keep -side top -fill x
pack .svn_update.options.trunk -side top -fill x
pack .svn_update.options.branch -side top -fill x
pack .svn_update.options.tag -side top -fill x
pack .svn_update.options.revision -side top -fill x
# If the user wants to simply do a normal update
ttk::radiobutton .svn_update.options.keep.select \
-text "Update to most recent revision on same branch or trunk." \
-variable cvsglb(tagmode_selection) -value "Keep"
message .svn_update.options.keep.explain -font $colorglb(listboxfont) \
-justify left -width 400 \
-text "If local directory is on main trunk, get latest on main trunk.
If local directory is on a branch, get latest on that branch."
pack .svn_update.options.keep.select -side top -fill x -padx 4
pack .svn_update.options.keep.explain -side top -fill x -pady 1 -ipady 0
# If the user wants to update to the head revision
ttk::radiobutton .svn_update.options.trunk.select \
-text "Switch local files to be on main trunk" \
-variable cvsglb(tagmode_selection) -value "Trunk"
message .svn_update.options.trunk.explain -font $colorglb(listboxfont) \
-justify left -width 400 \
-text "Advice: If your local directories are currently on a branch, \
you may want to commit any local changes to that branch first."
pack .svn_update.options.trunk.select -side top -fill x -padx 4
pack .svn_update.options.trunk.explain -side top -fill x -pady 1 -ipady 0
# If the user wants to update to a branch
ttk::radiobutton .svn_update.options.branch.select \
-text "Switch local files to be on a branch" \
-variable cvsglb(tagmode_selection) -value "Branch"
frame .svn_update.options.branch.lblentry
label .svn_update.lbranch -text "Branch" -justify left
entry .svn_update.tbranch -relief sunken -textvariable cvsglb(branchname)
pack .svn_update.options.branch.select -side top -fill x -padx 4
pack .svn_update.options.branch.lblentry -side top -fill x \
-expand y -pady 1 -ipady 0
pack .svn_update.lbranch -in .svn_update.options.branch.lblentry \
-side left -fill x -pady 4
pack .svn_update.tbranch -in .svn_update.options.branch.lblentry \
-side left -fill x -padx 2 -pady 4
# If the user wants to update to a tag
ttk::radiobutton .svn_update.options.tag.select \
-text "Switch local files to be on a tag" \
-variable cvsglb(tagmode_selection) -value "Tag"
frame .svn_update.options.tag.lblentry
label .svn_update.ltag -text "Tag" -anchor w
entry .svn_update.ttag -relief sunken -textvariable cvsglb(tagname)
pack .svn_update.options.tag.select -side top -fill x -padx 4
pack .svn_update.options.tag.lblentry -side top -fill x \
-expand y -pady 1 -ipady 0
pack .svn_update.ltag -in .svn_update.options.tag.lblentry \
-side left -fill x -pady 4
pack .svn_update.ttag -in .svn_update.options.tag.lblentry \
-side left -fill x -padx 2 -pady 4
# Where user enters a revision number
ttk::radiobutton .svn_update.options.revision.select \
-text "Update local files to be a specific revision:" \
-variable cvsglb(tagmode_selection) -value "Revision"
frame .svn_update.options.revision.lblentry
label .svn_update.lrev -text "Revision" -anchor w
entry .svn_update.trev -relief sunken -textvariable cvsglb(revnumber)
pack .svn_update.options.revision.select -side top -fill x -padx 4
pack .svn_update.options.revision.lblentry -side top -fill x \
-expand y -pady 1 -ipady 0
pack .svn_update.lrev -in .svn_update.options.revision.lblentry \
-side left -fill x -pady 4
pack .svn_update.trev -in .svn_update.options.revision.lblentry \
-side left -fill x -padx 2 -pady 4
# The OK/Cancel buttons
button .svn_update.ok -text "OK" \
-command { svn_opt_update; wm withdraw .svn_update }
button .svn_update.apply -text "Apply" \
-command { svn_opt_update }
button .svn_update.quit -text "Close" \
-command { wm withdraw .svn_update }
pack .svn_update.ok .svn_update.apply .svn_update.quit -in .svn_update.down \
-side left -ipadx 2 -ipady 2 -padx 4 -pady 4 -fill both -expand 1
# Window Manager stuff
wm title .svn_update "Update from Repository"
dialog_position .svn_update .workdir
wm minsize .svn_update 1 1
gen_log:log T "LEAVE"
}
# Called from merge procs in svn.tcl and cvs.tcl
proc assemble_mergetags {from} {
global cvscfg
global current_tagname
gen_log:log T "ENTER ($from)"
# Construct tag names
set totagbegin [string first "_BRANCH_" $cvscfg(mergetoformat)]
set totagend [expr {$totagbegin + 8}]
set toprefix [string range $cvscfg(mergetoformat) 0 [expr {$totagbegin - 1}]]
set fromtagbegin [string first "_BRANCH_" $cvscfg(mergefromformat)]
set fromprefix [string range $cvscfg(mergefromformat) 0 [expr {$fromtagbegin - 1}]]
set datef [string range $cvscfg(mergetoformat) $totagend end]
set today [clock format [clock seconds] -format "$datef"]
if {[llength $current_tagname] == 1} {
set curr_tag $current_tagname
} else {
set curr_tag "trunk"
}
set curr $curr_tag
gen_log:log D "curr_tag $curr"
if {$curr == "trunk"} {set curr $cvscfg(mergetrunkname)}
if {$from == "trunk"} {set from $cvscfg(mergetrunkname)}
set totag "${toprefix}_${curr}_$today"
set fromtag "${fromprefix}_${from}_$today"
# I had symbolic tags in mind, but some people are using untagged versions.
# Substitute the dots, which are illegal for tagnames.
regsub -all {\.} $totag {-} totag
regsub -all {\.} $fromtag {-} fromtag
gen_log:log T "LEAVE ($curr_tag $fromtag $totag)"
return [list $curr_tag $fromtag $totag]
}
# Ask to verify and finish (commit) a merge. Called from workdir browser
proc dialog_merge_notice {sys from frombranch fromtag totag filelist} {
global cvscfg
if {[winfo exists .reminder]} {
destroy .reminder
}
toplevel .reminder
wm attributes .reminder -topmost 1
wm title .reminder "Tag and Commit"
dialog_position .reminder .workdir
frame .reminder.top
label .reminder.m1 -text \
"Now, you must examine the merged files and resolve any conflicts.\
\nLeave this dialog up, and when you are ready to commit,\
press the Ready button"
button .reminder.ready -text "I'm ready" \
-command {
foreach w {m2 totag fromtag bottom.ok} {
.reminder.$w configure -state normal
}
foreach w {m1 ready} {
.reminder.$w configure -state disabled
}
}
label .reminder.m2 -text \
"If you check the box, TkRev will apply the \"to\" tag,\
\ncommit your changes, and finally\napply the \"from\" tag.\
\nIf you don't check the box, the changes will be committed\
\nbut no tagging will be done"
ttk::checkbutton .reminder.autotag -text "Apply these tags" \
-variable cvscfg(auto_tag)
entry .reminder.totag -width 32
.reminder.totag insert end $totag
entry .reminder.fromtag -width 32
.reminder.fromtag insert end $fromtag
frame .reminder.bottom -relief raised -bd 2
button .reminder.bottom.cancel -text "Cancel" \
-command {destroy .reminder}
button .reminder.bottom.ok -text "OK" \
-command "${sys}_merge_tag_seq $from $frombranch $totag $fromtag $filelist;\
destroy .reminder"
pack .reminder.bottom -side bottom -fill x
pack .reminder.bottom.ok -side left -expand yes
pack .reminder.bottom.cancel -side right -expand yes
pack .reminder.top -side top -expand yes -fill both
pack .reminder.m1 -in .reminder.top -side top
pack .reminder.ready -in .reminder.top -side top
pack .reminder.m2 -in .reminder.top -side top
pack .reminder.autotag -in .reminder.top -side top -padx 4
pack .reminder.fromtag -in .reminder.top -side top -padx 2
pack .reminder.totag -in .reminder.top -side top -padx 2
foreach w {m2 totag fromtag bottom.ok} {
.reminder.$w configure -state disabled
}
}
# Keep a log of commit log messages. We want to do this whether the
# history has ever been examined by the user or not
proc commit_history {comment} {
global cvsglb
set comment [string trimright $comment]
set c 0
foreach ch [array names cvsglb commit_comment,*] {
if {$comment eq $cvsglb($ch)} {
# We already have this one. We don't have to
# do anything else.
gen_log:log D "Comment is a duplicate"
return
}
incr c
}
# We don't have this one yet
set cvsglb(commit_comment,$c) $comment
gen_log:log D "New comment $c"
if {[winfo exists .ci_history]} {
.ci_history.text insert end "$comment"
.ci_history.text insert end "\n"
.ci_history.text insert end "================================================================================\n"
}
}
# See the previous log messages
proc history_browser {} {
global cvsglb
gen_log:log T "ENTER history_browser"
if {! [winfo exists .ci_history]} {
toplevel .ci_history
wm protocol .ci_history WM_DELETE_WINDOW { wm withdraw .ci_history }
wm title .ci_history "Commit Log History for Session"
text .ci_history.text -setgrid yes -relief sunken -borderwidth 2 \
-exportselection 1 -yscrollcommand" .ci_history.scroll set"
ttk::scrollbar .ci_history.scroll -command ".ci_history.text yview"
frame .ci_history.bottom
search_textwidget_init
button .ci_history.bottom.srchbtn -text Search \
-command "search_textwidget .ci_history.text"
entry .ci_history.bottom.entry -width 20 -textvariable cvsglb(searchstr)
bind .ci_history.bottom.entry \
"search_textwidget .ci_history.text"
button .ci_history.bottom.close -text "Close" \
-command { wm withdraw .ci_history }
pack .ci_history.bottom -side bottom -fill x
pack .ci_history.scroll -side right -fill y
pack .ci_history.text -fill both -expand 1
pack .ci_history.bottom.srchbtn -side left
pack .ci_history.bottom.entry -side left
pack .ci_history.bottom.close -side right
# If this is the first time we've built the window, add the history we have so far
foreach ch [array names cvsglb commit_comment,*] {
.ci_history.text insert end $cvsglb($ch)
.ci_history.text insert end "\n"
.ci_history.text insert end "================================================================================\n"
}
}
wm deiconify .ci_history
gen_log:log T "LEAVE"
}
# Git update with options. Called from workdir bupdateopts button
proc git_update_options {} {
global cvscfg
global cvsglb
global colorglb
gen_log:log T "ENTER"
if {[winfo exists .git_update]} {
wm deiconify .git_update
raise .git_update
gen_log:log T "LEAVE"
return
}
# Set defaults
if {! [info exists cvsglb(tagmode_selection)]} {
update_set_defaults
}
toplevel .git_update
wm attributes .git_update -topmost 1
frame .git_update.explaintop
frame .git_update.options
frame .git_update.down
frame .git_update.options.keep -relief groove -borderwidth 2
frame .git_update.options.trunk -relief groove -borderwidth 2
frame .git_update.options.branch -relief groove -borderwidth 2
frame .git_update.options.tag -relief groove -borderwidth 2
frame .git_update.options.revision -relief groove -borderwidth 2
pack .git_update.down -side bottom -fill x
pack .git_update.explaintop -side top -fill x -pady 1
pack .git_update.options -side top -fill x -pady 1
# Provide an explanation of this dialog box
message .git_update.explain -justify left -aspect 500 -relief groove \
-text "Update all files in local directory"
pack .git_update.explain \
-in .git_update.explaintop -side top -fill x
pack .git_update.options.keep -side top -fill x
pack .git_update.options.trunk -side top -fill x
pack .git_update.options.branch -side top -fill x
pack .git_update.options.tag -side top -fill x
pack .git_update.options.revision -side top -fill x
# If the user wants to simply do a normal update
ttk::radiobutton .git_update.options.keep.select \
-text "Update to most recent revision on same branch or trunk." \
-variable cvsglb(tagmode_selection) -value "Keep"
message .git_update.options.keep.explain -font $colorglb(listboxfont) \
-justify left -width 400 \
-text "If local directory is on main trunk, get latest on main trunk.
If local directory is on a branch, get latest on that branch."
pack .git_update.options.keep.select -side top -fill x -padx 4
pack .git_update.options.keep.explain -side top -fill x -pady 1 -ipady 0
# If the user wants to update to the head revision
ttk::radiobutton .git_update.options.trunk.select \
-text "Switch local files to be on master" \
-variable cvsglb(tagmode_selection) -value "Trunk"
message .git_update.options.trunk.explain -font $colorglb(listboxfont) \
-justify left -width 400 \
-text "Advice: If your local directories are currently on a branch, \
you may want to commit any local changes to that branch first."
pack .git_update.options.trunk.select -side top -fill x -padx 4
pack .git_update.options.trunk.explain -side top -fill x -pady 1 -ipady 0
# If the user wants to update to a branch
ttk::radiobutton .git_update.options.branch.select \
-text "Switch local files to be on a branch" \
-variable cvsglb(tagmode_selection) -value "Branch"
frame .git_update.options.branch.lblentry
label .git_update.lbranch -text "Branch" -justify left
entry .git_update.tbranch -relief sunken -textvariable cvsglb(branchname)
pack .git_update.options.branch.select -side top -fill x -padx 4
pack .git_update.options.branch.lblentry -side top -fill x \
-expand y -pady 1 -ipady 0
pack .git_update.lbranch -in .git_update.options.branch.lblentry \
-side left -fill x -pady 4
pack .git_update.tbranch -in .git_update.options.branch.lblentry \
-side left -fill x -padx 2 -pady 4
# If the user wants to update to a tag
ttk::radiobutton .git_update.options.tag.select \
-text "Switch local files to be on a tag" \
-variable cvsglb(tagmode_selection) -value "Tag"
frame .git_update.options.tag.lblentry
label .git_update.ltag -text "Tag" -anchor w
entry .git_update.ttag -relief sunken -textvariable cvsglb(tagname)
pack .git_update.options.tag.select -side top -fill x -padx 4
pack .git_update.options.tag.lblentry -side top -fill x \
-expand y -pady 1 -ipady 0
pack .git_update.ltag -in .git_update.options.tag.lblentry \
-side left -fill x -pady 4
pack .git_update.ttag -in .git_update.options.tag.lblentry \
-side left -fill x -padx 2 -pady 4
# Where user enters a commit number
ttk::radiobutton .git_update.options.revision.select \
-text "Update local files to be a specific ID:" \
-variable cvsglb(tagmode_selection) -value "Commit"
frame .git_update.options.revision.lblentry
label .git_update.lrev -text "Commit ID" -anchor w
entry .git_update.trev -relief sunken -textvariable cvsglb(revnumber)
pack .git_update.options.revision.select -side top -fill x -padx 4
pack .git_update.options.revision.lblentry -side top -fill x \
-expand y -pady 1 -ipady 0
pack .git_update.lrev -in .git_update.options.revision.lblentry \
-side left -fill x -pady 4
pack .git_update.trev -in .git_update.options.revision.lblentry \
-side left -fill x -padx 2 -pady 4
# The OK/Cancel buttons
button .git_update.ok -text "OK" \
-command { git_opt_update; wm withdraw .git_update }
button .git_update.apply -text "Apply" \
-command { git_opt_update }
button .git_update.quit -text "Close" \
-command { wm withdraw .git_update }
pack .git_update.ok .git_update.apply .git_update.quit -in .git_update.down \
-side left -ipadx 2 -ipady 2 -padx 4 -pady 4 -fill both -expand 1
# Window Manager stuff
wm title .git_update "Update from Repository"
dialog_position .git_update .workdir
wm minsize .git_update 1 1
gen_log:log T "LEAVE"
}
# Toggle the state of a widget
proc toggle_state {widg} {
set curstate [$widg cget -state]
switch -- $curstate {
"normal" {
$widg configure -state disabled
}
"disabled" {
$widg configure -state normal
}
}
}
tkrev_9.6.1/tkrev/mkmanpage 0000775 0001750 0001750 00000001566 14702572343 016314 0 ustar dorothyr dorothyr #!/bin/sh
#-*-tcl-*-
# the next line restarts using tclsh \
exec tclsh "$0" -- ${1+"$@"}
# This prints the help text in manpage format
# First, source in the help procs
source help.tcl
# Get the manual sections as defined there
define_sections
# Nop the gen_log calls
proc gen_log:log {args} {}
set manpage "tkrev.1"
if {[catch {set fo [open $manpage w]}]} {
puts stderr "Can't open file $manpage"
exit
}
puts $fo ".TH tkrev 1"
puts $fo ".SH NAME"
puts $fo "\\fBtkrev\\fP - a Tk/Tcl Graphical Interface to CVS, Subversion and Git"
# Now do the sections in the online help
dict for {section title} $toc_dict {
# Call the proc in help.tcl
puts stderr $title
$section null "$title" $fo
}
puts $fo ".SH SEE ALSO"
puts $fo "\t\\fBtkdiff\\fP online help, \\fBcvs\\fP, \\fBsvn\\fP, \\fBgit<\\fP"
close $fo
puts "Wrote $manpage"
puts "To look at it, \"man -l tkrev.1\""
tkrev_9.6.1/tkrev/modbrowse.tcl 0000664 0001750 0001750 00000062432 15024174573 017133 0 ustar dorothyr dorothyr #
# Set up a check out dialog.
#
proc modbrowse_setup {} {
global cwd
global cvsroot
global modbrowse_module
global modbrowse_path
global modbrowse_title
global env
global cvsglb
global cvscfg
global colorglb
global tcl_platform
gen_log:log T "ENTER"
set cwd [pwd]
if {[winfo exists .modbrowse]} {
wm deiconify .modbrowse
raise .modbrowse
return
}
# Window manager stuff.
toplevel .modbrowse
wm title .modbrowse "TkRev Repository Browser"
wm iconname .modbrowse "TkRev Repository Browser"
wm iconphoto .modbrowse -default AppIcon
wm minsize .modbrowse 430 300
wm protocol .modbrowse WM_DELETE_WINDOW {.modbrowse.bottom.buttons.close invoke}
wm withdraw .modbrowse
if {[info exists cvscfg(modgeom)]} {
update
wm geometry .modbrowse $cvscfg(modgeom)
}
menubar_menus .modbrowse
modbrowse_menus .modbrowse
help_menu .modbrowse
#
# Top section - module, tags, root
#
frame .modbrowse.top -relief groove -borderwidth 2
pack .modbrowse.top -side top -fill x
label .modbrowse.top.lmcode -text "Module"
entry .modbrowse.top.tmcode -textvariable modbrowse_module \
-font $colorglb(listboxfont) -borderwidth 2
bind .modbrowse.top.tmcode { modbrowse_run }
# We have these possibilities
foreach VCS {cvs svn git} {
if {[info exists env(${VCS}ROOT)]} {
gen_log:log D "env(${VCS}ROOT) $env(${VCS}ROOT)"
picklist_used cvsroot "$env(${VCS}ROOT)"
}
}
foreach VCS {cvs svn git} {
if {[info exists cvscfg(${VCS}root)]} {
gen_log:log D "cvscfg(${VCS}root) $cvscfg(${VCS}root)"
picklist_used cvsroot "$cvscfg(${VCS}root)"
}
}
# Where do we think we are?
gen_log:log D "cvsglb(root) $cvsglb(root) cvsglb(vcs) $cvsglb(vcs)"
label .modbrowse.top.lroot -text "Repository"
ttk::combobox .modbrowse.top.troot -textvariable cvsglb(root)
.modbrowse.top.troot configure -values $cvsglb(cvsroot)
bind .modbrowse.top.troot { modbrowse_run }
bind .modbrowse.top.troot <> { modbrowse_run }
button .modbrowse.top.bworkdir -image Workdir \
-command {workdir_setup}
label .modbrowse.top.lcwd -text "Current Directory"
ttk::combobox .modbrowse.top.tcwd -textvariable cwd
.modbrowse.top.tcwd configure -values $cvsglb(directory)
.modbrowse.top.tcwd configure -values $cvsglb(directory)
bind .modbrowse.top.tcwd {set cwd [validate_dirpath %W $cwd]}
bind .modbrowse.top.tcwd ".modbrowse.top.tcwd configure -foreground $colorglb(textfg)"
bind .modbrowse.top.tcwd {
if {[change_dir "$cwd"]} {%W configure -foreground black}
}
bind .modbrowse.top.tcwd <> {
if {[change_dir "$cwd"]} {%W configure -foreground black}
}
grid columnconf .modbrowse.top 1 -weight 1
grid rowconf .modbrowse.top 3 -weight 1
grid .modbrowse.top.lroot -column 0 -row 0 -sticky w
grid .modbrowse.top.troot -column 1 -row 0 -columnspan 2 -padx 4 -sticky ew
grid .modbrowse.top.lmcode -column 0 -row 1 -sticky w
grid .modbrowse.top.tmcode -column 1 -row 1 -padx 3 -sticky ew
grid .modbrowse.top.lcwd -column 0 -row 2 -sticky w
grid .modbrowse.top.tcwd -column 1 -row 2 -padx 4 -sticky ew
grid .modbrowse.top.bworkdir -column 2 -row 1 -rowspan 2 -sticky w
# Pack the bottom before the middle so it doesnt disappear if
# the window is resized smaller
frame .modbrowse.bottom -relief groove -borderwidth 2 -height 128
frame .modbrowse.bottom.buttons
frame .modbrowse.bottom.buttons.cvsfuncs -relief groove -bd 2
frame .modbrowse.bottom.buttons.svnfuncs -relief groove -bd 2
frame .modbrowse.bottom.buttons.modfuncs -relief groove -bd 2
frame .modbrowse.bottom.buttons.closefm
pack .modbrowse.bottom -side bottom -fill x
pack .modbrowse.bottom.buttons -side top -fill x -expand yes
pack .modbrowse.bottom.buttons.closefm -side right -expand yes
pack .modbrowse.bottom.buttons.cvsfuncs -side left
pack .modbrowse.bottom.buttons.svnfuncs -side left -expand yes
pack .modbrowse.bottom.buttons.modfuncs -side left -expand yes
#
# Create buttons
#
button .modbrowse.bottom.buttons.modfuncs.filebrowse -image Files \
-command { browse_files $modbrowse_module }
button .modbrowse.bottom.buttons.modfuncs.patchsummary -image Patches \
-command { dialog_cvs_patch $cvscfg(cvsroot) $modbrowse_module 1 }
button .modbrowse.bottom.buttons.modfuncs.patchfile -image Patchfile \
-command { dialog_cvs_patch $cvscfg(cvsroot) $modbrowse_module 0 }
button .modbrowse.bottom.buttons.modfuncs.checkout -image Checkout \
-command { dialog_cvs_checkout $cvscfg(cvsroot) $modbrowse_module }
button .modbrowse.bottom.buttons.modfuncs.export -image Export \
-command { dialog_cvs_export $cvscfg(cvsroot) $modbrowse_module }
button .modbrowse.bottom.buttons.modfuncs.tag -image Tag \
-command { rtag_dialog $cvscfg(cvsroot) $modbrowse_module "tag" }
button .modbrowse.bottom.buttons.modfuncs.branchtag -image Branchtag \
-command { rtag_dialog $cvscfg(cvsroot) $modbrowse_module "branch" }
button .modbrowse.bottom.buttons.svnfuncs.filecat -image Fileview \
-command { svn_filecat $cvscfg(svnroot) $modbrowse_path $modbrowse_title}
button .modbrowse.bottom.buttons.svnfuncs.filelog -image Log \
-command { svn_filelog $cvscfg(svnroot) $modbrowse_path $modbrowse_title}
button .modbrowse.bottom.buttons.svnfuncs.remove -image SvnRemove \
-command { svn_delete $cvscfg(svnroot) $modbrowse_path }
button .modbrowse.bottom.buttons.cvsfuncs.import -image Import \
-command { cvs_import_setup }
button .modbrowse.bottom.buttons.cvsfuncs.who -image Who \
-command {cvs_history all $modbrowse_module}
button .modbrowse.bottom.buttons.cvsfuncs.brefresh -image Refresh \
-command { modbrowse_run }
button .modbrowse.bottom.buttons.close -text "Close" \
-command { module_exit; exit_cleanup 0 }
grid .modbrowse.bottom.buttons.cvsfuncs.brefresh -column 0 -row 0 \
-ipadx 4 -ipady 4
grid .modbrowse.bottom.buttons.cvsfuncs.who -column 1 -row 0 \
-ipadx 4 -ipady 4
grid .modbrowse.bottom.buttons.cvsfuncs.import -column 2 -row 0 \
-ipadx 4 -ipady 4
grid .modbrowse.bottom.buttons.modfuncs.filebrowse -column 0 -row 0 \
-ipadx 4 -ipady 4
grid .modbrowse.bottom.buttons.modfuncs.checkout -column 1 -row 0 \
-ipadx 4 -ipady 4
grid .modbrowse.bottom.buttons.modfuncs.export -column 2 -row 0 \
-ipadx 4 -ipady 4
grid .modbrowse.bottom.buttons.modfuncs.tag -column 3 -row 0 \
-ipadx 4 -ipady 4
grid .modbrowse.bottom.buttons.modfuncs.branchtag -column 4 -row 0 \
-ipadx 4 -ipady 4
grid .modbrowse.bottom.buttons.modfuncs.patchsummary -column 5 -row 0 \
-ipadx 4 -ipady 4
grid .modbrowse.bottom.buttons.modfuncs.patchfile -column 6 -row 0 \
-ipadx 4 -ipady 4
grid .modbrowse.bottom.buttons.svnfuncs.filecat -column 0 -row 0 \
-ipadx 4 -ipady 4
grid .modbrowse.bottom.buttons.svnfuncs.filelog -column 1 -row 0 \
-ipadx 4 -ipady 4
grid .modbrowse.bottom.buttons.svnfuncs.remove -column 2 -row 0 \
-ipadx 4 -ipady 4
pack .modbrowse.bottom.buttons.close \
-in .modbrowse.bottom.buttons.closefm -side right \
-fill both -expand yes
set_tooltips .modbrowse.bottom.buttons.modfuncs.checkout \
{"Check out selection from the repository"}
set_tooltips .modbrowse.bottom.buttons.modfuncs.export \
{"Export selection from the repository"}
set_tooltips .modbrowse.bottom.buttons.modfuncs.tag \
{"Tag all files in a module"}
set_tooltips .modbrowse.bottom.buttons.modfuncs.branchtag \
{"Branch all files in a module"}
set_tooltips .modbrowse.bottom.buttons.modfuncs.filebrowse \
{"Browse the files in a CVS module"}
set_tooltips .modbrowse.bottom.buttons.svnfuncs.filecat \
{"Show a file in the repository"}
set_tooltips .modbrowse.bottom.buttons.svnfuncs.filelog \
{"Show the history log of a file"}
set_tooltips .modbrowse.bottom.buttons.svnfuncs.remove \
{"Remove something from the SVN repository"}
set_tooltips .modbrowse.bottom.buttons.modfuncs.patchsummary \
{"Show a summary of differences between versions"}
set_tooltips .modbrowse.bottom.buttons.modfuncs.patchfile \
{"Create a patch file"}
set_tooltips .modbrowse.bottom.buttons.cvsfuncs.import \
{"Import the current directory into the repository"}
set_tooltips .modbrowse.bottom.buttons.cvsfuncs.who \
{"Show who has modules checked out"}
set_tooltips .modbrowse.bottom.buttons.cvsfuncs.brefresh \
{"Re-read the modules"}
set_tooltips .modbrowse.bottom.buttons.close \
{"Close the repository browser"}
set_tooltips .modbrowse.top.bworkdir \
{"Open the Working Directory Browser"}
frame .modbrowse.treeframe -bg $colorglb(treebg)
pack .modbrowse.treeframe -side bottom -fill both -expand yes -pady 0
set screenWidth [winfo vrootwidth .]
set screenHeight [winfo vrootheight .]
wm maxsize .modbrowse $screenWidth $screenHeight
wm minsize .modbrowse 430 300
gen_log:log T "LEAVE"
}
# Try to contact the repository somehow to guess what kind it is
proc modbrowse_guess_vcs {} {
global cvsglb
global cvscfg
global modbrowse_module
gen_log:log T "ENTER"
gen_log:log D "cvsglb(root) = $cvsglb(root)"
# If there's no root at all, don't waste our time
if {$cvsglb(root) eq ""} {
gen_log:log D "cvsglb(root) is empty. Not proceeding further."
gen_log:log T "LEAVE ($cvsglb(vcs))"
return $cvsglb(vcs)
}
set vcs ""
set cvs_cmd "cvs -d $cvsglb(root) rdiff -l -s -D 01/01/1971 \"$modbrowse_module\""
gen_log:log C $cvs_cmd
set cvsret [catch {exec {*}$cvs_cmd > $cvscfg(null)} cvsout]
if {[string match {*Diffing*} $cvsout]} {
gen_log:log T "LEAVE (cvs)"
return "cvs"
} else {
gen_log:log E $cvsout
}
set svn_cmd "svn list $cvsglb(root)"
gen_log:log C $svn_cmd
set svnret [catch {exec {*}$svn_cmd} svnout]
if {$svnret} {
gen_log:log E $svnout
} else {
gen_log:log T "LEAVE (svn)"
return "svn"
}
set git_cmd "git ls-remote $cvsglb(root)"
gen_log:log C $git_cmd
set gitret [catch {exec {*}$git_cmd} gitout]
if {$gitret} {
gen_log:log E $gitout
} else {
set cvscfg(gitroot) $cvsglb(root)
gen_log:log T "LEAVE (git)"
return "git"
}
gen_log:log T "LEAVE ($cvsglb(vcs))"
return $cvsglb(vcs)
}
proc modbrowse_run {} {
global env
global incvs insvn inrcs ingit
global cvscfg
global cvsglb
global cvs
global cmd
global cvsroot
global modval
global modtitle
global modbrowse_module
global modbrowse_path
global modbrowse_title
gen_log:log T "ENTER ()"
gen_log:log D "incvs=$incvs insvn=$insvn inrcs=$inrcs ingit=$ingit"
gen_log:log D "cvsglb(root) $cvsglb(root)"
catch {unset modval}
catch {unset modtitle}
set modbrowse_module ""
if {$incvs} {
set cvsglb(vcs) cvs
read_cvs_dir "[pwd]/CVS"
} elseif {$insvn} {
set cvsglb(vcs) svn
read_svn_dir "[pwd]"
set cvsglb(root) $cvscfg(url)
set cvscfg(root) $cvsglb(root)
} elseif {$ingit} {
set cvsglb(vcs) git
read_git_dir "[pwd]"
set cvsglb(root) $cvsglb(repos_top)
} elseif {$inrcs} {
set cvsglb(vcs) rcs
} else {
set cvsglb(vcs) [modbrowse_guess_vcs]
}
gen_log:log D "cvsglb(vcs) $cvsglb(vcs)"
if {! [winfo exists .modbrowse]} {
modbrowse_setup
}
wm deiconify .modbrowse
raise .modbrowse
ModTree:destroy .modbrowse.treeframe
busy_start .modbrowse
switch $cvsglb(vcs) {
svn {
.modbrowse.top.lroot configure -text "SVN URL"
.modbrowse.top.lmcode configure -text "Selection"
# Set up ModTree and tell it to use clbk just-in-time-listdir
ModTree:create .modbrowse.treeframe
pack .modbrowse.treeframe.pw -side bottom -fill both -expand yes
.modbrowse.treeframe.pw heading file -text "File"
.modbrowse.treeframe.pw heading information -text "Date"
.modbrowse.treeframe.pw configure -selectmode extended
# parse_svnmodules will do "svn list" and post the files and directories
bind .modbrowse.treeframe.pw <> svn_jit_listdir
bind .modbrowse.treeframe.pw <> svn_closedir
bind .modbrowse.treeframe.pw <> {
global modbrowse_module
global modbrowse_path
global modbrowse_title
set selection [.modbrowse.treeframe.pw selection]
set modbrowse_title [string trimleft $selection "/"]
set modbrowse_path $modbrowse_title
set modbrowse_module $modbrowse_path
}
# parse_svnmodules does svn list of the repository
# For SVN. The URL changes depending on what directory we're in, so if we're
# in an SVN directory, use svnroot instead of cvsglb(root)
if {! [info exists cvscfg(svnroot)]} {
set cvscfg(svnroot) $cvsglb(root)
}
parse_svnmodules $cvscfg(svnroot)
}
cvs {
.modbrowse.top.lroot configure -text "CVSROOT"
.modbrowse.top.lmcode configure -text "Module"
# Set up ModTree
ModTree:create .modbrowse.treeframe
pack .modbrowse.treeframe.pw -side bottom -fill both -expand yes
.modbrowse.treeframe.pw heading file -text "Module"
.modbrowse.treeframe.pw heading information -text "Information"
.modbrowse.treeframe.pw column #0 -width [expr {$cvsglb(mod_iconwidth) * 2}]
.modbrowse.treeframe.pw configure -selectmode extended
bind .modbrowse.treeframe.pw <> {
global modbrowse_module
global modbrowse_path
global modbrowse_title
set selection [.modbrowse.treeframe.pw selection]
set modbrowse_title [string trimleft $selection "/"]
set modbrowse_path $modbrowse_title
set modbrowse_module $modbrowse_path
}
# parse_cvsmodules will check out CVSROOT/modules and post what it finds
parse_cvsmodules $cvsglb(root)
}
git {
.modbrowse.top.lroot configure -text "Origin"
.modbrowse.top.lmcode configure -text "Selection"
# Set up ModTree for a git ls-remote
ModTree:create .modbrowse.treeframe
pack .modbrowse.treeframe.pw -side bottom -fill both -expand yes
.modbrowse.treeframe.pw heading file -text "Reference"
.modbrowse.treeframe.pw heading information -text "Commit ID"
.modbrowse.treeframe.pw column #0 -width 0
.modbrowse.treeframe.pw configure -selectmode browse
bind .modbrowse.treeframe.pw <> {
global modbrowse_module
global modbrowse_path
global modbrowse_title
set selection [.modbrowse.treeframe.pw selection]
set modbrowse_title $selection
set modbrowse_path $modbrowse_title
# The hash, not the name
lappend modbrowse_module [lindex [.modbrowse.treeframe.pw item $modbrowse_path -values] 1]
}
# parse_gitlist will do git ls-remote and post what it finds
parse_gitlist $cvsglb(root)
}
rcs {
.modbrowse.top.lroot configure -text "RCS Path"
.modbrowse.top.lmcode configure -text "Selection"
# There's no such thing as a remote RCS repository as far as I know,
# so we can just do a directory listing
ModTree:create .modbrowse.treeframe
pack .modbrowse.treeframe.pw -side bottom -fill both -expand yes
.modbrowse.treeframe.pw heading file -text "File"
.modbrowse.treeframe.pw heading information -text "Date"
.modbrowse.treeframe.pw column #0 -width 0
.modbrowse.treeframe.pw column #2 -width 150
.modbrowse.treeframe.pw column #2 -width 30
.modbrowse.treeframe.pw configure -selectmode browse
bind .modbrowse.treeframe.pw <> {
global modbrowse_module
global modbrowse_path
global modbrowse_title
set selection [.modbrowse.treeframe.pw selection]
set modbrowse_title $selection
set modbrowse_path $modbrowse_title
#set modbrowse_module $modbrowse_path
set modbrowse_module [lindex [.modbrowse.treeframe.pw item $modbrowse_path -values] 0]
}
find_rcsfiles $cvsglb(root)
}
default {
# Just make an empty frame
ModTree:create .modbrowse.treeframe
pack .modbrowse.treeframe.pw -side bottom -fill both -expand yes
busy_done .modbrowse
return
}
}
busy_done .modbrowse
# Maybe this root is new to us?
picklist_used cvsroot "$cvsglb(root)"
# Have to do this to display the new value in the list
.modbrowse.top.troot configure -values $cvsglb(cvsroot)
# Start without revision-control menu
gen_log:log D "CONFIGURE VCS MENUS"
foreach label {"CVS" "SVN" "GIT" "RCS" "Import"} {
if {! [catch {set vcsmenu_idx [.modbrowse.menubar index "$label"]}]} {
.modbrowse.menubar delete $vcsmenu_idx
}
}
set filemenu_idx [.modbrowse.menubar index "File"]
switch $cvsglb(vcs) {
cvs {
.modbrowse.bottom.buttons.modfuncs.filebrowse configure \
-command { browse_files $modbrowse_module }
.modbrowse.bottom.buttons.modfuncs.checkout configure -state normal \
-command { dialog_cvs_checkout $cvscfg(cvsroot) $modbrowse_module }
.modbrowse.bottom.buttons.cvsfuncs.import configure -state normal \
-command { cvs_import_setup }
.modbrowse.bottom.buttons.modfuncs.checkout configure -state normal \
-command { dialog_cvs_checkout $cvscfg(cvsroot) $modbrowse_module }
.modbrowse.bottom.buttons.modfuncs.export configure -state normal \
-command { dialog_cvs_export $cvscfg(cvsroot) $modbrowse_module }
.modbrowse.bottom.buttons.modfuncs.tag configure -state normal \
-command { rtag_dialog $cvscfg(cvsroot) $modbrowse_module "tag" }
.modbrowse.bottom.buttons.modfuncs.branchtag configure -state normal \
-command { rtag_dialog $cvscfg(cvsroot) $modbrowse_module "branch" }
.modbrowse.bottom.buttons.modfuncs.patchsummary configure -state normal \
-command { dialog_cvs_patch $cvscfg(cvsroot) $modbrowse_module 1 }
.modbrowse.bottom.buttons.modfuncs.patchfile configure -state normal \
-command { dialog_cvs_patch $cvscfg(cvsroot) $modbrowse_module 0 }
.modbrowse.bottom.buttons.cvsfuncs.who configure -state normal
.modbrowse.bottom.buttons.svnfuncs.filecat configure -state disabled
.modbrowse.bottom.buttons.svnfuncs.filelog configure -state disabled
.modbrowse.bottom.buttons.svnfuncs.remove configure -state disabled
.modbrowse.menubar insert [expr {$filemenu_idx + 1}] cascade -label "CVS" \
-menu .modbrowse.menubar.cvs
}
svn {
.modbrowse.bottom.buttons.cvsfuncs.import configure -state normal \
-command { svn_import_run }
.modbrowse.bottom.buttons.modfuncs.filebrowse configure -state disabled
.modbrowse.bottom.buttons.modfuncs.checkout configure -state normal \
-command { dialog_svn_checkout $cvscfg(svnroot) $modbrowse_path checkout}
.modbrowse.bottom.buttons.modfuncs.export configure -state normal \
-command { dialog_svn_checkout $cvscfg(svnroot) $modbrowse_path export}
.modbrowse.bottom.buttons.modfuncs.tag configure -state normal \
-command { dialog_svn_tag $cvscfg(svnroot) $modbrowse_path "tags" }
.modbrowse.bottom.buttons.modfuncs.branchtag configure -state normal \
-command { dialog_svn_tag $cvscfg(svnroot) $modbrowse_path "branches" }
.modbrowse.bottom.buttons.modfuncs.patchsummary configure -state normal \
-command { dialog_svn_patch $cvscfg(svnroot) $modbrowse_path {} 1 }
.modbrowse.bottom.buttons.modfuncs.patchfile configure -state normal \
-command { dialog_svn_patch $cvscfg(svnroot) $modbrowse_path {} 0 }
.modbrowse.bottom.buttons.cvsfuncs.who configure -state disabled
.modbrowse.bottom.buttons.svnfuncs.filecat configure -state normal
.modbrowse.bottom.buttons.svnfuncs.filelog configure -state normal
.modbrowse.bottom.buttons.svnfuncs.remove configure -state normal
.modbrowse.menubar insert [expr {$filemenu_idx + 1}] cascade -label "SVN" \
-menu .modbrowse.menubar.svn
}
git {
# Disable all except clone
.modbrowse.bottom.buttons.cvsfuncs.import configure -state disabled
.modbrowse.bottom.buttons.modfuncs.filebrowse configure -state disabled
.modbrowse.bottom.buttons.modfuncs.checkout configure -state normal \
-command { dialog_git_clone $cvscfg(gitroot) $modbrowse_module }
.modbrowse.bottom.buttons.modfuncs.export configure -state disabled
.modbrowse.bottom.buttons.modfuncs.tag configure -state disabled
.modbrowse.bottom.buttons.modfuncs.branchtag configure -state disabled
.modbrowse.bottom.buttons.modfuncs.patchsummary configure -state disabled
.modbrowse.bottom.buttons.modfuncs.patchfile configure -state disabled
.modbrowse.bottom.buttons.cvsfuncs.who configure -state disabled
.modbrowse.bottom.buttons.svnfuncs.filecat configure -state disabled
.modbrowse.bottom.buttons.svnfuncs.filelog configure -state disabled
.modbrowse.bottom.buttons.svnfuncs.remove configure -state disabled
.modbrowse.menubar insert [expr {$filemenu_idx + 1}] cascade -label "GIT" \
-menu .modbrowse.menubar.git
}
rcs {
# Disable all except fileview and filelog
.modbrowse.bottom.buttons.cvsfuncs.import configure -state disabled
.modbrowse.bottom.buttons.modfuncs.filebrowse configure -state disabled
.modbrowse.bottom.buttons.modfuncs.checkout configure -state disabled
.modbrowse.bottom.buttons.modfuncs.export configure -state disabled
.modbrowse.bottom.buttons.modfuncs.tag configure -state disabled
.modbrowse.bottom.buttons.modfuncs.branchtag configure -state disabled
.modbrowse.bottom.buttons.modfuncs.patchsummary configure -state disabled
.modbrowse.bottom.buttons.modfuncs.patchfile configure -state disabled
.modbrowse.bottom.buttons.cvsfuncs.who configure -state disabled
.modbrowse.bottom.buttons.svnfuncs.filecat configure -state normal \
-command { rcs_fileview_checkout . "$modbrowse_module" }
.modbrowse.bottom.buttons.svnfuncs.filelog configure -state normal \
-command { rcs_log verbose "$modbrowse_module" }
.modbrowse.bottom.buttons.svnfuncs.remove configure -state disabled
}
default {
# Disable all
.modbrowse.bottom.buttons.cvsfuncs.import configure -state disabled
.modbrowse.bottom.buttons.modfuncs.filebrowse configure -state disabled
.modbrowse.bottom.buttons.modfuncs.checkout configure -state disabled
.modbrowse.bottom.buttons.modfuncs.export configure -state disabled
.modbrowse.bottom.buttons.modfuncs.tag configure -state disabled
.modbrowse.bottom.buttons.modfuncs.branchtag configure -state disabled
.modbrowse.bottom.buttons.modfuncs.patchsummary configure -state disabled
.modbrowse.bottom.buttons.modfuncs.patchfile configure -state disabled
.modbrowse.bottom.buttons.cvsfuncs.who configure -state disabled
.modbrowse.bottom.buttons.svnfuncs.filecat configure -state disabled
.modbrowse.bottom.buttons.svnfuncs.filelog configure -state disabled
.modbrowse.bottom.buttons.svnfuncs.remove configure -state disabled
}
}
if {$insvn || $incvs || $inrcs || $ingit} {
# Don't allow an attempt to import from a version-controlled directory
.modbrowse.bottom.buttons.cvsfuncs.import configure -state disabled
}
# Populate the tree
switch $cvsglb(vcs) {
svn {
# Make sure branches and tags names come first, before any of their
# contents, so we get the "# tags" and "# branches" labels
set newlist ""
foreach item [array names modval] {
if {! ($item == $cvscfg(svn_branchdir) || $item == $cvscfg(svn_tagdir))} {
lappend newlist $item
}
}
set newlist [lsort $newlist]
set newlist [concat {$cvscfg(svn_branchdir} {$cvscfg(svn_tagdir)} $newlist]
}
cvs {
cvs_modbrowse_tree [lsort [array names modval]] "/"
}
git {
# Nothing to do here
}
}
busy_done .modbrowse
gen_log:log T "LEAVE"
}
proc module_exit { } {
global cvscfg
global cvs
global cmd
gen_log:log T "ENTER"
# Stop any checkout that may be in process
if {[info exists cmd(cvs_co)]} {
catch {$cmd(cvs_co)\::abort}
catch {unset cmd(cvs_co)}
}
set pid [pid]
set cwd [pwd]
set sandbox [file join $cvscfg(tmpdir) cvstmpdir.$pid]
if {[file isdirectory $sandbox]} {
gen_log:log F "CD $sandbox"
cd $sandbox
set dirs ""
foreach d [glob -nocomplain *] {
lappend dirs $d
}
gen_log:log C "$cvs -Q release $dirs"
catch {exec {*}$cvs -Q release $dirs}
# Doing it this way makes it pop up an error on windows.
# Very annoying.
#set finish [exec::new "$cvs -Q release $dirs"]
#$finish\::wait
}
cd $cwd
gen_log:log F "CD [pwd]"
set cvscfg(modgeom) [wm geometry .modbrowse]
ModTree:destroy .modbrowse.modtree
destroy .modbrowse
catch {destroy .tooltips_wind}
exit_cleanup 0
gen_log:log T "LEAVE"
}
proc ModTree:create {w} {
global cvsglb
global cvscfg
ttk::treeview $w.pw -yscrollcommand "$w.yscroll set"
$w.pw configure -columns "file information"
$w.pw column #0 -minwidth 0
$w.pw column #0 -width $cvsglb(mod_iconwidth)
$w.pw column #0 -stretch no
ttk::scrollbar $w.yscroll -orient vertical \
-command "$w.pw yview"
pack $w.yscroll -side right -fill y
focus $w.pw
}
proc ModTree:destroy {w} {
destroy $w.pw
destroy $w.yscroll
}
tkrev_9.6.1/tkrev/preferences.tcl 0000664 0001750 0001750 00000034074 14715513010 017421 0 ustar dorothyr dorothyr
# Make a tabbed notebook for Preferences
proc prefdialog {} {
global cvscfg
if {[winfo exists .prefdlg]} {
destroy .prefdlg
}
set pd .prefdlg
toplevel $pd
wm title $pd "TkRev Preferences"
wm protocol $pd WM_DELETE_WINDOW { prefs_close }
wm withdraw .prefdlg
lassign [winfo pointerxy .] x y
incr x -150
wm geometry .prefdlg +$x+$y
ttk::notebook $pd.prefnb
ttk::notebook::enableTraversal $pd.prefnb
frame $pd.bot -relief raised -bd 2
button $pd.bot.save -text "Save" -command { set cvsglb(vcspref) $cvscfg(vcspref); save_options }
button $pd.bot.close -text "Close" -command { prefs_close }
pack $pd.bot.save -side left -padx 4 -pady 2
pack $pd.bot.close -side right -padx 4 -pady 2
pack $pd.bot -side bottom -expand 0 -fill x
# Build the pages
prefs_general $pd.prefnb
prefs_diagram $pd.prefnb
prefs_git $pd.prefnb
prefs_subversion $pd.prefnb
prefs_cvs $pd.prefnb
pack $pd.prefnb -side top -expand y -fill both
if {[info exists cvscfg(preftab)]} {
.prefdlg.prefnb select $cvscfg(preftab)
}
if {! [winfo ismapped .prefdlg]} {
wm deiconify .prefdlg
}
bind .prefdlg.prefnb <> {set cvscfg(preftab) [.prefdlg.prefnb select]}
raise $pd
}
# General preferences
proc prefs_general {w} {
global cvscfg
global colorglb
frame $w.general -background $colorglb(menubg)
$w add $w.general -text "General" -sticky nsew
ttk::checkbutton $w.general.allfiles -style Tabs.TCheckbutton \
-text "Show Dotfiles" -variable cvscfg(allfiles) -onvalue true -offvalue false
ttk::checkbutton $w.general.confirmation -style Tabs.TCheckbutton \
-text "Show Confirmation Dialogs" \
-variable cvscfg(confirm_prompt) -onvalue true -offvalue false
ttk::checkbutton $w.general.auto -style Tabs.TCheckbutton \
-text "Automatic Workdir Status" \
-variable cvscfg(auto_status) -onvalue true -offvalue false
label $w.general.lshell -text "Terminal" \
-background $colorglb(menubg) -foreground $colorglb(menufg)
entry $w.general.eshell -textvariable cvscfg(shell)
label $w.general.leditor -text "Text Editor" \
-background $colorglb(menubg) -foreground $colorglb(menufg)
entry $w.general.eeditor -textvariable cvscfg(editor)
ttk::checkbutton $w.general.ext_editor -style Tabs.TCheckbutton \
-text "Use Native Editor for Check In" \
-variable cvscfg(use_cvseditor) -onvalue true -offvalue false
label $w.general.ldiff -text "Diff Visualizer" \
-background $colorglb(menubg) -foreground $colorglb(menufg)
entry $w.general.ediff -textvariable cvscfg(tkdiff)
label $w.general.lvcsorder -text "VCS Precedence" \
-background $colorglb(menubg) -foreground $colorglb(menufg)
entry $w.general.evcsorder -textvariable cvscfg(vcspref)
grid columnconf $w.general 1 -weight 1
grid $w.general.allfiles -padx 4 -sticky w -column 0 -row 0 -columnspan 2
grid $w.general.confirmation -padx 4 -sticky w -column 0 -row 1 -columnspan 2
grid $w.general.auto -padx 4 -sticky w -column 0 -row 2 -columnspan 2
grid $w.general.ext_editor -padx 4 -sticky w -column 0 -row 3 -columnspan 2
grid $w.general.leditor -sticky w -column 0 -row 4
grid $w.general.eeditor -sticky ew -column 1 -row 4 -padx 2
grid $w.general.ldiff -sticky w -column 0 -row 5
grid $w.general.ediff -sticky ew -column 1 -row 5 -padx 2
grid $w.general.lshell -sticky w -column 0 -row 6
grid $w.general.eshell -sticky ew -column 1 -row 6 -padx 2
grid $w.general.lvcsorder -sticky w -column 0 -row 7
grid $w.general.evcsorder -sticky ew -column 1 -row 7 -padx 2
if {[tk windowingsystem] eq "x11"} {
ttk::separator $w.general.sep1
label $w.general.x11lbl -text "X11" \
-background $colorglb(menubg) -foreground $colorglb(menufg)
ttk::checkbutton $w.general.match_desk -style Tabs.TCheckbutton \
-text "Match GTK or CDE colors (requires restart)" \
-variable cvscfg(match_desktop) -onvalue true -offvalue false
grid $w.general.sep1 -sticky ew -column 0 -row 8 -columnspan 3 -pady 4
grid $w.general.x11lbl -sticky w -column 0 -row 9 -pady 2
grid $w.general.match_desk -sticky w -column 0 -row 10 -padx 4 -columnspan 3
}
}
# For the Branch diagrams
proc prefs_diagram {w} {
global logcfg
global colorglb
frame $w.logcanv -bg $colorglb(menubg)
$w add $w.logcanv -text "Branch Browser" -sticky nsew
frame $w.logcanv.layout -bg $colorglb(menubg)
ttk::checkbutton $w.logcanv.layout.showtags -style Tabs.TCheckbutton \
-text "Show Tags" \
-variable logcfg(show_tags) -onvalue 1 -offvalue 0
ttk::checkbutton $w.logcanv.layout.showbranches -style Tabs.TCheckbutton \
-text "Show Branches" \
-variable logcfg(show_branches) -onvalue 1 -offvalue 0
ttk::checkbutton $w.logcanv.layout.showempty -style Tabs.TCheckbutton \
-text "Show Empty Branches (CVS)" \
-variable logcfg(show_empty_branches) -onvalue 1 -offvalue 0
ttk::checkbutton $w.logcanv.layout.showintermed -style Tabs.TCheckbutton \
-text "Show Intermediate Revisions" \
-variable logcfg(show_inter_revs) -onvalue 1 -offvalue 0
ttk::checkbutton $w.logcanv.layout.showmerg -style Tabs.TCheckbutton \
-text "Show Merges" \
-variable logcfg(show_merges) -onvalue 1 -offvalue 0
pack $w.logcanv.layout -side top -fill x
grid columnconf $w.logcanv.layout 1 -weight 1
grid $w.logcanv.layout.showtags -padx 4 -sticky w -column 0 -row 0 -columnspan 2
grid $w.logcanv.layout.showbranches -padx 4 -sticky w -column 0 -row 1 -columnspan 2
grid $w.logcanv.layout.showempty -padx 4 -sticky w -column 0 -row 2 -columnspan 2
grid $w.logcanv.layout.showintermed -padx 4 -sticky w -column 0 -row 3 -columnspan 2
grid $w.logcanv.layout.showmerg -padx 4 -sticky w -column 0 -row 4 -columnspan 2
ttk::separator $w.logcanv.sep1
pack $w.logcanv.sep1 -side top -fill x -pady 3
frame $w.logcanv.scale -bg $colorglb(menubg)
label $w.logcanv.scale.lspin -text "Scale" \
-background $colorglb(menubg) -foreground $colorglb(menufg)
ttk::spinbox $w.logcanv.scale.sspin -from .2 -to 1.5 -increment .1 \
-textvariable logcfg(scale)
pack $w.logcanv.scale
grid columnconf $w.logcanv.scale 1 -weight 1
grid $w.logcanv.scale.lspin -sticky w -column 0 -row 0
grid $w.logcanv.scale.sspin -sticky w -column 1 -row 0
ttk::separator $w.logcanv.sep2
pack $w.logcanv.sep2 -side top -fill x -pady 3
frame $w.logcanv.revs -bg $colorglb(menubg)
ttk::checkbutton $w.logcanv.revs.showrev -style Tabs.TCheckbutton \
-text "Show Revision #" \
-variable logcfg(show_box_rev) -onvalue 1 -offvalue 0
ttk::checkbutton $w.logcanv.revs.showrevwho -style Tabs.TCheckbutton \
-text "Show Author" \
-variable logcfg(show_box_revwho) -onvalue 1 -offvalue 0
ttk::checkbutton $w.logcanv.revs.showrevdate -style Tabs.TCheckbutton \
-text "Show Date" \
-variable logcfg(show_box_revdate) -onvalue 1 -offvalue 0
ttk::checkbutton $w.logcanv.revs.showrevtime -style Tabs.TCheckbutton \
-text "Show Time" \
-variable logcfg(show_box_revtime) -onvalue 1 -offvalue 0
pack $w.logcanv.revs -side top -fill x
grid columnconf $w.logcanv.revs 1 -weight 1
grid $w.logcanv.revs.showrev -padx 4 -sticky w -column 0 -row 0 -columnspan 2
grid $w.logcanv.revs.showrevwho -padx 4 -sticky w -column 0 -row 1 -columnspan 2
grid $w.logcanv.revs.showrevdate -padx 4 -sticky w -column 0 -row 2 -columnspan 2
grid $w.logcanv.revs.showrevtime -padx 4 -sticky w -column 0 -row 3 -columnspan 2
}
# For CVS
proc prefs_cvs {w} {
global colorglb
frame $w.cvs -bg $colorglb(menubg)
$w add $w.cvs -text "CVS" -sticky nsew
ttk::checkbutton $w.cvs.editing -style Tabs.TCheckbutton \
-text "Allow cvs edit" \
-variable cvscfg(econtrol) -onvalue true -offvalue false -state disabled
ttk::checkbutton $w.cvs.locking -style Tabs.TCheckbutton \
-text "Allow cvs lock" \
-variable cvscfg(cvslock) -onvalue true -offvalue false -state disabled
grid columnconf $w.cvs 1 -weight 1
grid $w.cvs.editing -padx 4 -sticky w -column 0 -row 0
grid $w.cvs.locking -padx 4 -sticky w -column 0 -row 1
}
# For Subversion
proc prefs_subversion {w} {
global colorglb
frame $w.svn -bg $colorglb(menubg)
$w add $w.svn -text "Subversion" -sticky nsew
frame $w.svn.dirnames -bg $colorglb(menubg)
label $w.svn.dirnames.ltrunkdir -text "Trunk Directory" \
-background $colorglb(menubg) -foreground $colorglb(menufg)
entry $w.svn.dirnames.etrunkdir -textvariable cvscfg(svn_trunkdir)
label $w.svn.dirnames.lbranchdir -text "Branches Directory" \
-background $colorglb(menubg) -foreground $colorglb(menufg)
entry $w.svn.dirnames.ebranchdir -textvariable cvscfg(svn_branchdir)
label $w.svn.dirnames.ltagdir -text "Tags Directory" \
-background $colorglb(menubg) -foreground $colorglb(menufg)
entry $w.svn.dirnames.etagdir -textvariable cvscfg(svn_tagdir)
pack $w.svn.dirnames -side top -fill x
grid columnconf $w.svn.dirnames 1 -weight 1
grid $w.svn.dirnames.ltrunkdir -sticky w -column 0 -row 0
grid $w.svn.dirnames.etrunkdir -sticky ew -column 1 -row 0 -padx 2
grid $w.svn.dirnames.lbranchdir -sticky w -column 0 -row 1
grid $w.svn.dirnames.ebranchdir -sticky ew -column 1 -row 1 -padx 2
grid $w.svn.dirnames.ltagdir -sticky w -column 0 -row 2
grid $w.svn.dirnames.etagdir -sticky ew -column 1 -row 2 -padx 2
ttk::separator $w.svn.sep1
pack $w.svn.sep1 -side top -fill x -pady 3
frame $w.svn.branchbr -bg $colorglb(menubg)
label $w.svn.branchbr.lmaxtag -text "Maximum SVN Tags" \
-background $colorglb(menubg) -foreground $colorglb(menufg)
entry $w.svn.branchbr.emaxtag -textvariable cvscfg(toomany_tags)
pack $w.svn.branchbr -side top -fill x
grid columnconf $w.svn.branchbr 1 -weight 1
grid $w.svn.branchbr.lmaxtag -sticky w -column 0 -row 0
grid $w.svn.branchbr.emaxtag -sticky ew -column 1 -row 0 -padx 2
}
# For Git
proc prefs_git {w} {
global colorglb
frame $w.git -bg $colorglb(menubg)
$w add $w.git -text "Git" -sticky nsew
frame $w.git.workdir -bg $colorglb(menubg)
ttk::checkbutton $w.git.workdir.detail -style Tabs.TCheckbutton \
-text "Detailed Workdir Status" \
-variable cvscfg(gitdetail) -onvalue true -offvalue false
pack $w.git.workdir -side top -fill x
grid columnconf $w.git.workdir 1 -weight 1
grid $w.git.workdir.detail -padx 4 -sticky w -column 0 -row 0 -columnspan 2
ttk::separator $w.git.sep1
pack $w.git.sep1 -side top -fill x -pady 3
frame $w.git.blame -bg $colorglb(menubg)
label $w.git.blame.blamelbl -text "Annotate/Blame" \
-background $colorglb(menubg) -foreground $colorglb(menufg)
label $w.git.blame.lgitblame_since -text "Since" \
-background $colorglb(menubg) -foreground $colorglb(menufg)
entry $w.git.blame.egitblame_since -textvariable cvscfg(gitblame_since)
pack $w.git.blame -side top -fill x
grid columnconf $w.git.blame 1 -weight 1
grid $w.git.blame.blamelbl -sticky w -column 0 -row 0 -columnspan 2
grid $w.git.blame.lgitblame_since -sticky w -column 0 -row 1
grid $w.git.blame.egitblame_since -sticky ew -column 1 -row 1 -padx 2
ttk::separator $w.git.sep2
pack $w.git.sep2 -side top -fill x -pady 3
frame $w.git.branchbr -bg $colorglb(menubg)
label $w.git.branchbr.blamelbl -text "Log Browser" \
-background $colorglb(menubg) -foreground $colorglb(menufg)
label $w.git.branchbr.lgitlog_since -text "Since" \
-background $colorglb(menubg) -foreground $colorglb(menufg)
entry $w.git.branchbr.egitlog_since -textvariable cvscfg(gitlog_since)
label $w.git.branchbr.lmaxhist -text "Maximum Git History" \
-background $colorglb(menubg) -foreground $colorglb(menufg)
entry $w.git.branchbr.emaxhist -textvariable cvscfg(gitmaxhist)
label $w.git.branchbr.lmaxbranches -text "Maximum Git Branches" \
-background $colorglb(menubg) -foreground $colorglb(menufg)
entry $w.git.branchbr.emaxbranches -textvariable cvscfg(gitmaxbranch)
label $w.git.branchbr.llogopts -text "Git Log Options" \
-background $colorglb(menubg) -foreground $colorglb(menufg)
entry $w.git.branchbr.elogopts -textvariable cvscfg(gitlog_opts)
ttk::radiobutton $w.git.branchbr.br_file -style Tabs.TCheckbutton \
-text " File-specific branches only" \
-variable cvscfg(gitbranchgroups) -value "F"
ttk::radiobutton $w.git.branchbr.br_local -style Tabs.TCheckbutton \
-text " All local branches" \
-variable cvscfg(gitbranchgroups) -value "FL"
ttk::radiobutton $w.git.branchbr.br_remote -style Tabs.TCheckbutton \
-text " Local + Remote branches" \
-variable cvscfg(gitbranchgroups) -value "FLR"
label $w.git.branchbr.lbrglob -text "Git Branch Filter (regex)" \
-background $colorglb(menubg) -foreground $colorglb(menufg)
entry $w.git.branchbr.ebrglob -textvariable cvscfg(gitbranchregex)
label $w.git.branchbr.hbrglob -text "master and current always included" \
-background $colorglb(menubg) -foreground $colorglb(menufg)
pack $w.git.branchbr -side top -fill x
grid columnconf $w.git.branchbr 1 -weight 1
grid $w.git.branchbr.blamelbl -sticky w -column 0 -row 0 -columnspan 2
grid $w.git.branchbr.lgitlog_since -sticky w -column 0 -row 1
grid $w.git.branchbr.egitlog_since -sticky ew -column 1 -row 1 -padx 2
grid $w.git.branchbr.lmaxhist -sticky w -column 0 -row 2
grid $w.git.branchbr.emaxhist -sticky ew -column 1 -row 2 -padx 2
grid $w.git.branchbr.lmaxbranches -sticky w -column 0 -row 3
grid $w.git.branchbr.emaxbranches -sticky ew -column 1 -row 3 -padx 2
grid $w.git.branchbr.llogopts -sticky w -column 0 -row 4
grid $w.git.branchbr.elogopts -sticky ew -column 1 -row 4 -padx 2
grid $w.git.branchbr.br_file -padx 4 -sticky w -column 1 -row 5
grid $w.git.branchbr.br_local -padx 4 -sticky w -column 1 -row 6
grid $w.git.branchbr.br_remote -padx 4 -sticky w -column 1 -row 7
grid $w.git.branchbr.lbrglob -sticky w -column 0 -row 8
grid $w.git.branchbr.ebrglob -sticky ew -column 1 -row 8 -padx 2
grid $w.git.branchbr.hbrglob -sticky w -column 1 -row 9
}
proc prefs_close { } {
global cvscfg
gen_log:log D "Preferences Tab $cvscfg(preftab)"
destroy .prefdlg
exit_cleanup 0
}
tkrev_9.6.1/tkrev/svn_import.tcl 0000664 0001750 0001750 00000006743 15015446517 017335 0 ustar dorothyr dorothyr #
# Tcl Library for TkRev
#
#
# Adds a new document to the repository.
#
proc svn_import_run {} {
global cvsglb
global cvscfg
global incvs insvn inrcs ingit
gen_log:log T "ENTER"
lassign [vcs_detect [pwd]] incvs insvn inrcs ingit
if {$insvn} {
cvsok "This directory is already in Subversion.\nCan\'t import here!" .svn_import
gen_log:log T "LEAVE"
return
} elseif {$incvs} {
cvsok "There are CVS directories here.\nPlease remove them first." .svn_import
gen_log:log T "LEAVE"
return
}
set cvsglb(imdir) [file tail [pwd]]
# This is just a default. The user can change it.
if {[info exists cvscfg(svnroot)] && $cvscfg(svnroot) != ""} {
set cvsglb(imtop) $cvscfg(svnroot)
} else {
set cvsglb(imtop) "< URL Required >"
}
# Can't use file join or it will mess up the URL
set cvsglb(imtop) "$cvsglb(imtop)/trunk"
if {[winfo exists .svn_import]} {
wm deiconify .svn_import
raise .svn_import
grab set .svn_import
gen_log:log T "LEAVE"
return
}
toplevel .svn_import
grab set .svn_import
frame .svn_import.top
message .svn_import.top.explain -justify left -width 500 -relief groove \
-text "This will import the current directory and its sub-directories\
into SVN. If you haven't created a Subversion repository,\
you must do that first with \"svnadmin create.\""
label .svn_import.top.lsvnroot -text "URL of SVN Repository" -anchor w
entry .svn_import.top.tsvnroot -textvariable cvsglb(imtop)
grid .svn_import.top.explain -column 0 -row 0 -columnspan 3 -sticky ew
#grid .svn_import.top.lnewdir -column 0 -row 1 -sticky w
#grid .svn_import.top.tnewdir -column 1 -row 1 -sticky ew
grid .svn_import.top.lsvnroot -column 0 -row 2 -sticky e
grid .svn_import.top.tsvnroot -column 1 -row 2 -sticky ew
frame .svn_import.down -relief groove -borderwidth 2
button .svn_import.down.ok -text "OK" \
-command {
grab release .svn_import
wm withdraw .svn_import
svn_do_import $cvsglb(imtop) $cvsglb(imdir)
}
button .svn_import.down.quit -text "Cancel" \
-command {
grab release .svn_import
wm withdraw .svn_import
}
pack .svn_import.down -side bottom -expand yes -fill x
pack .svn_import.top -side top -expand yes -fill x
pack .svn_import.down.ok -side left -expand yes
pack .svn_import.down.quit -side left -expand yes
wm title .svn_import "Import a Project into Subversion"
wm minsize .svn_import 1 1
gen_log:log T "LEAVE"
}
proc svn_do_import {imtop imdir} {
gen_log:log T "ENTER"
set imdir [pwd]
set cwd [pwd]
set commandline "svn import . $imtop -m \"Imported using TkRev\""
set v [viewer::new "Import Project"]
$v\::log "\nSVN Import\n"
$v\::do "$commandline"
$v\::wait
update
# Now check out the new module
cd ..
gen_log:log F "CD [pwd]"
# We have to move the original stuff entirely out of the way.
# Otherwise checkout won't do the whole tree.
gen_log:log F "MOVE $imdir $imdir.orig"
if {[file isdirectory $imdir.orig]} {
file delete -force -- $imdir.orig
}
file rename $imdir $imdir.orig
set commandline "svn checkout $imtop $imdir"
$v\::log "\nSVN Checkout\n"
$v\::do "$commandline"
$v\::wait
if {[catch "cd $imdir" err]} {
# If we didn't check out the new dir sucessfully, put the old one back
file rename $imdir.orig $imdir
cvsok "$err" .isvn_mport
} else {
gen_log:log F "CD [pwd]"
}
setup_dir
modbrowse_run
gen_log:log T "LEAVE"
}
tkrev_9.6.1/tkrev/ui_misc.tcl 0000664 0001750 0001750 00000032115 15033645673 016561 0 ustar dorothyr dorothyr
# Bindings to make canvases scroll. Canvases have no bindings at all
# by default.
proc scrollbindings {cnvs} {
# Page keys
bind $cnvs [list %W yview scroll 1 pages]
bind $cnvs [list %W yview scroll -1 pages]
bind $cnvs [list %W yview scroll -1 units]
bind $cnvs [list %W yview scroll 1 units]
bind $cnvs [list %W xview scroll -1 pages]
bind $cnvs [list %W xview scroll 1 pages]
# Middle button dragging
bind $cnvs [list dragbind %W %x %y]
# Wheelmouse
bind $cnvs [list wheelbind %W %D]
bind $cnvs [list %W yview scroll -1 pages]
bind $cnvs [list %W yview scroll 1 pages]
}
# Generic Copy popup for read-only text widgets
proc copy_paste_popup {win X Y} {
global colorglb
#gen_log:log T "ENTER ($win $X $Y)"
if {! [winfo exists $win.copy_paste_pop] } {
menu $win.copy_paste_pop
$win.copy_paste_pop add command -label "Copy selection" \
-command [list event generate $win <>]
$win.copy_paste_pop add command -label "Select all" \
-command [list $win tag add sel 0.0 end]
}
tk_popup $win.copy_paste_pop $X $Y
$win.copy_paste_pop configure -background $colorglb(menubg) -foreground $colorglb(menufg)
}
# Disable all key sequences for text widget except for navigation
# and copy-to-clipboard
proc ro_textbindings {txtw} {
#gen_log:log T "ENTER ($txtw)"
bind $txtw {break}
bind $txtw {catch {%W yview moveto 0};break}
bind $txtw {catch {%W yview scroll -1 units};break}
bind $txtw {catch {%W yview scroll -1 pages};break}
bind $txtw {catch {%W yview scroll 1 pages};break}
bind $txtw {catch {%W yview scroll 1 units};break}
bind $txtw {catch {%W yview moveto 1};break}
bind $txtw {catch {%W xview scroll -1 units};break}
bind $txtw {catch {%W xview scroll 1 units};break}
bind $txtw {tk_textCopy %W;break}
bind $txtw {tk_textCopy %W;break}
bind $txtw {%W tag add sel 0.0 end;break}
bind $txtw {%W tag add sel 0.0 end;break}
# Disable the cut and paste events.
bind $txtw <> "break"
bind $txtw <> "break"
bind $txtw <2> "copy_paste_popup $txtw %X %Y"
bind $txtw <3> "copy_paste_popup $txtw %X %Y"
}
# Save the contents of a text widget to a file
proc save_viewcontents {w} {
global tcl_version
set types { {"Text Files" {*.txt *.log}} {"All Files" *} }
set savfile [ \
tk_getSaveFile -title "Save Results Summary" \
-initialdir "." \
-filetypes $types \
-parent $w \
]
if {$savfile == ""} {
return
}
if {[catch {set fo [open $savfile w]}]} {
puts "Cannot open $savfile for writing"
return
}
if {$tcl_version >= 9.0} {chan configure $fo -profile tcl8}
puts $fo [$w.text get 1.0 end]
close $fo
}
# Get the selected text lines, to pass to git annotate
# Works with what's already selected
proc get_textlines {w} {
lassign [$w.text tag ranges sel] firstsel lastsel
set firstline [lindex [split $firstsel "."] 0]
set lastline [lindex [split $lastsel "."] 0]
return [list $firstline $lastline]
}
#
# Search functionality for text widgets
#
proc search_textwidget_init {} {
# Initialize the globals for general text searches
global cvsglb
if {! [info exists cvsglb(searchstr)] } {
set cvsglb(searchstr) ""
}
if {! [info exists cvsglb(last_searchstr)] } {
set cvsglb(last_searchstr) ""
}
set cvsglb(searchidx) "1.0"
}
proc search_textwidget { wtx } {
# Search the text widget
global cvsglb
#gen_log:log T "ENTER ($wtx)"
if {$cvsglb(searchstr) != $cvsglb(last_searchstr)} {
$wtx tag delete match
set cvsglb(searchidx) "1.0"
}
$wtx tag configure sel -background gray -foreground #000000
$wtx tag raise sel
$wtx tag configure match -background gray -foreground #000000 \
-relief groove -borderwidth 2
$wtx tag raise match
set searchstr $cvsglb(searchstr)
set match [$wtx search -- $searchstr $cvsglb(searchidx)]
if {[string length $match] > 0} {
set length [string length $searchstr]
$wtx mark set insert $match
$wtx tag add match $match "$match + ${length}c"
$wtx see $match
set cvsglb(searchidx) "$match + ${length}c"
}
set cvsglb(last_searchstr) $cvsglb(searchstr)
}
proc search_listbox_init {} {
# Initialize the globals for searches
global cvsglb
if {! [info exists cvsglb(searchstr)] } {
set cvsglb(searchstr) ""
}
if {! [info exists cvsglb(last_searchstr)] } {
set cvsglb(last_searchstr) ""
}
set cvsglb(lsearchidx) 0
}
proc search_listbox { lbx } {
# Search a listbox
global cvsglb
global colorglb
gen_log:log T "ENTER ($lbx)"
#gen_log:log D "search string = \"$cvsglb(searchstr)\""
#gen_log:log D "search index = \"$cvsglb(lsearchidx)\""
set ndx [$lbx index end]
if {$cvsglb(searchstr) != $cvsglb(last_searchstr)} {
set cvsglb(lsearchidx) 0
for {set i 0} {$i < $ndx} {incr i} {
$lbx itemconfigure $i -background $colorglb(bg)
}
}
if {$cvsglb(lsearchidx) > $ndx} {
gen_log:log D "No more matches"
return
}
for {set i $cvsglb(lsearchidx)} {$i < $ndx} {incr i} {
set str [$lbx get $i]
if {[string match "*$cvsglb(searchstr)*" $str]} {
gen_log:log D "MATCH $str $cvsglb(searchstr)"
set cvsglb(lsearchidx) $i
$lbx itemconfigure $i -background $colorglb(hlbg)
$lbx see $i
break
} else {
$lbx itemconfigure $i -background $colorglb(bg)
}
}
set cvsglb(last_searchstr) $cvsglb(searchstr)
incr cvsglb(lsearchidx)
}
proc dragbind {W x y} {
set height [$W cget -height]
if {$y < 0} {set y 0}
if {$y > $height} {set y $height}
set yfrac [expr {double($y) / $height}]
set width [$W cget -width]
if {$x < 0} {set x 0}
if {$x > $height} {set x $height}
set xfrac [expr {double($x) / $width}]
eval $W yview moveto $yfrac
eval $W xview moveto $xfrac
}
proc wheelbind {W D} {
eval $W yview scroll [expr {-($D/120)*4}] units
}
# start and stop busy cursor
proc busy_start {w} {
foreach widget [winfo children $w] {
catch {$widget config -cursor watch}
}
update idletasks
}
proc busy_done {w} {
foreach widget [winfo children $w] {
catch {$widget config -cursor ""}
}
}
# Position the dialogs relative to the workdir or module browser
proc dialog_position {dialog parent} {
set x [winfo x $parent]
set x [winfo x $parent]
set X [expr {$x + 60}]
set y [winfo y $parent]
set Y [expr {$y + 40}]
wm geometry $dialog +$X+$Y
}
# Read a file containing user's saved picklist variables and values
proc picklist_load {} {
global cvscfg
global cvsglb
if {! [catch {set file [open [file join $cvscfg(home) {.tkrev-picklists}] r]}]} {
while {[gets $file var_name] > 0} {
lappend vars $var_name
while {[gets $file item] > 0} {
lappend cvsglb($var_name) "$item"
}
}
close $file
}
}
# See if current value is in the saved list. If not, add it.
# If so, promote it to the beginning (last used)
proc picklist_used {var_name value} {
global cvsglb
gen_log:log T "ENTER ($var_name $value)"
if {$value == {} } {
return
}
if {[info exists cvsglb($var_name)]} {
if {[set i [lsearch -exact $cvsglb($var_name) "$value"]] >= 0} {
gen_log:log D "$value is already in cvsglb($var_name). Removing to change position"
set cvsglb($var_name) [lreplace $cvsglb($var_name) $i $i]
}
# The value might have spaces. That's what the concat list is about.
set cvsglb($var_name) [lrange [concat [list "$value"] $cvsglb($var_name)] 0 50]
gen_log:log D "appending $value to cvsglb($var_name)"
#lappend cvsglb($var_name) "$value"
} else {
gen_log:log D "Initializing variable cvsglb($var_name)!"
set cvsglb($var_name) [concat [list "$value"]]
}
}
# Save user's picklist variables and values to a file
proc picklist_save {} {
global cvscfg
global cvsglb
if {! [catch {set file [open [file join $cvscfg(home) {.tkrev-picklists}] w]}]} {
foreach var_name {cvsroot directory} {
puts $file $var_name
set c 0
if {! [info exists cvsglb($var_name)]} {
puts $file ""
continue
}
foreach item $cvsglb($var_name) {
# number of items saved is a preference
if {$c >= $cvscfg(picklist_items)} {break}
puts $file "$item"
incr c
}
puts $file ""
}
close $file
}
}
proc validate_dirpath {W path} {
# Returning path instead of canonpath preserves tcl8.x
# behavior when using that version
global colorglb
if {$path == ""} {
return $path
}
set ret [tildChk $path checkresult canonpath]
if {$ret} {
$W configure -foreground red
set checkresult 0
return $path
}
if {$checkresult == 1} {
$W configure -foreground green
$W icursor end
return $path
}
if {![file isdirectory $path]} {
$W configure -foreground red
return $path
}
$W configure -foreground $colorglb(textfg)
return $path
}
proc change_dir {new_dir} {
global cwd
set new_dir [tildecheck "$new_dir"]
if {![file isdirectory "$new_dir"]} {
set cwd [pwd]
cvsfail "Directory $new_dir doesn\'t exist or isn't a directory" .workdir
return 1
}
cd "$new_dir"
set cwd $new_dir
gen_log:log F "CD $new_dir"
# Deleting the tree discards the saved scroll position
# so we start with yview 0 in a new directory
if {[winfo exists .workdir]} {
DirCanvas:deltree .workdir.main.tree
setup_dir
}
if {[winfo exists .modbrowse]} {
vcs_detect $cwd
modbrowse_run
}
return 0
}
# tcl/tk 9.0 won't allow tilde in filenames
proc tildecheck {path} {
global tcl_version
if {$tcl_version < 9.0} {
return $path
} else {
if {[catch {file tildeexpand $path} exp]} {
gen_log:log E "$exp"
return $exp
} else {
set fullpath $exp
#gen_log:log F "expand: $path -> $fullpath"
return $fullpath
}
}
}
# By vampm, borrowed from tkdiff
proc tildChk {fnam result canon} {
global tcl_version
# point OUR locals AT callers Vars
upvar $result resptr
upvar $canon canptr
# CALLER is responsible for which returned values (RetCode/result/canon)
# are of logical importance within ITS specific CALLING situation
# Original V8 check produced 3 possible 'result' value sets (w/o errs):
# 0 - fnam doesnt exist w/RetCod=0
# 1 - fnam does exist w/RetCod=0
# FailedMsg - tilde conversion failed (no such user) w/Retcod=1
# V9 adds an ADDITIONAL output datum (canon) to those sets:
# 0 - defaulted as fnam CLONE w/Retcod=1
# 1 - canonical form of converted fnam w/Retcod=0
# FailedMsg - tilde conversion failed (no user/home) w/Retcod=1
#
# User EXPECTED to prefix initial fnam with './' to PREVENT tildeexpand,
# although code ATTEMPTS such evaluation if tildeexpand was IMPOSSIBLE
if {$tcl_version >= 9.0 && [string index $fnam 0] == "~"} {
# isolate first fragment from ANY subsequent GLOB syntax
# THEN perform tilde expansion on JUST 1st frag, OR (if that fails)
# a DIRECT CWD filename search, again on only that 1st fragment
set f1 [lindex [set frags [file split $fnam]] 0]
if {![set Err [catch {file tildeexpand $f1} newf1]] || \
[llength [set nms [glob -n $f1]]]} {
# If Err non-zero HERE, there IS a CWD-relative LITERAL tilde name
# (of which there MUST be only a SINGLE name via the V9 GLOB)
# TWO possible ways to success:
if {$Err && [llength $nms] == 1} {
# reassemble fnam w/FOUND literal tilde as 1st frag, THEN ...
set fnam [file join $nms [lrange $frags 1 end]]
} elseif {!$Err} {
# reassemble fnam using tilde EXPANDED 1st fragment, THEN ...
set fnam [file join $newf1 [lrange $frags 1 end]]
} else {
# failed: expansion was IMPOSSIBLE (w/no SINGLE LITERAL tilde)
set resptr $newf1; # shove msg where it belongs
set canptr $fnam; # has NO canonical form; return unaltered
return $Err; # and tell caller theres a DEFINITE problem
}
# ...EXIT via V8 GLOB code secure it'll GLOB from PROPER (HOME/CWD)
# (N.B> catch is superfluous as V9 GLOB has no reason to fault)
} else {
# failed: expansion was IMPOSSIBLE (AND found no LITERAL tilde)
set resptr $newf1; # shove msg where it belongs
set canptr $fnam; # has NO canonical form; return unaltered
return $Err; # and tell caller theres a definite problem
}
# replicate default V9 semantic tildeexpand behavior as preparartion for V8
} else {
set canptr $fnam
}
# (N.B> V8/V9 BOTH rely on GLOB to provide filesystem EXISTENCE of result)
if {![set Err [catch {llength [set nms [glob -n $fnam]]} resptr]]} {
# success, but given the V9 semantic, must overwrite canon now ...
if {$resptr == 1} {
set canptr $nms ; # rewrite using expanded name
# ... Yet multiple names NOT permitted; TREAT the same as NONE found
} else { set resptr 0 }
}
return $Err
}
tkrev_9.6.1/tkrev/cvs_subimport.tcl 0000664 0001750 0001750 00000017644 15033645673 020042 0 ustar dorothyr dorothyr #
# Tcl Library for TkRev
#
#
# subimport.tcl is similar to import.tcl except that it is used for
# importing to an existing module.
# By: Eugene Lee, Aerospace Corporation, 10/16/03
#
# Called from "Import To An Existing Module"
proc cvs_subimport_setup {} {
global cwd
global incvs
global insvn
global ingit
global inrcs
global cvsglb
gen_log:log T "ENTER"
# Make sure we're not in a directory that's already under revision control
lassign [vcs_detect [pwd]] incvs insvn inrcs ingit
if {$incvs} {
cvsok "This directory is already in CVS.\nCan\'t import here!" .import
gen_log:log T "LEAVE"
return
}
if {$insvn} {
cvsok "There are Subversion directories here.\nPlease remove them first." .import
gen_log:log T "LEAVE"
return
}
if {$ingit} {
cvsok "There are Git directories here.\nPlease remove them first." .import
gen_log:log T "LEAVE"
return
}
if {$inrcs} {
cvsok "There are RCS directories here.\nPlease remove them first." .import
gen_log:log T "LEAVE"
return
}
if {[winfo exists .subimport]} {
wm deiconify .subimport
raise .subimport
grab set .subimport
gen_log:log T "LEAVE"
return
}
# Set some defaults
set cvsglb(existmodule) ""
set cvsglb(newcode) [file tail $cwd]
set cvsglb(newdir) $cvsglb(newcode)
set cvsglb(newdesc) ""
set cvsglb(newvers) "1.1.1"
toplevel .subimport
grab set .subimport
frame .subimport.top
message .subimport.top.explain -justify left -width 500 -relief groove \
-text "This will import the current directory and its sub-directories\
into an Existing CVS module."
label .subimport.top.lnewcode -text "Module Name" -anchor w
label .subimport.top.lnewdir -text "Path relative to \$CVSROOT" -anchor w
label .subimport.top.lnewdesc -text "Descriptive Title" -anchor w
label .subimport.top.lnewvers -text "Version Number" -anchor w
label .subimport.top.tnewcode -textvariable cvsglb(existmodule) \
-relief sunken -width 40 -anchor w
label .subimport.top.tnewdir -textvariable cvsglb(newdir) \
-relief sunken -width 40 -anchor w
entry .subimport.top.tnewvers -textvariable cvsglb(newvers) -width 40
button .subimport.top.bnewcode -text "Browse ..." -command "moduleDialog"
grid .subimport.top.explain -column 0 -row 0 -columnspan 3 -sticky ew
grid .subimport.top.lnewcode -column 0 -row 1 -sticky w
grid .subimport.top.tnewcode -column 1 -row 1 -sticky w
grid .subimport.top.bnewcode -column 2 -row 1 -sticky e
grid .subimport.top.lnewdir -column 0 -row 2 -sticky w
grid .subimport.top.tnewdir -column 1 -row 2 -sticky w
grid .subimport.top.lnewvers -column 0 -row 3 -sticky w
grid .subimport.top.tnewvers -column 1 -row 3 -sticky ew
frame .subimport.down -relief groove -borderwidth 2
button .subimport.down.ok -text "OK" \
-command {
if {! [cvs_import_errorcheck]} {
grab release .subimport
wm withdraw .subimport
cvs_subimport_do
}
}
button .subimport.down.quit -text "Cancel" -command {
grab release .subimport
wm withdraw .subimport
}
pack .subimport.down -side bottom -expand yes -fill x
pack .subimport.top -side top -expand yes -fill x
pack .subimport.down.ok -side left -expand yes
pack .subimport.down.quit -side left -expand yes
wm title .subimport "Import To An Existing Module"
wm minsize .subimport 1 1
# The module browser has to be running for the module selection dialog to work
if {! [info exists modlist_sorted]} {
modbrowse_run
}
gen_log:log T "LEAVE"
}
proc cvs_subimport_do {} {
global cvs
global cvsglb
global cvscfg
global cwd
global modlist_sorted
global modval
gen_log:log T "ENTER"
set imdir [pwd]
# Error checks
if {$cvsglb(existmodule) == ""} {
cvsok "You must select an existing module from the repository." .subimport
raise .subimport
grab set .subimport
return 1
}
if {$cvsglb(newdir) == ""} {
cvsok "You must select an existing module from the repository." .subimport
raise .subimport
grab set .subimport
return 1
}
if {$cvsglb(newvers) == ""} {
cvsok "You must type in a version number." .subimport
raise .subimport
grab set .subimport
return 1
}
wm withdraw .subimport
# After no more errors
# See if all apropriate Directories in newdirname exist. CVS import will
# create them, but we'll want to make a #D entry.
set cvsglb(newdir) [string trimleft $cvsglb(newdir) "/"]
set pathname [file dirname $cvsglb(newdir)]
set need_Dir 0
if {$pathname != "."} {
foreach idx $modlist_sorted {
lappend knowndirs [lindex $idx 0]
}
gen_log:log D "looking for $pathname in known directories ($knowndirs)"
if {$pathname ni $knowndirs} {
set need_Dir 1
}
}
# Make a baseline tag
set versions [split $cvsglb(newvers) ".,/ -"]
set baseline "baseline-[join $versions {_}]"
set v [viewer::new "Import Module"]
set commandline "$cvs -d $cvscfg(cvsroot) import -m \"Imported using TkRev\" $cvsglb(newdir) VENDOR $baseline"
$v\::log "\nCVS Import\n"
$v\::do "$commandline"
$v\::wait
update
# No need to update the modules file.
cd ../
gen_log:log F "CD [pwd]"
set commandline "$cvs -d $cvscfg(cvsroot) -Q release -d CVSROOT"
$v\::do "$commandline"
$v\::wait
cd $cwd
gen_log:log F "CD [pwd]"
# Now check out the new module
cd ..
gen_log:log F "CD [pwd]"
set ckmoddir $cwd
# save later for use in checking out
# We have to move the original stuff entirely out of the way.
# Otherwise checkout won't do the whole tree.
gen_log:log F "MOVE $imdir $imdir.orig"
file rename $imdir $imdir.orig
set $cwd $cwd.orig
set commandline "$cvs -d $cvscfg(cvsroot) checkout -r$baseline \"$cvsglb(existmodule)\""
$v\::log "\nCVS Checkout\n"
$v\::do "$commandline"
$v\::wait
set cwd $imdir.orig
# cd to the checked out module. $cwd is the correct directory to cd to
# only if the name of the existing module is the same as the directory name
# where the source code is in. If the existing module name is different modify
# ckmoddir
if {$cvsglb(existmodule) != [file tail $ckmoddir]} {
set ckmoddir [file join [file dirname $ckmoddir] $cvsglb(existmodule)]
}
change_dir $ckmoddir
gen_log:log F "CD [pwd]"
if {$cvscfg(auto_status)} {
setup_dir
}
gen_log:log T "LEAVE"
}
proc getExistModDialog {} {
global modval
global ExModList ExModDirList
set ExModList ""
set ExModDirList ""
foreach {key value} [array get modval] {
if {$key != ""} {
lappend ExModList $key
lappend ExModDirList $value
}
}
set ExModList [lsort $ExModList]
}
proc moduleDialog {} {
global ExModList ExModDirList
set w .modDialog
grab release .subimport
catch {destroy $w}
toplevel $w
wm title $w "Select An Existing Module"
wm minsize $w 28 3
grab set $w
frame $w.buttons
pack $w.buttons -side bottom -fill x -pady 2m
button $w.buttons.ok -text Ok -command {
destroy .modDialog
raise .subimport
grab set .subimport
}
button $w.buttons.cancel -text Cancel -command {
grab release .modDialog
wm withdraw .modDialog
}
pack $w.buttons.ok -side left -expand 1
pack $w.buttons.cancel -side left -expand 1
frame $w.frame -borderwidth .5c
pack $w.frame -side top -expand yes -fill y
ttk::scrollbar $w.frame.scroll -command "$w.frame.list yview"
listbox $w.frame.list -yscrollcommand "$w.frame.scroll set" -setgrid 1 -height 5
pack $w.frame.scroll -side right -fill y
pack $w.frame.list -side left -expand 1 -fill both
getExistModDialog
set nModule [llength $ExModList]
for {set i 0} {$i < $nModule} {incr i} {
$w.frame.list insert end [lindex $ExModList $i]
}
bind $w.frame.list {
set cvsglb(existmodule) [%W get [%W nearest %y]]
set tmp [%W get [%W nearest %y]]
set cvsglb(newdir) $tmp
set index [lsearch -exact $ExModList $tmp]
set cvsglb(newdir) [lindex $ExModDirList $index]
}
}
tkrev_9.6.1/tkrev/help.tcl 0000664 0001750 0001750 00000173255 15034126547 016067 0 ustar dorothyr dorothyr #
# Tcl Library for TkRev
#
# Help procedures and help data.
#
#########################################
#
# Developers: Please don't majorly change the formatting of this
# file unless you know what you're doing.
# The script "mkmanpage.pl" builds a manpage out of it, and the
# thing is the product of an unbelievable number of hours spent
# tweaking this file and the script so that both the help and
# the manpage look sort of OK.
#
# If you do add something to this, do "mkmanpage.pl > tkrev.n"
# to keep the manpage in sync, then look at it to make sure
# it worked.
#
# - dorothy
#########################################
proc aboutbox {} {
global cvscfg
global colorglb
toplevel .about
wm title .about "About TkRev"
frame .about.top
frame .about.top.g1
message .about.top.msg1 -width 400 -justify c \
-text "\nTkRev Version $cvscfg(version)\n" -font $colorglb(guifont)
pack .about.top -side top -expand 1 -fill both
label .about.top.g1.gif1 -image Tclfish
label .about.top.g1.gif2 -image Toothyfish
label .about.top.gif3 -image Squid
append string2 "A friendly graphical interface\n"
append string2 "for CVS, Subversion and Git\n"
append string2 "\nConsult the Help menu to\n"
append string2 "learn about its features.\n\n"
append string2 "TkCVS was written by Del.\n"
append string2 "Later, Subversion functionality\n"
append string2 "was added by Dorothy.\n"
append string2 "Later still, Git functionality\n"
append string2 "was added by Dorothy with some\n"
append string2 "assistance from Mentor Graphics.\n"
append string2 "Finally, the name was changed to TkRev.\n"
message .about.top.msg3 -width 400 -justify c \
-text $string2
append about_string "Download: https://sourceforge.net/projects/tkcvs\n"
message .about.top.msg4 -width 365 -justify c \
-text $about_string -font $colorglb(listboxfont)
pack .about.top -side top -expand 1 -fill both
pack .about.top.msg1 -expand 1 -fill x
pack .about.top.g1 -side top -expand 1 -fill both
pack .about.top.g1.gif1 -side left -pady 2
pack .about.top.gif3 -side top
pack .about.top.g1.gif2 -side right -pady 2
pack .about.top.msg3 -expand 1 -fill x
pack .about.top.msg4 -expand 1 -fill x
frame .about.down
button .about.down.ok -text "OK" -command {destroy .about}
pack .about.down -side bottom -expand 1 -fill x -pady 2
pack .about.down.ok
}
proc help_cvs_version {visual} {
#
# This shows the banners of the available revision control systems.
#
global cvs
global cvsglb
gen_log:log T "ENTER"
set cvsglb(have_cvs) 0
set cvsglb(have_svn) 0
set cvsglb(have_rcs) 0
set cvsglb(have_git) 0
set whichcvs [auto_execok $cvs]
if {[llength $whichcvs]} {
set whichcvs [join $whichcvs]
set commandline "$cvs -v"
gen_log:log C "$commandline"
catch {exec {*}$commandline} cvs_output
set cvsglb(have_cvs) 1
}
set whichsvn [auto_execok svn]
if {[llength $whichsvn]} {
set whichsvn [join $whichsvn]
set commandline "svn --version"
gen_log:log C "$commandline"
set ret [catch {exec {*}$commandline} svn_output]
set cvsglb(have_svn) 1
}
set whichrcs [auto_execok rcs]
if {[llength $whichrcs]} {
set whichrcs [join $whichrcs]
set commandline "rcs --version"
gen_log:log C "$commandline"
set ret [catch {exec {*}$commandline} rcs_output]
set cvsglb(have_rcs) 1
}
set whichgit [auto_execok git]
if {[llength $whichgit]} {
set whichgit [join $whichgit]
set commandline "git --version"
gen_log:log C "$commandline"
set ret [catch {exec {*}$commandline} git_output]
set cvsglb(have_git) 1
}
if {$visual} {
set v [viewer::new "Versions"]
$v\::log "-----------------------------------------\n" blue
if {$cvsglb(have_cvs)} {
$v\::log "$whichcvs\n$cvs_output"
} else {
$v\::log "$cvs was not found in your path."
}
$v\::log "\n-----------------------------------------\n" blue
if {$cvsglb(have_svn)} {
$v\::log "$whichsvn\n$svn_output"
} else {
$v\::log "svn was not found in your path."
}
$v\::log "\n-----------------------------------------\n" blue
if {$cvsglb(have_rcs)} {
$v\::log "$whichrcs\n$rcs_output"
} else {
$v\::log "rcs was not found in your path."
}
$v\::log "\n-----------------------------------------\n" blue
if {$cvsglb(have_git)} {
$v\::log "$whichgit\n$git_output"
} else {
$v\::log "git was not found in your path."
}
}
gen_log:log T "LEAVE"
}
proc wish_version {{parent {.}}} {
global tk_patchLevel
set version $tk_patchLevel
set whichwish [info nameofexecutable]
set about_string "$whichwish\n\n"
append about_string "Tk version $version"
tk_messageBox -title "About Wish" \
-message $about_string \
-parent $parent \
-type ok
}
######################################################################
#
# text formatting routines derived from Klondike
# Reproduced here with permission from their author.
#
# Copyright (C) 1993,1994 by John Heidemann
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of John Heidemann may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY JOHN HEIDEMANN ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL JOHN HEIDEMANN BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
######################################################################
# This posts the tagged text to the text widget
proc post_text {tw t} {
gen_log:log T "ENTER ($tw ...)"
set t $t
while {[regexp -indices {<([^@>]*)>} $t match inds] == 1} {
set start [lindex $inds 0]
set end [lindex $inds 1]
set keyword [string range $t $start $end]
#set oldend [$tw index end]
$tw insert end [string range $t 0 [expr {$start - 2}]]
if {[string range $keyword 0 0] == "/"} {
set keyword [string trimleft $keyword "/"]
if {[info exists tags($keyword)] == 0} {
error "end tag $keyword without beginning"
}
$tw tag add $keyword $tags($keyword) insert
unset tags($keyword)
} else {
if {[info exists tags($keyword)] == 1} {
error "nesting of begin tag $keyword"
}
set tags($keyword) [$tw index insert]
}
set t [string range $t [expr {$end + 2}] end]
}
#set oldend [$tw index end]
$tw insert end $t
gen_log:log T "LEAVE"
}
# This outputs the text in nroff format for the manpage
proc put_text {t fo} {
gen_log:log T "ENTER ( ...)"
# Strip the first newline
set t [string trimleft $t "\n"]
# and trailing space
set t [string trimright $t " \n"]
# That should have left only internal newlines
#regsub -all {\n} $t "\n.br\n" t
# Bold
regsub -all {} $t {\\fB} t
regsub -all {} $t {\\fP} t
# Italic (underline)
regsub -all {} $t {\\fI} t
regsub -all {} $t {\\fP} t
# Section Head (SYNOPSIS, OPTIONS, etc)
regsub -all {