Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
ed5b3d8b
Commit
ed5b3d8b
authored
Mar 24, 1998
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
give in to tab police
parent
3db0e371
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
440 additions
and
435 deletions
+440
-435
Tools/scripts/cvsfiles.py
Tools/scripts/cvsfiles.py
+29
-29
Tools/scripts/fixnotice.py
Tools/scripts/fixnotice.py
+4
-4
Tools/scripts/linktree.py
Tools/scripts/linktree.py
+20
-17
Tools/scripts/logmerge.py
Tools/scripts/logmerge.py
+63
-63
Tools/scripts/mailerdaemon.py
Tools/scripts/mailerdaemon.py
+226
-224
Tools/scripts/treesync.py
Tools/scripts/treesync.py
+98
-98
No files found.
Tools/scripts/cvsfiles.py
View file @
ed5b3d8b
...
...
@@ -20,53 +20,53 @@ cutofftime = 0
def
main
():
try
:
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"n:"
)
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"n:"
)
except
getopt
.
error
,
msg
:
print
msg
print
__doc__
,
return
1
print
msg
print
__doc__
,
return
1
global
cutofftime
newerfile
=
None
for
o
,
a
in
opts
:
if
o
==
'-n'
:
cutofftime
=
getmtime
(
a
)
if
o
==
'-n'
:
cutofftime
=
getmtime
(
a
)
if
args
:
for
arg
in
args
:
process
(
arg
)
for
arg
in
args
:
process
(
arg
)
else
:
process
(
"."
)
process
(
"."
)
def
process
(
dir
):
cvsdir
=
0
subdirs
=
[]
names
=
os
.
listdir
(
dir
)
for
name
in
names
:
fullname
=
os
.
path
.
join
(
dir
,
name
)
if
name
==
"CVS"
:
cvsdir
=
fullname
else
:
if
os
.
path
.
isdir
(
fullname
):
if
not
os
.
path
.
islink
(
fullname
):
subdirs
.
append
(
fullname
)
fullname
=
os
.
path
.
join
(
dir
,
name
)
if
name
==
"CVS"
:
cvsdir
=
fullname
else
:
if
os
.
path
.
isdir
(
fullname
):
if
not
os
.
path
.
islink
(
fullname
):
subdirs
.
append
(
fullname
)
if
cvsdir
:
entries
=
os
.
path
.
join
(
cvsdir
,
"Entries"
)
for
e
in
open
(
entries
).
readlines
():
words
=
string
.
split
(
e
,
'/'
)
if
words
[
0
]
==
''
and
words
[
1
:]:
name
=
words
[
1
]
fullname
=
os
.
path
.
join
(
dir
,
name
)
if
cutofftime
and
getmtime
(
fullname
)
<=
cutofftime
:
pass
else
:
print
fullname
entries
=
os
.
path
.
join
(
cvsdir
,
"Entries"
)
for
e
in
open
(
entries
).
readlines
():
words
=
string
.
split
(
e
,
'/'
)
if
words
[
0
]
==
''
and
words
[
1
:]:
name
=
words
[
1
]
fullname
=
os
.
path
.
join
(
dir
,
name
)
if
cutofftime
and
getmtime
(
fullname
)
<=
cutofftime
:
pass
else
:
print
fullname
for
sub
in
subdirs
:
process
(
sub
)
process
(
sub
)
def
getmtime
(
filename
):
try
:
st
=
os
.
stat
(
filename
)
st
=
os
.
stat
(
filename
)
except
os
.
error
:
return
0
return
0
return
st
[
stat
.
ST_MTIME
]
sys
.
exit
(
main
())
Tools/scripts/fixnotice.py
View file @
ed5b3d8b
...
...
@@ -50,9 +50,9 @@ import os, sys, string
def
main
():
args
=
sys
.
argv
[
1
:]
if
not
args
:
print
"No arguments."
print
"No arguments."
for
arg
in
args
:
process
(
arg
)
process
(
arg
)
def
process
(
arg
):
f
=
open
(
arg
)
...
...
@@ -60,8 +60,8 @@ def process(arg):
f
.
close
()
i
=
string
.
find
(
data
,
OLD_NOTICE
)
if
i
<
0
:
##
print "No old notice in", arg
return
##
print "No old notice in", arg
return
data
=
data
[:
i
]
+
NEW_NOTICE
+
data
[
i
+
len
(
OLD_NOTICE
):]
new
=
arg
+
".new"
backup
=
arg
+
".bak"
...
...
Tools/scripts/linktree.py
View file @
ed5b3d8b
...
...
@@ -55,22 +55,25 @@ def linknames(old, new, link):
print
old
+
': warning: cannot listdir:'
,
msg
return
for
name
in
names
:
if
name
not
in
(
os
.
curdir
,
os
.
pardir
):
oldname
=
os
.
path
.
join
(
old
,
name
)
linkname
=
os
.
path
.
join
(
link
,
name
)
newname
=
os
.
path
.
join
(
new
,
name
)
if
debug
>
1
:
print
oldname
,
newname
,
linkname
if
os
.
path
.
isdir
(
oldname
)
and
not
os
.
path
.
islink
(
oldname
):
try
:
os
.
mkdir
(
newname
,
0777
)
ok
=
1
except
:
print
newname
+
': warning: cannot mkdir:'
,
msg
ok
=
0
if
ok
:
linkname
=
os
.
path
.
join
(
os
.
pardir
,
linkname
)
linknames
(
oldname
,
newname
,
linkname
)
else
:
os
.
symlink
(
linkname
,
newname
)
if
name
not
in
(
os
.
curdir
,
os
.
pardir
):
oldname
=
os
.
path
.
join
(
old
,
name
)
linkname
=
os
.
path
.
join
(
link
,
name
)
newname
=
os
.
path
.
join
(
new
,
name
)
if
debug
>
1
:
print
oldname
,
newname
,
linkname
if
os
.
path
.
isdir
(
oldname
)
and
\
not
os
.
path
.
islink
(
oldname
):
try
:
os
.
mkdir
(
newname
,
0777
)
ok
=
1
except
:
print
newname
+
\
': warning: cannot mkdir:'
,
msg
ok
=
0
if
ok
:
linkname
=
os
.
path
.
join
(
os
.
pardir
,
linkname
)
linknames
(
oldname
,
newname
,
linkname
)
else
:
os
.
symlink
(
linkname
,
newname
)
sys
.
exit
(
main
())
Tools/scripts/logmerge.py
View file @
ed5b3d8b
...
...
@@ -26,25 +26,25 @@ from their output.
import
os
,
sys
,
getopt
,
string
,
re
sep1
=
'='
*
77
+
'
\
n
'
# file separator
sep2
=
'-'
*
28
+
'
\
n
'
# revision separator
sep1
=
'='
*
77
+
'
\
n
'
# file separator
sep2
=
'-'
*
28
+
'
\
n
'
# revision separator
def
main
():
"""Main program"""
truncate_last
=
0
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"-t"
)
for
o
,
a
in
opts
:
if
o
==
'-t'
:
truncate_last
=
1
if
o
==
'-t'
:
truncate_last
=
1
database
=
[]
while
1
:
chunk
=
read_chunk
(
sys
.
stdin
)
if
not
chunk
:
break
records
=
digest_chunk
(
chunk
)
if
truncate_last
:
del
records
[
-
1
]
database
[
len
(
database
):]
=
records
chunk
=
read_chunk
(
sys
.
stdin
)
if
not
chunk
:
break
records
=
digest_chunk
(
chunk
)
if
truncate_last
:
del
records
[
-
1
]
database
[
len
(
database
):]
=
records
database
.
sort
()
database
.
reverse
()
format_output
(
database
)
...
...
@@ -58,19 +58,19 @@ def read_chunk(fp):
chunk
=
[]
lines
=
[]
while
1
:
line
=
fp
.
readline
()
if
not
line
:
break
if
line
==
sep1
:
if
lines
:
chunk
.
append
(
lines
)
break
if
line
==
sep2
:
if
lines
:
chunk
.
append
(
lines
)
lines
=
[]
else
:
lines
.
append
(
line
)
line
=
fp
.
readline
()
if
not
line
:
break
if
line
==
sep1
:
if
lines
:
chunk
.
append
(
lines
)
break
if
line
==
sep2
:
if
lines
:
chunk
.
append
(
lines
)
lines
=
[]
else
:
lines
.
append
(
line
)
return
chunk
def
digest_chunk
(
chunk
):
...
...
@@ -79,53 +79,53 @@ def digest_chunk(chunk):
key
=
'Working file:'
keylen
=
len
(
key
)
for
line
in
lines
:
if
line
[:
keylen
]
==
key
:
working_file
=
string
.
strip
(
line
[
keylen
:])
break
if
line
[:
keylen
]
==
key
:
working_file
=
string
.
strip
(
line
[
keylen
:])
break
else
:
working_file
=
None
working_file
=
None
records
=
[]
for
lines
in
chunk
[
1
:]:
revline
=
lines
[
0
]
dateline
=
lines
[
1
]
text
=
lines
[
2
:]
words
=
string
.
split
(
dateline
)
author
=
None
if
len
(
words
)
>=
3
and
words
[
0
]
==
'date:'
:
dateword
=
words
[
1
]
timeword
=
words
[
2
]
if
timeword
[
-
1
:]
==
';'
:
timeword
=
timeword
[:
-
1
]
date
=
dateword
+
' '
+
timeword
if
len
(
words
)
>=
5
and
words
[
3
]
==
'author:'
:
author
=
words
[
4
]
if
author
[
-
1
:]
==
';'
:
author
=
author
[:
-
1
]
else
:
date
=
None
text
.
insert
(
0
,
revline
)
words
=
string
.
split
(
revline
)
if
len
(
words
)
>=
2
and
words
[
0
]
==
'revision'
:
rev
=
words
[
1
]
else
:
rev
=
None
text
.
insert
(
0
,
revline
)
records
.
append
((
date
,
working_file
,
rev
,
author
,
text
))
revline
=
lines
[
0
]
dateline
=
lines
[
1
]
text
=
lines
[
2
:]
words
=
string
.
split
(
dateline
)
author
=
None
if
len
(
words
)
>=
3
and
words
[
0
]
==
'date:'
:
dateword
=
words
[
1
]
timeword
=
words
[
2
]
if
timeword
[
-
1
:]
==
';'
:
timeword
=
timeword
[:
-
1
]
date
=
dateword
+
' '
+
timeword
if
len
(
words
)
>=
5
and
words
[
3
]
==
'author:'
:
author
=
words
[
4
]
if
author
[
-
1
:]
==
';'
:
author
=
author
[:
-
1
]
else
:
date
=
None
text
.
insert
(
0
,
revline
)
words
=
string
.
split
(
revline
)
if
len
(
words
)
>=
2
and
words
[
0
]
==
'revision'
:
rev
=
words
[
1
]
else
:
rev
=
None
text
.
insert
(
0
,
revline
)
records
.
append
((
date
,
working_file
,
rev
,
author
,
text
))
return
records
def
format_output
(
database
):
prevtext
=
None
prev
=
[]
database
.
append
((
None
,
None
,
None
,
None
,
None
))
# Sentinel
for
(
date
,
working_file
,
rev
,
author
,
text
)
in
database
:
if
text
!=
prevtext
:
if
prev
:
print
sep2
,
for
(
p_date
,
p_working_file
,
p_rev
,
p_author
)
in
prev
:
print
p_date
,
p_author
,
p_working_file
sys
.
stdout
.
writelines
(
prevtext
)
prev
=
[]
prev
.
append
((
date
,
working_file
,
rev
,
author
))
prevtext
=
text
if
text
!=
prevtext
:
if
prev
:
print
sep2
,
for
(
p_date
,
p_working_file
,
p_rev
,
p_author
)
in
prev
:
print
p_date
,
p_author
,
p_working_file
sys
.
stdout
.
writelines
(
prevtext
)
prev
=
[]
prev
.
append
((
date
,
working_file
,
rev
,
author
))
prevtext
=
text
main
()
Tools/scripts/mailerdaemon.py
View file @
ed5b3d8b
This diff is collapsed.
Click to expand it.
Tools/scripts/treesync.py
View file @
ed5b3d8b
...
...
@@ -12,11 +12,11 @@ entry in the master tree are synchronized. This means:
If the files differ:
if the slave file is newer:
normalize the slave file
if the files still differ:
copy the slave to the master
else (the master is newer):
copy the master to the slave
normalize the slave file
if the files still differ:
copy the slave to the master
else (the master is newer):
copy the master to the slave
normalizing the slave means replacing CRLF with LF when the master
doesn't use CRLF
...
...
@@ -37,107 +37,107 @@ def main():
global
create_directories
,
write_master
,
write_slave
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"nym:s:d:f:a:"
)
for
o
,
a
in
opts
:
if
o
==
'-y'
:
default_answer
=
"yes"
if
o
==
'-n'
:
default_answer
=
"no"
if
o
==
'-s'
:
write_slave
=
a
if
o
==
'-m'
:
write_master
=
a
if
o
==
'-d'
:
create_directories
=
a
if
o
==
'-f'
:
create_files
=
a
if
o
==
'-a'
:
create_files
=
create_directories
=
write_slave
=
write_master
=
a
if
o
==
'-y'
:
default_answer
=
"yes"
if
o
==
'-n'
:
default_answer
=
"no"
if
o
==
'-s'
:
write_slave
=
a
if
o
==
'-m'
:
write_master
=
a
if
o
==
'-d'
:
create_directories
=
a
if
o
==
'-f'
:
create_files
=
a
if
o
==
'-a'
:
create_files
=
create_directories
=
write_slave
=
write_master
=
a
try
:
[
slave
,
master
]
=
args
[
slave
,
master
]
=
args
except
ValueError
:
print
"usage: python"
,
sys
.
argv
[
0
]
or
"treesync.py"
,
print
"[-n] [-y] [-m y|n|a] [-s y|n|a] [-d y|n|a] [-f n|y|a]"
,
print
"slavedir masterdir"
return
print
"usage: python"
,
sys
.
argv
[
0
]
or
"treesync.py"
,
print
"[-n] [-y] [-m y|n|a] [-s y|n|a] [-d y|n|a] [-f n|y|a]"
,
print
"slavedir masterdir"
return
process
(
slave
,
master
)
def
process
(
slave
,
master
):
cvsdir
=
os
.
path
.
join
(
master
,
"CVS"
)
if
not
os
.
path
.
isdir
(
cvsdir
):
print
"skipping master subdirectory"
,
master
print
"-- not under CVS"
return
print
"skipping master subdirectory"
,
master
print
"-- not under CVS"
return
print
"-"
*
40
print
"slave "
,
slave
print
"master"
,
master
if
not
os
.
path
.
isdir
(
slave
):
if
not
okay
(
"create slave directory %s?"
%
slave
,
answer
=
create_directories
):
print
"skipping master subdirectory"
,
master
print
"-- no corresponding slave"
,
slave
return
print
"creating slave directory"
,
slave
try
:
os
.
mkdir
(
slave
)
except
os
.
error
,
msg
:
print
"can't make slave directory"
,
slave
,
":"
,
msg
return
else
:
print
"made slave directory"
,
slave
if
not
okay
(
"create slave directory %s?"
%
slave
,
answer
=
create_directories
):
print
"skipping master subdirectory"
,
master
print
"-- no corresponding slave"
,
slave
return
print
"creating slave directory"
,
slave
try
:
os
.
mkdir
(
slave
)
except
os
.
error
,
msg
:
print
"can't make slave directory"
,
slave
,
":"
,
msg
return
else
:
print
"made slave directory"
,
slave
cvsdir
=
None
subdirs
=
[]
names
=
os
.
listdir
(
master
)
for
name
in
names
:
mastername
=
os
.
path
.
join
(
master
,
name
)
slavename
=
os
.
path
.
join
(
slave
,
name
)
if
name
==
"CVS"
:
cvsdir
=
mastername
else
:
if
os
.
path
.
isdir
(
mastername
)
and
not
os
.
path
.
islink
(
mastername
):
subdirs
.
append
((
slavename
,
mastername
))
mastername
=
os
.
path
.
join
(
master
,
name
)
slavename
=
os
.
path
.
join
(
slave
,
name
)
if
name
==
"CVS"
:
cvsdir
=
mastername
else
:
if
os
.
path
.
isdir
(
mastername
)
and
not
os
.
path
.
islink
(
mastername
):
subdirs
.
append
((
slavename
,
mastername
))
if
cvsdir
:
entries
=
os
.
path
.
join
(
cvsdir
,
"Entries"
)
for
e
in
open
(
entries
).
readlines
():
words
=
string
.
split
(
e
,
'/'
)
if
words
[
0
]
==
''
and
words
[
1
:]:
name
=
words
[
1
]
s
=
os
.
path
.
join
(
slave
,
name
)
m
=
os
.
path
.
join
(
master
,
name
)
compare
(
s
,
m
)
entries
=
os
.
path
.
join
(
cvsdir
,
"Entries"
)
for
e
in
open
(
entries
).
readlines
():
words
=
string
.
split
(
e
,
'/'
)
if
words
[
0
]
==
''
and
words
[
1
:]:
name
=
words
[
1
]
s
=
os
.
path
.
join
(
slave
,
name
)
m
=
os
.
path
.
join
(
master
,
name
)
compare
(
s
,
m
)
for
(
s
,
m
)
in
subdirs
:
process
(
s
,
m
)
process
(
s
,
m
)
def
compare
(
slave
,
master
):
try
:
sf
=
open
(
slave
,
'r'
)
sf
=
open
(
slave
,
'r'
)
except
IOError
:
sf
=
None
sf
=
None
try
:
mf
=
open
(
master
,
'rb'
)
mf
=
open
(
master
,
'rb'
)
except
IOError
:
mf
=
None
mf
=
None
if
not
sf
:
if
not
mf
:
print
"Neither master nor slave exists"
,
master
return
print
"Creating missing slave"
,
slave
copy
(
master
,
slave
,
answer
=
create_files
)
return
if
not
mf
:
print
"Neither master nor slave exists"
,
master
return
print
"Creating missing slave"
,
slave
copy
(
master
,
slave
,
answer
=
create_files
)
return
if
not
mf
:
print
"Not updating missing master"
,
master
return
print
"Not updating missing master"
,
master
return
if
sf
and
mf
:
if
identical
(
sf
,
mf
):
return
if
identical
(
sf
,
mf
):
return
sft
=
mtime
(
sf
)
mft
=
mtime
(
mf
)
if
mft
>
sft
:
# Master is newer -- copy master to slave
sf
.
close
()
mf
.
close
()
print
"Master "
,
master
print
"is newer than slave"
,
slave
copy
(
master
,
slave
,
answer
=
write_slave
)
return
# Master is newer -- copy master to slave
sf
.
close
()
mf
.
close
()
print
"Master "
,
master
print
"is newer than slave"
,
slave
copy
(
master
,
slave
,
answer
=
write_slave
)
return
# Slave is newer -- copy slave to master
print
"Slave is"
,
sft
-
mft
,
"seconds newer than master"
# But first check what to do about CRLF
...
...
@@ -146,20 +146,20 @@ def compare(slave, master):
mf
.
close
()
sf
.
close
()
if
fun
:
print
"***UPDATING MASTER (BINARY COPY)***"
copy
(
slave
,
master
,
"rb"
,
answer
=
write_master
)
print
"***UPDATING MASTER (BINARY COPY)***"
copy
(
slave
,
master
,
"rb"
,
answer
=
write_master
)
else
:
print
"***UPDATING MASTER***"
copy
(
slave
,
master
,
"r"
,
answer
=
write_master
)
print
"***UPDATING MASTER***"
copy
(
slave
,
master
,
"r"
,
answer
=
write_master
)
BUFSIZE
=
16
*
1024
def
identical
(
sf
,
mf
):
while
1
:
sd
=
sf
.
read
(
BUFSIZE
)
md
=
mf
.
read
(
BUFSIZE
)
if
sd
!=
md
:
return
0
if
not
sd
:
break
sd
=
sf
.
read
(
BUFSIZE
)
md
=
mf
.
read
(
BUFSIZE
)
if
sd
!=
md
:
return
0
if
not
sd
:
break
return
1
def
mtime
(
f
):
...
...
@@ -168,36 +168,36 @@ def mtime(f):
def
funnychars
(
f
):
while
1
:
buf
=
f
.
read
(
BUFSIZE
)
if
not
buf
:
break
if
'
\
r
'
in
buf
or
'
\
0
'
in
buf
:
return
1
buf
=
f
.
read
(
BUFSIZE
)
if
not
buf
:
break
if
'
\
r
'
in
buf
or
'
\
0
'
in
buf
:
return
1
return
0
def
copy
(
src
,
dst
,
rmode
=
"rb"
,
wmode
=
"wb"
,
answer
=
'ask'
):
print
"copying"
,
src
print
" to"
,
dst
if
not
okay
(
"okay to copy? "
,
answer
):
return
return
f
=
open
(
src
,
rmode
)
g
=
open
(
dst
,
wmode
)
while
1
:
buf
=
f
.
read
(
BUFSIZE
)
if
not
buf
:
break
g
.
write
(
buf
)
buf
=
f
.
read
(
BUFSIZE
)
if
not
buf
:
break
g
.
write
(
buf
)
f
.
close
()
g
.
close
()
def
okay
(
prompt
,
answer
=
'ask'
):
answer
=
string
.
lower
(
string
.
strip
(
answer
))
if
not
answer
or
answer
[
0
]
not
in
'ny'
:
answer
=
raw_input
(
prompt
)
answer
=
string
.
lower
(
string
.
strip
(
answer
))
if
not
answer
:
answer
=
default_answer
answer
=
raw_input
(
prompt
)
answer
=
string
.
lower
(
string
.
strip
(
answer
))
if
not
answer
:
answer
=
default_answer
if
answer
[:
1
]
==
'y'
:
return
1
return
1
if
answer
[:
1
]
==
'n'
:
return
0
return
0
print
"Yes or No please -- try again:"
return
okay
(
prompt
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment