Example #1
0
 def handle_repo(self, repo, *args, **options):
     opts = copy.copy(options)
     if len(args) == 1:
         opts.update(parse_changesets(args[0]))
     elif len(args) > 1:
         raise CommandError("Wrong changeset ID(s) given")
     if options.get('limit') and not options['limit'].isdigit():
         raise CommandError("Limit must be a number")
     changesets = self.get_changesets(repo, **opts)
     self.iter_changesets(repo, changesets, **options)
Example #2
0
 def handle_repo(self, repo, *args, **options):
     if len(args) < self.min_args:
         raise CommandError("At least %s arguments required" %
                            self.min_args)
     changeset = self.get_changeset(**options)
     for arg in args:
         self.handle_arg(changeset, arg, **options)
Example #3
0
    def get_command_class(self, cmd):
        """
        Returns command class from the registry for a given ``cmd``.

        :param cmd: command to run (key at the registry)
        """
        try:
            cmdpath = self.registry[cmd]
        except KeyError:
            raise CommandError("No such command %r" % cmd)
        if isinstance(cmdpath, basestring):
            Command = import_class(cmdpath)
        else:
            Command = cmdpath
        return Command
Example #4
0
    def __init__(self, stdout=None, stderr=None, repo=None):
        """
        Accepts extra argument:

        :param repo: repository instance. If not given, repository would be
          calculated based on current directory.
        """
        if repo is None:
            curdir = abspath(os.curdir)
            try:
                scm, path = get_scm(curdir, search_up=True)
                self.repo = vcs.get_repo(path, scm)
            except VCSError:
                raise CommandError('Repository not found')
        else:
            self.repo = repo
        super(RepositoryCommand, self).__init__(stdout, stderr)