On Wednesday, 22 March 2006 at 19:24, Lele Gaifax wrote:
> Neal Becker ha scritto:
> >    self.source.prepareSourceRepository()
> >AttributeError: 'HgWorkingDir' object has no attribute 
> >'prepareSourceRepository'
> 
> It seems you are trying to use the CLI version of the hg backend, which 
> is a target only implementation. Use "hglib" instead, which implements 
> both directions.
> 
> This should probably be properly catched and alerted, feel free to open 
> a ticket.
> 
> Another approach would be of dismissing the CLI backend, leaving only 
> the native implementation, as it was done for bazaar-ng. Any takers?

I haven't looked at the error-reporting piece, but I think the
attached patch should replace hg with hglib.
New patches:

[Replace hg backend with hglib
Brendan Cully <[EMAIL PROTECTED]>**20060324213118] {
hunk ./vcpx/hg.py 1
-# -*- mode: python; coding: utf-8 -*-
-# :Progetto: vcpx -- Mercurial stuff
-# :Creato:   ven 24 giu 2005 20:42:46 CEST
-# :Autore:   Lele Gaifax <[EMAIL PROTECTED]>
-# :Licenza:  GNU General Public License
-#
-
-"""
-This module implements the backends for Mercurial.
-"""
-
-__docformat__ = 'reStructuredText'
-
-from shwrap import ExternalCommand, ReopenableNamedTemporaryFile, PIPE
-from target import SyncronizableTargetWorkingDir, TargetInitializationFailure, 
\
-     ChangesetReplayFailure
-from source import ChangesetApplicationFailure
-
-class HgWorkingDir(SyncronizableTargetWorkingDir):
-
-    ## SyncronizableTargetWorkingDir
-
-    def _addPathnames(self, names):
-        """
-        Add some new filesystem objects.
-        """
-
-        from os.path import join, isdir
-
-        # Currently hg does not handle directories at all, so filter
-        # them out.
-
-        notdirs = [n for n in names if not isdir(join(self.basedir, n))]
-        if notdirs:
-            cmd = self.repository.command("add")
-            ExternalCommand(cwd=self.basedir, command=cmd).execute(notdirs)
-
-    def _commit(self, date, author, patchname, changelog=None, entries=None):
-        """
-        Commit the changeset.
-        """
-
-        from time import mktime
-
-        encode = self.repository.encode
-
-        logmessage = []
-        if patchname:
-            logmessage.append(patchname)
-        if changelog:
-            logmessage.append(changelog)
-
-        cmd = self.repository.command("commit", "-u", encode(author),
-                                      "-l", "%(logfile)s",
-                                      "-d", "%(time)d 0")
-        c = ExternalCommand(cwd=self.basedir, command=cmd)
-
-        rontf = ReopenableNamedTemporaryFile('hg', 'tailor')
-        log = open(rontf.name, "w")
-        log.write(encode('\n'.join(logmessage)) or "Empty changelog")
-        log.close()
-
-        c.execute(logfile=rontf.name, time=mktime(date.timetuple()))
-
-        if c.exit_status:
-            raise ChangesetApplicationFailure("%s returned status %d" %
-                                              (str(c), c.exit_status))
-
-    def _removePathnames(self, names):
-        """
-        Remove some filesystem object.
-        """
-
-        from os.path import join, isdir
-
-        # Currently hg does not handle directories at all, so filter
-        # them out.
-
-        notdirs = [n for n in names if not isdir(join(self.basedir, n))]
-        if notdirs:
-            cmd = self.repository.command("remove")
-            ExternalCommand(cwd=self.basedir, command=cmd).execute(notdirs)
-
-    def _renamePathname(self, oldname, newname):
-        """
-        Rename a filesystem object.
-        """
-
-        from os.path import join, isdir, normpath
-
-        cmd = self.repository.command("rename", "--after")
-        copy = ExternalCommand(cwd=self.basedir, command=cmd)
-        if isdir(join(self.basedir, newname)):
-            # Given lack of support for directories in current HG,
-            # loop over all files presented by "hg manifest" under the
-            # old directory and do a copy on them.
-            cmd = self.repository.command("manifest")
-            manifest = ExternalCommand(cwd=self.basedir, command=cmd)
-            output = manifest.execute(stdout=PIPE)[0]
-            for row in output:
-                sha, mode, oldpath = row[:-1].split(' ', 2)
-                oldpath = normpath(oldpath)
-                if oldpath.startswith(oldname):
-                    tail = oldpath[len(oldname)+1:]
-                    copy.execute(oldpath, join(newname, tail))
-                    if copy.exit_status:
-                        raise ChangesetReplayFailure("Could not rename %r "
-                                                     "into %r: maybe using a "
-                                                     "pre 0.7 mercurial?")
-        else:
-            copy.execute(oldname, newname)
-            if copy.exit_status:
-                raise ChangesetReplayFailure("Could not rename %r "
-                                             "into %r: maybe using a "
-                                             "pre 0.7 mercurial?")
-
-    def _prepareTargetRepository(self):
-        """
-        Execute ``hg init``.
-        """
-
-        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"))
-            init.execute()
-
-            if init.exit_status:
-                raise TargetInitializationFailure(
-                    "%s returned status %s" % (str(init), init.exit_status))
-
-    def _prepareWorkingDirectory(self, source_repo):
-        """
-        Create the .hgignore.
-        """
-
-        from os.path import join
-        from re import escape
-        from dualwd import IGNORED_METADIRS
-
-        # Create the .hgignore file, that contains a regexp per line
-        # with all known VCs metadirs to be skipped.
-        ignore = open(join(self.basedir, '.hgignore'), 'w')
-        ignore.write('\n'.join(['(^|/)%s($|/)' % escape(md)
-                                for md in IGNORED_METADIRS]))
-        ignore.write('\n')
-        if self.logfile.startswith(self.basedir):
-            ignore.write('^')
-            ignore.write(self.logfile[len(self.basedir)+1:])
-            ignore.write('$\n')
-        if self.state_file.filename.startswith(self.basedir):
-            sfrelname = self.state_file.filename[len(self.basedir)+1:]
-            ignore.write('^')
-            ignore.write(sfrelname)
-            ignore.write('$\n')
-            ignore.write('^')
-            ignore.write(sfrelname+'.old')
-            ignore.write('$\n')
-            ignore.write('^')
-            ignore.write(sfrelname+'.journal')
-            ignore.write('$\n')
-        ignore.close()
-
-    def _initializeWorkingDir(self):
-        """
-        Use ``hg addremove`` to import initial version of the tree.
-        """
-
-        ExternalCommand(cwd=self.basedir,
-                        command=self.repository.command("addremove")).execute()
rmfile ./vcpx/hg.py
move ./vcpx/hglib.py ./vcpx/hg.py
hunk ./README 373
-    hg-command = /usr/local/bin/hg
hunk ./README 531
-``cdv``, ``cvs``, ``darcs``, ``git``, ``hg``, ``hglib``, ``monotone``, 
-``svn``, ``svndump`` and ``tla``.
+``cdv``, ``cvs``, ``darcs``, ``git``, ``hg``, ``monotone``, ``svn``,
+``svndump`` and ``tla``.
hunk ./README 558
-  be used, as done in the example above for ``hg``.
+  be used.
hunk ./README 561
-  For pythonique backends such as *bzr* and *hglib* this indicates
+  For pythonique backends such as *bzr* and *hg* this indicates
hunk ./README 641
-
-..
-
-hglib
-%%%%%
hunk ./vcpx/hg.py 21
-class HglibWorkingDir(UpdatableSourceWorkingDir, 
SyncronizableTargetWorkingDir):
+class HgWorkingDir(UpdatableSourceWorkingDir, SyncronizableTargetWorkingDir):
hunk ./vcpx/repository.py 292
-        self.EXECUTABLE = project.config.get(self.name, 'hg-command', 'hg')
-        self.EXTRA_METADIRS = ['.hgtags']
-
-
-class HglibRepository(Repository):
-    METADIR = '.hg'
-
-    def _load(self, project):
-        Repository._load(self, project)
hunk ./vcpx/tests/tailor.py 135
-[cvs2hglib]
-root-directory = %(testdir)s/cvs2hglib
+[cvs2hg]
+root-directory = %(testdir)s/cvs2hg
hunk ./vcpx/tests/tailor.py 138
-target = hglib:cmsmini
+target = hg:cmsmini
hunk ./vcpx/tests/tailor.py 147
-[hglib:cmsmini]
+[hg:cmsmini]
hunk ./vcpx/tests/tailor.py 376
-        self.tailorize('cvs2hglib')
+        self.tailorize('cvs2hg')
}

Context:

[Update hglib backend to work with recent versions of Mercurial.
Travis Cross <[EMAIL PROTECTED]>**20060224200653
 Added required parameters to the calls to pull and clone.
] 
[Fix to hglib: don't try to .split() date as it is already a tuple.
Travis Cross <[EMAIL PROTECTED]>**20060224200525] 
[In hglib, check if a file is in the manifest before trying to rename it.
Travis Cross <[EMAIL PROTECTED]>**20060224200005] 
[Separate option name from its value
[EMAIL PROTECTED] 
[Remove spurious and dead code
[EMAIL PROTECTED]
 I'm not able to trace the origin of this code, reasonably that loop
 was in a support method and then moved inside __init__().
 Good catch, Evgeny!
] 
[Suggest #tailor IRC channel, not #darcs
[EMAIL PROTECTED] 
[Disallow encodings other than utf-8 for mercurial
Brendan Cully <[EMAIL PROTECTED]>**20060216201024] 
[hglib doesn't accept unicode strings for path names, so encode them
Brendan Cully <[EMAIL PROTECTED]>**20060216200909] 
[Don't force the LANG on svn commit
[EMAIL PROTECTED]
 Tailor used LANG=C to be able to catch the revision number generated
 by commit. It now assumes the revision number is the integer value
 printed out by svn in the last line of commit output.
] 
[Clever change to stop misreading the boolean expression as a keyword argument
[EMAIL PROTECTED] 
[Fix handling of tla archives with "untagged-source unrecognized" set
Cameron Patrick <[EMAIL PROTECTED]>**20060212173351
 If a tla archive has the "untagged-source unrecognized" option in its
 tagging-method file, tla will complain if there are any foreign files
 present (e.g. the _darcs directory containing darcs metadata).  The
 tla backend was supposed to fix this but the code there didn't work
 properly, as it was too fussy about tla exit codes and the output
 formats of `tla tree-lint`.
 This patch makes it work again (tested with tla 1.3.3).
] 
[More informative error messages
[EMAIL PROTECTED] 
[Fix to #30: handle CVS target, creating repository and working dir
[EMAIL PROTECTED] 
[Use "initialize+pull" instead of "get" when the directory already exist
[EMAIL PROTECTED] 
[Added a comment at top to clarify the strange markup
[EMAIL PROTECTED] 
[Fix typo
[EMAIL PROTECTED] 
[Convert the delay into a float
[EMAIL PROTECTED]
 This fixes #34.
] 
[Test also the default case for look-for-adds
[EMAIL PROTECTED] 
[Allow 'look-for-adds' for darcs repositories
[EMAIL PROTECTED]
 I'm little bit worried that this may hide real bugs, but here it is.
] 
[When collapsing two changesets into one, make sure the tags from the second go 
into the combined one.  Fixes ticket #26.
[EMAIL PROTECTED] 
[Do not stop on GetUpstreamChangesetsFailure
[EMAIL PROTECTED]
 When operating on several projects, do not stop on this kind of error,
 that most often is related to overloaded CVS servers, but keep going
 with the other projects.
] 
[There's no "string" builtin type, use "basestring" instead.
[EMAIL PROTECTED] 
[Annotate the characters that tailor washes out of Subversion XML logs
[EMAIL PROTECTED]
 when filter-badchars is set to True.
] 
[Fix cut-n-paste error
[EMAIL PROTECTED]
 This most probably caused some breakage in projects using distinct
 shared directories for source and target repositories.
] 
[M-x whitespace-cleanup
[EMAIL PROTECTED] 
[Do not add entries inside a moved/copied directory on bzr target
[EMAIL PROTECTED]
 The fix to #24 and indirectly #23 triggered (actually, the test did) a
 similar issue solved for Subversion with [840] and [841]. This patch
 applies a similar solution for BazaarNG, to prevent addition within a
 renamed/copied directory. Specifically, this may happen for example
 in a changeset coming from Svn that
 
 1. copies a directory
 2. replaces (a Subversion "R" event) an item in the target with
    something else
] 
[Reset the notion of external copies at each changeset
[EMAIL PROTECTED]
 Changesets [840] and [841] introduced a bug in the Subversion log
 parser, outlined by #24. This fix the case by resetting the list of
 copied paths at each changeset.
] 
[Avoid execution of too long command lines
[EMAIL PROTECTED]
 Now the mechanism that executes external commands respects a maximum
 size for the command line, eventually executing the external command
 multiple times operating on a slice of the original arguments at a
 time.
] 
[Do not use bzr's smart_add_tree as it ignores entries
[EMAIL PROTECTED]
 Also, do not add rename targets as they are already considered by bzr.
] 
[Parametrize the temporary directory used by tests
[EMAIL PROTECTED] 
[Simplify rst2html command line
[EMAIL PROTECTED]
 Recent docutils automatically embeds the right stylesheet.
] 
[Explicitly deprecate the current svndump backend
[EMAIL PROTECTED] 
[New option ignore-externals on svn source backend
[EMAIL PROTECTED]
 This **changes** the default behaviour of Tailor svn source backend: now
 it uses `--ignore-externals` to checkouts and updates. You can override
 the default putting "ignore-externals = False" in the svn repository
 section. 
] 
[TAG Version 0.9.20
[EMAIL PROTECTED] 
Patch bundle hash:
ef97cfc246d294a3933b0667fb41bb8eb3fe8d02
_______________________________________________
Tailor mailing list
[email protected]
http://lists.zooko.com/mailman/listinfo/tailor

Reply via email to