コード例 #1
0
ファイル: gitc_init.py プロジェクト: FuangCao/git-repo
  def Execute(self, opt, args):
    if not opt.gitc_client:
      print('fatal: gitc client (-c) is required', file=sys.stderr)
      sys.exit(1)
    self.client_dir = os.path.join(gitc_utils.get_gitc_manifest_dir(),
                                   opt.gitc_client)
    if not os.path.exists(gitc_utils.get_gitc_manifest_dir()):
      os.makedirs(gitc_utils.get_gitc_manifest_dir())
    if not os.path.exists(self.client_dir):
      os.mkdir(self.client_dir)
    super(GitcInit, self).Execute(opt, args)

    manifest_file = self.manifest.manifestFile
    if opt.manifest_file:
      if not os.path.exists(opt.manifest_file):
        print('fatal: Specified manifest file %s does not exist.' %
              opt.manifest_file)
        sys.exit(1)
      manifest_file = opt.manifest_file

    manifest = GitcManifest(self.repodir, opt.gitc_client)
    manifest.Override(manifest_file)
    gitc_utils.generate_gitc_manifest(None, manifest)
    print('Please run `cd %s` to view your GITC client.' %
          os.path.join(gitc_utils.GITC_FS_ROOT_DIR, opt.gitc_client))
コード例 #2
0
    def Execute(self, opt, args):
        if not opt.gitc_client:
            print('fatal: gitc client (-c) is required', file=sys.stderr)
            sys.exit(1)
        self.client_dir = os.path.join(gitc_utils.get_gitc_manifest_dir(),
                                       opt.gitc_client)
        if not os.path.exists(gitc_utils.get_gitc_manifest_dir()):
            os.makedirs(gitc_utils.get_gitc_manifest_dir())
        if not os.path.exists(self.client_dir):
            os.mkdir(self.client_dir)
        super(GitcInit, self).Execute(opt, args)

        manifest_file = self.manifest.manifestFile
        if opt.manifest_file:
            if not os.path.exists(opt.manifest_file):
                print('fatal: Specified manifest file %s does not exist.' %
                      opt.manifest_file)
                sys.exit(1)
            manifest_file = opt.manifest_file

        manifest = GitcManifest(self.repodir, opt.gitc_client)
        manifest.Override(manifest_file)
        gitc_utils.generate_gitc_manifest(None, manifest)
        print('Please run `cd %s` to view your GITC client.' %
              os.path.join(gitc_utils.GITC_FS_ROOT_DIR, opt.gitc_client))
コード例 #3
0
    def Execute(self, opt, args):
        gitc_client = gitc_utils.parse_clientdir(os.getcwd())
        if not gitc_client or (opt.gitc_client
                               and gitc_client != opt.gitc_client):
            print(
                'fatal: Please update your repo command. See go/gitc for instructions.',
                file=sys.stderr)
            sys.exit(1)
        self.client_dir = os.path.join(gitc_utils.get_gitc_manifest_dir(),
                                       gitc_client)
        super().Execute(opt, args)

        manifest_file = self.manifest.manifestFile
        if opt.manifest_file:
            if not os.path.exists(opt.manifest_file):
                print('fatal: Specified manifest file %s does not exist.' %
                      opt.manifest_file)
                sys.exit(1)
            manifest_file = opt.manifest_file

        manifest = GitcManifest(self.repodir, gitc_client)
        manifest.Override(manifest_file)
        gitc_utils.generate_gitc_manifest(None, manifest)
        print('Please run `cd %s` to view your GITC client.' %
              os.path.join(wrapper.Wrapper().GITC_FS_ROOT_DIR, gitc_client))
コード例 #4
0
 def __init__(self, repodir, gitc_client_name):
     """Initialize the GitcManifest object."""
     super(GitcManifest, self).__init__(repodir)
     self.isGitcClient = True
     self.gitc_client_name = gitc_client_name
     self.gitc_client_dir = os.path.join(gitc_utils.get_gitc_manifest_dir(),
                                         gitc_client_name)
     self.manifestFile = os.path.join(self.gitc_client_dir, '.manifest')
コード例 #5
0
ファイル: manifest_xml.py プロジェクト: android/tools_repo
 def __init__(self, repodir, gitc_client_name):
   """Initialize the GitcManifest object."""
   super(GitcManifest, self).__init__(repodir)
   self.isGitcClient = True
   self.gitc_client_name = gitc_client_name
   self.gitc_client_dir = os.path.join(gitc_utils.get_gitc_manifest_dir(),
                                       gitc_client_name)
   self.manifestFile = os.path.join(self.gitc_client_dir, '.manifest')
コード例 #6
0
ファイル: help.py プロジェクト: allrsb/repo
 def gitc_supported(cmd):
   if not isinstance(cmd, GitcAvailableCommand) and not isinstance(cmd, GitcClientCommand):
     return True
   if self.manifest.isGitcClient:
     return True
   if isinstance(cmd, GitcClientCommand):
     return False
   if gitc_utils.get_gitc_manifest_dir():
     return True
   return False
コード例 #7
0
ファイル: help.py プロジェクト: 4455jkjh/git-repo
 def gitc_supported(cmd):
   if not isinstance(cmd, GitcAvailableCommand) and not isinstance(cmd, GitcClientCommand):
     return True
   if self.manifest.isGitcClient:
     return True
   if isinstance(cmd, GitcClientCommand):
     return False
   if gitc_utils.get_gitc_manifest_dir():
     return True
   return False
コード例 #8
0
ファイル: gitc_init.py プロジェクト: TheQtCompany/git-repo
    def Execute(self, opt, args):
        if not opt.gitc_client:
            print("fatal: gitc client (-c) is required", file=sys.stderr)
            sys.exit(1)
        self.client_dir = os.path.join(gitc_utils.get_gitc_manifest_dir(), opt.gitc_client)
        if not os.path.exists(gitc_utils.get_gitc_manifest_dir()):
            os.makedirs(gitc_utils.get_gitc_manifest_dir())
        if not os.path.exists(self.client_dir):
            os.mkdir(self.client_dir)
        super(GitcInit, self).Execute(opt, args)

        for name, remote in self.manifest.remotes.iteritems():
            remote.fetchUrl = remote.resolvedFetchUrl

        if opt.manifest_file:
            if not os.path.exists(opt.manifest_file):
                print("fatal: Specified manifest file %s does not exist." % opt.manifest_file)
                sys.exit(1)
            self.manifest.Override(opt.manifest_file)
        gitc_utils.generate_gitc_manifest(self.client_dir, self.manifest)
        print(
            "Please run `cd %s` to view your GITC client." % os.path.join(gitc_utils.GITC_FS_ROOT_DIR, opt.gitc_client)
        )
コード例 #9
0
ファイル: gitc_init.py プロジェクト: 4455jkjh/git-repo
  def Execute(self, opt, args):
    gitc_client = gitc_utils.parse_clientdir(os.getcwd())
    if not gitc_client or (opt.gitc_client and gitc_client != opt.gitc_client):
      print('fatal: Please update your repo command. See go/gitc for instructions.', file=sys.stderr)
      sys.exit(1)
    self.client_dir = os.path.join(gitc_utils.get_gitc_manifest_dir(),
                                   gitc_client)
    super(GitcInit, self).Execute(opt, args)

    manifest_file = self.manifest.manifestFile
    if opt.manifest_file:
      if not os.path.exists(opt.manifest_file):
        print('fatal: Specified manifest file %s does not exist.' %
              opt.manifest_file)
        sys.exit(1)
      manifest_file = opt.manifest_file

    manifest = GitcManifest(self.repodir, gitc_client)
    manifest.Override(manifest_file)
    gitc_utils.generate_gitc_manifest(None, manifest)
    print('Please run `cd %s` to view your GITC client.' %
          os.path.join(wrapper.Wrapper().GITC_FS_ROOT_DIR, gitc_client))
