Show More
@@ -881,7 +881,7 b' class fixupstate:' | |||||
881 |
|
881 | |||
882 | dirstate._fsmonitorstate.invalidate = noop |
|
882 | dirstate._fsmonitorstate.invalidate = noop | |
883 | try: |
|
883 | try: | |
884 |
with dirstate. |
|
884 | with dirstate.changing_parents(self.repo): | |
885 | dirstate.rebuild(ctx.node(), ctx.manifest(), self.paths) |
|
885 | dirstate.rebuild(ctx.node(), ctx.manifest(), self.paths) | |
886 | finally: |
|
886 | finally: | |
887 | restore() |
|
887 | restore() |
@@ -776,7 +776,7 b' def writeworkingdir(repo, ctx, filedata,' | |||||
776 | newp1 = replacements.get(oldp1, oldp1) |
|
776 | newp1 = replacements.get(oldp1, oldp1) | |
777 | if newp1 != oldp1: |
|
777 | if newp1 != oldp1: | |
778 | assert repo.dirstate.p2() == nullid |
|
778 | assert repo.dirstate.p2() == nullid | |
779 |
with repo.dirstate. |
|
779 | with repo.dirstate.changing_parents(repo): | |
780 | scmutil.movedirstate(repo, repo[newp1]) |
|
780 | scmutil.movedirstate(repo, repo[newp1]) | |
781 |
|
781 | |||
782 |
|
782 |
@@ -384,7 +384,7 b' class gitdirstate:' | |||||
384 | pass |
|
384 | pass | |
385 |
|
385 | |||
386 | @contextlib.contextmanager |
|
386 | @contextlib.contextmanager | |
387 |
def |
|
387 | def changing_parents(self, repo): | |
388 | # TODO: track this maybe? |
|
388 | # TODO: track this maybe? | |
389 | yield |
|
389 | yield | |
390 |
|
390 |
@@ -696,7 +696,7 b' def kw_amend(orig, ui, repo, old, extra,' | |||||
696 | kwt = getattr(repo, '_keywordkwt', None) |
|
696 | kwt = getattr(repo, '_keywordkwt', None) | |
697 | if kwt is None: |
|
697 | if kwt is None: | |
698 | return orig(ui, repo, old, extra, pats, opts) |
|
698 | return orig(ui, repo, old, extra, pats, opts) | |
699 |
with repo.wlock(), repo.dirstate. |
|
699 | with repo.wlock(), repo.dirstate.changing_parents(repo): | |
700 | kwt.postcommit = True |
|
700 | kwt.postcommit = True | |
701 | newid = orig(ui, repo, old, extra, pats, opts) |
|
701 | newid = orig(ui, repo, old, extra, pats, opts) | |
702 | if newid != old.node(): |
|
702 | if newid != old.node(): | |
@@ -762,7 +762,7 b' def kw_dorecord(orig, ui, repo, commitfu' | |||||
762 | if ctx != recctx: |
|
762 | if ctx != recctx: | |
763 | modified, added = _preselect(wstatus, recctx.files()) |
|
763 | modified, added = _preselect(wstatus, recctx.files()) | |
764 | kwt.restrict = False |
|
764 | kwt.restrict = False | |
765 |
with repo.dirstate. |
|
765 | with repo.dirstate.changing_parents(repo): | |
766 | kwt.overwrite(recctx, modified, False, True) |
|
766 | kwt.overwrite(recctx, modified, False, True) | |
767 | kwt.overwrite(recctx, added, False, True, True) |
|
767 | kwt.overwrite(recctx, added, False, True, True) | |
768 | kwt.restrict = True |
|
768 | kwt.restrict = True |
@@ -517,7 +517,7 b' def updatelfiles(' | |||||
517 | filelist = set(filelist) |
|
517 | filelist = set(filelist) | |
518 | lfiles = [f for f in lfiles if f in filelist] |
|
518 | lfiles = [f for f in lfiles if f in filelist] | |
519 |
|
519 | |||
520 |
with lfdirstate. |
|
520 | with lfdirstate.changing_parents(repo): | |
521 | update = {} |
|
521 | update = {} | |
522 | dropped = set() |
|
522 | dropped = set() | |
523 | updated, removed = 0, 0 |
|
523 | updated, removed = 0, 0 | |
@@ -580,7 +580,7 b' def updatelfiles(' | |||||
580 | statuswriter(_(b'getting changed largefiles\n')) |
|
580 | statuswriter(_(b'getting changed largefiles\n')) | |
581 | cachelfiles(ui, repo, None, lfiles) |
|
581 | cachelfiles(ui, repo, None, lfiles) | |
582 |
|
582 | |||
583 |
with lfdirstate. |
|
583 | with lfdirstate.changing_parents(repo): | |
584 | for lfile in lfiles: |
|
584 | for lfile in lfiles: | |
585 | update1 = 0 |
|
585 | update1 = 0 | |
586 |
|
586 |
@@ -231,7 +231,7 b' def openlfdirstate(ui, repo, create=True' | |||||
231 | if len(standins) > 0: |
|
231 | if len(standins) > 0: | |
232 | vfs.makedirs(lfstoredir) |
|
232 | vfs.makedirs(lfstoredir) | |
233 |
|
233 | |||
234 |
with lfdirstate. |
|
234 | with lfdirstate.changing_parents(repo): | |
235 | for standin in standins: |
|
235 | for standin in standins: | |
236 | lfile = splitstandin(standin) |
|
236 | lfile = splitstandin(standin) | |
237 | lfdirstate.update_file( |
|
237 | lfdirstate.update_file( | |
@@ -581,7 +581,7 b' def markcommitted(orig, ctx, node):' | |||||
581 | repo = ctx.repo() |
|
581 | repo = ctx.repo() | |
582 |
|
582 | |||
583 | lfdirstate = openlfdirstate(repo.ui, repo) |
|
583 | lfdirstate = openlfdirstate(repo.ui, repo) | |
584 |
with lfdirstate. |
|
584 | with lfdirstate.changing_parents(repo): | |
585 | orig(node) |
|
585 | orig(node) | |
586 |
|
586 | |||
587 | # ATTENTION: "ctx.files()" may differ from "repo[node].files()" |
|
587 | # ATTENTION: "ctx.files()" may differ from "repo[node].files()" |
@@ -660,7 +660,7 b' def overridecalculateupdates(' | |||||
660 | def mergerecordupdates(orig, repo, actions, branchmerge, getfiledata): |
|
660 | def mergerecordupdates(orig, repo, actions, branchmerge, getfiledata): | |
661 | if MERGE_ACTION_LARGEFILE_MARK_REMOVED in actions: |
|
661 | if MERGE_ACTION_LARGEFILE_MARK_REMOVED in actions: | |
662 | lfdirstate = lfutil.openlfdirstate(repo.ui, repo) |
|
662 | lfdirstate = lfutil.openlfdirstate(repo.ui, repo) | |
663 |
with lfdirstate. |
|
663 | with lfdirstate.changing_parents(repo): | |
664 | for lfile, args, msg in actions[ |
|
664 | for lfile, args, msg in actions[ | |
665 | MERGE_ACTION_LARGEFILE_MARK_REMOVED |
|
665 | MERGE_ACTION_LARGEFILE_MARK_REMOVED | |
666 | ]: |
|
666 | ]: | |
@@ -1800,7 +1800,7 b' def mergeupdate(orig, repo, node, branch' | |||||
1800 | raise error.ProgrammingError( |
|
1800 | raise error.ProgrammingError( | |
1801 | b'largefiles is not compatible with in-memory merge' |
|
1801 | b'largefiles is not compatible with in-memory merge' | |
1802 | ) |
|
1802 | ) | |
1803 |
with lfdirstate. |
|
1803 | with lfdirstate.changing_parents(repo): | |
1804 | result = orig(repo, node, branchmerge, force, *args, **kwargs) |
|
1804 | result = orig(repo, node, branchmerge, force, *args, **kwargs) | |
1805 |
|
1805 | |||
1806 | newstandins = lfutil.getstandinsstate(repo) |
|
1806 | newstandins = lfutil.getstandinsstate(repo) |
@@ -1082,7 +1082,7 b' class queue:' | |||||
1082 |
|
1082 | |||
1083 | if merge and files: |
|
1083 | if merge and files: | |
1084 | # Mark as removed/merged and update dirstate parent info |
|
1084 | # Mark as removed/merged and update dirstate parent info | |
1085 |
with repo.dirstate. |
|
1085 | with repo.dirstate.changing_parents(repo): | |
1086 | for f in files: |
|
1086 | for f in files: | |
1087 | repo.dirstate.update_file_p1(f, p1_tracked=True) |
|
1087 | repo.dirstate.update_file_p1(f, p1_tracked=True) | |
1088 | p1 = repo.dirstate.p1() |
|
1088 | p1 = repo.dirstate.p1() | |
@@ -1830,7 +1830,7 b' class queue:' | |||||
1830 | if keepchanges and tobackup: |
|
1830 | if keepchanges and tobackup: | |
1831 | raise error.Abort(_(b"local changes found, qrefresh first")) |
|
1831 | raise error.Abort(_(b"local changes found, qrefresh first")) | |
1832 | self.backup(repo, tobackup) |
|
1832 | self.backup(repo, tobackup) | |
1833 |
with repo.dirstate. |
|
1833 | with repo.dirstate.changing_parents(repo): | |
1834 | for f in a: |
|
1834 | for f in a: | |
1835 | repo.wvfs.unlinkpath(f, ignoremissing=True) |
|
1835 | repo.wvfs.unlinkpath(f, ignoremissing=True) | |
1836 | repo.dirstate.update_file( |
|
1836 | repo.dirstate.update_file( | |
@@ -1988,7 +1988,7 b' class queue:' | |||||
1988 |
|
1988 | |||
1989 | bmlist = repo[top].bookmarks() |
|
1989 | bmlist = repo[top].bookmarks() | |
1990 |
|
1990 | |||
1991 |
with repo.dirstate. |
|
1991 | with repo.dirstate.changing_parents(repo): | |
1992 | # XXX do we actually need the dirstateguard |
|
1992 | # XXX do we actually need the dirstateguard | |
1993 | dsguard = None |
|
1993 | dsguard = None | |
1994 | try: |
|
1994 | try: |
@@ -320,7 +320,7 b' def _narrow(' | |||||
320 | repo.store.markremoved(f) |
|
320 | repo.store.markremoved(f) | |
321 |
|
321 | |||
322 | ui.status(_(b'deleting unwanted files from working copy\n')) |
|
322 | ui.status(_(b'deleting unwanted files from working copy\n')) | |
323 |
with repo.dirstate. |
|
323 | with repo.dirstate.changing_parents(repo): | |
324 | narrowspec.updateworkingcopy(repo, assumeclean=True) |
|
324 | narrowspec.updateworkingcopy(repo, assumeclean=True) | |
325 | narrowspec.copytoworkingcopy(repo) |
|
325 | narrowspec.copytoworkingcopy(repo) | |
326 |
|
326 | |||
@@ -380,7 +380,7 b' def _widen(' | |||||
380 | if ellipsesremote: |
|
380 | if ellipsesremote: | |
381 | ds = repo.dirstate |
|
381 | ds = repo.dirstate | |
382 | p1, p2 = ds.p1(), ds.p2() |
|
382 | p1, p2 = ds.p1(), ds.p2() | |
383 |
with ds. |
|
383 | with ds.changing_parents(repo): | |
384 | ds.setparents(repo.nullid, repo.nullid) |
|
384 | ds.setparents(repo.nullid, repo.nullid) | |
385 | if isoldellipses: |
|
385 | if isoldellipses: | |
386 | with wrappedextraprepare: |
|
386 | with wrappedextraprepare: | |
@@ -419,10 +419,12 b' def _widen(' | |||||
419 | bundle2.processbundle(repo, bundle, op=op, remote=remote) |
|
419 | bundle2.processbundle(repo, bundle, op=op, remote=remote) | |
420 |
|
420 | |||
421 | if ellipsesremote: |
|
421 | if ellipsesremote: | |
422 |
with ds. |
|
422 | with ds.changing_parents(repo): | |
423 | ds.setparents(p1, p2) |
|
423 | ds.setparents(p1, p2) | |
424 |
|
424 | |||
425 |
with repo.transaction(b'widening'), repo.dirstate. |
|
425 | with repo.transaction(b'widening'), repo.dirstate.changing_parents( | |
|
426 | repo | |||
|
427 | ): | |||
426 | repo.setnewnarrowpats() |
|
428 | repo.setnewnarrowpats() | |
427 | narrowspec.updateworkingcopy(repo) |
|
429 | narrowspec.updateworkingcopy(repo) | |
428 | narrowspec.copytoworkingcopy(repo) |
|
430 | narrowspec.copytoworkingcopy(repo) | |
@@ -591,7 +593,7 b' def trackedcmd(ui, repo, remotepath=None' | |||||
591 | if update_working_copy: |
|
593 | if update_working_copy: | |
592 | with repo.wlock(), repo.lock(), repo.transaction( |
|
594 | with repo.wlock(), repo.lock(), repo.transaction( | |
593 | b'narrow-wc' |
|
595 | b'narrow-wc' | |
594 |
), repo.dirstate. |
|
596 | ), repo.dirstate.changing_parents(repo): | |
595 | narrowspec.updateworkingcopy(repo) |
|
597 | narrowspec.updateworkingcopy(repo) | |
596 | narrowspec.copytoworkingcopy(repo) |
|
598 | narrowspec.copytoworkingcopy(repo) | |
597 | return 0 |
|
599 | return 0 |
@@ -134,7 +134,7 b' def dosplit(ui, repo, tr, ctx, opts):' | |||||
134 | # Set working parent to ctx.p1(), and keep working copy as ctx's content |
|
134 | # Set working parent to ctx.p1(), and keep working copy as ctx's content | |
135 | if ctx.node() != repo.dirstate.p1(): |
|
135 | if ctx.node() != repo.dirstate.p1(): | |
136 | hg.clean(repo, ctx.node(), show_stats=False) |
|
136 | hg.clean(repo, ctx.node(), show_stats=False) | |
137 |
with repo.dirstate. |
|
137 | with repo.dirstate.changing_parents(repo): | |
138 | scmutil.movedirstate(repo, ctx.p1()) |
|
138 | scmutil.movedirstate(repo, ctx.p1()) | |
139 |
|
139 | |||
140 | # Any modified, added, removed, deleted result means split is incomplete |
|
140 | # Any modified, added, removed, deleted result means split is incomplete |
@@ -236,7 +236,7 b' def uncommit(ui, repo, *pats, **opts):' | |||||
236 | # Fully removed the old commit |
|
236 | # Fully removed the old commit | |
237 | mapping[old.node()] = () |
|
237 | mapping[old.node()] = () | |
238 |
|
238 | |||
239 |
with repo.dirstate. |
|
239 | with repo.dirstate.changing_parents(repo): | |
240 | scmutil.movedirstate(repo, repo[newid], match) |
|
240 | scmutil.movedirstate(repo, repo[newid], match) | |
241 |
|
241 | |||
242 | scmutil.cleanupnodes(repo, mapping, b'uncommit', fixphase=True) |
|
242 | scmutil.cleanupnodes(repo, mapping, b'uncommit', fixphase=True) | |
@@ -317,7 +317,7 b' def unamend(ui, repo, **opts):' | |||||
317 | newpredctx = repo[newprednode] |
|
317 | newpredctx = repo[newprednode] | |
318 | dirstate = repo.dirstate |
|
318 | dirstate = repo.dirstate | |
319 |
|
319 | |||
320 |
with dirstate. |
|
320 | with dirstate.changing_parents(repo): | |
321 | scmutil.movedirstate(repo, newpredctx) |
|
321 | scmutil.movedirstate(repo, newpredctx) | |
322 |
|
322 | |||
323 | mapping = {curctx.node(): (newprednode,)} |
|
323 | mapping = {curctx.node(): (newprednode,)} |
@@ -216,7 +216,7 b' def reposetup(ui, repo):' | |||||
216 | def wrap_revert(orig, repo, ctx, names, uipathfn, actions, *args, **kwargs): |
|
216 | def wrap_revert(orig, repo, ctx, names, uipathfn, actions, *args, **kwargs): | |
217 | # reset dirstate cache for file we touch |
|
217 | # reset dirstate cache for file we touch | |
218 | ds = repo.dirstate |
|
218 | ds = repo.dirstate | |
219 |
with ds. |
|
219 | with ds.changing_parents(repo): | |
220 | for filename in actions[b'revert'][0]: |
|
220 | for filename in actions[b'revert'][0]: | |
221 | entry = ds.get_entry(filename) |
|
221 | entry = ds.get_entry(filename) | |
222 | if entry is not None: |
|
222 | if entry is not None: |
@@ -638,7 +638,7 b' def dorecord(' | |||||
638 | # already called within a `pendingchange`, However we |
|
638 | # already called within a `pendingchange`, However we | |
639 | # are taking a shortcut here in order to be able to |
|
639 | # are taking a shortcut here in order to be able to | |
640 | # quickly deprecated the older API. |
|
640 | # quickly deprecated the older API. | |
641 |
with dirstate. |
|
641 | with dirstate.changing_parents(repo): | |
642 | dirstate.update_file( |
|
642 | dirstate.update_file( | |
643 | realname, |
|
643 | realname, | |
644 | p1_tracked=True, |
|
644 | p1_tracked=True, | |
@@ -1532,7 +1532,7 b' def copy(ui, repo, pats, opts, rename=Fa' | |||||
1532 | new_node = mem_ctx.commit() |
|
1532 | new_node = mem_ctx.commit() | |
1533 |
|
1533 | |||
1534 | if repo.dirstate.p1() == ctx.node(): |
|
1534 | if repo.dirstate.p1() == ctx.node(): | |
1535 |
with repo.dirstate. |
|
1535 | with repo.dirstate.changing_parents(repo): | |
1536 | scmutil.movedirstate(repo, repo[new_node]) |
|
1536 | scmutil.movedirstate(repo, repo[new_node]) | |
1537 | replacements = {ctx.node(): [new_node]} |
|
1537 | replacements = {ctx.node(): [new_node]} | |
1538 | scmutil.cleanupnodes( |
|
1538 | scmutil.cleanupnodes( | |
@@ -1625,7 +1625,7 b' def copy(ui, repo, pats, opts, rename=Fa' | |||||
1625 | new_node = mem_ctx.commit() |
|
1625 | new_node = mem_ctx.commit() | |
1626 |
|
1626 | |||
1627 | if repo.dirstate.p1() == ctx.node(): |
|
1627 | if repo.dirstate.p1() == ctx.node(): | |
1628 |
with repo.dirstate. |
|
1628 | with repo.dirstate.changing_parents(repo): | |
1629 | scmutil.movedirstate(repo, repo[new_node]) |
|
1629 | scmutil.movedirstate(repo, repo[new_node]) | |
1630 | replacements = {ctx.node(): [new_node]} |
|
1630 | replacements = {ctx.node(): [new_node]} | |
1631 | scmutil.cleanupnodes(repo, replacements, b'copy', fixphase=True) |
|
1631 | scmutil.cleanupnodes(repo, replacements, b'copy', fixphase=True) | |
@@ -3024,7 +3024,7 b' def amend(ui, repo, old, extra, pats, op' | |||||
3024 | newid = repo.commitctx(new) |
|
3024 | newid = repo.commitctx(new) | |
3025 | ms.reset() |
|
3025 | ms.reset() | |
3026 |
|
3026 | |||
3027 |
with repo.dirstate. |
|
3027 | with repo.dirstate.changing_parents(repo): | |
3028 | # Reroute the working copy parent to the new changeset |
|
3028 | # Reroute the working copy parent to the new changeset | |
3029 | repo.setparents(newid, repo.nullid) |
|
3029 | repo.setparents(newid, repo.nullid) | |
3030 |
|
3030 |
@@ -6264,7 +6264,7 b' def resolve(ui, repo, *pats, **opts):' | |||||
6264 | # |
|
6264 | # | |
6265 | # All this should eventually happens, but in the mean time, we use this |
|
6265 | # All this should eventually happens, but in the mean time, we use this | |
6266 | # context manager slightly out of the context it should be. |
|
6266 | # context manager slightly out of the context it should be. | |
6267 |
with repo.dirstate. |
|
6267 | with repo.dirstate.changing_parents(repo): | |
6268 | mergestatemod.recordupdates(repo, ms.actions(), branchmerge, None) |
|
6268 | mergestatemod.recordupdates(repo, ms.actions(), branchmerge, None) | |
6269 |
|
6269 | |||
6270 | if not didwork and pats: |
|
6270 | if not didwork and pats: |
@@ -1595,7 +1595,7 b' class workingctx(committablectx):' | |||||
1595 | if p2node is None: |
|
1595 | if p2node is None: | |
1596 | p2node = self._repo.nodeconstants.nullid |
|
1596 | p2node = self._repo.nodeconstants.nullid | |
1597 | dirstate = self._repo.dirstate |
|
1597 | dirstate = self._repo.dirstate | |
1598 |
with dirstate. |
|
1598 | with dirstate.changing_parents(self._repo): | |
1599 | copies = dirstate.setparents(p1node, p2node) |
|
1599 | copies = dirstate.setparents(p1node, p2node) | |
1600 | pctx = self._repo[p1node] |
|
1600 | pctx = self._repo[p1node] | |
1601 | if copies: |
|
1601 | if copies: | |
@@ -2050,7 +2050,7 b' class workingctx(committablectx):' | |||||
2050 | return sorted(f for f in ds.matches(match) if ds.get_entry(f).tracked) |
|
2050 | return sorted(f for f in ds.matches(match) if ds.get_entry(f).tracked) | |
2051 |
|
2051 | |||
2052 | def markcommitted(self, node): |
|
2052 | def markcommitted(self, node): | |
2053 |
with self._repo.dirstate. |
|
2053 | with self._repo.dirstate.changing_parents(self._repo): | |
2054 | for f in self.modified() + self.added(): |
|
2054 | for f in self.modified() + self.added(): | |
2055 | self._repo.dirstate.update_file( |
|
2055 | self._repo.dirstate.update_file( | |
2056 | f, p1_tracked=True, wc_tracked=True |
|
2056 | f, p1_tracked=True, wc_tracked=True |
@@ -69,7 +69,7 b' class rootcache(filecache):' | |||||
69 | def requires_parents_change(func): |
|
69 | def requires_parents_change(func): | |
70 | def wrap(self, *args, **kwargs): |
|
70 | def wrap(self, *args, **kwargs): | |
71 | if not self.pendingparentchange(): |
|
71 | if not self.pendingparentchange(): | |
72 |
msg = 'calling `%s` outside of a |
|
72 | msg = 'calling `%s` outside of a changing_parents context' | |
73 | msg %= func.__name__ |
|
73 | msg %= func.__name__ | |
74 | raise error.ProgrammingError(msg) |
|
74 | raise error.ProgrammingError(msg) | |
75 | if self._invalidated_context: |
|
75 | if self._invalidated_context: | |
@@ -83,7 +83,7 b' def requires_parents_change(func):' | |||||
83 | def requires_no_parents_change(func): |
|
83 | def requires_no_parents_change(func): | |
84 | def wrap(self, *args, **kwargs): |
|
84 | def wrap(self, *args, **kwargs): | |
85 | if self.pendingparentchange(): |
|
85 | if self.pendingparentchange(): | |
86 |
msg = 'calling `%s` inside of a |
|
86 | msg = 'calling `%s` inside of a changing_parents context' | |
87 | msg %= func.__name__ |
|
87 | msg %= func.__name__ | |
88 | raise error.ProgrammingError(msg) |
|
88 | raise error.ProgrammingError(msg) | |
89 | return func(self, *args, **kwargs) |
|
89 | return func(self, *args, **kwargs) | |
@@ -127,7 +127,7 b' class dirstate:' | |||||
127 | self._dirty_tracked_set = False |
|
127 | self._dirty_tracked_set = False | |
128 | self._ui = ui |
|
128 | self._ui = ui | |
129 | self._filecache = {} |
|
129 | self._filecache = {} | |
130 |
# nesting level of ` |
|
130 | # nesting level of `changing_parents` context | |
131 | self._parentwriters = 0 |
|
131 | self._parentwriters = 0 | |
132 | # True if the current dirstate changing operations have been |
|
132 | # True if the current dirstate changing operations have been | |
133 | # invalidated (used to make sure all nested contexts have been exited) |
|
133 | # invalidated (used to make sure all nested contexts have been exited) | |
@@ -151,7 +151,7 b' class dirstate:' | |||||
151 | self._pl |
|
151 | self._pl | |
152 |
|
152 | |||
153 | @contextlib.contextmanager |
|
153 | @contextlib.contextmanager | |
154 |
def |
|
154 | def changing_parents(self, repo): | |
155 | """Context manager for handling dirstate parents. |
|
155 | """Context manager for handling dirstate parents. | |
156 |
|
156 | |||
157 | If an exception occurs in the scope of the context manager, |
|
157 | If an exception occurs in the scope of the context manager, | |
@@ -180,6 +180,14 b' class dirstate:' | |||||
180 | assert self._parentwriters == 0 |
|
180 | assert self._parentwriters == 0 | |
181 | self._invalidated_context = False |
|
181 | self._invalidated_context = False | |
182 |
|
182 | |||
|
183 | # here to help migration to the new code | |||
|
184 | def parentchange(self): | |||
|
185 | msg = ( | |||
|
186 | "Mercurial 6.4 and later requires call to " | |||
|
187 | "`dirstate.changing_parents(repo)`" | |||
|
188 | ) | |||
|
189 | raise error.ProgrammingError(msg) | |||
|
190 | ||||
183 | def pendingparentchange(self): |
|
191 | def pendingparentchange(self): | |
184 | """Returns true if the dirstate is in the middle of a set of changes |
|
192 | """Returns true if the dirstate is in the middle of a set of changes | |
185 | that modify the dirstate parent. |
|
193 | that modify the dirstate parent. | |
@@ -399,7 +407,7 b' class dirstate:' | |||||
399 | if self._parentwriters == 0: |
|
407 | if self._parentwriters == 0: | |
400 | raise ValueError( |
|
408 | raise ValueError( | |
401 | b"cannot set dirstate parent outside of " |
|
409 | b"cannot set dirstate parent outside of " | |
402 |
b"dirstate. |
|
410 | b"dirstate.changing_parents context manager" | |
403 | ) |
|
411 | ) | |
404 |
|
412 | |||
405 | self._dirty = True |
|
413 | self._dirty = True | |
@@ -523,7 +531,7 b' class dirstate:' | |||||
523 | rewriting operation. |
|
531 | rewriting operation. | |
524 |
|
532 | |||
525 | It should not be called during a merge (p2 != nullid) and only within |
|
533 | It should not be called during a merge (p2 != nullid) and only within | |
526 |
a `with dirstate. |
|
534 | a `with dirstate.changing_parents(repo):` context. | |
527 | """ |
|
535 | """ | |
528 | if self.in_merge: |
|
536 | if self.in_merge: | |
529 | msg = b'update_file_reference should not be called when merging' |
|
537 | msg = b'update_file_reference should not be called when merging' | |
@@ -566,7 +574,7 b' class dirstate:' | |||||
566 | This is to be called when the direstates parent changes to keep track |
|
574 | This is to be called when the direstates parent changes to keep track | |
567 | of what is the file situation in regards to the working copy and its parent. |
|
575 | of what is the file situation in regards to the working copy and its parent. | |
568 |
|
576 | |||
569 |
This function must be called within a `dirstate. |
|
577 | This function must be called within a `dirstate.changing_parents` context. | |
570 |
|
578 | |||
571 | note: the API is at an early stage and we might need to adjust it |
|
579 | note: the API is at an early stage and we might need to adjust it | |
572 | depending of what information ends up being relevant and useful to |
|
580 | depending of what information ends up being relevant and useful to |
@@ -35,7 +35,7 b' class idirstate(interfaceutil.Interface)' | |||||
35 | _checkexec = interfaceutil.Attribute("""Callable for checking exec bits.""") |
|
35 | _checkexec = interfaceutil.Attribute("""Callable for checking exec bits.""") | |
36 |
|
36 | |||
37 | @contextlib.contextmanager |
|
37 | @contextlib.contextmanager | |
38 |
def |
|
38 | def changing_parents(repo): | |
39 | """Context manager for handling dirstate parents. |
|
39 | """Context manager for handling dirstate parents. | |
40 |
|
40 | |||
41 | If an exception occurs in the scope of the context manager, |
|
41 | If an exception occurs in the scope of the context manager, |
@@ -2155,7 +2155,7 b' def _update(' | |||||
2155 | assert len(getfiledata) == ( |
|
2155 | assert len(getfiledata) == ( | |
2156 | mresult.len((mergestatemod.ACTION_GET,)) if wantfiledata else 0 |
|
2156 | mresult.len((mergestatemod.ACTION_GET,)) if wantfiledata else 0 | |
2157 | ) |
|
2157 | ) | |
2158 |
with repo.dirstate. |
|
2158 | with repo.dirstate.changing_parents(repo): | |
2159 | ### Filter Filedata |
|
2159 | ### Filter Filedata | |
2160 | # |
|
2160 | # | |
2161 | # We gathered "cache" information for the clean file while |
|
2161 | # We gathered "cache" information for the clean file while | |
@@ -2377,7 +2377,7 b' def graft(' | |||||
2377 | # fix up dirstate for copies and renames |
|
2377 | # fix up dirstate for copies and renames | |
2378 | copies.graftcopies(wctx, ctx, base) |
|
2378 | copies.graftcopies(wctx, ctx, base) | |
2379 | else: |
|
2379 | else: | |
2380 |
with repo.dirstate. |
|
2380 | with repo.dirstate.changing_parents(repo): | |
2381 | repo.setparents(pctx.node(), pother) |
|
2381 | repo.setparents(pctx.node(), pother) | |
2382 | repo.dirstate.write(repo.currenttransaction()) |
|
2382 | repo.dirstate.write(repo.currenttransaction()) | |
2383 | # fix up dirstate for copies and renames |
|
2383 | # fix up dirstate for copies and renames |
@@ -637,7 +637,7 b' def _docreatecmd(ui, repo, pats, opts):' | |||||
637 |
|
637 | |||
638 | ui.status(_(b'shelved as %s\n') % name) |
|
638 | ui.status(_(b'shelved as %s\n') % name) | |
639 | if opts[b'keep']: |
|
639 | if opts[b'keep']: | |
640 |
with repo.dirstate. |
|
640 | with repo.dirstate.changing_parents(repo): | |
641 | scmutil.movedirstate(repo, parent, match) |
|
641 | scmutil.movedirstate(repo, parent, match) | |
642 | else: |
|
642 | else: | |
643 | hg.update(repo, parent.node()) |
|
643 | hg.update(repo, parent.node()) | |
@@ -862,14 +862,14 b' def unshelvecontinue(ui, repo, state, op' | |||||
862 | shelvectx = repo[state.parents[1]] |
|
862 | shelvectx = repo[state.parents[1]] | |
863 | pendingctx = state.pendingctx |
|
863 | pendingctx = state.pendingctx | |
864 |
|
864 | |||
865 |
with repo.dirstate. |
|
865 | with repo.dirstate.changing_parents(repo): | |
866 | repo.setparents(state.pendingctx.node(), repo.nullid) |
|
866 | repo.setparents(state.pendingctx.node(), repo.nullid) | |
867 | repo.dirstate.write(repo.currenttransaction()) |
|
867 | repo.dirstate.write(repo.currenttransaction()) | |
868 |
|
868 | |||
869 | targetphase = _target_phase(repo) |
|
869 | targetphase = _target_phase(repo) | |
870 | overrides = {(b'phases', b'new-commit'): targetphase} |
|
870 | overrides = {(b'phases', b'new-commit'): targetphase} | |
871 | with repo.ui.configoverride(overrides, b'unshelve'): |
|
871 | with repo.ui.configoverride(overrides, b'unshelve'): | |
872 |
with repo.dirstate. |
|
872 | with repo.dirstate.changing_parents(repo): | |
873 | repo.setparents(state.parents[0], repo.nullid) |
|
873 | repo.setparents(state.parents[0], repo.nullid) | |
874 | newnode, ispartialunshelve = _createunshelvectx( |
|
874 | newnode, ispartialunshelve = _createunshelvectx( | |
875 | ui, repo, shelvectx, basename, interactive, opts |
|
875 | ui, repo, shelvectx, basename, interactive, opts | |
@@ -1068,7 +1068,7 b' def _rebaserestoredcommit(' | |||||
1068 | ) |
|
1068 | ) | |
1069 | raise error.ConflictResolutionRequired(b'unshelve') |
|
1069 | raise error.ConflictResolutionRequired(b'unshelve') | |
1070 |
|
1070 | |||
1071 |
with repo.dirstate. |
|
1071 | with repo.dirstate.changing_parents(repo): | |
1072 | repo.setparents(tmpwctx.node(), repo.nullid) |
|
1072 | repo.setparents(tmpwctx.node(), repo.nullid) | |
1073 | newnode, ispartialunshelve = _createunshelvectx( |
|
1073 | newnode, ispartialunshelve = _createunshelvectx( | |
1074 | ui, repo, shelvectx, basename, interactive, opts |
|
1074 | ui, repo, shelvectx, basename, interactive, opts |
@@ -451,7 +451,7 b' def filterupdatesactions(repo, wctx, mct' | |||||
451 | message, |
|
451 | message, | |
452 | ) |
|
452 | ) | |
453 |
|
453 | |||
454 |
with repo.dirstate. |
|
454 | with repo.dirstate.changing_parents(repo): | |
455 | mergemod.applyupdates( |
|
455 | mergemod.applyupdates( | |
456 | repo, |
|
456 | repo, | |
457 | tmresult, |
|
457 | tmresult, | |
@@ -655,7 +655,7 b' def clearrules(repo, force=False):' | |||||
655 | The remaining sparse config only has profiles, if defined. The working |
|
655 | The remaining sparse config only has profiles, if defined. The working | |
656 | directory is refreshed, as needed. |
|
656 | directory is refreshed, as needed. | |
657 | """ |
|
657 | """ | |
658 |
with repo.wlock(), repo.dirstate. |
|
658 | with repo.wlock(), repo.dirstate.changing_parents(repo): | |
659 | raw = repo.vfs.tryread(b'sparse') |
|
659 | raw = repo.vfs.tryread(b'sparse') | |
660 | includes, excludes, profiles = parseconfig(repo.ui, raw, b'sparse') |
|
660 | includes, excludes, profiles = parseconfig(repo.ui, raw, b'sparse') | |
661 |
|
661 | |||
@@ -671,7 +671,7 b' def importfromfiles(repo, opts, paths, f' | |||||
671 | The updated sparse config is written out and the working directory |
|
671 | The updated sparse config is written out and the working directory | |
672 | is refreshed, as needed. |
|
672 | is refreshed, as needed. | |
673 | """ |
|
673 | """ | |
674 |
with repo.wlock(), repo.dirstate. |
|
674 | with repo.wlock(), repo.dirstate.changing_parents(repo): | |
675 | # read current configuration |
|
675 | # read current configuration | |
676 | raw = repo.vfs.tryread(b'sparse') |
|
676 | raw = repo.vfs.tryread(b'sparse') | |
677 | includes, excludes, profiles = parseconfig(repo.ui, raw, b'sparse') |
|
677 | includes, excludes, profiles = parseconfig(repo.ui, raw, b'sparse') | |
@@ -730,7 +730,7 b' def updateconfig(' | |||||
730 |
|
730 | |||
731 | The new config is written out and a working directory refresh is performed. |
|
731 | The new config is written out and a working directory refresh is performed. | |
732 | """ |
|
732 | """ | |
733 |
with repo.wlock(), repo.lock(), repo.dirstate. |
|
733 | with repo.wlock(), repo.lock(), repo.dirstate.changing_parents(repo): | |
734 | raw = repo.vfs.tryread(b'sparse') |
|
734 | raw = repo.vfs.tryread(b'sparse') | |
735 | oldinclude, oldexclude, oldprofiles = parseconfig( |
|
735 | oldinclude, oldexclude, oldprofiles = parseconfig( | |
736 | repo.ui, raw, b'sparse' |
|
736 | repo.ui, raw, b'sparse' |
@@ -74,7 +74,7 b' have this method available in narrowhg p' | |||||
74 | > narrowspec.copytoworkingcopy(repo) |
|
74 | > narrowspec.copytoworkingcopy(repo) | |
75 | > newmatcher = narrowspec.match(repo.root, includes, excludes) |
|
75 | > newmatcher = narrowspec.match(repo.root, includes, excludes) | |
76 | > added = matchmod.differencematcher(newmatcher, currentmatcher) |
|
76 | > added = matchmod.differencematcher(newmatcher, currentmatcher) | |
77 |
> with repo.dirstate. |
|
77 | > with repo.dirstate.changing_parents(repo): | |
78 | > for f in repo[b'.'].manifest().walk(added): |
|
78 | > for f in repo[b'.'].manifest().walk(added): | |
79 | > repo.dirstate.update_file( |
|
79 | > repo.dirstate.update_file( | |
80 | > f, |
|
80 | > f, |
@@ -17,7 +17,7 b'' | |||||
17 | > try: |
|
17 | > try: | |
18 | > for file in pats: |
|
18 | > for file in pats: | |
19 | > if opts.get('normal_lookup'): |
|
19 | > if opts.get('normal_lookup'): | |
20 |
> with repo.dirstate. |
|
20 | > with repo.dirstate.changing_parents(repo): | |
21 | > repo.dirstate.update_file( |
|
21 | > repo.dirstate.update_file( | |
22 | > file, |
|
22 | > file, | |
23 | > p1_tracked=True, |
|
23 | > p1_tracked=True, |
General Comments 0
You need to be logged in to leave comments.
Login now