From 6d3739e08b242fc28ab5a01f34be1897e7407f85 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 28 Jun 2010 01:21:13 +0200 Subject: darcs-fast-import: don't fail for first empty commit --- exporters/darcs/TODO | 2 ++ exporters/darcs/darcs-fast-import | 9 +++++++++ exporters/darcs/t/lib.sh | 1 + 3 files changed, 12 insertions(+) diff --git a/exporters/darcs/TODO b/exporters/darcs/TODO index 2f199d1..c6892c8 100644 --- a/exporters/darcs/TODO +++ b/exporters/darcs/TODO @@ -4,3 +4,5 @@ not enabled, etc. parse the patches manually so we can avoid re-adding existing files manually. avoid darcs apply. + +import: handle evil merges (git-subtree), maybe using git log --first-parent diff --git a/exporters/darcs/darcs-fast-import b/exporters/darcs/darcs-fast-import index 75116a7..c50ab90 100755 --- a/exporters/darcs/darcs-fast-import +++ b/exporters/darcs/darcs-fast-import @@ -186,24 +186,29 @@ class Handler: self.read_next_line() while self.line.startswith("merge "): self.read_next_line() + change = False while len(self.line) > 0: if self.line.startswith("deleteall"): path = self.line[2:-1] for path in self.files: os.unlink(path) self.files = [] + change = True elif self.line.startswith("D "): path = self.line[2:-1] if os.path.exists(path): os.unlink(path) if path in self.files: self.files.remove(path) + change = True elif self.line.startswith("R "): self.invoke_darcs("mv %s" % self.line[2:]) + change = True elif self.line.startswith("C "): src, dest = self.line[:-1].split(' ')[1:] shutil.copy(src.strip('"'), dest.strip('"')) self.invoke_add(dest) + change = True elif self.line.startswith("M "): items = self.line.split(' ') path = items[3][:-1] @@ -231,6 +236,7 @@ class Handler: adds.append(path) if path not in self.files: self.files.append(path) + change = True else: self.unread_line = True break @@ -238,6 +244,9 @@ class Handler: if not len(self.line): break + if not change: + # darcs does not support empty commits + return for i in adds: self.invoke_add(i) sock = subprocess.Popen(["darcs", "record", "--ignore-times", "-a", "--pipe"], stdin=subprocess.PIPE, stdout=subprocess.PIPE) diff --git a/exporters/darcs/t/lib.sh b/exporters/darcs/t/lib.sh index c0f30c2..095f9ef 100644 --- a/exporters/darcs/t/lib.sh +++ b/exporters/darcs/t/lib.sh @@ -191,6 +191,7 @@ create_git() mkdir -p $1 cd $1 git init $2 + git commit --allow-empty -m 'root commit' echo A > file git add file git commit -a -m A -- cgit v1.2.1