Skip to content

Commit 0459ef6

Browse files
EvaBardouEvaBardou
andauthored
Improve logging in Repository.apply_build() (#83)
* Improve logging in Repository.apply_build() * Nits Co-authored-by: EvaBardou <ebardou@teklia.com>
1 parent 29e37de commit 0459ef6

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

libmozevent/mercurial.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,10 @@ def apply_build(self, build):
150150

151151
# When base revision is missing, update to default revision
152152
hg_base = needed_stack[0].base_revision
153+
build.base_revision = hg_base
153154
build.missing_base_revision = not self.has_revision(hg_base)
154155
if build.missing_base_revision:
155-
logger.info(
156+
logger.warning(
156157
"Missing base revision from Phabricator",
157158
revision=hg_base,
158159
fallback=self.default_revision,
@@ -210,11 +211,15 @@ def get_author(commit):
210211
message += "Differential Diff: {}".format(patch.phid)
211212

212213
logger.info("Applying patch", phid=patch.phid, message=message)
213-
self.repo.import_(
214-
patches=io.BytesIO(patch.patch.encode("utf-8")),
215-
message=message.encode("utf-8"),
216-
user=user.encode("utf-8"),
217-
)
214+
try:
215+
self.repo.import_(
216+
patches=io.BytesIO(patch.patch.encode("utf-8")),
217+
message=message.encode("utf-8"),
218+
user=user.encode("utf-8"),
219+
)
220+
except Exception as e:
221+
logger.error("Failed to apply patch: {}".format(e), phid=patch.phid)
222+
raise
218223

219224
def add_try_commit(self, build):
220225
"""

libmozevent/phabricator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def __init__(self, request):
4646
self.reviewers = []
4747
self.diff = None
4848
self.stack = []
49+
self.base_revision = None
4950
self.missing_base_revision = False
5051

5152
def __str__(self):

0 commit comments

Comments
 (0)