##// END OF EJS Templates
localrepo: "blindly" do a dirstate backup at the end of the transaction...
marmoute -
r50979:5b9c3ae8 default
parent child Browse files
Show More
@@ -1615,6 +1615,22 b' class dirstate:'
1615 else:
1615 else:
1616 return self._filename
1616 return self._filename
1617
1617
1618 def all_file_names(self):
1619 """list all filename currently used by this dirstate
1620
1621 This is only used to do `hg rollback` related backup in the transaction
1622 """
1623 if not self._opener.exists(self._filename):
1624 # no data every written to disk yet
1625 return ()
1626 elif self._use_dirstate_v2:
1627 return (
1628 self._filename,
1629 self._map.docket.data_filename(),
1630 )
1631 else:
1632 return (self._filename,)
1633
1618 def data_backup_filename(self, backupname):
1634 def data_backup_filename(self, backupname):
1619 if not self._use_dirstate_v2:
1635 if not self._use_dirstate_v2:
1620 return None
1636 return None
@@ -2647,6 +2647,32 b' class localrepository:'
2647 tr.addpostclose(b'refresh-filecachestats', self._refreshfilecachestats)
2647 tr.addpostclose(b'refresh-filecachestats', self._refreshfilecachestats)
2648 self._transref = weakref.ref(tr)
2648 self._transref = weakref.ref(tr)
2649 scmutil.registersummarycallback(self, tr, desc)
2649 scmutil.registersummarycallback(self, tr, desc)
2650 # This only exist to deal with the need of rollback to have viable
2651 # parents at the end of the operation. So backup viable parents at the
2652 # time of this operation.
2653 #
2654 # We only do it when the `wlock` is taken, otherwise other might be
2655 # altering the dirstate under us.
2656 #
2657 # This is really not a great way to do this (first, because we cannot
2658 # always do it). There are more viable alternative that exists
2659 #
2660 # - backing only the working copy parent in a dedicated files and doing
2661 # a clean "keep-update" to them on `hg rollback`.
2662 #
2663 # - slightly changing the behavior an applying a logic similar to "hg
2664 # strip" to pick a working copy destination on `hg rollback`
2665 if self.currentwlock() is not None:
2666 ds = self.dirstate
2667
2668 def backup_dirstate(tr):
2669 for f in ds.all_file_names():
2670 # hardlink backup is okay because `dirstate` is always
2671 # atomically written and possible data file are append only
2672 # and resistant to trailing data.
2673 tr.addbackup(f, hardlink=True, location=b'plain')
2674
2675 tr.addvalidator(b'dirstate-backup', backup_dirstate)
2650 return tr
2676 return tr
2651
2677
2652 def _journalfiles(self):
2678 def _journalfiles(self):
General Comments 0
You need to be logged in to leave comments. Login now