diff -rN -u old-tailor/README new-tailor/README --- old-tailor/README 2006-06-04 16:42:52.000000000 +0200 +++ new-tailor/README 2006-06-04 16:42:52.000000000 +0200 @@ -661,7 +661,21 @@ git %%% -.. no specific options +parent-repo : string + Relative path to a git directory to use as a parent. This is useful + to import repository branches. If this parameter is empty, the + branch has no parent (default behaviour). + +parent-rev : string + A reference to the git commit which is the parent for the first + revision on the branch to be imported (ie, the branch point). It + can be a tag name or any syntax acceptable by git (eg. something + like "tag~2", if you want to correct the idea of where the + branchpoint is. + + Since tailor generates mostly-stable SHA1 revisions, you can also + use a SHA1 as branchpoint. Just import your trunk first, find the + correct SHA1, and setup and import your branch. hg %% diff -rN -u old-tailor/vcpx/git.py new-tailor/vcpx/git.py --- old-tailor/vcpx/git.py 2006-06-04 16:42:52.000000000 +0200 +++ new-tailor/vcpx/git.py 2006-06-04 16:42:52.000000000 +0200 @@ -298,19 +298,39 @@ def _prepareTargetRepository(self): """ - Execute ``git init-db``. + Initialize .git through ``git init-db`` or ``git-clone``. """ + from os import renames from os.path import join, exists if not exists(join(self.basedir, self.repository.METADIR)): - init = ExternalCommand(cwd=self.basedir, - command=self.repository.command("init-db")) - init.execute() - - if init.exit_status: - raise TargetInitializationFailure( - "%s returned status %s" % (str(init), init.exit_status)) + if self.repository.PARENT_REPO == '': + cmd = self.repository.command("init-db") + init = ExternalCommand(cwd=self.basedir, command=cmd) + init.execute() + if init.exit_status: + raise TargetInitializationFailure( + "%s returned status %s" % (str(init), init.exit_status)) + else: + cmd = self.repository.command("clone", "--shared", "-n", + self.repository.PARENT_REPO, 'tmp') + clone = ExternalCommand(cwd=self.basedir, command=cmd) + clone.execute() + if clone.exit_status: + raise TargetInitializationFailure( + "%s returned status %s" % (str(clone), clone.exit_status)) + + renames('%s/%s/tmp/.git' % (self.repository.rootdir, self.repository.subdir), + '%s/%s/.git' % (self.repository.rootdir, self.repository.subdir)) + + cmd = self.repository.command("reset", "--soft", self.repository.PARENT_REV) + reset = ExternalCommand(cwd=self.basedir, command=cmd) + reset.execute() + if reset.exit_status: + raise TargetInitializationFailure( + "%s returned status %s" % (str(reset), reset.exit_status)) + def _prepareWorkingDirectory(self, source_repo): """ diff -rN -u old-tailor/vcpx/repository.py new-tailor/vcpx/repository.py --- old-tailor/vcpx/repository.py 2006-06-04 16:42:52.000000000 +0200 +++ new-tailor/vcpx/repository.py 2006-06-04 16:42:52.000000000 +0200 @@ -287,6 +287,8 @@ def _load(self, project): Repository._load(self, project) self.EXECUTABLE = project.config.get(self.name, 'git-command', 'git') + self.PARENT_REPO = project.config.get(self.name, 'parent-repo', '') + self.PARENT_REV = project.config.get(self.name, 'parent-rev', 'HEAD') class HgRepository(Repository): diff -rN -u old-tailor/vcpx/tailor.py new-tailor/vcpx/tailor.py --- old-tailor/vcpx/tailor.py 2006-06-04 16:42:52.000000000 +0200 +++ new-tailor/vcpx/tailor.py 2006-06-04 16:42:52.000000000 +0200 @@ -74,7 +74,9 @@ raise try: - dwd.importFirstRevision(self.source, actual, 'INITIAL'==revision) + dwd.importFirstRevision(self.source, actual, + self.target.PARENT_REPO != '' or + 'INITIAL'==revision) except: self.log.critical('Could not import checked out tree in "%s"!', self.rootdir)