Patchwork D12134: notify: don't produce errors if a revision is not found

login
register
mail settings
Submitter phabricator
Date Feb. 7, 2022, 6:40 a.m.
Message ID <differential-rev-PHID-DREV-wkamykaux7o67gghytcc-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50468/
State New
Headers show

Comments

phabricator - Feb. 7, 2022, 6:40 a.m.
av6 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Notify extension has a way to only subscribe to a specific revset, such as
  "branch(foo)". Before this patch, when there was no branch with that name, it
  would produce a traceback saying "unknown revision: foo". With this patch it
  would no longer do that, and instead it'll assume there are no revisions that
  match this revset. I think this patch is an improvement in general, but there's
  a reason I'm sending it now.
  
  test-notify.t has a test case where it obsoletes the only revision on a branch,
  and previously that wouldn't produce any complications, because head
  computation wasn't obsolescence-aware. Now if the only revision on a branch is
  obsolete, repo should not see that branch at all.
  
  That branch will still be present in branchcache (with an empty list of
  revisions) until the next patch.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12134

AFFECTED FILES
  hgext/notify.py

CHANGE DETAILS




To: av6, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/hgext/notify.py b/hgext/notify.py
--- a/hgext/notify.py
+++ b/hgext/notify.py
@@ -435,7 +435,10 @@ 
             if spec is None:
                 subs.add(sub)
                 continue
-            revs = self.repo.revs(b'%r and %d:', spec, ctx.rev())
+            try:
+                revs = self.repo.revs(b'%r and %d:', spec, ctx.rev())
+            except error.RepoLookupError:
+                continue
             if len(revs):
                 subs.add(sub)
                 continue