def PickHistoryName(args):
  """Returns the results history name to use to look up a history ID.

  The history ID corresponds to a history name. If the user provides their
  own history name, we use that to look up the history ID; If not, but the user
  provides an app-package name, we use the app-package name with ' (gcloud)'
  appended as the history name. Otherwise, we punt and let the Testing service
  determine the appropriate history ID to publish to.

  Args:
    args: an argparse namespace. All the arguments that were provided to the
      command invocation (i.e. group and command arguments combined).

  Returns:
    Either a string containing a history name derived from user-supplied data,
    or None if we lack the required information.
  """
  if args.results_history_name:
    return args.results_history_name
  if args.app_package:
    return args.app_package + ' (gcloud)'
  return None