dirstate: pre-indent some of the backup code
authorPierre-Yves David <pierre-yves.david@octobus.net>
Tue, 14 Feb 2023 22:46:26 +0100
changeset 50001 9313d8666a0f
parent 50000 1f28172cfce9
child 50002 e358f6e0e50e
dirstate: pre-indent some of the backup code This will make the next changeset clearer.
mercurial/dirstate.py
--- a/mercurial/dirstate.py	Tue Feb 14 22:27:24 2023 +0100
+++ b/mercurial/dirstate.py	Tue Feb 14 22:46:26 2023 +0100
@@ -1530,26 +1530,27 @@
             tr.registertmp(filename, location=b'plain')
 
         self._opener.tryunlink(backupname)
-        # hardlink backup is okay because _writedirstate is always called
-        # with an "atomictemp=True" file.
-        util.copyfile(
-            self._opener.join(filename),
-            self._opener.join(backupname),
-            hardlink=True,
-        )
-        data_pair = self._new_backup_data_filename(backupname)
-        if data_pair is not None:
-            data_filename, bck_data_filename = data_pair
+        if True:
+            # hardlink backup is okay because _writedirstate is always called
+            # with an "atomictemp=True" file.
             util.copyfile(
-                self._opener.join(data_filename),
-                self._opener.join(bck_data_filename),
+                self._opener.join(filename),
+                self._opener.join(backupname),
                 hardlink=True,
             )
-            if tr is not None:
-                # ensure that pending file written above is unlinked at
-                # failure, even if tr.writepending isn't invoked until the
-                # end of this transaction
-                tr.registertmp(bck_data_filename, location=b'plain')
+            data_pair = self._new_backup_data_filename(backupname)
+            if data_pair is not None:
+                data_filename, bck_data_filename = data_pair
+                util.copyfile(
+                    self._opener.join(data_filename),
+                    self._opener.join(bck_data_filename),
+                    hardlink=True,
+                )
+                if tr is not None:
+                    # ensure that pending file written above is unlinked at
+                    # failure, even if tr.writepending isn't invoked until the
+                    # end of this transaction
+                    tr.registertmp(bck_data_filename, location=b'plain')
 
     def restorebackup(self, tr, backupname):
         '''Restore dirstate by backup file'''