diff mercurial/dirstateguard.py @ 43075:57875cf423c9

style: run a patched black on a subset of mercurial This applied black to the 20 smallest files in mercurial/: ls -S1 mercurial/*.py | tail -n20 | xargs black --skip-string-normalization Note that a few files failed to format, presumably due to a bug in my patch. The intent is to be able to compare results to D5064 with https://github.com/python/black/pull/826 applied to black. I skipped string normalization on this patch for clarity - in reality I think we'd want one pass without string normalization, followed by another to normalize strings (which is basically replacing ' with " globally.) # skip-blame mass-reformatting only Differential Revision: https://phab.mercurial-scm.org/D6342
author Augie Fackler <augie@google.com>
date Sat, 05 Oct 2019 10:29:34 -0400
parents b74481038438
children 687b865b95ad
line wrap: on
line diff
--- a/mercurial/dirstateguard.py	Fri Oct 04 15:53:45 2019 -0400
+++ b/mercurial/dirstateguard.py	Sat Oct 05 10:29:34 2019 -0400
@@ -15,6 +15,7 @@
     util,
 )
 
+
 class dirstateguard(util.transactional):
     '''Restore dirstate at unexpected failure.
 
@@ -34,14 +35,16 @@
         self._active = False
         self._closed = False
         self._backupname = 'dirstate.backup.%s.%d' % (name, id(self))
-        self._narrowspecbackupname = ('narrowspec.backup.%s.%d' %
-                                      (name, id(self)))
+        self._narrowspecbackupname = 'narrowspec.backup.%s.%d' % (
+            name,
+            id(self),
+        )
         repo.dirstate.savebackup(repo.currenttransaction(), self._backupname)
         narrowspec.savewcbackup(repo, self._narrowspecbackupname)
         self._active = True
 
     def __del__(self):
-        if self._active: # still active
+        if self._active:  # still active
             # this may occur, even if this class is used correctly:
             # for example, releasing other resources like transaction
             # may raise exception before ``dirstateguard.release`` in
@@ -49,27 +52,33 @@
             self._abort()
 
     def close(self):
-        if not self._active: # already inactivated
-            msg = (_("can't close already inactivated backup: %s")
-                   % self._backupname)
+        if not self._active:  # already inactivated
+            msg = (
+                _("can't close already inactivated backup: %s")
+                % self._backupname
+            )
             raise error.Abort(msg)
 
-        self._repo.dirstate.clearbackup(self._repo.currenttransaction(),
-                                         self._backupname)
+        self._repo.dirstate.clearbackup(
+            self._repo.currenttransaction(), self._backupname
+        )
         narrowspec.clearwcbackup(self._repo, self._narrowspecbackupname)
         self._active = False
         self._closed = True
 
     def _abort(self):
         narrowspec.restorewcbackup(self._repo, self._narrowspecbackupname)
-        self._repo.dirstate.restorebackup(self._repo.currenttransaction(),
-                                           self._backupname)
+        self._repo.dirstate.restorebackup(
+            self._repo.currenttransaction(), self._backupname
+        )
         self._active = False
 
     def release(self):
         if not self._closed:
-            if not self._active: # already inactivated
-                msg = (_("can't release already inactivated backup: %s")
-                       % self._backupname)
+            if not self._active:  # already inactivated
+                msg = (
+                    _("can't release already inactivated backup: %s")
+                    % self._backupname
+                )
                 raise error.Abort(msg)
             self._abort()