D152: repo: skip invalidation of changelog if it has 'delayed' changes (API)

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Tue Aug 8 04:29:55 UTC 2017


martinvonz updated this revision to Diff 619.
martinvonz marked an inline comment as done.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D152?vs=321&id=619

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(b'4', 'wb') as f:
+        f.write(b'4')
+    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]



To: martinvonz, #hg-reviewers, quark, indygreg
Cc: indygreg, quark, mercurial-devel


More information about the Mercurial-devel mailing list