100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
return 1
}
}
return 0
}
proc eskil::rev::HG::detect {file} {
if {$file eq ""} {
set dir [pwd]
} else {
set dir [file dirname $file]
}
# HG, detect two steps down. Could be improved. FIXA
if {[file isdirectory [file join $dir .hg]] ||
[file isdirectory [file join $dir .. .hg]] ||
[file isdirectory [file join $dir .. .. .hg]]} {
if {[auto_execok hg] ne ""} {
return 1
}
}
return 0
}
proc eskil::rev::BZR::detect {file} {
if {$file eq ""} {
set dir [pwd]
} else {
set dir [file dirname $file]
}
# HG, detect two steps down. Could be improved. FIXA
if {[file isdirectory [file join $dir .bzr]] ||
[file isdirectory [file join $dir .. .bzr]] ||
[file isdirectory [file join $dir .. .. .bzr]]} {
if {[auto_execok bzr] ne ""} {
return 1
}
}
return 0
}
|
|
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
|
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
return 1
}
}
return 0
}
proc eskil::rev::HG::detect {file} {
if {[SearchUpwardsFromFile $file .hg]} {
if {[auto_execok hg] ne ""} {
return 1
}
}
return 0
}
proc eskil::rev::BZR::detect {file} {
if {[SearchUpwardsFromFile $file .bzr]} {
if {[auto_execok bzr] ne ""} {
return 1
}
}
return 0
}
|
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
}
cd $old
}
return 0
}
proc eskil::rev::GIT::detect {file} {
if {$file eq ""} {
set dir [pwd]
} else {
set dir [file dirname $file]
}
# Git, detect two steps down. Could be improved. FIXA
if {[file isdirectory [file join $dir .git]] ||
[file isdirectory [file join $dir .. .git]] ||
[file isdirectory [file join $dir .. .. .git]]} {
if {[auto_execok git] ne ""} {
return 1
}
}
return 0
}
proc eskil::rev::FOSSIL::detect {file} {
if {$file eq ""} {
set dir [pwd]
} else {
set dir [file dirname $file]
}
# Fossil, detect three steps down. Could be improved. FIXA
if {[file exists [file join $dir _FOSSIL_]] ||
[file exists [file join $dir .. _FOSSIL_]] ||
[file exists [file join $dir .. .. _FOSSIL_]] ||
[file exists [file join $dir .. .. .. _FOSSIL_]]} {
if {[auto_execok fossil] ne ""} {
return 1
}
}
return 0
}
|
|
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
|
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
}
cd $old
}
return 0
}
proc eskil::rev::GIT::detect {file} {
if {[SearchUpwardsFromFile $file .git]} {
if {[auto_execok git] ne ""} {
return 1
}
}
return 0
}
proc eskil::rev::FOSSIL::detect {file} {
if {[SearchUpwardsFromFile $file _FOSSIL_ .fos]} {
if {[auto_execok fossil] ne ""} {
return 1
}
}
return 0
}
|
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
|
return [eskil::rev::${type}::getPatch $revs $files]
}
##############################################################################
# Utilities
##############################################################################
# Get the last two elements in a file path
proc GetLastTwoPath {path} {
set last [file tail $path]
set penultimate [file tail [file dirname $path]]
if {$penultimate eq "."} {
return $last
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
|
return [eskil::rev::${type}::getPatch $revs $files]
}
##############################################################################
# Utilities
##############################################################################
# Search upwards the directory structure for a file
proc SearchUpwardsFromFile {file args} {
if {$file eq ""} {
set dir [pwd]
} elseif {[file isdirectory $file]} {
set dir $file
} else {
set dir [file dirname $file]
}
while {[file readable $dir] && [file isdirectory $dir]} {
foreach candidate $args {
if {[file exists [file join $dir $candidate]]} {
return 1
}
}
set parent [file dirname $dir]
# Make sure to stop if we reach a dead end
if {$parent eq $dir} break
set dir $parent
}
return 0
}
# Get the last two elements in a file path
proc GetLastTwoPath {path} {
set last [file tail $path]
set penultimate [file tail [file dirname $path]]
if {$penultimate eq "."} {
return $last
|