The attached file adds basic (and incomplete) support for aegis as a
target repository.

-- 
Walter Franzini
http://aegis.stepbuild.org/

PGP Public key ID: 1024D/CB3FEB43
Key fingerprint  : FA26 C33B CAFF 7848 EFEB  7327 96AA 2D57 CB3F EB43
Key server       : http://www.keyserver.net
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


New patches:

[basic support for aegis as a target
[EMAIL PROTECTED] {
adddir ./vcpx/repository/aegis
addfile ./test-scripts/test-darcs2aegis-simple.sh
hunk ./test-scripts/test-darcs2aegis-simple.sh 1
+#!/bin/sh
+#
+# Copyright (C) 2008 Walter Franzini
+#
+
+here=`pwd`
+
+#
+# Add the development dir to the PATH
+#
+PATH=$here:$PATH
+export PATH
+
+pass()
+{
+    exit 0
+}
+
+fail()
+{
+    echo "FAILED: $activity"
+    exit 1
+}
+
+no_result()
+{
+    echo "NO_RESULT: $activity"
+    exit 2
+}
+
+work=${TMPDIR-/tmp}/TAILOR.$$
+mkdir $work
+if test $? -ne 0; then no_result; fi
+
+cd $work
+
+activity="darcs setup"
+mkdir $work/darcs-repo > log 2>&1
+if test $? -ne 0; then cat log; no_result; fi
+
+darcs initialize --repodir=$work/darcs-repo > log 2>&1
+if test $? -ne 0; then cat log; no_result; fi
+
+activity="create foo"
+cat > $work/darcs-repo/foo.txt <<EOF
+A simple text file
+EOF
+if test $? -ne 0; then no_result; fi
+
+darcs add foo.txt --repodir=$work/darcs-repo > log 2>&1
+if test $? -ne 0; then cat log; no_result; fi
+
+darcs record --repodir=$work/darcs-repo -a -A Nobody -m "initial commit" \
+    > log 2>&1
+if test $? -ne 0; then cat log; no_result; fi
+
+cat > $work/darcs-repo/foo.txt <<EOF
+A simple text file
+wit some more text.
+EOF
+if test $? -ne 0; then no_result; fi
+
+darcs record --repodir=$work/darcs-repo -a -A Nobody --ignore-time \
+    -m "second commit" > log 2>&1
+if test $? -ne 0; then cat log; no_result; fi
+
+cat > $work/darcs-repo/foo.txt <<EOF
+A simple text file
+wit some more text.
+more text again!
+EOF
+if test $? -ne 0; then no_result; fi
+
+darcs record --repodir=$work/darcs-repo -a -A Nobody --ignore-time \
+    -m "third commit" > log 2>&1
+if test $? -ne 0; then cat log; no_result; fi
+
+#
+# Initialize the aegis repository
+#
+
+unset AEGIS_PROJECT
+unset AEGIS_CHANGE
+unset AEGIS_PATH
+unset AEGIS
+umask 022
+
+LINES=24
+export LINES
+COLS=80
+export COLS
+
+USER=${USER:-${LOGNAME:-`whoami`}}
+
+PAGER=cat
+export PAGER
+AEGIS_FLAGS="delete_file_preference = no_keep; \
+        lock_wait_preference = always; \
+        diff_preference = automatic_merge; \
+        pager_preference = never; \
+        persevere_preference = all; \
+        log_file_preference = never; \
+        default_development_directory = \"$work\";"
+export AEGIS_FLAGS
+AEGIS_THROTTLE=-1
+export AEGIS_THROTTLE
+
+# This tells aeintegratq that it is being used by a test.
+AEGIS_TEST_DIR=$work
+export AEGIS_TEST_DIR
+
+if test $? -ne 0; then exit 2; fi
+
+AEGIS_DATADIR=$here/lib
+export AEGIS_DATADIR
+
+AEGIS_MESSAGE_LIBRARY=$work/no-such-dir
+export AEGIS_MESSAGE_LIBRARY
+unset LANG
+unset LANGUAGE
+unset LC_ALL
+
+AEGIS_PROJECT=example
+export AEGIS_PROJECT
+AEGIS_PATH=$work/lib
+export AEGIS_PATH
+
+mkdir $AEGIS_PATH
+
+chmod 777 $AEGIS_PATH
+if test $? -ne 0; then no_result; cat log; fi
+
+workproj=$work/foo.proj
+workchan=$work/foo.chan
+
+activity="new project"
+aegis -npr $AEGIS_PROJECT -version "" -lib $AEGIS_PATH \
+    -dir $workproj/ > log 2>&1
+if test $? -ne 0; then cat log; no_result; fi
+
+activity="project_acttributes"
+cat > $work/pa <<EOF
+description = "A bogus project created to test tailor functionality.";
+developer_may_review = true;
+developer_may_integrate = true;
+reviewer_may_integrate = true;
+default_test_exemption = true;
+develop_end_action = goto_awaiting_integration;
+EOF
+if test $? -ne 0 ; then no_result; fi
+
+aegis -pa -f $work/pa > log 2>&1
+if test $? -ne 0 ; then cat log; no_result; fi
+
+#
+# add the staff
+#
+activity="staff 62"
+aegis -nd $USER > log 2>&1
+if test $? -ne 0 ; then cat log; no_result; fi
+aegis -nrv $USER > log 2>&1
+if test $? -ne 0 ; then cat log; no_result; fi
+aegis -ni $USER > log 2>&1
+if test $? -ne 0 ; then cat log; no_result; fi
+
+#
+# tailor config
+#
+cat > $work/tailor.conf <<EOF
+[DEFAULT]
+verbose = True
+Debug = True
+
+[project]
+patch-name-format = %(revision)s
+root-directory = $PWD/rootdir
+source = darcs:source
+target = aegis:target
+
+[darcs:source]
+repository = $work/darcs-repo
+#module = project
+subdir = darcs1side
+
+[aegis:target]
+module = $AEGIS_PROJECT
+subdir = aegisside
+EOF
+if test $? -ne 0; then no_result; fi
+
+activity="run tailor"
+python $here/tailor -c $work/tailor.conf > log 2>&1
+if test $? -ne 0; then cat log; fail; fi
+
+activity="check aegis project history"
+aegis -list project_history -unformatted
+if test $? -ne 0; then cat log; no_result; fi
+
+pass
addfile ./vcpx/repository/aegis/__init__.py
hunk ./vcpx/repository/aegis/__init__.py 1
+#
+# Copyright (C) 2008 Walter Franzini
+#
+
+import re
+
+from vcpx.repository import Repository
+from vcpx.shwrap import ExternalCommand
+
+from vcpx.target import TargetInitializationFailure
+
+class AegisRepository(Repository):
+
+    def _load(self, project):
+        Repository._load (self, project)
+        cget = project.config.get
+        self.EXECUTABLE = cget(self.name, 'aegis-command', 'aegis')
+
+    def _validateConfiguration(self):
+        pass
+
+    def command(self, *args, **kwargs):
+        original_command = self.EXECUTABLE
+        #
+        # aefinish is a different executable.  Take care of it.
+        #
+        if args[0] == "-finish":
+            self.EXECUTABLE = "aefinish"
+            args = args[1:]
+        args = args + ('-verbose',)
+        rc = Repository.command(self, *args, **kwargs)
+        self.EXECUTABLE = original_command
+        return rc
addfile ./vcpx/repository/aegis/target.py
hunk ./vcpx/repository/aegis/target.py 1
+#
+# Copyright (C) 2008 Walter Franzini
+#
+
+"""
+This module contains the target specific bits of the Aegis backend.
+"""
+
+__docformat__ = 'reStructuredText'
+
+import os
+import os.path
+import re
+from tempfile import mkstemp, NamedTemporaryFile
+
+from vcpx.shwrap import ExternalCommand, PIPE, STDOUT
+from vcpx.source import ChangesetApplicationFailure
+from vcpx.target import SynchronizableTargetWorkingDir
+from vcpx.tzinfo import UTC
+
+
+MOTD = """\
+Tailorized equivalent of
+%s
+"""
+
+
+__docformat__ = 'reStructuredText'
+
+import re
+
+from vcpx.shwrap import ExternalCommand, PIPE, STDOUT
+from vcpx.source import ChangesetApplicationFailure
+from vcpx.target import SynchronizableTargetWorkingDir
+from vcpx.tzinfo import UTC
+
+
+MOTD = """\
+Tailorized equivalent of
+%s
+"""
+
+
+class AegisTargetWorkingDir(SynchronizableTargetWorkingDir):
+    """
+    A target working directory under ``Aegis``.
+    """
+
+    change_number = "not-a-number"
+
+    def _commit(self, date, author, patchname, changelog=None, entries=None,
+                tags = [], isinitialcommit = False):
+        """
+        Commit the changeset.
+        """
+        self.__develop_end()
+        #
+        # If the change cannot be closed, e.g. because a file is
+        # modified in a change not yet integrated, then we should stop here.
+        #
+        # return False
+        #
+        # Next step only if develop_end => awaiting_integration
+        #
+        self.__integrate_begin()
+        self.__finish()
+
+
+    def _prepareTargetRepository(self):
+        #
+        # Add the very first change to the repository.
+        # This change set add aegis configuration file to the project.
+        #
+
+        #
+        # Aegis refuse to use an already existing directory as the
+        # development directory of a change.
+        #
+        if os.path.exists(self.repository.basedir):
+            os.rmdir(self.repository.basedir)
+
+        self.change_number = self.__new_change("setup aegis",
+                                               "Prepare aegis configuration")
+        self.__develop_begin()
+        self.__new_file("aegis.conf", "config")
+        self.__config_file(self.repository.basedir, "aegis.conf")
+        self.__develop_end()
+        self.__integrate_begin()
+        self.__integrate_pass()
+
+    def _prepareToReplayChangeset(self, changeset):
+        """
+        Runs aegis -New_Change -dir target.basedir
+        """
+        self.change_number = self.__new_change(changeset.revision, "bla bla")
+        self.__develop_begin()
+        #
+        # This function MUST return
+        #
+        return True
+
+    def _prepareWorkingDirectory(self, source_repo):
+        #
+        # Receive the first changeset from the source repository.
+        #
+        self.change_number = self.__new_change("bla2", "bla2 bla2")
+        self.__develop_begin()
+        return True
+
+    def _addPathnames(self, names):
+        for name in names:
+            self.__new_file(name)
+
+    def _editPathnames(self, names):
+        for name in names:
+            self.__copy_file(name)
+
+    def _removePathnames(self, named):
+        for name in names:
+            self.__remove_file(name)
+
+    def _renamePathname(self, oldname, newname):
+        self.__move_file(oldname, newname)
+
+    #
+    # The following methods wraps change's related aegis commands.
+    #
+    def __new_change(self, title, description):
+        change_attr = NamedTemporaryFile()
+        change_attr.write("brief_description = \"%s\";\n" % title)
+        change_attr.write("description = \"%s\";" % description)
+        change_attr.write("cause = external_improvement;\n")
+        change_attr.flush()
+        change_number_file = mkstemp()[1]
+        cmd = self.repository.command("-new_change",
+                                      "-project", self.repository.module,
+                                      "-file", change_attr.name,
+                                      "-output", change_number_file)
+        new_change = ExternalCommand(cwd="/tmp", command=cmd)
+        output = new_change.execute(stdout = PIPE, stderr = STDOUT)[0]
+        if new_change.exit_status > 0:
+            raise ChangesetApplicationFailure(
+                "%s returned status %d, saying: %s" % (str(new_change),
+                                                       new_change.exit_status,
+                                                       output.read()))
+        f = open(change_number_file, "r")
+        change_number = f.read()
+        f.close()
+        return change_number.strip()
+
+    def __develop_begin(self):
+        cmd = self.repository.command("-develop_begin",
+                                      "-project", self.repository.module,
+                                      "-change", self.change_number,
+                                      "-directory", self.repository.basedir)
+        develop_begin = ExternalCommand(cwd="/tmp", command=cmd)
+        output = develop_begin.execute(stdout = PIPE, stderr = STDOUT)[0]
+        if develop_begin.exit_status > 0:
+            raise ChangesetApplicationFailure(
+                "%s returned status %d, saying: %s" %
+                (str(develop_begin), develop_begin.exit_status, output.read()))
+        self.log.info(output.read())
+
+    def __develop_end(self):
+        self.__finish()
+
+    def __integrate_begin(self):
+        cmd = self.repository.command("-integrate_begin",
+                                      "-project", self.repository.module,
+                                      "-change", self.change_number)
+        integrate_begin = ExternalCommand(cwd="/tmp", command=cmd)
+        output = integrate_begin.execute(stdout = PIPE, stderr = STDOUT)[0]
+        if integrate_begin > 0:
+            raise ChangesetApplicationFailure(
+                "%s returned status %d, saying: %s" %
+                (str(integrate_begin), integrate_begin.exit_status,
+                 output.read()))
+
+    def __integrate_pass(self):
+        self.__finish()
+
+    def __finish(self):
+        cmd = self.repository.command("-finish",
+                                      "-project", self.repository.module,
+                                      "-change", self.change_number)
+        finish = ExternalCommand(cwd="/tmp", command=cmd)
+        output = finish.execute(stdout = PIPE, stderr = STDOUT)[0]
+        if finish > 0:
+            raise ChangesetApplicationFailure(
+                "%s returned status %d, saying: %s" %
+                (str(finish), finish.exit_status, output.read()))
+
+    def __change_attribute(self):
+        pass
+
+    #
+    # File's related change commands.
+    #
+    def __new_file(self, file_names, usage = None):
+        if usage == "config":
+            cmd = self.repository.command("-new_file", "-keep", "-config",
+                                          "-project", self.repository.module,
+                                          "-change", self.change_number)
+        else:
+            cmd = self.repository.command("-new_file", "-keep",
+                                          "-project", self.repository.module,
+                                          "-change", self.change_number)
+        new_file = ExternalCommand(cwd=self.repository.basedir,
+                                   command=cmd)
+        output = new_file.execute(file_names, stdout = PIPE, stderr = 
STDOUT)[0]
+        if new_file.exit_status > 0:
+            raise ChangesetApplicationFailure(
+                "%s returned status %d, saying: %s" %
+                (str(new_file), new_file.exit_status, output.read()))
+
+
+    def __copy_file(self, file_names):
+        cmd = self.repository.command("-copy", "-keep",
+                                      "-project", self.repository.module,
+                                      "-change", self.change_number)
+        copy_file = ExternalCommand(cwd=self.repository.basedir,
+                                    command=cmd)
+        output = copy_file.execute(file_names, stdout = PIPE, stderr = 
STDOUT)[0]
+        if copy_file.exit_status > 0:
+            raise ChangesetApplicationFailure(
+                "%s returned status %d, saying: %s" %
+                (str(copy_file), copy_file.exit_status, output.read()))
+
+    def __move_file(self, old_name, new_name):
+        self.log.info("AEGIS: aegis -move -project %s -change %s "
+                      "-base-relative %s %s", self.repository.module,
+                      self.change_number, old_name, new_name)
+        pass
+
+    def __remove_file(self, file_name):
+        self.log.info("AEGIS: aegis -remove -project %s -change %s "
+                      "-base-relative %s", self.repository.module,
+                      self.change_number, file_name)
+        pass
+
+    def __config_file(self, dir, name):
+        c = open(os.path.join(dir, name), "wb", 0777)
+        c.write("""
+build_command = "exit 0";
+link_integration_directory = true;
+
+history_get_command = "aesvt -check-out -edit ${quote $edit} "
+    "-history ${quote $history} -f ${quote $output}";
+history_put_command = "aesvt -check-in -history ${quote $history} "
+    "-f ${quote $input}";
+history_query_command = "aesvt -query -history ${quote $history}";
+history_content_limitation = binary_capable;
+
+diff_command = "set +e; $diff $orig $i > $out; test $$? -le 1";
+merge_command = "(diff3 -e $i $orig $mr | sed -e '/^w$$/d' -e '/^q$$/d'; \
+       echo '1,$$p' ) | ed - $i > $out";
+patch_diff_command = "set +e; $diff -C0 -L $index -L $index $orig $i > $out; \
+test $$? -le 1";
+""")
+        c.close()
+
}

Context:

[TAG Version 0.9.33
[EMAIL PROTECTED] 
Patch bundle hash:
abd583df9cb92afaa4c7ce0d4a235a532f88a38e
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFINoqplqotV8s/60MRAgk+AKDdNuuBi+kej2B4R9mQvSO27c5UhwCg8MNg
VBQObqgy8dGBZ5QQ3YOxF9E=
=Y86r
-----END PGP SIGNATURE-----

Attachment: pgpwT9TOKg0k0.pgp
Description: PGP signature

_______________________________________________
Tailor mailing list
[email protected]
http://lists.zooko.com/mailman/listinfo/tailor

Reply via email to