Patchwork D7457: shelve: fix a missing variable in the exception handler for delete

login
register
mail settings
Submitter phabricator
Date Nov. 19, 2019, 10:46 p.m.
Message ID <differential-rev-PHID-DREV-57k6dx7sx2ftyvnyscfv-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/43367/
State Superseded
Headers show

Comments

phabricator - Nov. 19, 2019, 10:46 p.m.
mharbison72 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Caught by pytype.  I haven't paid much attention to the progress of this
  extension, but I *think* this was the intent.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/shelve.py

CHANGE DETAILS




To: mharbison72, #hg-reviewers
Cc: mercurial-devel
phabricator - Nov. 20, 2019, 2:43 a.m.
mharbison72 added a comment.


  This and the next one should probably go on stable.   I'm a bit surprised there's no test coverage, at least for the next one.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7457/new/

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

To: mharbison72, #hg-reviewers
Cc: mercurial-devel
phabricator - Nov. 20, 2019, 7:59 a.m.
dlax added a comment.
dlax accepted this revision.


  I don't see any test for `hg shelve --delete NAME` that's not a command error case; adding some in D7460 <https://phab.mercurial-scm.org/D7460>.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7457/new/

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

To: mharbison72, #hg-reviewers, dlax
Cc: dlax, mercurial-devel

Patch

diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -603,8 +603,8 @@ 
     if not pats:
         raise error.Abort(_(b'no shelved changes specified!'))
     with repo.wlock():
-        try:
-            for name in pats:
+        for name in pats:
+            try:
                 for suffix in shelvefileextensions:
                     shfile = shelvedfile(repo, name, suffix)
                     # patch file is necessary, as it should
@@ -614,11 +614,11 @@ 
                     # bundle
                     if shfile.exists() or suffix == patchextension:
                         shfile.movetobackup()
+            except OSError as err:
+                if err.errno != errno.ENOENT:
+                    raise
+                raise error.Abort(_(b"shelved change '%s' not found") % name)
             cleanupoldbackups(repo)
-        except OSError as err:
-            if err.errno != errno.ENOENT:
-                raise
-            raise error.Abort(_(b"shelved change '%s' not found") % name)
 
 
 def listshelves(repo):