Patchwork [1,of,2,STABLE] automation: allow exit code of 1 for `hg push`

login
register
mail settings
Submitter Gregory Szorc
Date July 29, 2019, 1:38 a.m.
Message ID <9905d2b89f8ca2f542cd.1564364337@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/41091/
State Accepted
Headers show

Comments

Gregory Szorc - July 29, 2019, 1:38 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1564362968 25200
#      Sun Jul 28 18:16:08 2019 -0700
# Branch stable
# Node ID 9905d2b89f8ca2f542cd79986a0daf4bd72766d1
# Parent  7fae3b0bd893b75e0fb65ad3032b7532089e2341
automation: allow exit code of 1 for `hg push`

`hg push` exits 1 for no-ops. No-op pushes should be fine in the
context of automation.
Pulkit Goyal - July 29, 2019, 9:57 a.m.
On Mon, Jul 29, 2019 at 4:41 AM Gregory Szorc <gregory.szorc@gmail.com> wrote:
>
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1564362968 25200
> #      Sun Jul 28 18:16:08 2019 -0700
> # Branch stable
> # Node ID 9905d2b89f8ca2f542cd79986a0daf4bd72766d1
> # Parent  7fae3b0bd893b75e0fb65ad3032b7532089e2341
> automation: allow exit code of 1 for `hg push`
>
> `hg push` exits 1 for no-ops. No-op pushes should be fine in the
> context of automation.
>

Queued the series, many thanks!

Patch

diff --git a/contrib/automation/hgautomation/linux.py b/contrib/automation/hgautomation/linux.py
--- a/contrib/automation/hgautomation/linux.py
+++ b/contrib/automation/hgautomation/linux.py
@@ -489,7 +489,11 @@  def synchronize_hg(source_path: pathlib.
             'ssh://%s//hgwork/src' % public_ip,
         ]
 
-        subprocess.run(args, cwd=str(source_path), env=env, check=True)
+        res = subprocess.run(args, cwd=str(source_path), env=env)
+
+        # Allow 1 (no-op) to not trigger error.
+        if res.returncode not in (0, 1):
+            res.check_returncode()
 
         # TODO support synchronizing dirty working directory.
 
diff --git a/contrib/automation/hgautomation/windows.py b/contrib/automation/hgautomation/windows.py
--- a/contrib/automation/hgautomation/windows.py
+++ b/contrib/automation/hgautomation/windows.py
@@ -180,7 +180,11 @@  def synchronize_hg(hg_repo: pathlib.Path
             'ssh://%s/c:/hgdev/src' % public_ip,
         ]
 
-        subprocess.run(args, cwd=str(hg_repo), env=env, check=True)
+        res = subprocess.run(args, cwd=str(hg_repo), env=env)
+
+        # Allow 1 (no-op) to not trigger error.
+        if res.returncode not in (0, 1):
+            res.check_returncode()
 
         run_powershell(winrm_client,
                        HG_UPDATE_CLEAN.format(revision=full_revision))