コード例 #10
0
ファイル: main.py プロジェクト: 4455jkjh/git-repo
  def _Run(self, argv):
    result = 0
    name = None
    glob = []

    for i in range(len(argv)):
      if not argv[i].startswith('-'):
        name = argv[i]
        if i > 0:
          glob = argv[:i]
        argv = argv[i + 1:]
        break
    if not name:
      glob = argv
      name = 'help'
      argv = []
    gopts, _gargs = global_options.parse_args(glob)

    if gopts.trace:
      SetTrace()
    if gopts.show_version:
      if name == 'help':
        name = 'version'
      else:
        print('fatal: invalid usage of --version', file=sys.stderr)
        return 1

    SetDefaultColoring(gopts.color)

    try:
      cmd = self.commands[name]
    except KeyError:
      print("repo: '%s' is not a repo command.  See 'repo help'." % name,
            file=sys.stderr)
      return 1

    cmd.repodir = self.repodir
    cmd.manifest = XmlManifest(cmd.repodir)
    cmd.gitc_manifest = None
    gitc_client_name = gitc_utils.parse_clientdir(os.getcwd())
    if gitc_client_name:
      cmd.gitc_manifest = GitcManifest(cmd.repodir, gitc_client_name)
      cmd.manifest.isGitcClient = True

    Editor.globalConfig = cmd.manifest.globalConfig

    if not isinstance(cmd, MirrorSafeCommand) and cmd.manifest.IsMirror:
      print("fatal: '%s' requires a working directory" % name,
            file=sys.stderr)
      return 1

    if isinstance(cmd, GitcAvailableCommand) and not gitc_utils.get_gitc_manifest_dir():
      print("fatal: '%s' requires GITC to be available" % name,
            file=sys.stderr)
      return 1

    if isinstance(cmd, GitcClientCommand) and not gitc_client_name:
      print("fatal: '%s' requires a GITC client" % name,
            file=sys.stderr)
      return 1

    try:
      copts, cargs = cmd.OptionParser.parse_args(argv)
      copts = cmd.ReadEnvironmentOptions(copts)
    except NoManifestException as e:
      print('error: in `%s`: %s' % (' '.join([name] + argv), str(e)),
        file=sys.stderr)
      print('error: manifest missing or unreadable -- please run init',
            file=sys.stderr)
      return 1

    if not gopts.no_pager and not isinstance(cmd, InteractiveCommand):
      config = cmd.manifest.globalConfig
      if gopts.pager:
        use_pager = True
      else:
        use_pager = config.GetBoolean('pager.%s' % name)
        if use_pager is None:
          use_pager = cmd.WantPager(copts)
      if use_pager:
        RunPager(config)

    start = time.time()
    try:
      result = cmd.Execute(copts, cargs)
    except (DownloadError, ManifestInvalidRevisionError,
        NoManifestException) as e:
      print('error: in `%s`: %s' % (' '.join([name] + argv), str(e)),
        file=sys.stderr)
      if isinstance(e, NoManifestException):
        print('error: manifest missing or unreadable -- please run init',
              file=sys.stderr)
      result = 1
    except NoSuchProjectError as e:
      if e.name:
        print('error: project %s not found' % e.name, file=sys.stderr)
      else:
        print('error: no project in current directory', file=sys.stderr)
      result = 1
    except InvalidProjectGroupsError as e:
      if e.name:
        print('error: project group must be enabled for project %s' % e.name, file=sys.stderr)
      else:
        print('error: project group must be enabled for the project in the current directory', file=sys.stderr)
      result = 1
    finally:
      elapsed = time.time() - start
      hours, remainder = divmod(elapsed, 3600)
      minutes, seconds = divmod(remainder, 60)
      if gopts.time:
        if hours == 0:
          print('real\t%dm%.3fs' % (minutes, seconds), file=sys.stderr)
        else:
          print('real\t%dh%dm%.3fs' % (hours, minutes, seconds),
                file=sys.stderr)

    return result
