# HG changeset patch # User Pierre-Yves David # Date 1677767584 -3600 # Node ID f92afdf3cff99e4efc4137a62a75c70387d17182 # Parent 307c155e6275984611c05fc2d5ddc229aa264343 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. diff -r 307c155e6275 -r f92afdf3cff9 mercurial/dirstate.py --- 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): """ diff -r 307c155e6275 -r f92afdf3cff9 mercurial/localrepo.py --- 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():