summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@frugalware.org>2010-06-27 18:51:11 +0200
committerMiklos Vajna <vmiklos@frugalware.org>2010-06-27 18:51:11 +0200
commitca8d573ab98e5c10e51293df66963cf696b6e0b5 (patch)
tree83aebc92edb25af4dfcdb7a48899869cf7275b95
parentb3ce87bb2a686428817f0575db509a80bb720217 (diff)
downloadpython-fastimport-ca8d573ab98e5c10e51293df66963cf696b6e0b5.tar.gz
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.
-rwxr-xr-xexporters/darcs/darcs-fast-import3
-rw-r--r--exporters/darcs/darcs-fast-import.txt8
-rw-r--r--exporters/darcs/t/testimport-gitsymlink.sh31
3 files changed, 42 insertions, 0 deletions
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 $?