コード例 #11
0
  def _Run(self, argv):
    result = 0
    name = None
    glob = []

    for i in range(len(argv)):
      if not argv[i].startswith('-'):
        name = argv[i]
        if i > 0:
          glob = argv[:i]
        argv = argv[i + 1:]
        break
    if not name:
      glob = argv
      name = 'help'
      argv = []
    gopts, _gargs = global_options.parse_args(glob)

    if gopts.trace:
      SetTrace()
    if gopts.show_version:
      if name == 'help':
        name = 'version'
      else:
        print('fatal: invalid usage of --version', file=sys.stderr)
        return 1

    SetDefaultColoring(gopts.color)

    try:
      cmd = self.commands[name]
    except KeyError:
      print("repo: '%s' is not a repo command.  See 'repo help'." % name,
            file=sys.stderr)
      return 1

    cmd.repodir = self.repodir
    cmd.manifest = XmlManifest(cmd.repodir)
    cmd.gitc_manifest = None
    gitc_client_name = gitc_utils.parse_clientdir(os.getcwd())
    if gitc_client_name:
      cmd.gitc_manifest = GitcManifest(cmd.repodir, gitc_client_name)
      cmd.manifest.isGitcClient = True

    Editor.globalConfig = cmd.manifest.globalConfig

    if not isinstance(cmd, MirrorSafeCommand) and cmd.manifest.IsMirror:
      print("fatal: '%s' requires a working directory" % name,
            file=sys.stderr)
      return 1

    if isinstance(cmd, GitcAvailableCommand) and not gitc_utils.get_gitc_manifest_dir():
      print("fatal: '%s' requires GITC to be available" % name,
            file=sys.stderr)
      return 1

    if isinstance(cmd, GitcClientCommand) and not gitc_client_name:
      print("fatal: '%s' requires a GITC client" % name,
            file=sys.stderr)
      return 1

    try:
      copts, cargs = cmd.OptionParser.parse_args(argv)
      copts = cmd.ReadEnvironmentOptions(copts)
    except NoManifestException as e:
      print('error: in `%s`: %s' % (' '.join([name] + argv), str(e)),
        file=sys.stderr)
      print('error: manifest missing or unreadable -- please run init',
            file=sys.stderr)
      return 1

    if not gopts.no_pager and not isinstance(cmd, InteractiveCommand):
      config = cmd.manifest.globalConfig
      if gopts.pager:
        use_pager = True
      else:
        use_pager = config.GetBoolean('pager.%s' % name)
        if use_pager is None:
          use_pager = cmd.WantPager(copts)
      if use_pager:
        RunPager(config)

    start = time.time()
    try:
      result = cmd.Execute(copts, cargs)
    except (DownloadError, ManifestInvalidRevisionError,
        NoManifestException) as e:
      print('error: in `%s`: %s' % (' '.join([name] + argv), str(e)),
        file=sys.stderr)
      if isinstance(e, NoManifestException):
        print('error: manifest missing or unreadable -- please run init',
              file=sys.stderr)
      result = 1
    except NoSuchProjectError as e:
      if e.name:
        print('error: project %s not found' % e.name, file=sys.stderr)
      else:
        print('error: no project in current directory', file=sys.stderr)
      result = 1
    except InvalidProjectGroupsError as e:
      if e.name:
        print('error: project group must be enabled for project %s' % e.name, file=sys.stderr)
      else:
        print('error: project group must be enabled for the project in the current directory', file=sys.stderr)
      result = 1
    finally:
      elapsed = time.time() - start
      hours, remainder = divmod(elapsed, 3600)
      minutes, seconds = divmod(remainder, 60)
      if gopts.time:
        if hours == 0:
          print('real\t%dm%.3fs' % (minutes, seconds), file=sys.stderr)
        else:
          print('real\t%dh%dm%.3fs' % (hours, minutes, seconds),
                file=sys.stderr)

    return result
