D11030: parsers: move DirstateItem to attr.s
durin42 created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11030 AFFECTED FILES mercurial/pure/parsers.py CHANGE DETAILS diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py --- a/mercurial/pure/parsers.py +++ b/mercurial/pure/parsers.py @@ -14,6 +14,7 @@ nullrev, sha1nodeconstants, ) +from ..thirdparty import attr from .. import ( error, pycompat, @@ -43,6 +44,7 @@ AMBIGUOUS_TIME = -1 +@attr.s class DirstateItem(object): """represent a dirstate entry @@ -54,13 +56,10 @@ - mtime, """ -__slot__ = ('_state', '_mode', '_size', '_mtime') - -def __init__(self, state, mode, size, mtime): -self._state = state -self._mode = mode -self._size = size -self._mtime = mtime +_state = attr.ib() +_mode = attr.ib() +_size = attr.ib() +_mtime = attr.ib() def __getitem__(self, idx): if idx == 0 or idx == -4: To: durin42, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
mercurial@47506: 42 new changesets (5 on stable)
42 new changesets (5 on stable) in mercurial: https://www.mercurial-scm.org/repo/hg/rev/bc8536e09a20 changeset: 47465:bc8536e09a20 parent: 47463:5fa083a5ff04 user:Pierre-Yves David date:Tue Jun 22 11:09:25 2021 +0200 summary: revlog: rewrite `censors.py` to `rewrite.py` https://www.mercurial-scm.org/repo/hg/rev/f7a94e2d4470 changeset: 47466:f7a94e2d4470 user:Pierre-Yves David date:Tue Jun 22 21:22:55 2021 +0200 summary: censor: put the tuple of open files in an explicit variable https://www.mercurial-scm.org/repo/hg/rev/3ab267f0cbe4 changeset: 47467:3ab267f0cbe4 user:Pierre-Yves David date:Tue Jun 22 21:41:33 2021 +0200 summary: censor: extract the part about writing the censored revision in a function https://www.mercurial-scm.org/repo/hg/rev/9b70aa7bcbab changeset: 47468:9b70aa7bcbab user:Pierre-Yves David date:Tue Jun 22 21:49:31 2021 +0200 summary: censor: extract the part about writing the other revision in a function https://www.mercurial-scm.org/repo/hg/rev/60c48458ee6c changeset: 47469:60c48458ee6c user:Pierre-Yves David date:Tue Jun 22 22:10:22 2021 +0200 summary: censor: extract the part about recomputing delta in a function https://www.mercurial-scm.org/repo/hg/rev/d6afe1478a2a changeset: 47470:d6afe1478a2a user:Pierre-Yves David date:Tue Jun 22 22:28:51 2021 +0200 summary: censor: extract the part about creating and opening new files in a function https://www.mercurial-scm.org/repo/hg/rev/aab064416f0c changeset: 47471:aab064416f0c user:Pierre-Yves David date:Tue Jun 22 22:35:37 2021 +0200 summary: censor: rename `rl` to `revlog` in the main function https://www.mercurial-scm.org/repo/hg/rev/c81a5297f185 changeset: 47472:c81a5297f185 user:Pierre-Yves David date:Tue Jun 22 23:20:32 2021 +0200 summary: censor: migrate the logic to a set of `censor_revs` https://www.mercurial-scm.org/repo/hg/rev/5045ba2a3afd changeset: 47473:5045ba2a3afd user:Pierre-Yves David date:Tue Jun 22 22:52:08 2021 +0200 summary: censor: split the core of the logic into its own function https://www.mercurial-scm.org/repo/hg/rev/c657beacdf2e changeset: 47474:c657beacdf2e user:Simon Sapin date:Fri Jun 04 15:26:38 2021 +0200 summary: dirstate-v2: Drop cached read_dir results after .hgignore changes https://www.mercurial-scm.org/repo/hg/rev/94e38822d395 changeset: 47475:94e38822d395 user:Simon Sapin date:Thu Jun 24 21:54:14 2021 +0200 summary: status: Extend read_dir caching to directories with ignored files https://www.mercurial-scm.org/repo/hg/rev/f23eafb036af changeset: 47476:f23eafb036af user:Simon Sapin date:Mon Jun 28 15:41:50 2021 +0200 summary: dirstate-v2: Use 32-bit integers instead of 64-bit for offsets https://www.mercurial-scm.org/repo/hg/rev/eb416759af7e changeset: 47477:eb416759af7e user:Simon Sapin date:Mon Jun 28 15:52:10 2021 +0200 summary: dirstate: Removed unused instances of `DirsMultiset` https://www.mercurial-scm.org/repo/hg/rev/ca8121d26732 changeset: 47478:ca8121d26732 user:Simon Sapin date:Mon Jun 28 16:50:19 2021 +0200 summary: dirstate-tree: Keep a counter of descendant nodes that have an entry https://www.mercurial-scm.org/repo/hg/rev/e6b303eb8f7d changeset: 47479:e6b303eb8f7d user:Pierre-Yves David date:Thu Jul 01 18:56:34 2021 +0200 summary: dirstate: split a not-so-one-liner https://www.mercurial-scm.org/repo/hg/rev/f93298a48da1 changeset: 47480:f93298a48da1 user:Pierre-Yves David date:Thu Jul 01 18:57:35 2021 +0200 summary: dirstate: split a not-so-one-liner https://www.mercurial-scm.org/repo/hg/rev/612f5f36fcf6 changeset: 47481:612f5f36fcf6 user:Pierre-Yves David date:Thu Jul 01 18:59:29 2021 +0200 summary: dirstate: split a not-so-one-liner https://www.mercurial-scm.org/repo/hg/rev/cb29484eaade changeset: 47482:cb29484eaade user:Pierre-Yves David date:Thu Jul 01 19:04:11 2021 +0200 summary: dirstate: introduce a symbolic constant for the FROM_P2 marker https://www.mercurial-scm.org/repo/hg/rev/4ac418b4a6af changeset: 47483:4ac418b4a6af user:Pierre-Yves David date:Thu Jul 01 19:15:22 2021 +0200 summary: dirstate: introduce a symbolic constant for the NONNORMAL marker https://www.mercurial-scm.org/repo/hg/rev/3f13dfa1fa78 changeset: 47484:3f13dfa1fa78 user:Pierre-Yves David date:Thu Jul 01 19:15:30 2021 +0200 summary: dirstate: introduce a symbolic constant for the AMBIGUOUS_TIME marker https://www.mercurial-scm.org/repo/hg/rev/5eb65ec12465 changeset: 47485:5eb65ec12465 user:Pierre-Yves David date:Fri Jul 02 01:02:46 2021 +0200 summary: dirstate: move the _rangemask filtering closer to its
D11026: revert: use `set_untracked` instead of `drop` when applicable
marmoute created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11026 AFFECTED FILES mercurial/cmdutil.py CHANGE DETAILS diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -3569,12 +3569,12 @@ ) if choice == 0: prntstatusmsg(b'forget', f) -repo.dirstate.drop(f) +repo.dirstate.set_untracked(f) else: excluded_files.append(f) else: prntstatusmsg(b'forget', f) -repo.dirstate.drop(f) +repo.dirstate.set_untracked(f) for f in actions[b'remove'][0]: audit_path(f) if interactive: To: marmoute, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D11028: parse: make sure we adjust the dirstate while adjust the dirstate to parent
marmoute created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY This is more correct and help our API split. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11028 AFFECTED FILES mercurial/context.py CHANGE DETAILS diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -2022,13 +2022,13 @@ self._repo.dirstate.setparents(node) self._repo._quick_access_changeid_invalidate() +sparse.aftercommit(self._repo, node) + # write changes out explicitly, because nesting wlock at # runtime may prevent 'wlock.release()' in 'repo.commit()' # from immediately doing so for subsequent changing files self._repo.dirstate.write(self._repo.currenttransaction()) -sparse.aftercommit(self._repo, node) - def mergestate(self, clean=False): if clean: return mergestatemod.mergestate.clean(self._repo) To: marmoute, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D11029: sparse: clear rules in the context of a `parentchanges` context
marmoute created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY This is the same logic as the change we did for narrow. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11029 AFFECTED FILES mercurial/sparse.py CHANGE DETAILS diff --git a/mercurial/sparse.py b/mercurial/sparse.py --- a/mercurial/sparse.py +++ b/mercurial/sparse.py @@ -630,7 +630,7 @@ The remaining sparse config only has profiles, if defined. The working directory is refreshed, as needed. """ -with repo.wlock(): +with repo.wlock(), repo.dirstate.parentchange(): raw = repo.vfs.tryread(b'sparse') includes, excludes, profiles = parseconfig(repo.ui, raw, b'sparse') @@ -708,7 +708,7 @@ The new config is written out and a working directory refresh is performed. """ -with repo.wlock(): +with repo.wlock(), repo.dirstate.parentchange(): raw = repo.vfs.tryread(b'sparse') oldinclude, oldexclude, oldprofiles = parseconfig( repo.ui, raw, b'sparse' To: marmoute, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D11027: narrow: update narrow spec within a dirstate.parentchange context
marmoute created this revision. Herald added a reviewer: durin42. Herald added a reviewer: martinvonz. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY Even if the parents does not changes, the parents' content we consider is changed. So this seems legitimate. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11027 AFFECTED FILES hgext/narrow/narrowcommands.py CHANGE DETAILS diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py --- a/hgext/narrow/narrowcommands.py +++ b/hgext/narrow/narrowcommands.py @@ -321,8 +321,9 @@ repo.store.markremoved(f) ui.status(_(b'deleting unwanted files from working copy\n')) -narrowspec.updateworkingcopy(repo, assumeclean=True) -narrowspec.copytoworkingcopy(repo) +with repo.dirstate.parentchange(): +narrowspec.updateworkingcopy(repo, assumeclean=True) +narrowspec.copytoworkingcopy(repo) repo.destroyed() @@ -422,7 +423,7 @@ with ds.parentchange(): ds.setparents(p1, p2) -with repo.transaction(b'widening'): +with repo.transaction(b'widening'), repo.dirstate.parentchange(): repo.setnewnarrowpats() narrowspec.updateworkingcopy(repo) narrowspec.copytoworkingcopy(repo) @@ -589,7 +590,9 @@ return 0 if update_working_copy: -with repo.wlock(), repo.lock(), repo.transaction(b'narrow-wc'): +with repo.wlock(), repo.lock(), repo.transaction( +b'narrow-wc' +), repo.dirstate.parentchange(): narrowspec.updateworkingcopy(repo) narrowspec.copytoworkingcopy(repo) return 0 To: marmoute, durin42, martinvonz, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Failed pipeline for branch/default | mercurial-devel | 0a05a610
Pipeline #24130 has failed! Project: mercurial-devel ( https://foss.heptapod.net/octobus/mercurial-devel ) Branch: branch/default ( https://foss.heptapod.net/octobus/mercurial-devel/-/commits/branch/default ) Commit: 0a05a610 ( https://foss.heptapod.net/octobus/mercurial-devel/-/commit/0a05a610e50f33cb5cd28e8f597c0fe8824fcb27 ) Commit Message: dirstate: drop the last explicit `state` usage ... Commit Author: Pierre-Yves David ( https://foss.heptapod.net/marmoute ) Pipeline #24130 ( https://foss.heptapod.net/octobus/mercurial-devel/-/pipelines/24130 ) triggered by Administrator ( https://foss.heptapod.net/root ) had 1 failed build. Job #215892 ( https://foss.heptapod.net/octobus/mercurial-devel/-/jobs/215892/raw ) Stage: tests Name: test-py3-rhg -- You're receiving this email because of your account on foss.heptapod.net. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D11025: ci-windows: introduce manual windows CI
Alphare created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY Note: most of the foundational work of this commit was done by Matt Harbison, but enough has changed that I don't feel comfortable sending this patch as his. In our quest to remove Python 2 from Mercurial, we need to get Windows CI going to check that Python 3 support is up to an acceptable standard. This is the first step: adding a manual step to run a full Windows CI, with a certain definition of "full" since some things are not installed yet, like SVN. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11025 AFFECTED FILES contrib/heptapod-ci.yml CHANGE DETAILS diff --git a/contrib/heptapod-ci.yml b/contrib/heptapod-ci.yml --- a/contrib/heptapod-ci.yml +++ b/contrib/heptapod-ci.yml @@ -139,3 +139,35 @@ RUNTEST_ARGS: " --allow-slow-tests tests/test-check-pytype.t" PYTHON: python3 TEST_HGMODULEPOLICY: "c" + +# `sh.exe --login` sets a couple of extra environment variables that are defined +# in the MinGW shell, but switches CWD to /home/$username. The previous value +# is stored in OLDPWD. Of the added variables, MSYSTEM is crucial to running +# run-tests.py- it is needed to make run-tests.py generate a `python3` script +# that satisfies the various shebang lines and delegates to `py -3`. +.window_runtests_template: _runtests +stage: tests +before_script: + # Temporary until this is adjusted in the environment + - $Env:TEMP="C:/Temp" + - $Env:TMP="C:/Temp" + # TODO: find/install cvs, bzr, perforce, gpg, sqlite3 + +script: +- echo "Entering script section" +- echo "python used, $Env:PYTHON" +- Invoke-Expression "$Env:PYTHON -V" +- Invoke-Expression "$Env:PYTHON -m black --version" +- echo "$Env:RUNTEST_ARGS" + +- C:/MinGW/msys/1.0/bin/sh.exe --login -c 'cd "$OLDPWD" && HGTESTS_ALLOW_NETIO="$TEST_HGTESTS_ALLOW_NETIO" HGMODULEPOLICY="$TEST_HGMODULEPOLICY" $PYTHON tests/run-tests.py --color=always $RUNTEST_ARGS' + +windows-py3: +<<: *windows_runtests +when: manual +tags: + - windows +timeout: 2h +variables: +RUNTEST_ARGS: "--blacklist /tmp/check-tests.txt" +PYTHON: py -3 To: Alphare, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D11024: encoding: move case-related utils up
Alphare created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY This will be useful for the next commit that needs this code earlier. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11024 AFFECTED FILES mercurial/encoding.py CHANGE DETAILS diff --git a/mercurial/encoding.py b/mercurial/encoding.py --- a/mercurial/encoding.py +++ b/mercurial/encoding.py @@ -284,6 +284,57 @@ strmethod = pycompat.identity + +def lower(s): +# type: (bytes) -> bytes +"""best-effort encoding-aware case-folding of local string s""" +try: +return asciilower(s) +except UnicodeDecodeError: +pass +try: +if isinstance(s, localstr): +u = s._utf8.decode("utf-8") +else: +u = s.decode(_sysstr(encoding), _sysstr(encodingmode)) + +lu = u.lower() +if u == lu: +return s # preserve localstring +return lu.encode(_sysstr(encoding)) +except UnicodeError: +return s.lower() # we don't know how to fold this except in ASCII +except LookupError as k: +raise error.Abort(k, hint=b"please check your locale settings") + + +def upper(s): +# type: (bytes) -> bytes +"""best-effort encoding-aware case-folding of local string s""" +try: +return asciiupper(s) +except UnicodeDecodeError: +return upperfallback(s) + + +def upperfallback(s): +# type: (Any) -> Any +try: +if isinstance(s, localstr): +u = s._utf8.decode("utf-8") +else: +u = s.decode(_sysstr(encoding), _sysstr(encodingmode)) + +uu = u.upper() +if u == uu: +return s # preserve localstring +return uu.encode(_sysstr(encoding)) +except UnicodeError: +return s.upper() # we don't know how to fold this except in ASCII +except LookupError as k: +raise error.Abort(k, hint=b"please check your locale settings") + + if not _nativeenviron: # now encoding and helper functions are available, recreate the environ # dict to be exported to other modules @@ -441,56 +492,6 @@ return ellipsis # no enough room for multi-column characters -def lower(s): -# type: (bytes) -> bytes -"""best-effort encoding-aware case-folding of local string s""" -try: -return asciilower(s) -except UnicodeDecodeError: -pass -try: -if isinstance(s, localstr): -u = s._utf8.decode("utf-8") -else: -u = s.decode(_sysstr(encoding), _sysstr(encodingmode)) - -lu = u.lower() -if u == lu: -return s # preserve localstring -return lu.encode(_sysstr(encoding)) -except UnicodeError: -return s.lower() # we don't know how to fold this except in ASCII -except LookupError as k: -raise error.Abort(k, hint=b"please check your locale settings") - - -def upper(s): -# type: (bytes) -> bytes -"""best-effort encoding-aware case-folding of local string s""" -try: -return asciiupper(s) -except UnicodeDecodeError: -return upperfallback(s) - - -def upperfallback(s): -# type: (Any) -> Any -try: -if isinstance(s, localstr): -u = s._utf8.decode("utf-8") -else: -u = s.decode(_sysstr(encoding), _sysstr(encodingmode)) - -uu = u.upper() -if u == uu: -return s # preserve localstring -return uu.encode(_sysstr(encoding)) -except UnicodeError: -return s.upper() # we don't know how to fold this except in ASCII -except LookupError as k: -raise error.Abort(k, hint=b"please check your locale settings") - - class normcasespecs(object): """what a platform's normcase does to ASCII strings To: Alphare, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Failed pipeline for branch/default | mercurial-devel | 49169413
Pipeline #24110 has failed! Project: mercurial-devel ( https://foss.heptapod.net/octobus/mercurial-devel ) Branch: branch/default ( https://foss.heptapod.net/octobus/mercurial-devel/-/commits/branch/default ) Commit: 49169413 ( https://foss.heptapod.net/octobus/mercurial-devel/-/commit/4916941309b3456b77b86545df0e25a37b202eb1 ) Commit Message: tests: add test case for issue 6262 If you spl... Commit Author: Martin von Zweigbergk ( https://foss.heptapod.net/martinvonz ) Pipeline #24110 ( https://foss.heptapod.net/octobus/mercurial-devel/-/pipelines/24110 ) triggered by Administrator ( https://foss.heptapod.net/root ) had 1 failed build. Job #215586 ( https://foss.heptapod.net/octobus/mercurial-devel/-/jobs/215586/raw ) Stage: phabricator Name: phabricator-refresh -- You're receiving this email because of your account on foss.heptapod.net. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Failed pipeline for branch/default | mercurial-devel | 57fb91be
Pipeline #24099 has failed! Project: mercurial-devel ( https://foss.heptapod.net/octobus/mercurial-devel ) Branch: branch/default ( https://foss.heptapod.net/octobus/mercurial-devel/-/commits/branch/default ) Commit: 57fb91be ( https://foss.heptapod.net/octobus/mercurial-devel/-/commit/57fb91bea6e694f0ee0a5b6712709f0ef88a4342 ) Commit Message: tests: add test case for issue 6262 If you spl... Commit Author: Martin von Zweigbergk ( https://foss.heptapod.net/martinvonz ) Pipeline #24099 ( https://foss.heptapod.net/octobus/mercurial-devel/-/pipelines/24099 ) triggered by Pulkit Goyal ( https://foss.heptapod.net/pulkit.goyal ) had 4 failed builds. Job #215415 ( https://foss.heptapod.net/octobus/mercurial-devel/-/jobs/215415/raw ) Stage: tests Name: test-py2-rust Job #215418 ( https://foss.heptapod.net/octobus/mercurial-devel/-/jobs/215418/raw ) Stage: tests Name: test-py2-chg Job #215411 ( https://foss.heptapod.net/octobus/mercurial-devel/-/jobs/215411/raw ) Stage: tests Name: test-py2 Job #215413 ( https://foss.heptapod.net/octobus/mercurial-devel/-/jobs/215413/raw ) Stage: tests Name: test-py2-pure -- You're receiving this email because of your account on foss.heptapod.net. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D11023: dirstate: introduce and internal `_drop` method
marmoute created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY dropping a file from the dirstate is decision that the dirstate itself should be able to move. So we will slowly migrate caller to more appropriate API. In order to easily find caller from current (soon, old) API, we introduce an internal method that internal dirstate code can call when necessary. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11023 AFFECTED FILES mercurial/dirstate.py CHANGE DETAILS diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -572,10 +572,14 @@ def drop(self, f): '''Drop a file from the dirstate''' -if self._map.dropfile(f): +self._drop(f) + +def _drop(self, filename): +"""internal function to drop a file from the dirstate""" +if self._map.dropfile(filename): self._dirty = True -self._updatedfiles.add(f) -self._map.copymap.pop(f, None) +self._updatedfiles.add(filename) +self._map.copymap.pop(filename, None) def _discoverpath(self, path, normed, ignoremissing, exists, storemap): if exists is None: @@ -689,7 +693,7 @@ for f in to_lookup: self.normallookup(f) for f in to_drop: -self.drop(f) +self._drop(f) self._dirty = True To: marmoute, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D11021: mq: use `set_untracked` in `qrename`
marmoute created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY This is the new shinny API. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11021 AFFECTED FILES hgext/mq.py CHANGE DETAILS diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -3639,7 +3639,7 @@ wctx = r[None] with r.wlock(): if r.dirstate[patch] == b'a': -r.dirstate.drop(patch) +r.dirstate.set_untracked(patch) r.dirstate.set_tracked(name) else: wctx.copy(patch, name) To: marmoute, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D11022: revert: use `set_untracked` when performing a revert
marmoute created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY This is the new shinny API. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11022 AFFECTED FILES mercurial/cmdutil.py CHANGE DETAILS diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -3554,7 +3554,7 @@ repo.wvfs.unlinkpath(f, rmdir=rmdir) except OSError: pass -repo.dirstate.remove(f) +repo.dirstate.set_untracked(f) def prntstatusmsg(action, f): exact = names[f] @@ -3592,7 +3592,7 @@ for f in actions[b'drop'][0]: audit_path(f) prntstatusmsg(b'drop', f) -repo.dirstate.remove(f) +repo.dirstate.set_untracked(f) normal = None if node == parent: To: marmoute, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D11020: context: use `dirstate.set_untracked` in context.forget
marmoute created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY This is the new shinny API. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11020 AFFECTED FILES mercurial/context.py CHANGE DETAILS diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -1711,13 +1711,9 @@ uipath = lambda f: ds.pathto(pathutil.join(prefix, f)) rejected = [] for f in files: -if f not in ds: +if not ds.set_untracked(f): self._repo.ui.warn(_(b"%s not tracked!\n") % uipath(f)) rejected.append(f) -elif ds[f] != b'a': -ds.remove(f) -else: -ds.drop(f) return rejected def copy(self, source, dest): To: marmoute, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D11018: mq: use `set_tracked` in `qrename`
marmoute created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY This is the new shinny API. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11018 AFFECTED FILES hgext/mq.py CHANGE DETAILS diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -3640,7 +3640,7 @@ with r.wlock(): if r.dirstate[patch] == b'a': r.dirstate.drop(patch) -r.dirstate.add(name) +r.dirstate.set_tracked(name) else: wctx.copy(patch, name) wctx.forget([patch]) To: marmoute, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D11017: mq: update the dirstate and its parent within a `parentchange` context
marmoute created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY This is more correct, and move our plan of separated API for different dirstate usage forward. note: maybe the `parentchange` context manager should replace the dirstateguard entirely ? (in this case we should probably deprecated dirstateguard). REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11017 AFFECTED FILES hgext/mq.py CHANGE DETAILS diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -2002,67 +2002,68 @@ bmlist = repo[top].bookmarks() -dsguard = None -try: -dsguard = dirstateguard.dirstateguard(repo, b'mq.refresh') -if diffopts.git or diffopts.upgrade: -copies = {} -for dst in a: -src = repo.dirstate.copied(dst) -# during qfold, the source file for copies may -# be removed. Treat this as a simple add. -if src is not None and src in repo.dirstate: -copies.setdefault(src, []).append(dst) -repo.dirstate.add(dst) -# remember the copies between patchparent and qtip -for dst in aaa: -src = ctx[dst].copysource() -if src: -copies.setdefault(src, []).extend( -copies.get(dst, []) -) -if dst in a: -copies[src].append(dst) -# we can't copy a file created by the patch itself -if dst in copies: -del copies[dst] -for src, dsts in pycompat.iteritems(copies): -for dst in dsts: -repo.dirstate.copy(src, dst) -else: -for dst in a: -repo.dirstate.add(dst) -# Drop useless copy information -for f in list(repo.dirstate.copies()): -repo.dirstate.copy(None, f) -for f in r: -repo.dirstate.remove(f) -# if the patch excludes a modified file, mark that -# file with mtime=0 so status can see it. -mm = [] -for i in pycompat.xrange(len(m) - 1, -1, -1): -if not match1(m[i]): -mm.append(m[i]) -del m[i] -for f in m: -repo.dirstate.normal(f) -for f in mm: -repo.dirstate.normallookup(f) -for f in forget: -repo.dirstate.drop(f) - -user = ph.user or ctx.user() - -oldphase = repo[top].phase() - -# assumes strip can roll itself back if interrupted -repo.setparents(*cparents) -self.applied.pop() -self.applieddirty = True -strip(self.ui, repo, [top], update=False, backup=False) -dsguard.close() -finally: -release(dsguard) +with repo.dirstate.parentchange(): +dsguard = None +try: +dsguard = dirstateguard.dirstateguard(repo, b'mq.refresh') +if diffopts.git or diffopts.upgrade: +copies = {} +for dst in a: +src = repo.dirstate.copied(dst) +# during qfold, the source file for copies may +# be removed. Treat this as a simple add. +if src is not None and src in repo.dirstate: +copies.setdefault(src, []).append(dst) +repo.dirstate.add(dst) +# remember the copies between patchparent and qtip +for dst in aaa: +src = ctx[dst].copysource() +if src: +copies.setdefault(src, []).extend( +copies.get(dst, []) +) +if dst in a: +copies[src].append(dst) +# we can't copy a file created by the patch itself +if dst in copies: +del copies[dst] +for src, dsts in pycompat.iteritems(copies): +for dst in dsts: +repo.dirstate.copy(src,
D11019: dirstate: add a set_untracked method for "hg remove"-like usage
marmoute created this revision. Herald added a reviewer: durin42. Herald added a reviewer: martinvonz. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY This is a step further toward clarifying the semantic of various dirstate call. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11019 AFFECTED FILES hgext/largefiles/lfutil.py hgext/narrow/narrowdirstate.py hgext/sparse.py mercurial/dirstate.py CHANGE DETAILS diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -460,6 +460,27 @@ return True return False +def set_untracked(self, filename): +"""a "public" method for generic code to mark a file as untracked + +This function is to be called outside of "update/merge" case. For +example by a command like `hg remove X`. + +return True the file was previously tracked, False otherwise. +""" +if self._parentwriters > 0: +msg = b'calling set_tracked inside a parentchange context' +raise error.ProgrammingError(msg) +entry = self._map.get(filename) +if entry is None: +return False +elif entry.added: +self.drop(filename) +return True +else: +self._remove(filename) +return True + def update_file_reference( self, filename, diff --git a/hgext/sparse.py b/hgext/sparse.py --- a/hgext/sparse.py +++ b/hgext/sparse.py @@ -257,6 +257,7 @@ editfuncs = [ b'normal', b'set_tracked', +b'set_untracked', b'add', b'normallookup', b'copy', diff --git a/hgext/narrow/narrowdirstate.py b/hgext/narrow/narrowdirstate.py --- a/hgext/narrow/narrowdirstate.py +++ b/hgext/narrow/narrowdirstate.py @@ -42,6 +42,10 @@ return super(narrowdirstate, self).set_tracked(*args) @_editfunc +def set_untracked(self, *args): +return super(narrowdirstate, self).set_untracked(*args) + +@_editfunc def add(self, *args): return super(narrowdirstate, self).add(*args) diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py --- a/hgext/largefiles/lfutil.py +++ b/hgext/largefiles/lfutil.py @@ -165,6 +165,9 @@ def set_tracked(self, f): return super(largefilesdirstate, self).set_tracked(unixpath(f)) +def set_untracked(self, f): +return super(largefilesdirstate, self).set_untracked(unixpath(f)) + def normal(self, f): return super(largefilesdirstate, self).normal(unixpath(f)) To: marmoute, durin42, martinvonz, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D11016: context: use `dirstate.set_tracked` for `revert`
marmoute created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY This is the new shinny API. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11016 AFFECTED FILES mercurial/cmdutil.py CHANGE DETAILS diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -3693,7 +3693,7 @@ if f not in newlyaddedandmodifiedfiles: prntstatusmsg(b'add', f) checkout(f) -repo.dirstate.add(f) +repo.dirstate.set_tracked(f) normal = repo.dirstate.normallookup if node == parent and p2 == repo.nullid: To: marmoute, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D11015: context: use `dirstate.set_tracked` in context.copy
marmoute created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY This is the new shinny API. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11015 AFFECTED FILES mercurial/context.py CHANGE DETAILS diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -1738,10 +1738,7 @@ else: with self._repo.wlock(): ds = self._repo.dirstate -if ds[dest] in b'?': -ds.add(dest) -elif ds[dest] in b'r': -ds.normallookup(dest) +ds.set_tracked(dest) ds.copy(source, dest) def match( To: marmoute, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D11014: context: use `dirstate.set_tracked` in context.add
marmoute created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY This is the new shinny API. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11014 AFFECTED FILES mercurial/context.py CHANGE DETAILS diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -1701,12 +1701,8 @@ % uipath(f) ) rejected.append(f) -elif ds[f] in b'amn': +elif not ds.set_tracked(f): ui.warn(_(b"%s already tracked!\n") % uipath(f)) -elif ds[f] == b'r': -ds.normallookup(f) -else: -ds.add(f) return rejected def forget(self, files, prefix=b""): To: marmoute, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D11013: dirstate: add a set_tracked method for "hg add"-like usage
marmoute created this revision. Herald added a reviewer: durin42. Herald added a reviewer: martinvonz. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY This is a step further toward clarifying the semantic of various dirstate call. Having a dedicated function comes with a couple of benefits: 1. we can move duplicated logic about how to handle the previous state within the dirstate. Since we are sure this is always called in the same situation, we can implement that logic once in the dirstate. 2. having a dedicated method for this case unlock having a dedicated method for the other case and recording more information at that time. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11013 AFFECTED FILES hgext/largefiles/lfutil.py hgext/narrow/narrowdirstate.py hgext/sparse.py mercurial/dirstate.py CHANGE DETAILS diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -440,6 +440,26 @@ def copies(self): return self._map.copymap +def set_tracked(self, filename): +"""a "public" method for generic code to mark a file as tracked + +This function is to be called outside of "update/merge" case. For +example by a command like `hg add X`. + +return True the file was previously untracked, False otherwise. +""" +if self._parentwriters > 0: +msg = b'calling set_tracked inside a parentchange context' +raise error.ProgrammingError(msg) +entry = self._map.get(filename) +if entry is None: +self._add(filename) +return True +elif not entry.tracked: +self.normallookup(filename) +return True +return False + def update_file_reference( self, filename, diff --git a/hgext/sparse.py b/hgext/sparse.py --- a/hgext/sparse.py +++ b/hgext/sparse.py @@ -256,6 +256,7 @@ # Prevent adding files that are outside the sparse checkout editfuncs = [ b'normal', +b'set_tracked', b'add', b'normallookup', b'copy', diff --git a/hgext/narrow/narrowdirstate.py b/hgext/narrow/narrowdirstate.py --- a/hgext/narrow/narrowdirstate.py +++ b/hgext/narrow/narrowdirstate.py @@ -38,6 +38,10 @@ return super(narrowdirstate, self).normal(*args, **kwargs) @_editfunc +def set_tracked(self, *args): +return super(narrowdirstate, self).set_tracked(*args) + +@_editfunc def add(self, *args): return super(narrowdirstate, self).add(*args) diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py --- a/hgext/largefiles/lfutil.py +++ b/hgext/largefiles/lfutil.py @@ -162,6 +162,9 @@ def __getitem__(self, key): return super(largefilesdirstate, self).__getitem__(unixpath(key)) +def set_tracked(self, f): +return super(largefilesdirstate, self).set_tracked(unixpath(f)) + def normal(self, f): return super(largefilesdirstate, self).normal(unixpath(f)) To: marmoute, durin42, martinvonz, #hg-reviewers Cc: mercurial-patches, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel