superproject: prepend messages with - "repo superproject"

Changed _LogError method to _LogWarning.

Replaced 'repo error:' with "repo superproject warning:"(except IOError
message, which is still an "repo superproject error:" message)

Tested:
$ ./run_tests

Tested the errors and warnings by forcing the error/warning.
$ repo_dev sync -j 20 --use-superproject platform/packages/apps/Music
  ...
  repo superproject warning: please file a bug using go/repo-bug to report missing commit_ids for: []
  ...
  repo superproject error: cannot write manifest to : /sdc/android/src/aosp/.repo/exp-superproject/superproject_override.xml
  ...

Bug: [google internal] b/193711236

Change-Id: Ia0b6c830e04cf18dfc1a2ce325181a5b1160e054
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/314642
Tested-by: Raman Tenneti <rtenneti@google.com>
Reviewed-by: Raman Tenneti <rtenneti@google.com>
Reviewed-by: Ian Kasprzak <iankaz@google.com>
Reviewed-by: Xin Li <delphij@google.com>
diff --git a/git_superproject.py b/git_superproject.py
index 8769355..c677924 100644
--- a/git_superproject.py
+++ b/git_superproject.py
@@ -122,11 +122,19 @@
       branch = branch[len(R_HEADS):]
     return branch
 
-  def _LogError(self, message):
+  def _LogMessage(self, message):
     """Logs message to stderr and _git_event_log."""
     print(message, file=sys.stderr)
     self._git_event_log.ErrorEvent(message, '')
 
+  def _LogError(self, message):
+    """Logs error message to stderr and _git_event_log."""
+    self._LogMessage(f'repo superproject error: {message}')
+
+  def _LogWarning(self, message):
+    """Logs warning message to stderr and _git_event_log."""
+    self._LogMessage(f'repo superproject warning: {message}')
+
   def _Init(self):
     """Sets up a local Git repository to get a copy of a superproject.
 
@@ -146,8 +154,8 @@
                    capture_stderr=True)
     retval = p.Wait()
     if retval:
-      self._LogError(f'repo: error: git init call failed, command: git {cmd}, '
-                     f'return code: {retval}, stderr: {p.stderr}')
+      self._LogWarning(f'git init call failed, command: git {cmd}, '
+                       f'return code: {retval}, stderr: {p.stderr}')
       return False
     return True
 
@@ -161,7 +169,7 @@
       True if fetch is successful, or False.
     """
     if not os.path.exists(self._work_git):
-      self._LogError(f'git fetch missing directory: {self._work_git}')
+      self._LogWarning(f'git fetch missing directory: {self._work_git}')
       return False
     if not git_require((2, 28, 0)):
       print('superproject requires a git version 2.28 or later', file=sys.stderr)
@@ -176,8 +184,8 @@
                    capture_stderr=True)
     retval = p.Wait()
     if retval:
-      self._LogError(f'repo: error: git fetch call failed, command: git {cmd}, '
-                     f'return code: {retval}, stderr: {p.stderr}')
+      self._LogWarning(f'git fetch call failed, command: git {cmd}, '
+                       f'return code: {retval}, stderr: {p.stderr}')
       return False
     return True
 
@@ -190,7 +198,7 @@
       data: data returned from 'git ls-tree ...' instead of None.
     """
     if not os.path.exists(self._work_git):
-      self._LogError(f'git ls-tree missing directory: {self._work_git}')
+      self._LogWarning(f'git ls-tree missing directory: {self._work_git}')
       return None
     data = None
     branch = 'HEAD' if not self._branch else self._branch
@@ -205,8 +213,8 @@
     if retval == 0:
       data = p.stdout
     else:
-      self._LogError(f'repo: error: git ls-tree call failed, command: git {cmd}, '
-                     f'return code: {retval}, stderr: {p.stderr}')
+      self._LogWarning(f'git ls-tree call failed, command: git {cmd}, '
+                       f'return code: {retval}, stderr: {p.stderr}')
     return data
 
   def Sync(self):
@@ -219,15 +227,15 @@
           'address described in `repo version`', file=sys.stderr)
 
     if not self._manifest.superproject:
-      self._LogError(f'repo error: superproject tag is not defined in manifest: '
-                     f'{self._manifest.manifestFile}')
+      self._LogWarning(f'superproject tag is not defined in manifest: '
+                       f'{self._manifest.manifestFile}')
       return SyncResult(False, False)
 
     should_exit = True
     url = self._manifest.superproject['remote'].url
     if not url:
-      self._LogError(f'repo error: superproject URL is not defined in manifest: '
-                     f'{self._manifest.manifestFile}')
+      self._LogWarning(f'superproject URL is not defined in manifest: '
+                       f'{self._manifest.manifestFile}')
       return SyncResult(False, should_exit)
 
     if not self._Init():
@@ -277,7 +285,7 @@
       manifest_path: Path name of the file into which manifest is written instead of None.
     """
     if not os.path.exists(self._superproject_path):
-      self._LogError(f'error: missing superproject directory: {self._superproject_path}')
+      self._LogWarning(f'missing superproject directory: {self._superproject_path}')
       return None
     manifest_str = self._manifest.ToXml(groups=self._manifest.GetGroupsStr()).toxml()
     manifest_path = self._manifest_path
@@ -285,7 +293,7 @@
       with open(manifest_path, 'w', encoding='utf-8') as fp:
         fp.write(manifest_str)
     except IOError as e:
-      self._LogError(f'error: cannot write manifest to : {manifest_path} {e}')
+      self._LogError(f'cannot write manifest to : {manifest_path} {e}')
       return None
     return manifest_path
 
@@ -336,8 +344,8 @@
     # If superproject doesn't have a commit id for a project, then report an
     # error event and continue as if do not use superproject is specified.
     if projects_missing_commit_ids:
-      self._LogError(f'error: please file a bug using {self._manifest.contactinfo.bugurl} '
-                     f'to report missing commit_ids for: {projects_missing_commit_ids}')
+      self._LogWarning(f'please file a bug using {self._manifest.contactinfo.bugurl} '
+                       f'to report missing commit_ids for: {projects_missing_commit_ids}')
       return UpdateProjectsResult(None, False)
 
     for project in projects:
diff --git a/tests/fixtures/test.gitconfig b/tests/fixtures/test.gitconfig
index d71f8e7..d69e162 100644
--- a/tests/fixtures/test.gitconfig
+++ b/tests/fixtures/test.gitconfig
@@ -12,10 +12,10 @@
 	intm = 10m
 	intg = 10g
 [repo "syncstate.main"]
-	synctime = 2021-07-29T22:07:43.463365Z
+	synctime = 2021-08-11T17:54:14.530286Z
 	version = 1
 [repo "syncstate.sys"]
-	argv = ['/usr/bin/pytest-3']
+	argv = ['/usr/bin/pytest-3', '-v']
 [repo "syncstate.superproject"]
 	test = false
 [repo "syncstate.options"]