コード例 #12
0
ファイル: main.py プロジェクト: t971/git-repo
    def _Run(self, name, gopts, argv):
        """Execute the requested subcommand."""
        result = 0

        if gopts.trace:
            SetTrace()
        if gopts.show_version:
            if name == 'help':
                name = 'version'
            else:
                print('fatal: invalid usage of --version', file=sys.stderr)
                return 1

        SetDefaultColoring(gopts.color)

        try:
            cmd = self.commands[name]
        except KeyError:
            print("repo: '%s' is not a repo command.  See 'repo help'." % name,
                  file=sys.stderr)
            return 1

        cmd.repodir = self.repodir
        cmd.manifest = XmlManifest(cmd.repodir)
        cmd.gitc_manifest = None
        gitc_client_name = gitc_utils.parse_clientdir(os.getcwd())
        if gitc_client_name:
            cmd.gitc_manifest = GitcManifest(cmd.repodir, gitc_client_name)
            cmd.manifest.isGitcClient = True

        Editor.globalConfig = cmd.manifest.globalConfig

        if not isinstance(cmd, MirrorSafeCommand) and cmd.manifest.IsMirror:
            print("fatal: '%s' requires a working directory" % name,
                  file=sys.stderr)
            return 1

        if isinstance(cmd, GitcAvailableCommand
                      ) and not gitc_utils.get_gitc_manifest_dir():
            print("fatal: '%s' requires GITC to be available" % name,
                  file=sys.stderr)
            return 1

        if isinstance(cmd, GitcClientCommand) and not gitc_client_name:
            print("fatal: '%s' requires a GITC client" % name, file=sys.stderr)
            return 1

        try:
            copts, cargs = cmd.OptionParser.parse_args(argv)
            copts = cmd.ReadEnvironmentOptions(copts)
        except NoManifestException as e:
            print('error: in `%s`: %s' % (' '.join([name] + argv), str(e)),
                  file=sys.stderr)
            print('error: manifest missing or unreadable -- please run init',
                  file=sys.stderr)
            return 1

        if gopts.pager is not False and not isinstance(cmd,
                                                       InteractiveCommand):
            config = cmd.manifest.globalConfig
            if gopts.pager:
                use_pager = True
            else:
                use_pager = config.GetBoolean('pager.%s' % name)
                if use_pager is None:
                    use_pager = cmd.WantPager(copts)
            if use_pager:
                RunPager(config)

        start = time.time()
        cmd_event = cmd.event_log.Add(name, event_log.TASK_COMMAND, start)
        cmd.event_log.SetParent(cmd_event)
        try:
            cmd.ValidateOptions(copts, cargs)
            result = cmd.Execute(copts, cargs)
        except (DownloadError, ManifestInvalidRevisionError,
                NoManifestException) as e:
            print('error: in `%s`: %s' % (' '.join([name] + argv), str(e)),
                  file=sys.stderr)
            if isinstance(e, NoManifestException):
                print(
                    'error: manifest missing or unreadable -- please run init',
                    file=sys.stderr)
            result = 1
        except NoSuchProjectError as e:
            if e.name:
                print('error: project %s not found' % e.name, file=sys.stderr)
            else:
                print('error: no project in current directory',
                      file=sys.stderr)
            result = 1
        except InvalidProjectGroupsError as e:
            if e.name:
                print('error: project group must be enabled for project %s' %
                      e.name,
                      file=sys.stderr)
            else:
                print(
                    'error: project group must be enabled for the project in the current directory',
                    file=sys.stderr)
            result = 1
        except SystemExit as e:
            if e.code:
                result = e.code
            raise
        finally:
            finish = time.time()
            elapsed = finish - start
            hours, remainder = divmod(elapsed, 3600)
            minutes, seconds = divmod(remainder, 60)
            if gopts.time:
                if hours == 0:
                    print('real\t%dm%.3fs' % (minutes, seconds),
                          file=sys.stderr)
                else:
                    print('real\t%dh%dm%.3fs' % (hours, minutes, seconds),
                          file=sys.stderr)

            cmd.event_log.FinishEvent(cmd_event, finish, result is None
                                      or result == 0)
            if gopts.event_log:
                cmd.event_log.Write(
                    os.path.abspath(os.path.expanduser(gopts.event_log)))

        return result
