mercurial/localrepo.py
changeset 50084 5b9c3ae807c8
parent 50082 a66926099c0f
child 50085 ff12f42415f5
equal deleted inserted replaced
50083:a28cedb26139 50084:5b9c3ae807c8
  2645         # avoid eager cache invalidation. in-memory data should be identical
  2645         # avoid eager cache invalidation. in-memory data should be identical
  2646         # to stored data if transaction has no error.
  2646         # to stored data if transaction has no error.
  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):
  2653         first = (
  2679         first = (
  2654             (self.svfs, b'journal'),
  2680             (self.svfs, b'journal'),