[tryjobs] Fix result comparison for tryjobs against release branches

Previously, the branch was ignored and tryjobs always compared against
master.

Change-Id: Ifde8dcc4fb4f93fb00fb19e26676f31a790bc64a
Reviewed-on: https://dart-review.googlesource.com/c/recipes/+/139760
Reviewed-by: William Hesse <whesse@google.com>
diff --git a/README.recipes.md b/README.recipes.md
index 8cff48c..31da468 100644
--- a/README.recipes.md
+++ b/README.recipes.md
@@ -32,7 +32,7 @@
 &mdash; **def [schedule](/recipe_modules/bisect_build/api.py#19)(self, repo_url, reason):**
 ### *recipe_modules* / [dart](/recipe_modules/dart)
 
-[DEPS](/recipe_modules/dart/__init__.py#5): [build/goma][build/recipe_modules/goma], [build/swarming\_client][build/recipe_modules/swarming_client], [depot\_tools/bot\_update][depot_tools/recipe_modules/bot_update], [depot\_tools/depot\_tools][depot_tools/recipe_modules/depot_tools], [depot\_tools/gclient][depot_tools/recipe_modules/gclient], [depot\_tools/gerrit][depot_tools/recipe_modules/gerrit], [depot\_tools/git][depot_tools/recipe_modules/git], [depot\_tools/gsutil][depot_tools/recipe_modules/gsutil], [depot\_tools/tryserver][depot_tools/recipe_modules/tryserver], [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/cipd][recipe_engine/recipe_modules/cipd], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/file][recipe_engine/recipe_modules/file], [recipe\_engine/json][recipe_engine/recipe_modules/json], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/python][recipe_engine/recipe_modules/python], [recipe\_engine/raw\_io][recipe_engine/recipe_modules/raw_io], [recipe\_engine/runtime][recipe_engine/recipe_modules/runtime], [recipe\_engine/service\_account][recipe_engine/recipe_modules/service_account], [recipe\_engine/step][recipe_engine/recipe_modules/step], [recipe\_engine/swarming][recipe_engine/recipe_modules/swarming]
+[DEPS](/recipe_modules/dart/__init__.py#5): [build/goma][build/recipe_modules/goma], [build/swarming\_client][build/recipe_modules/swarming_client], [depot\_tools/bot\_update][depot_tools/recipe_modules/bot_update], [depot\_tools/depot\_tools][depot_tools/recipe_modules/depot_tools], [depot\_tools/gclient][depot_tools/recipe_modules/gclient], [depot\_tools/git][depot_tools/recipe_modules/git], [depot\_tools/gsutil][depot_tools/recipe_modules/gsutil], [depot\_tools/tryserver][depot_tools/recipe_modules/tryserver], [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/cipd][recipe_engine/recipe_modules/cipd], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/file][recipe_engine/recipe_modules/file], [recipe\_engine/json][recipe_engine/recipe_modules/json], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/python][recipe_engine/recipe_modules/python], [recipe\_engine/raw\_io][recipe_engine/recipe_modules/raw_io], [recipe\_engine/runtime][recipe_engine/recipe_modules/runtime], [recipe\_engine/service\_account][recipe_engine/recipe_modules/service_account], [recipe\_engine/step][recipe_engine/recipe_modules/step], [recipe\_engine/swarming][recipe_engine/recipe_modules/swarming]
 
 #### **class [DartApi](/recipe_modules/dart/api.py#40)([RecipeApi][recipe_engine/wkt/RecipeApi]):**
 
@@ -60,11 +60,11 @@
 
 Returns the path to the checked-in SDK dart executable.
 
-&mdash; **def [delete\_debug\_log](/recipe_modules/dart/api.py#562)(self):**
+&mdash; **def [delete\_debug\_log](/recipe_modules/dart/api.py#565)(self):**
 
 Deletes the debug log file
 
-&mdash; **def [download\_browser](/recipe_modules/dart/api.py#833)(self, runtime, version):**
+&mdash; **def [download\_browser](/recipe_modules/dart/api.py#836)(self, runtime, version):**
 
 &mdash; **def [download\_parent\_isolate](/recipe_modules/dart/api.py#155)(self):**
 
@@ -76,7 +76,7 @@
 
 Kills leftover tasks from previous runs or steps.
 
-&mdash; **def [read\_debug\_log](/recipe_modules/dart/api.py#550)(self):**
+&mdash; **def [read\_debug\_log](/recipe_modules/dart/api.py#553)(self):**
 
 Reads the debug log file
 
@@ -85,7 +85,7 @@
 Runs test.py in the given isolate, sharded over several swarming tasks.
 Returns the created tasks, which can be collected with collect_all().
 
-&mdash; **def [test](/recipe_modules/dart/api.py#568)(self, test_data):**
+&mdash; **def [test](/recipe_modules/dart/api.py#571)(self, test_data):**
 
 Reads the test-matrix.json file in checkout and runs each step listed
 in the file.
@@ -123,7 +123,7 @@
 
 &mdash; **def [Build](/recipes/dart/flutter_engine.py#52)(api, checkout_dir, config, \*targets):**
 
-&mdash; **def [BuildAndTest](/recipes/dart/flutter_engine.py#339)(api, start_dir, checkout_dir, flutter_rev):**
+&mdash; **def [BuildAndTest](/recipes/dart/flutter_engine.py#338)(api, start_dir, checkout_dir, flutter_rev):**
 
 &mdash; **def [BuildLinux](/recipes/dart/flutter_engine.py#104)(api, checkout_dir):**
 
@@ -177,9 +177,9 @@
 &mdash; **def [RunSteps](/recipes/dart/package_co19.py#18)(api):**
 ### *recipes* / [dart:examples/example](/recipe_modules/dart/examples/example.py)
 
-[DEPS](/recipe_modules/dart/examples/example.py#19): [dart](#recipe_modules-dart), [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/file][recipe_engine/recipe_modules/file], [recipe\_engine/json][recipe_engine/recipe_modules/json], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/raw\_io][recipe_engine/recipe_modules/raw_io], [recipe\_engine/runtime][recipe_engine/recipe_modules/runtime], [recipe\_engine/step][recipe_engine/recipe_modules/step], [recipe\_engine/swarming][recipe_engine/recipe_modules/swarming]
+[DEPS](/recipe_modules/dart/examples/example.py#19): [dart](#recipe_modules-dart), [depot\_tools/tryserver][depot_tools/recipe_modules/tryserver], [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/file][recipe_engine/recipe_modules/file], [recipe\_engine/json][recipe_engine/recipe_modules/json], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/raw\_io][recipe_engine/recipe_modules/raw_io], [recipe\_engine/runtime][recipe_engine/recipe_modules/runtime], [recipe\_engine/step][recipe_engine/recipe_modules/step], [recipe\_engine/swarming][recipe_engine/recipe_modules/swarming]
 
-&mdash; **def [RunSteps](/recipe_modules/dart/examples/example.py#314)(api):**
+&mdash; **def [RunSteps](/recipe_modules/dart/examples/example.py#315)(api):**
 ### *recipes* / [dart:examples/example-get\_secret](/recipe_modules/dart/examples/example-get_secret.py)
 
 [DEPS](/recipe_modules/dart/examples/example-get_secret.py#7): [dart](#recipe_modules-dart), [recipe\_engine/platform][recipe_engine/recipe_modules/platform]
@@ -192,7 +192,6 @@
 [depot_tools/recipe_modules/bot_update]: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+/a3b6fd06f9d70795dc18d4ce8c7d66f6bf5a9c04/recipes/README.recipes.md#recipe_modules-bot_update
 [depot_tools/recipe_modules/depot_tools]: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+/a3b6fd06f9d70795dc18d4ce8c7d66f6bf5a9c04/recipes/README.recipes.md#recipe_modules-depot_tools
 [depot_tools/recipe_modules/gclient]: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+/a3b6fd06f9d70795dc18d4ce8c7d66f6bf5a9c04/recipes/README.recipes.md#recipe_modules-gclient
-[depot_tools/recipe_modules/gerrit]: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+/a3b6fd06f9d70795dc18d4ce8c7d66f6bf5a9c04/recipes/README.recipes.md#recipe_modules-gerrit
 [depot_tools/recipe_modules/git]: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+/a3b6fd06f9d70795dc18d4ce8c7d66f6bf5a9c04/recipes/README.recipes.md#recipe_modules-git
 [depot_tools/recipe_modules/gitiles]: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+/a3b6fd06f9d70795dc18d4ce8c7d66f6bf5a9c04/recipes/README.recipes.md#recipe_modules-gitiles
 [depot_tools/recipe_modules/gsutil]: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+/a3b6fd06f9d70795dc18d4ce8c7d66f6bf5a9c04/recipes/README.recipes.md#recipe_modules-gsutil
diff --git a/recipe_modules/dart/__init__.py b/recipe_modules/dart/__init__.py
index 04e62d8..c5a334c 100644
--- a/recipe_modules/dart/__init__.py
+++ b/recipe_modules/dart/__init__.py
@@ -6,7 +6,6 @@
     'depot_tools/bot_update',
     'depot_tools/depot_tools',
     'depot_tools/gclient',
-    'depot_tools/gerrit',
     'depot_tools/git',
     'depot_tools/gsutil',
     'depot_tools/tryserver',
diff --git a/recipe_modules/dart/api.py b/recipe_modules/dart/api.py
index 2afc635..b223e62 100644
--- a/recipe_modules/dart/api.py
+++ b/recipe_modules/dart/api.py
@@ -356,6 +356,9 @@
     builder = self.m.buildbucket.builder_name
     if builder.endswith('-try'):
       builder = builder[:-4]
+      target = self.m.tryserver.gerrit_change_target_ref.split('/')[-1]
+      if target != 'master':
+        builder = '%s-%s' % (builder, target)
     return str(builder)
 
 
diff --git a/recipe_modules/dart/examples/example.expected/basic.json b/recipe_modules/dart/examples/example.expected/basic.json
index cae48d4..c31d4bb 100644
--- a/recipe_modules/dart/examples/example.expected/basic.json
+++ b/recipe_modules/dart/examples/example.expected/basic.json
@@ -61,7 +61,7 @@
     "~followup_annotations": [
       "@@@STEP_LOG_LINE@json.output@[@@@",
       "@@@STEP_LOG_LINE@json.output@  {@@@",
-      "@@@STEP_LOG_LINE@json.output@    \"branch\": \"master\", @@@",
+      "@@@STEP_LOG_LINE@json.output@    \"branch\": \"refs/heads/stable\", @@@",
       "@@@STEP_LOG_LINE@json.output@    \"revisions\": {@@@",
       "@@@STEP_LOG_LINE@json.output@      \"184ebe53805e102605d11f6b143486d15c23a09c\": {@@@",
       "@@@STEP_LOG_LINE@json.output@        \"_number\": \"7\", @@@",
@@ -91,9 +91,11 @@
       "--output_json",
       "/path/to/tmp/json",
       "--patch_ref",
-      "https://dart.googlesource.com/sdk@refs/heads/master:refs/changes/56/123456/7",
+      "https://dart.googlesource.com/sdk@refs/heads/stable:refs/changes/56/123456/7",
       "--revision",
-      "sdk@HEAD"
+      "sdk@refs/heads/stable",
+      "--refs",
+      "refs/heads/stable"
     ],
     "cwd": "[CACHE]/builder",
     "env": {
@@ -1374,7 +1376,7 @@
       "RECIPE_REPO[depot_tools]/gsutil.py",
       "----",
       "cp",
-      "gs://dart-test-results/builders/dart2js-strong-linux-x64-firefox/latest",
+      "gs://dart-test-results/builders/dart2js-strong-linux-x64-firefox-stable/latest",
       "/path/to/tmp/"
     ],
     "cwd": "[CACHE]/builder/sdk",
@@ -1395,7 +1397,7 @@
       "RECIPE_REPO[depot_tools]/gsutil.py",
       "----",
       "cp",
-      "gs://dart-test-results/builders/dart2js-strong-linux-x64-firefox/123/revision",
+      "gs://dart-test-results/builders/dart2js-strong-linux-x64-firefox-stable/123/revision",
       "/path/to/tmp/"
     ],
     "cwd": "[CACHE]/builder/sdk",
@@ -1472,7 +1474,7 @@
       "RECIPE_REPO[depot_tools]/gsutil.py",
       "----",
       "cp",
-      "gs://dart-test-results/builders/dart2js-strong-linux-x64-firefox/123/*.json",
+      "gs://dart-test-results/builders/dart2js-strong-linux-x64-firefox-stable/123/*.json",
       "[CACHE]/builder/sdk/LATEST"
     ],
     "cwd": "[CACHE]/builder/sdk",
diff --git a/recipe_modules/dart/examples/example.py b/recipe_modules/dart/examples/example.py
index ac788f3..7008eb0 100644
--- a/recipe_modules/dart/examples/example.py
+++ b/recipe_modules/dart/examples/example.py
@@ -18,6 +18,7 @@
 
 DEPS = [
     'dart',
+    'depot_tools/tryserver',
     'recipe_engine/buildbucket',
     'recipe_engine/file',
     'recipe_engine/json',
@@ -368,6 +369,7 @@
       _canned_step(api, 'custom_runner', deflake=False),
       api.step_data(
           'upload testing fileset test', stdout=api.raw_io.output('test_hash')),
+      api.tryserver.gerrit_change_target_ref('refs/heads/stable'),
       api.step_data('download previous results.gsutil find latest build',
                     api.raw_io.output_text('123', name='latest')),
       api.step_data('add fields to result records',