コード例 #13
0
ファイル: help.py プロジェクト: hf7612/repo_analyse
 def gitc_supported(cmd):
     if not isinstance(cmd, RequiresGitcCommand):
         return True
     if gitc_utils.get_gitc_manifest_dir():
         return True
     return False
コード例 #14
0
 if gopts.trace: SetTrace()
 if gopts.show_version:
   if name == 'help': name = 'version'
   else: print('fatal: invalid usage of --version', file=sys.stderr) return 1
 SetDefaultColoring(gopts.color)
 try: cmd = self.commands[name] except KeyError: print("re po: '%s' is not a re po command.  See 're po help'." % name, file=sys.stderr) return 1
 cmd.repodir = self.repodir
 cmd.manifest = XmlManifest(cmd.repodir)
 cmd.gitc_manifest = None
 gitc_client_name = gitc_utils.parse_clientdir(os.getcwd())
 if gitc_client_name: cmd.gitc_manifest = GitcManifest(cmd.repodir, gitc_client_name)
   cmd.manifest.isGitcClient = True
 Editor.globalConfig = cmd.manifest.globalConfig
 if not isinstance(cmd, MirrorSafeCommand) and cmd.manifest.IsMirror: print("fatal: '%s' requires a working directory" % name, file=sys.stderr)
   return 1
 if isinstance(cmd, RequiresGitcCommand) and not gitc_utils.get_gitc_manifest_dir(): print("fatal: '%s' requires GITC to be available" % name, file=sys.stderr)
   return 1
 try:
   copts, cargs = cmd.OptionParser.parse_args(argv)
   copts = cmd.ReadEnvironmentOptions(copts) except NoManifestException as e: print('error: in `%s`: %s' % (' '.join([name] + argv), str(e)), file=sys.stderr) print('error: manifest missing or unreadable -- please run init', file=sys.stderr) return 1
 if not gopts.no_pager and not isinstance(cmd, InteractiveCommand):
   config = cmd.manifest.globalConfig
   if gopts.pager:
     use_pager = True
   else:
     use_pager = config.GetBoolean('pager.%s' % name)
     if use_pager is None:
       use_pager = cmd.WantPager(copts)
   if use_pager:
     RunPager(config)
 start = time.time()
