1
0
mirror of synced 2026-03-15 06:44:17 +00:00

Compare commits

..

5 Commits

Author SHA1 Message Date
rmkaplan
4fac4e3e96 Merge pull request #352 from Interlisp/restore-versions
Add small util for restoring versions from git history
2021-07-21 17:14:53 -07:00
Larry Masinter
966b837351 Add small util for restoring versions from git history 2021-07-21 17:09:40 -07:00
rmkaplan
dac0acd0d5 Merge pull request #346 from Interlisp/recover-unversioned
Some files were checked in with only versioned files (from unix side)
2021-07-21 16:43:24 -07:00
Larry Masinter
105b0d1f3a Some files were checked in with only versioned files (from unix side) 2021-06-23 20:52:49 -07:00
Larry Masinter
10e3916e7e See PR #275 for discusssion 2021-05-06 16:24:43 -07:00
11 changed files with 138 additions and 7 deletions

View File

@@ -1,13 +1,13 @@
(DEFINE-FILE-INFO READTABLE "INTERLISP" PACKAGE "INTERLISP")
(FILECREATED "12-Jun-90 15:31:15" {DSK}<usr>local>lde>lispcore>library>SYSEDIT.;2 1411
(FILECREATED " 6-May-2021 16:22:01" {DSK}<home>larry>ilisp>medley>library>SYSEDIT.;6 1312
changes to%: (VARS SYSEDITCOMS)
previous date%: " 9-Mar-87 10:53:12" {DSK}<usr>local>lde>lispcore>library>SYSEDIT.;1)
previous date%: "12-Jun-90 15:31:15" {DSK}<home>larry>ilisp>medley>library>SYSEDIT.;1)
(* ; "
Copyright (c) 1984, 1987, 1990 by Venue & Xerox Corporation. All rights reserved.
Copyright (c) 1984, 1987, 1990, 2021 by Venue & Xerox Corporation.
")
(PRETTYCOMPRINT SYSEDITCOMS)
@@ -15,7 +15,6 @@ Copyright (c) 1984, 1987, 1990 by Venue & Xerox Corporation. All rights reserve
(RPAQQ SYSEDITCOMS
[(VARS (CLISPIFYPRETTYFLG)
(MSRECORDTRANFLG T)
(MSMACROPROPS COMPILERMACROPROPS)
(RECOMPILEDEFAULT 'CHANGES)
(CLEANUPOPTIONS '(RC F))
(GLOBALVARFLG T)
@@ -30,8 +29,6 @@ Copyright (c) 1984, 1987, 1990 by Venue & Xerox Corporation. All rights reserve
(RPAQQ MSRECORDTRANFLG T)
(RPAQ MSMACROPROPS COMPILERMACROPROPS)
(RPAQQ RECOMPILEDEFAULT CHANGES)
(RPAQQ CLEANUPOPTIONS (RC F))
@@ -46,7 +43,7 @@ Copyright (c) 1984, 1987, 1990 by Venue & Xerox Corporation. All rights reserve
(DIRECTORIES DIRECTORIES))
(FILESLOAD (SOURCE)
EXPORTS.ALL))
(PUTPROPS SYSEDIT COPYRIGHT ("Venue & Xerox Corporation" 1984 1987 1990))
(PUTPROPS SYSEDIT COPYRIGHT ("Venue & Xerox Corporation" 1984 1987 1990 2021))
(DECLARE%: DONTCOPY
(FILEMAP (NIL)))
STOP

134
scripts/restore-versions.sh Executable file
View File

@@ -0,0 +1,134 @@
#!/bin/sh
# restore old versions from git repo
# For use after a rm-versions or in a newly cloned repo
# not guaranteed to return the SAME version as before
# but it tries when it can.
# version numbers follow git history
# LC_ALL is needed for tr to keep it from getting confused
export LC_ALL=C
file="$1"
# If given a directory, restore all versions from that directory
# There's a suble difference, bcause glob expansion won't try
# to reversion .git .github at top level.
if [ -d "$file" ]; then
for dir in "$file/"*[a-zA-Z0-9]
do echo restoring versions "$dir" && \
find "$dir" -type f -iname "*[a-z0-9]" -exec "$0" {} \;
done
exit 0
fi
if [ ! -f "$file" ]; then
echo no such file "$file"
exit 1
fi
# file already has versions?
for vfn in "$file".~[1-9]*~
do if [ -f "$vfn" ]; then
echo "Already has versions: " $vfn && \
exit 1
fi
done
#stash file and remember status
#The $stash remembers if it did something or not
stash=`git stash push -- $file 2>&1`
# max is the maximum version checked in as as separate
max=0
# find commits with explicit old versions
# In most cases there will be only one commit
# these versions are restored, and n is set to 1+max of them
# this is specific to our situation where we checked in some
# ~nn~ versions and then .gitignore *~ was set
for commit in `git log --remove-empty --reverse --format="%h" -- "$file.~[1-9]*~"`
do git checkout -q $commit "$file.~[1-9]*~" 2>/dev/null && \
for version in "$file".~[1-9]*~
do vn=`echo $version | sed 's/^.*\.~\([1-9][0-9]*\)~$/\1/'`
if [ ! -z $vn ]; then
vn=`expr $vn + 1`
if [ $max -lt $vn ]; then
max=$vn
fi
fi
done
done
# if file and max version are the same, link them
# this obsoletes medley-fix-links
if cmp -q $file $file.~$max~ >/dev/null 2>&1
then
rm $file.~$max~
ln $file $file.~$max~
fi
# $base is used to look for mentions of DSK versions
base=`basename "$file" .LCOM`
base=`basename "$base" .DFASL`
pattern='{DSK}.*'"$base"'\.\?;[1-9][0-9]*'
# Restore versions from git history. This process starts with
# the max from the previous calculation and would go up by 1, but it
# also prefers to restore files to their FILECREATED version
# number. It does this by looking for {DSK}...root.~nn~ and using nn
# as the version number if it isn't too small. It then makes a hard
# link (each time for each commit) since the checkout will break any
# old links
n=`expr $max + 1`
####
# !!!! if you don't want these post-github versions
# skip until end
# If you want things before the last delete, remove the '--remove empty'
####
for commit in `git log --remove-empty --reverse --format="%h" -- "$file"`
do git checkout -q $commit "$file" && \
fcv=`tr '\r' '\n' <"$file" | head -n 6 | grep -ai --max-count=1 --only-matching "$pattern"`
fcv=`echo $fcv | sed 's/^.*;\([1-9][0-9]*\)$/\1/'`
if [ ! -z $fcv ]; then
if [ $fcv -gt $n ]; then
n=$fcv
fi
fi
ln "$file" "$file.~"$n"~" && n=`expr $n + 1`
done
### END SKIP
# if the 'stash' at the beginning did something, restore the stashed file
case $stash in
"error*" | "No local changes*")
;;
"*")
git stash pop -- "$file" && \
ln $file "$file.~"$n"~" && n=`expr $n + 1`
;;
esac
# if the result is only one version ;1 remove it
# Otherwise, make sure no versions are staged
if [ $n -eq 2 ]; then
rm -f "$file".~1~
else
git restore --staged "$file.~[1-9]*~" 2>/dev/null
fi