D152: repo: skip invalidation of changelog if it has 'delayed' changes (API)
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Wed Jul 19 22:09:35 UTC 2017
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
The changelog object can store recently added revisions in memory
until the transaction is committed. We don't want to lose those
changes even if repo.invalidate(clearfilecache=True), so let's skip
the changelog when it has such 'delayed' changes.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D152
AFFECTED FILES
mercurial/localrepo.py
tests/test-context.py
CHANGE DETAILS
diff --git a/tests/test-context.py b/tests/test-context.py
--- a/tests/test-context.py
+++ b/tests/test-context.py
@@ -179,3 +179,14 @@
print('data mismatch')
except Exception as ex:
print('cannot read data: %r' % ex)
+
+with repo.wlock(), repo.lock(), repo.transaction('test'):
+ with open('4', 'wb') as f:
+ f.write(i)
+ repo.dirstate.normal('4')
+ repo.commit('4')
+ revsbefore = len(repo.changelog)
+ repo.invalidate(clearfilecache=True)
+ revsafter = len(repo.changelog)
+ if revsbefore != revsafter:
+ print('changeset lost by repo.invalidate()')
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1466,6 +1466,13 @@
# dirstate is invalidated separately in invalidatedirstate()
if k == 'dirstate':
continue
+ if (k == 'changelog' and
+ self.currenttransaction() and
+ self.changelog._delayed):
+ # The changelog object may store unwritten revisions. We don't
+ # want to lose them.
+ # TODO: Solve the problem instead of working around it.
+ continue
if clearfilecache:
del self._filecache[k]
EMAIL PREFERENCES
https://phab.mercurial-scm.org/settings/panel/emailpreferences/
To: martinvonz, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list