コード例 #15
0
ファイル: main.py プロジェクト: MoKee/git-repo
    def _Run(self, name, gopts, argv):
        """Execute the requested subcommand."""
        result = 0

        if gopts.trace:
            SetTrace()

        # Handle options that terminate quickly first.
        if gopts.help or gopts.help_all:
            self._PrintHelp(short=False, all_commands=gopts.help_all)
            return 0
        elif gopts.show_version:
            # Always allow global --version regardless of subcommand validity.
            name = 'version'
        elif gopts.show_toplevel:
            print(os.path.dirname(self.repodir))
            return 0
        elif not name:
            # No subcommand specified, so show the help/subcommand.
            self._PrintHelp(short=True)
            return 1

        SetDefaultColoring(gopts.color)

        git_trace2_event_log = EventLog()
        repo_client = RepoClient(self.repodir)
        gitc_manifest = None
        gitc_client_name = gitc_utils.parse_clientdir(os.getcwd())
        if gitc_client_name:
            gitc_manifest = GitcClient(self.repodir, gitc_client_name)
            repo_client.isGitcClient = True

        try:
            cmd = self.commands[name](repodir=self.repodir,
                                      client=repo_client,
                                      manifest=repo_client.manifest,
                                      gitc_manifest=gitc_manifest,
                                      git_event_log=git_trace2_event_log)
        except KeyError:
            print("repo: '%s' is not a repo command.  See 'repo help'." % name,
                  file=sys.stderr)
            return 1

        Editor.globalConfig = cmd.client.globalConfig

        if not isinstance(cmd, MirrorSafeCommand) and cmd.manifest.IsMirror:
            print("fatal: '%s' requires a working directory" % name,
                  file=sys.stderr)
            return 1

        if isinstance(cmd, GitcAvailableCommand
                      ) and not gitc_utils.get_gitc_manifest_dir():
            print("fatal: '%s' requires GITC to be available" % name,
                  file=sys.stderr)
            return 1

        if isinstance(cmd, GitcClientCommand) and not gitc_client_name:
            print("fatal: '%s' requires a GITC client" % name, file=sys.stderr)
            return 1

        try:
            copts, cargs = cmd.OptionParser.parse_args(argv)
            copts = cmd.ReadEnvironmentOptions(copts)
        except NoManifestException as e:
            print('error: in `%s`: %s' % (' '.join([name] + argv), str(e)),
                  file=sys.stderr)
            print('error: manifest missing or unreadable -- please run init',
                  file=sys.stderr)
            return 1

        if gopts.pager is not False and not isinstance(cmd,
                                                       InteractiveCommand):
            config = cmd.client.globalConfig
            if gopts.pager:
                use_pager = True
            else:
                use_pager = config.GetBoolean('pager.%s' % name)
                if use_pager is None:
                    use_pager = cmd.WantPager(copts)
            if use_pager:
                RunPager(config)

        start = time.time()
        cmd_event = cmd.event_log.Add(name, event_log.TASK_COMMAND, start)
        cmd.event_log.SetParent(cmd_event)
        git_trace2_event_log.StartEvent()
        git_trace2_event_log.CommandEvent(name='repo', subcommands=[name])

        try:
            cmd.CommonValidateOptions(copts, cargs)
            cmd.ValidateOptions(copts, cargs)
            result = cmd.Execute(copts, cargs)
        except (DownloadError, ManifestInvalidRevisionError,
                NoManifestException) as e:
            print('error: in `%s`: %s' % (' '.join([name] + argv), str(e)),
                  file=sys.stderr)
            if isinstance(e, NoManifestException):
                print(
                    'error: manifest missing or unreadable -- please run init',
                    file=sys.stderr)
            result = 1
        except NoSuchProjectError as e:
            if e.name:
                print('error: project %s not found' % e.name, file=sys.stderr)
            else:
                print('error: no project in current directory',
                      file=sys.stderr)
            result = 1
        except InvalidProjectGroupsError as e:
            if e.name:
                print('error: project group must be enabled for project %s' %
                      e.name,
                      file=sys.stderr)
            else:
                print(
                    'error: project group must be enabled for the project in the current directory',
                    file=sys.stderr)
            result = 1
        except SystemExit as e:
            if e.code:
                result = e.code
            raise
        finally:
            finish = time.time()
            elapsed = finish - start
            hours, remainder = divmod(elapsed, 3600)
            minutes, seconds = divmod(remainder, 60)
            if gopts.time:
                if hours == 0:
                    print('real\t%dm%.3fs' % (minutes, seconds),
                          file=sys.stderr)
                else:
                    print('real\t%dh%dm%.3fs' % (hours, minutes, seconds),
                          file=sys.stderr)

            cmd.event_log.FinishEvent(cmd_event, finish, result is None
                                      or result == 0)
            git_trace2_event_log.DefParamRepoEvents(
                cmd.manifest.manifestProject.config.DumpConfigDict())
            git_trace2_event_log.ExitEvent(result)

            if gopts.event_log:
                cmd.event_log.Write(
                    os.path.abspath(os.path.expanduser(gopts.event_log)))

            git_trace2_event_log.Write(gopts.git_trace2_event_log)
        return result