From ca8d573ab98e5c10e51293df66963cf696b6e0b5 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 27 Jun 2010 18:51:11 +0200 Subject: darcs-fast-import: better error handling for symlinks The importer can't handle them till Darcs does not so, but at least we can give an easy-to-understand error message and a separate exit code. --- exporters/darcs/darcs-fast-import | 3 +++ exporters/darcs/darcs-fast-import.txt | 8 ++++++++ exporters/darcs/t/testimport-gitsymlink.sh | 31 ++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 exporters/darcs/t/testimport-gitsymlink.sh diff --git a/exporters/darcs/darcs-fast-import b/exporters/darcs/darcs-fast-import index 4892438..a7a4834 100755 --- a/exporters/darcs/darcs-fast-import +++ b/exporters/darcs/darcs-fast-import @@ -198,6 +198,9 @@ class Handler: os.system("darcs add %s" % dest) elif self.line.startswith("M "): items = self.line.split(' ') + if items[1] == "120000": + print "Adding symbolic links (symlinks) is not supported by Darcs." + sys.exit(2) path = items[3][:-1] dir = os.path.split(path)[0] if len(dir) and not os.path.exists(dir): diff --git a/exporters/darcs/darcs-fast-import.txt b/exporters/darcs/darcs-fast-import.txt index 09c7b1e..314b947 100644 --- a/exporters/darcs/darcs-fast-import.txt +++ b/exporters/darcs/darcs-fast-import.txt @@ -33,3 +33,11 @@ as well, via the --import-marks / --export-marks switches. --logfile:: The output of external commands are redirected to a log file. You can specify the path of that file with this parameter. + +== EXIT CODES + +The exit code is: + +* 0 on success +* 1 on unhandled exception +* 2 in case the stream would try to let the importer create a symlink diff --git a/exporters/darcs/t/testimport-gitsymlink.sh b/exporters/darcs/t/testimport-gitsymlink.sh new file mode 100644 index 0000000..340a493 --- /dev/null +++ b/exporters/darcs/t/testimport-gitsymlink.sh @@ -0,0 +1,31 @@ +. ./lib.sh + +create_git test +cd test +# add two dirs with the some contents, then remove the second +# and make it a symlink to the first +mkdir dira +echo blabla > dira/file +echo blablabla > dira/file2 +mkdir dirb +touch dirb/file +touch dirb/file2 +git add dira dirb +git commit -a -m "add dira/dirb" +rm -rf dirb +ln -s dira dirb +git add dirb +git commit -a -m "change a dir to a symlink" +cd .. + +rm -rf test.darcs +mkdir test.darcs +cd test.darcs +darcs init +cd .. +(cd test; git fast-export --progress=2 HEAD) | (cd test.darcs; darcs-fast-import) +# we *do* want this to fail, but with error code 2. that means that we +# detected that symlinks are not supported and the user does not get a +# meaningless exception +[ $? = 2 ] +exit $? -- cgit v1.2.1