Mike Fleetwood [Sun, 1 Sep 2013 11:34:47 +0000 (12:34 +0100)]
Fix importing of branches into RCS
RCS requires the parent revision to be locked to checkin a new revision.
When there is only a single branch everything works, but when jumping to
a different branch `ci' fails reporting the parent revision on this
branch isn't locked.
Remember the previous revision, which is locked in RCS, for every
checked in file. If the parent of the revision being checked in is not
the previously checked in revision then unlock the locked revision and
relock the parent revision.
Test case:
$ cat test-04-branches.fastexp
commit refs/heads/master
mark :1
committer Joe Bloggs <joe.bloggs@example.com> 999091736 +0100
data 13
Add file.txt
M 644 inline file.txt
data 51
Contents of file.txt, changeset 1/3, branch master
commit refs/heads/b1
mark :2
committer Joe Bloggs <joe.bloggs@example.com> 999098479 +0100
data 29
Update file.txt on branch b1
from :1
M 644 inline file.txt
data 47
Contents of file.txt, changeset 2/3, branch b1
commit refs/heads/master
mark :3
committer Joe Bloggs <joe.bloggs@example.com> 999098479 +0100
data 33
Update file.txt on branch master
from :1
M 644 inline file.txt
data 51
Contents of file.txt, changeset 3/3, branch master
$ rcs-fast-import -v -v -v < test-04-branches.fastexp
rcs-fast-import: repository fast import creates
/tmp/test/.rs2845
rcs-fast-import:......(0.00 sec) done.
commit refs/heads/master
rcs-fast-import: :1 M file.txt
rcs-fast-import: linking ../.rs2845/inline-156562380 to file.txt
Assigning 1.1 to file.txt
rcs-fast-import: executing 'ci -l1.1 -d'Wed 29 Aug 2001 14:28:56 +0100'
-m'Committer: Joe Bloggs <joe.bloggs@example.com>
Committer-Date: Wed 29 Aug 2001 14:28:56 +0100
Mark: :1
Add file.txt
' file.txt RCS/file.txt,v' modify
RCS/file.txt,v <-- file.txt
initial revision: 1.1
done
rcs-fast-import: removing file.txt
commit refs/heads/b1
rcs-fast-import: :2 M file.txt
rcs-fast-import: linking ../.rs2845/inline-156562924 to file.txt
Assigning 1.1.1.1 to file.txt
rcs-fast-import: executing 'ci -l1.1.1.1 -d'Wed 29 Aug 2001 16:21:19
+0100' -m'Committer: Joe Bloggs <joe.bloggs@example.com>
Committer-Date: Wed 29 Aug 2001 16:21:19 +0100
Mark: :2
Parents: :1
Update file.txt on branch b1
' file.txt RCS/file.txt,v' modify
RCS/file.txt,v <-- file.txt
new revision: 1.1.1.1; previous revision: 1.1
done
rcs-fast-import: removing file.txt
rcs-fast-import: executing 'rcs -N'refs/heads/b1':1.1.1 RCS/file.txt,v'
RCS file: RCS/file.txt,v
done
commit refs/heads/master
rcs-fast-import: :3 M file.txt
rcs-fast-import: linking ../.rs2845/inline-156563340 to file.txt
Assigning 1.2 to file.txt
rcs-fast-import: executing 'ci -l1.2 -d'Wed 29 Aug 2001 16:21:19 +0100'
-m'Committer: Joe Bloggs <joe.bloggs@example.com>
Committer-Date: Wed 29 Aug 2001 16:21:19 +0100
Mark: :3
Parents: :1
Update file.txt on branch master
' file.txt RCS/file.txt,v' modify
RCS/file.txt,v <-- file.txt
ci: RCS/file.txt,v: no lock set by mike for revision 1.1
cleaning up......(0.00 sec) done.
rcs-fast-import: cleaning up
/tmp/test/.rs2845......(0.00 sec)
done.
rcs-fast-import: child returned 1.
Mike Fleetwood [Fri, 30 Aug 2013 21:35:20 +0000 (22:35 +0100)]
Fix shell quoting issues with the commit messages
The commit message was subject to shell double quote expansion because
it was passed as a parameter to `ci' and external commands are executed
via a shell. This could cause commit messages to be modified and to
even fail the import. Single quote the commit message instead.
Test case:
$ cat test-03-comment-quoting.fastexp
commit refs/heads/master
mark :1
committer Joe Bloggs <joe.bloggs@example.com> 998655365 +0100
data 84
Commit message containing shell double quote special characters (`) ($HOME) and (')
M 644 inline file.txt
data 21
Contents of file.txt
$ rcs-fast-export -v -v -v < test-03-comment-quoting.fastexp
rcs-fast-import: repository fast import creates
/tmp/test/.rs24387
rcs-fast-import:......(0.00 sec) done.
commit refs/heads/master
rcs-fast-import: :1 M file.txt
rcs-fast-import: linking ../.rs24387/inline-152187820 to file.txt
Assigning 1.1 to file.txt
rcs-fast-import: executing 'ci -l1.1 -d'Fri 24 Aug 2001 13:16:05 +0100'
-m"Committer: Joe Bloggs <joe.bloggs@example.com>
Committer-Date: Fri 24 Aug 2001 13:16:05 +0100
Mark: :1
Commit message containing shell double quote special characters (`) ($HOME) and (')
" file.txt RCS/file.txt,v' modify
/bin/sh: -c: line 4: unexpected EOF while looking for matching ``'
/bin/sh: -c: line 6: syntax error: unexpected end of file
cleaning up......(0.00 sec) done.
rcs-fast-import: cleaning up
/tmp/test/.rs24387......(0.00 sec)
done.
rcs-fast-import: child returned 1.
Mike Fleetwood [Thu, 29 Aug 2013 22:43:25 +0000 (23:43 +0100)]
Fix importing of inline data
Import of inline data was failing because the temporary file containing
the inline data was written to .../.rs<PID>/inline-<OBJID> but was being
accessed from the current working directory .../temp-import-<PID> using
just the file name without a path. Save the full path to the inline
data file, rather than just the file name.
Test case:
$ cat test-01-inline-data.fastexp
commit refs/heads/master
mark :1
committer Joe Bloggs <joe.bloggs@example.com> 998655365 +0100
data 13
Add file.txt
M 644 inline file.txt
data 21
Contents of file.txt
$ rcs-fast-import -v -v -v < test-01-inline-data.fastexp
rcs-fast-import: repository fast import creates /tmp/test/.rs16719
rcs-fast-import:......(0.00 sec) done.
commit refs/heads/master
rcs-fast-import: :1 M file.txt
rcs-fast-import: linking inline-164709420 to file.txt
cleaning up......(0.00 sec) done.
rcs-fast-import: cleaning up /tmp/test/.rs16719......(0.00 sec) done.
rcs-fast-import: refusing to step on file.txt: OSError(2, 'No such file or directory').