Mercurial > hg
changeset 50267:f92afdf3cff9
transaction: remove the `branch` backup for transaction
We can now back it up at the end of the transaction as we do for the rest of
the dirstate.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 02 Mar 2023 15:33:04 +0100 |
parents | 307c155e6275 |
children | ffdfb1066ac6 |
files | mercurial/dirstate.py mercurial/localrepo.py |
diffstat | 2 files changed, 7 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/dirstate.py Thu Mar 02 11:54:29 2023 +0100 +++ b/mercurial/dirstate.py Thu Mar 02 15:33:04 2023 +0100 @@ -1765,16 +1765,12 @@ This is only used to do `hg rollback` related backup in the transaction """ - if not self._opener.exists(self._filename): - # no data every written to disk yet - return () - elif self._use_dirstate_v2: - return ( - self._filename, - self._map.docket.data_filename(), - ) - else: - return (self._filename,) + files = [b'branch'] + if self._opener.exists(self._filename): + files.append(self._filename) + if self._use_dirstate_v2: + files.append(self._map.docket.data_filename()) + return tuple(files) def verify(self, m1, m2, p1, narrow_matcher=None): """
--- a/mercurial/localrepo.py Thu Mar 02 11:54:29 2023 +0100 +++ b/mercurial/localrepo.py Thu Mar 02 15:33:04 2023 +0100 @@ -2673,13 +2673,9 @@ # strip" to pick a working copy destination on `hg rollback` if self.currentwlock() is not None: ds = self.dirstate - if ds.branch() == b'default': + if not self.vfs.exists(b'branch'): # force a file to be written if None exist ds.setbranch(b'default', None) - # we cannot simply add "branch" to `all_file_names` because branch - # is written outside of the transaction control. So we need to - # backup early. - tr.addbackup(b"branch", hardlink=True, location=b'plain') def backup_dirstate(tr): for f in ds.all_file_names():