D11670: rhg: fix formatting error reported by test-check-format-rust.t
martinvonz 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/D11670 AFFECTED FILES rust/hg-core/src/operations/cat.rs CHANGE DETAILS diff --git a/rust/hg-core/src/operations/cat.rs b/rust/hg-core/src/operations/cat.rs --- a/rust/hg-core/src/operations/cat.rs +++ b/rust/hg-core/src/operations/cat.rs @@ -104,10 +104,8 @@ bytes.extend(file_log.data_for_node(file_node)?.data()?); } -let missing: Vec = missing -.iter() -.map(|file| (*file).to_owned()) -.collect(); +let missing: Vec = +missing.iter().map(|file| (*file).to_owned()).collect(); Ok(CatOutput { found_any, concatenated: bytes, To: 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
D11669: chistedit: add option to show order of commits in opposite order
martinvonz created this revision. Herald added a reviewer: durin42. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY Many users (including me) expect the order of commits in histedit to match the order in `hg log -G` and are confused because it doesnn't. This patch adds an option to show later commits first in the list. I've only added support for it in chistedit for now. As a consequence, I've marked the config option experimental (I think it should apply to both interfaces before it graduates). REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11669 AFFECTED FILES hgext/histedit.py CHANGE DETAILS diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -282,6 +282,11 @@ default=None, ) configitem(b'histedit', b'summary-template', default=b'{rev} {desc|firstline}') +# TODO: Teach the text-based histedit interface to respect this config option +# before we make it non-experimental. +configitem( +b'histedit', b'later-commits-first', default=False, experimental=True +) # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should @@ -1240,6 +1245,11 @@ self.repo = repo self.rules = rules self.stdscr = stdscr +self.later_on_top = repo.ui.configbool( +b'histedit', b'later-commits-first' +) +# The current item in display order, initialized to point to the top +# of the screen. self.pos = 0 self.selected = None self.mode = (MODE_INIT, MODE_INIT) @@ -1256,7 +1266,7 @@ def render_commit(self, win): """Renders the commit window that shows the log of the current selected commit""" -rule = self.rules[self.pos] +rule = self.rules[self.display_pos_to_rule_pos(self.pos)] ctx = rule.ctx win.box() @@ -1342,6 +1352,19 @@ b'main': (mainlen, maxx), } +def display_pos_to_rule_pos(self, display_pos): +"""Converts a position in display order to rule order. + +The `display_pos` is the order from the top in display order, not +considering which items are currently visible on the screen. Thus, +`display_pos=0` is the item at the top (possibly after scrolling to +the top) +""" +if self.later_on_top: +return len(self.rules) - 1 - display_pos +else: +return display_pos + def render_rules(self, rulesscr): start = self.modes[MODE_RULES][b'line_offset'] @@ -1352,18 +1375,21 @@ ) addln(rulesscr, -1, 0, line, curses.color_pair(COLOR_WARN)) -for y, rule in enumerate(self.rules[start:]): -if y >= self.page_height: -break +for display_pos in range(start, len(self.rules)): +y = display_pos - start +if y < 0 or y >= self.page_height: +continue +rule_pos = self.display_pos_to_rule_pos(display_pos) +rule = self.rules[rule_pos] if len(rule.conflicts) > 0: rulesscr.addstr(y, 0, b" ", curses.color_pair(COLOR_WARN)) else: rulesscr.addstr(y, 0, b" ", curses.COLOR_BLACK) -if y + start == self.selected: +if display_pos == self.selected: rollcolor = COLOR_ROLL_SELECTED addln(rulesscr, y, 2, rule, curses.color_pair(COLOR_SELECTED)) -elif y + start == self.pos: +elif display_pos == self.pos: rollcolor = COLOR_ROLL_CURRENT addln( rulesscr, @@ -1477,7 +1503,7 @@ def patch_contents(self): repo = self.repo -rule = self.rules[self.pos] +rule = self.rules[self.display_pos_to_rule_pos(self.pos)] displayer = logcmdutil.changesetdisplayer( repo.ui, repo, @@ -1521,21 +1547,26 @@ def swap(self, oldpos, newpos): """Swap two positions and calculate necessary conflicts in O(|newpos-oldpos|) time""" +old_rule_pos = self.display_pos_to_rule_pos(oldpos) +new_rule_pos = self.display_pos_to_rule_pos(newpos) rules = self.rules -assert 0 <= oldpos < len(rules) and 0 <= newpos < len(rules) - -rules[oldpos], rules[newpos] = rules[newpos], rules[oldpos] +assert 0 <= old_rule_pos < len(rules) and 0 <= new_rule_pos < len(rules) + +rules[old_rule_pos], rules[new_rule_pos] = ( +rules[new_rule_pos], +rules[old_rule_pos], +) # TODO: swap should not know about histeditrule's internals -rules[newpos].pos = newpos -rules[oldpos].pos = oldpos - -start = min(oldpos, newpos) -end = max(oldpos,
D11668: dirstate-v2: add an option to prevent unintentional slow dirstate-v2
marmoute created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY This is the project policy discussed in November 2020 and already put to use for the persistent nodemap. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11668 AFFECTED FILES mercurial/configitems.py mercurial/dirstate.py mercurial/localrepo.py tests/test-dirstate-race.t tests/test-dirstate-race2.t tests/test-dirstate.t tests/test-hgignore.t tests/test-permissions.t tests/test-purge.t tests/test-status.t tests/test-symlinks.t CHANGE DETAILS diff --git a/tests/test-symlinks.t b/tests/test-symlinks.t --- a/tests/test-symlinks.t +++ b/tests/test-symlinks.t @@ -3,8 +3,12 @@ #testcases dirstate-v1 dirstate-v2 #if dirstate-v2 - $ echo '[format]' >> $HGRCPATH - $ echo 'exp-dirstate-v2=1' >> $HGRCPATH + $ cat >> $HGRCPATH << EOF + > [format] + > exp-dirstate-v2=1 + > [storage] + > dirstate-v2.slow-path=allow + > EOF #endif == tests added in 0.7 == diff --git a/tests/test-status.t b/tests/test-status.t --- a/tests/test-status.t +++ b/tests/test-status.t @@ -1,8 +1,12 @@ #testcases dirstate-v1 dirstate-v2 #if dirstate-v2 - $ echo '[format]' >> $HGRCPATH - $ echo 'exp-dirstate-v2=1' >> $HGRCPATH + $ cat >> $HGRCPATH << EOF + > [format] + > exp-dirstate-v2=1 + > [storage] + > dirstate-v2.slow-path=allow + > EOF #endif $ hg init repo1 diff --git a/tests/test-purge.t b/tests/test-purge.t --- a/tests/test-purge.t +++ b/tests/test-purge.t @@ -1,8 +1,12 @@ #testcases dirstate-v1 dirstate-v2 #if dirstate-v2 - $ echo '[format]' >> $HGRCPATH - $ echo 'exp-dirstate-v2=1' >> $HGRCPATH + $ cat >> $HGRCPATH << EOF + > [format] + > exp-dirstate-v2=1 + > [storage] + > dirstate-v2.slow-path=allow + > EOF #endif init diff --git a/tests/test-permissions.t b/tests/test-permissions.t --- a/tests/test-permissions.t +++ b/tests/test-permissions.t @@ -3,8 +3,12 @@ #testcases dirstate-v1 dirstate-v2 #if dirstate-v2 - $ echo '[format]' >> $HGRCPATH - $ echo 'exp-dirstate-v2=1' >> $HGRCPATH + $ cat >> $HGRCPATH << EOF + > [format] + > exp-dirstate-v2=1 + > [storage] + > dirstate-v2.slow-path=allow + > EOF #endif $ hg init t diff --git a/tests/test-hgignore.t b/tests/test-hgignore.t --- a/tests/test-hgignore.t +++ b/tests/test-hgignore.t @@ -1,8 +1,12 @@ #testcases dirstate-v1 dirstate-v2 #if dirstate-v2 - $ echo '[format]' >> $HGRCPATH - $ echo 'exp-dirstate-v2=1' >> $HGRCPATH + $ cat >> $HGRCPATH << EOF + > [format] + > exp-dirstate-v2=1 + > [storage] + > dirstate-v2.slow-path=allow + > EOF #endif $ hg init ignorerepo diff --git a/tests/test-dirstate.t b/tests/test-dirstate.t --- a/tests/test-dirstate.t +++ b/tests/test-dirstate.t @@ -1,8 +1,12 @@ #testcases dirstate-v1 dirstate-v2 #if dirstate-v2 - $ echo '[format]' >> $HGRCPATH - $ echo 'exp-dirstate-v2=1' >> $HGRCPATH + $ cat >> $HGRCPATH << EOF + > [format] + > exp-dirstate-v2=1 + > [storage] + > dirstate-v2.slow-path=allow + > EOF #endif -- Test dirstate._dirs refcounting diff --git a/tests/test-dirstate-race2.t b/tests/test-dirstate-race2.t --- a/tests/test-dirstate-race2.t +++ b/tests/test-dirstate-race2.t @@ -1,8 +1,12 @@ #testcases dirstate-v1 dirstate-v2 #if dirstate-v2 - $ echo '[format]' >> $HGRCPATH - $ echo 'exp-dirstate-v2=1' >> $HGRCPATH + $ cat >> $HGRCPATH << EOF + > [format] + > exp-dirstate-v2=1 + > [storage] + > dirstate-v2.slow-path=allow + > EOF #endif Checking the size/permissions/file-type of files stored in the diff --git a/tests/test-dirstate-race.t b/tests/test-dirstate-race.t --- a/tests/test-dirstate-race.t +++ b/tests/test-dirstate-race.t @@ -1,8 +1,12 @@ #testcases dirstate-v1 dirstate-v2 #if dirstate-v2 - $ echo '[format]' >> $HGRCPATH - $ echo 'exp-dirstate-v2=1' >> $HGRCPATH + $ cat >> $HGRCPATH << EOF + > [format] + > exp-dirstate-v2=1 + > [storage] + > dirstate-v2.slow-path=allow + > EOF #endif $ hg init repo diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1174,6 +1174,32 @@ if slow_path == b'abort': raise error.Abort(msg, hint=hint) options[b'persistent-nodemap'] = True +if requirementsmod.DIRSTATE_V2_REQUIREMENT in requirements: +slow_path = ui.config(b'storage', b'dirstate-v2.slow-path') +if slow_path not in (b'allow', b'warn', b'abort'): +default = ui.config_default(b'storage', b'dirstate-v2.slow-path') +msg = _(b'unknown value for config "dirstate-v2.slow-path": "%s"\n') +ui.warn(msg % slow_path) +if not ui.quiet: +ui.warn(_(b'falling back to default value: %s\n') % default) +slow_path = default + +msg = _( +b"accessing `dirstate-v2` repository without associated " +
mercurial-devel | Failed pipeline for branch/default | 9b98e726
Pipeline #27788 has failed! Project: mercurial-devel ( https://foss.heptapod.net/mercurial/mercurial-devel ) Branch: branch/default ( https://foss.heptapod.net/mercurial/mercurial-devel/-/commits/branch/default ) Commit: 9b98e726 ( https://foss.heptapod.net/mercurial/mercurial-devel/-/commit/9b98e7266ea444fac1dec0cfb18e0c276fd388e1 ) Commit Message: dirstate-v2: Separate HAS_FILE_MTIME and HAS_DI... Commit Author: Simon Sapin ( https://foss.heptapod.net/SimonSapin ) Pipeline #27788 ( https://foss.heptapod.net/mercurial/mercurial-devel/-/pipelines/27788 ) triggered by Administrator ( https://foss.heptapod.net/root ) had 7 failed jobs. Job #253609 ( https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/253609/raw ) Stage: tests Name: test-py2-chg Job #253604 ( https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/253604/raw ) Stage: tests Name: test-py2-pure Job #253606 ( https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/253606/raw ) Stage: tests Name: test-py2-rust Job #253602 ( https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/253602/raw ) Stage: tests Name: test-py2 Job #253608 ( https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/253608/raw ) Stage: tests Name: test-py3-rhg Job #253598 ( https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/253598/raw ) Stage: tests Name: checks-py2 Job #253599 ( https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/253599/raw ) Stage: tests Name: checks-py3 -- 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
D11667: copy: recommend `--at-rev .` if target was added in parent commit
martinvonz created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY If the target file was added in the working copy parent, it's much more likely that the user meant to use `--at-rev .` (to record the copy/rename in the that commit) than `--force` (to replace the just-added file by another file). REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11667 AFFECTED FILES mercurial/cmdutil.py tests/test-rename-rev.t CHANGE DETAILS diff --git a/tests/test-rename-rev.t b/tests/test-rename-rev.t --- a/tests/test-rename-rev.t +++ b/tests/test-rename-rev.t @@ -42,6 +42,17 @@ d1/b A d1/d d1/b +# Should get helpful message if we try to copy or rename after commit + $ hg cp --forget --at-rev . d1/d + saved backup bundle to $TESTTMP/.hg/strip-backup/3f7c325d3f9e-46f377bb-uncopy.hg + $ hg cp d1/b d1/d + d1/d: not overwriting - file already committed + ('hg copy --at-rev .' to record the copy in the parent of the working copy) + [1] + $ hg mv d1/b d1/d + d1/d: not overwriting - file already committed + ('hg rename --at-rev .' to record the rename in the parent of the working copy) + [1] Test moved file (not copied) using 'hg cp' command diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -1678,26 +1678,41 @@ if not opts[b'force']: if already_commited: msg = _(b'%s: not overwriting - file already committed\n') -if after: -flags = b'--after --force' -else: -flags = b'--force' -if rename: -hint = ( -_( -b"('hg rename %s' to replace the file by " -b'recording a rename)\n' +if abstarget in pctx and any( +abssrc in gpctx and abstarget not in gpctx +for gpctx in pctx.parents() +): +if rename: +hint = _( +b"('hg rename --at-rev .' to record the rename " +b"in the parent of the working copy)\n" +) +else: +hint = _( +b"('hg copy --at-rev .' to record the copy in " +b"the parent of the working copy)\n" ) -% flags -) else: -hint = ( -_( -b"('hg copy %s' to replace the file by " -b'recording a copy)\n' +if after: +flags = b'--after --force' +else: +flags = b'--force' +if rename: +hint = ( +_( +b"('hg rename %s' to replace the file by " +b'recording a rename)\n' +) +% flags ) -% flags -) +else: +hint = ( +_( +b"('hg copy %s' to replace the file by " +b'recording a copy)\n' +) +% flags +) else: msg = _(b'%s: not overwriting - file exists\n') if rename: To: 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
D11665: formatting: format with newer black version
martinvonz created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY My `black` was upgraded from 20.8b1-4 to 21.4b2-3 today, which made `test-check-format.t` fail. I don't know if we have specified a particular version we're supposed to use. I also haven't tried to downgrade black to see if the old version will complain about the new format. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11665 AFFECTED FILES mercurial/localrepo.py CHANGE DETAILS diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -360,7 +360,7 @@ common=None, bundlecaps=None, remote_sidedata=None, -**kwargs +**kwargs, ): chunks = exchange.getbundlechunks( self._repo, @@ -369,7 +369,7 @@ common=common, bundlecaps=bundlecaps, remote_sidedata=remote_sidedata, -**kwargs +**kwargs, )[1] cb = util.chunkbuffer(chunks) @@ -2447,7 +2447,7 @@ repo.hook( b'pretxnclose-bookmark', throw=True, -**pycompat.strkwargs(args) +**pycompat.strkwargs(args), ) if hook.hashook(repo.ui, b'pretxnclose-phase'): cl = repo.unfiltered().changelog @@ -2459,7 +2459,7 @@ repo.hook( b'pretxnclose-phase', throw=True, -**pycompat.strkwargs(args) +**pycompat.strkwargs(args), ) repo.hook( @@ -2536,7 +2536,7 @@ repo.hook( b'txnclose-bookmark', throw=False, -**pycompat.strkwargs(args) +**pycompat.strkwargs(args), ) if hook.hashook(repo.ui, b'txnclose-phase'): @@ -2552,7 +2552,7 @@ repo.hook( b'txnclose-phase', throw=False, -**pycompat.strkwargs(args) +**pycompat.strkwargs(args), ) repo.hook( To: 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
D11666: dirstate-v2: delete unused variable (to make test-check-pyflakes.t happy)
martinvonz 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/D11666 AFFECTED FILES mercurial/dirstateutils/v2.py CHANGE DETAILS diff --git a/mercurial/dirstateutils/v2.py b/mercurial/dirstateutils/v2.py --- a/mercurial/dirstateutils/v2.py +++ b/mercurial/dirstateutils/v2.py @@ -149,7 +149,6 @@ else: # There are no mtime-cached directories in the Python implementation flags = 0 -mode = 0 size = 0 mtime_s = 0 mtime_ns = 0 To: 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
D11664: rhg: fix `hg cat` interaction with null revision
aalekseyev 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/D11664 AFFECTED FILES rust/hg-core/src/revlog/revlog.rs tests/test-rhg.t CHANGE DETAILS diff --git a/tests/test-rhg.t b/tests/test-rhg.t --- a/tests/test-rhg.t +++ b/tests/test-rhg.t @@ -129,8 +129,8 @@ $ $NO_FALLBACK rhg cat -r d file-2 2 $ $NO_FALLBACK rhg cat -r file-2 - abort: invalid revision identifier: - [255] + file-2: no such file in rev + [1] Cat files $ cd $TESTTMP diff --git a/rust/hg-core/src/revlog/revlog.rs b/rust/hg-core/src/revlog/revlog.rs --- a/rust/hg-core/src/revlog/revlog.rs +++ b/rust/hg-core/src/revlog/revlog.rs @@ -76,7 +76,8 @@ Some(index_mmap) => { let version = get_version(_mmap)?; if version != 1 { -// A proper new version should have had a repo/store requirement. +// A proper new version should have had a repo/store +// requirement. return Err(HgError::corrupted("corrupted revlog")); } @@ -128,6 +129,9 @@ /// Returns the node ID for the given revision number, if it exists in this /// revlog pub fn node_from_rev(, rev: Revision) -> Option<> { +if rev == NULL_REVISION { +return Some(_NODE); +} Some(self.index.get_entry(rev)?.hash()) } @@ -424,6 +428,6 @@ .with_version(1) .build(); -assert_eq!(get_version().map_err(|_err|()), Ok(1)) +assert_eq!(get_version().map_err(|_err| ()), Ok(1)) } } To: aalekseyev, #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-devel | Failed pipeline for branch/default | 1f550350
Pipeline #27780 has failed! Project: mercurial-devel ( https://foss.heptapod.net/mercurial/mercurial-devel ) Branch: branch/default ( https://foss.heptapod.net/mercurial/mercurial-devel/-/commits/branch/default ) Commit: 1f550350 ( https://foss.heptapod.net/mercurial/mercurial-devel/-/commit/1f550350b8551817f4c126b1f9b1047a5748bebc ) Commit Message: rhg: stop manifest traversal when no more files... Commit Author: Arseniy Alekseyev Pipeline #27780 ( https://foss.heptapod.net/mercurial/mercurial-devel/-/pipelines/27780 ) triggered by Administrator ( https://foss.heptapod.net/root ) had 9 failed jobs. Job #253575 ( https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/253575/raw ) Stage: tests Name: test-py2-rust Job #253578 ( https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/253578/raw ) Stage: tests Name: test-py2-chg Job #253571 ( https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/253571/raw ) Stage: tests Name: test-py2 Job #253573 ( https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/253573/raw ) Stage: tests Name: test-py2-pure Job #253577 ( https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/253577/raw ) Stage: tests Name: test-py3-rhg Job #253579 ( https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/253579/raw ) Stage: tests Name: test-py3-chg Job #253574 ( https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/253574/raw ) Stage: tests Name: test-py3-pure Job #253567 ( https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/253567/raw ) Stage: tests Name: checks-py2 Job #253568 ( https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/253568/raw ) Stage: tests Name: checks-py3 -- 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
D11663: narrow: raise StateError when working copy is stale (for detailed exit code)
martinvonz created this revision. Herald added a reviewer: durin42. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11663 AFFECTED FILES mercurial/narrowspec.py tests/test-narrow-share.t CHANGE DETAILS diff --git a/tests/test-narrow-share.t b/tests/test-narrow-share.t --- a/tests/test-narrow-share.t +++ b/tests/test-narrow-share.t @@ -100,7 +100,7 @@ $ hg -R main files abort: working copy's narrowspec is stale (run 'hg tracked --update-working-copy') - [255] + [20] $ hg -R main tracked --update-working-copy not deleting possibly dirty file d3/f not deleting possibly dirty file d3/g @@ -138,7 +138,7 @@ $ hg -R main files abort: working copy's narrowspec is stale (run 'hg tracked --update-working-copy') - [255] + [20] $ hg -R main tracked --update-working-copy # d1/f, d3/f should be back $ hg -R main files @@ -189,7 +189,7 @@ $ hg ci -Am test abort: working copy's narrowspec is stale (run 'hg tracked --update-working-copy') - [255] + [20] $ hg tracked --update-working-copy $ hg st M d1/f diff --git a/mercurial/narrowspec.py b/mercurial/narrowspec.py --- a/mercurial/narrowspec.py +++ b/mercurial/narrowspec.py @@ -299,7 +299,7 @@ storespec = repo.svfs.tryread(FILENAME) wcspec = repo.vfs.tryread(DIRSTATE_FILENAME) if wcspec != storespec: -raise error.Abort( +raise error.StateError( _(b"working copy's narrowspec is stale"), hint=_(b"run 'hg tracked --update-working-copy'"), ) To: martinvonz, 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
D11662: dirstate-v2: Separate HAS_FILE_MTIME and HAS_DIRECTORY_MTIME flags
SimonSapin created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY Previously the same flag was used, with its meaning based on whether the node otherwise identifies a file tracked anywhere. In addition to being more explicit, this enables storing a directory mtime if a given path used to be tracked in a parent commit (so the dirstate still has data about it) but became a directory in the working copy. (However this is not done yet as it would require a larger change, replacing the `dirstate_map::NodeData` enum with struct fields.) REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11662 AFFECTED FILES mercurial/cext/parsers.c mercurial/cext/util.h mercurial/helptext/internals/dirstate-v2.txt mercurial/pure/parsers.py rust/hg-core/src/dirstate_tree/on_disk.rs CHANGE DETAILS diff --git a/rust/hg-core/src/dirstate_tree/on_disk.rs b/rust/hg-core/src/dirstate_tree/on_disk.rs --- a/rust/hg-core/src/dirstate_tree/on_disk.rs +++ b/rust/hg-core/src/dirstate_tree/on_disk.rs @@ -106,9 +106,10 @@ const P1_TRACKED = 1 << 1; const P2_INFO = 1 << 2; const HAS_MODE_AND_SIZE = 1 << 3; -const HAS_MTIME = 1 << 4; -const MODE_EXEC_PERM = 1 << 5; -const MODE_IS_SYMLINK = 1 << 6; +const HAS_FILE_MTIME = 1 << 4; +const HAS_DIRECTORY_MTIME = 1 << 5; +const MODE_EXEC_PERM = 1 << 6; +const MODE_IS_SYMLINK = 1 << 7; } } @@ -320,13 +321,15 @@ pub(super) fn cached_directory_mtime( , ) -> Result, DirstateV2ParseError> { -Ok( -if self.flags().contains(Flags::HAS_MTIME) && !self.has_entry() { -Some(self.mtime.try_into()?) +if self.flags().contains(Flags::HAS_DIRECTORY_MTIME) { +if self.flags().contains(Flags::HAS_FILE_MTIME) { +Err(DirstateV2ParseError) } else { -None -}, -) +Ok(Some(self.mtime.try_into()?)) +} +} else { +Ok(None) +} } fn synthesize_unix_mode() -> u32 { @@ -353,7 +356,7 @@ } else { None }; -let mtime = if self.flags().contains(Flags::HAS_MTIME) { +let mtime = if self.flags().contains(Flags::HAS_FILE_MTIME) { Some(self.mtime.truncated_seconds.into()) } else { None @@ -422,7 +425,7 @@ 0.into() }; let mtime = if let Some(m) = mtime_opt { -flags.insert(Flags::HAS_MTIME); +flags.insert(Flags::HAS_FILE_MTIME); PackedTruncatedTimestamp { truncated_seconds: m.into(), nanoseconds: 0.into(), @@ -580,9 +583,11 @@ dirstate_map::NodeData::Entry(entry) => { Node::from_dirstate_entry(entry) } -dirstate_map::NodeData::CachedDirectory { mtime } => { -(Flags::HAS_MTIME, 0.into(), (*mtime).into()) -} +dirstate_map::NodeData::CachedDirectory { mtime } => ( +Flags::HAS_DIRECTORY_MTIME, +0.into(), +(*mtime).into(), +), dirstate_map::NodeData::None => ( Flags::empty(), 0.into(), diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py --- a/mercurial/pure/parsers.py +++ b/mercurial/pure/parsers.py @@ -49,9 +49,10 @@ DIRSTATE_V2_P1_TRACKED = 1 << 1 DIRSTATE_V2_P2_INFO = 1 << 2 DIRSTATE_V2_HAS_MODE_AND_SIZE = 1 << 3 -DIRSTATE_V2_HAS_MTIME = 1 << 4 -DIRSTATE_V2_MODE_EXEC_PERM = 1 << 5 -DIRSTATE_V2_MODE_IS_SYMLINK = 1 << 6 +DIRSTATE_V2_HAS_FILE_MTIME = 1 << 4 +_DIRSTATE_V2_HAS_DIRCTORY_MTIME = 1 << 5 # Unused when Rust is not available +DIRSTATE_V2_MODE_EXEC_PERM = 1 << 6 +DIRSTATE_V2_MODE_IS_SYMLINK = 1 << 7 @attr.s(slots=True, init=False) @@ -138,7 +139,7 @@ p1_tracked=bool(flags & DIRSTATE_V2_P1_TRACKED), p2_info=bool(flags & DIRSTATE_V2_P2_INFO), has_meaningful_data=has_mode_size, -has_meaningful_mtime=bool(flags & DIRSTATE_V2_HAS_MTIME), +has_meaningful_mtime=bool(flags & DIRSTATE_V2_HAS_FILE_MTIME), parentfiledata=(mode, size, mtime), ) @@ -329,7 +330,7 @@ if stat.S_ISLNK(self.mode): flags |= DIRSTATE_V2_MODE_IS_SYMLINK if self._mtime is not None: -flags |= DIRSTATE_V2_HAS_MTIME +flags |= DIRSTATE_V2_HAS_FILE_MTIME return (flags, self._size or 0, self._mtime or 0) def v1_state(self): diff --git a/mercurial/helptext/internals/dirstate-v2.txt
D11661: dirstate-v2: Extend node flags to 16 bits
SimonSapin created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY Only 7 out of 8 available bits are used right now. Reserve some more. Future versions of Mercurial may assign meaning to some of these bits, with the limitation that then-older versions will always reset those bits to unset when writing nodes. (A new node is written for any mutation in its subtree, leaving the bytes of the old node unreachable until the data file is rewritten entirely.) REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11661 AFFECTED FILES mercurial/dirstateutils/v2.py mercurial/helptext/internals/dirstate-v2.txt rust/hg-core/src/dirstate_tree/on_disk.rs CHANGE DETAILS diff --git a/rust/hg-core/src/dirstate_tree/on_disk.rs b/rust/hg-core/src/dirstate_tree/on_disk.rs --- a/rust/hg-core/src/dirstate_tree/on_disk.rs +++ b/rust/hg-core/src/dirstate_tree/on_disk.rs @@ -33,7 +33,7 @@ /// Must match constants of the same names in `mercurial/dirstateutils/v2.py` const TREE_METADATA_SIZE: usize = 44; -const NODE_SIZE: usize = 43; +const NODE_SIZE: usize = 44; /// Make sure that size-affecting changes are made knowingly #[allow(unused)] @@ -94,15 +94,14 @@ children: ChildNodes, pub(super) descendants_with_entry_count: Size, pub(super) tracked_descendants_count: Size, -flags: Flags, +flags: U16Be, size: U32Be, mtime: PackedTruncatedTimestamp, } bitflags! { -#[derive(BytesCast)] #[repr(C)] -struct Flags: u8 { +struct Flags: u16 { const WDIR_TRACKED = 1 << 0; const P1_TRACKED = 1 << 1; const P2_INFO = 1 << 2; @@ -296,8 +295,12 @@ }) } +fn flags() -> Flags { +Flags::from_bits_truncate(self.flags.get()) +} + fn has_entry() -> bool { -self.flags.intersects( +self.flags().intersects( Flags::WDIR_TRACKED | Flags::P1_TRACKED | Flags::P2_INFO, ) } @@ -318,7 +321,7 @@ , ) -> Result, DirstateV2ParseError> { Ok( -if self.flags.contains(Flags::HAS_MTIME) && !self.has_entry() { +if self.flags().contains(Flags::HAS_MTIME) && !self.has_entry() { Some(self.mtime.try_into()?) } else { None @@ -327,12 +330,12 @@ } fn synthesize_unix_mode() -> u32 { -let file_type = if self.flags.contains(Flags::MODE_IS_SYMLINK) { +let file_type = if self.flags().contains(Flags::MODE_IS_SYMLINK) { libc::S_IFLNK } else { libc::S_IFREG }; -let permisions = if self.flags.contains(Flags::MODE_EXEC_PERM) { +let permisions = if self.flags().contains(Flags::MODE_EXEC_PERM) { 0o755 } else { 0o644 @@ -342,15 +345,15 @@ fn assume_entry() -> DirstateEntry { // TODO: convert through raw bits instead? -let wdir_tracked = self.flags.contains(Flags::WDIR_TRACKED); -let p1_tracked = self.flags.contains(Flags::P1_TRACKED); -let p2_info = self.flags.contains(Flags::P2_INFO); -let mode_size = if self.flags.contains(Flags::HAS_MODE_AND_SIZE) { +let wdir_tracked = self.flags().contains(Flags::WDIR_TRACKED); +let p1_tracked = self.flags().contains(Flags::P1_TRACKED); +let p2_info = self.flags().contains(Flags::P2_INFO); +let mode_size = if self.flags().contains(Flags::HAS_MODE_AND_SIZE) { Some((self.synthesize_unix_mode(), self.size.into())) } else { None }; -let mtime = if self.flags.contains(Flags::HAS_MTIME) { +let mtime = if self.flags().contains(Flags::HAS_MTIME) { Some(self.mtime.truncated_seconds.into()) } else { None @@ -600,7 +603,7 @@ tracked_descendants_count: node .tracked_descendants_count .into(), -flags, +flags: flags.bits().into(), size, mtime, } diff --git a/mercurial/helptext/internals/dirstate-v2.txt b/mercurial/helptext/internals/dirstate-v2.txt --- a/mercurial/helptext/internals/dirstate-v2.txt +++ b/mercurial/helptext/internals/dirstate-v2.txt @@ -372,7 +372,7 @@ This counter is used to implement `has_tracked_dir`. * Offset 30: - A single `flags` byte that packs some boolean values as bits. + A `flags` fields that packs some boolean values as bits of a 16-bit integer. Starting from least-significant, bit masks are:: WDIR_TRACKED = 1 << 0 @@ -384,22 +384,29 @@ MODE_IS_SYMLINK = 1 << 6 The meaning of each bit is described below. - Other bits are unset. -* Offset 31: + Other bits are unset. + They may be assigned meaning if the future, + with the
D11660: dirstate-v2: Use attributes as intended instead of properties in v2_data()
SimonSapin created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY The property return other integer values instead of None, so `is not None` does not work. This fixes test-dirstate-race.t in pure-Python mode, which currently fails on the default branch. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11660 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 @@ -322,15 +322,15 @@ flags |= DIRSTATE_V2_P1_TRACKED if self._p2_info: flags |= DIRSTATE_V2_P2_INFO -if self.mode is not None and self.size is not None: +if self._mode is not None and self._size is not None: flags |= DIRSTATE_V2_HAS_MODE_AND_SIZE if self.mode & stat.S_IXUSR: flags |= DIRSTATE_V2_MODE_EXEC_PERM if stat.S_ISLNK(self.mode): flags |= DIRSTATE_V2_MODE_IS_SYMLINK -if self.mtime is not None: +if self._mtime is not None: flags |= DIRSTATE_V2_HAS_MTIME -return (flags, self.size or 0, self.mtime or 0) +return (flags, self._size or 0, self._mtime or 0) def v1_state(self): """return a "state" suitable for v1 serialization""" To: SimonSapin, #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
D11659: rhg: do not try to open a nodemap for an inline index
aalekseyev created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY This saves an [open] system call per file, which is a small saving, but it showed up in the profile at large file counts (it accounted for 30ms out of 400ms needed for catting 1 files, on a ZFS filesystem on Linux, so ~3us per syscall). REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11659 AFFECTED FILES rust/hg-core/src/revlog/index.rs rust/hg-core/src/revlog/revlog.rs CHANGE DETAILS diff --git a/rust/hg-core/src/revlog/revlog.rs b/rust/hg-core/src/revlog/revlog.rs --- a/rust/hg-core/src/revlog/revlog.rs +++ b/rust/hg-core/src/revlog/revlog.rs @@ -99,14 +99,18 @@ Some(Box::new(data_mmap)) }; -let nodemap = NodeMapDocket::read_from_file(repo, index_path)?.map( -|(docket, data)| { -nodemap::NodeTree::load_bytes( -Box::new(data), -docket.data_length, -) -}, -); +let nodemap = if index.is_inline() { +None +} else { +NodeMapDocket::read_from_file(repo, index_path)?.map( +|(docket, data)| { +nodemap::NodeTree::load_bytes( +Box::new(data), +docket.data_length, +) +}, +) +}; Ok(Revlog { index, diff --git a/rust/hg-core/src/revlog/index.rs b/rust/hg-core/src/revlog/index.rs --- a/rust/hg-core/src/revlog/index.rs +++ b/rust/hg-core/src/revlog/index.rs @@ -57,7 +57,7 @@ /// Value of the inline flag. pub fn is_inline() -> bool { -is_inline() +self.offsets.is_some() } /// Return a slice of bytes if `revlog` is inline. Panic if not. To: aalekseyev, #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
D11658: dirstate: Remove unused variable
SimonSapin created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY This fixes test-check-pyflakes.t which is currently failing on the default branch. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11658 AFFECTED FILES mercurial/dirstateutils/v2.py CHANGE DETAILS diff --git a/mercurial/dirstateutils/v2.py b/mercurial/dirstateutils/v2.py --- a/mercurial/dirstateutils/v2.py +++ b/mercurial/dirstateutils/v2.py @@ -149,7 +149,6 @@ else: # There are no mtime-cached directories in the Python implementation flags = 0 -mode = 0 size = 0 mtime_s = 0 mtime_ns = 0 To: SimonSapin, #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
D11657: rust: Reformat source code
SimonSapin created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY This fixes test-check-rust-format.t which is currently failing on the default branch. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11657 AFFECTED FILES rust/hg-core/src/revlog/revlog.rs CHANGE DETAILS diff --git a/rust/hg-core/src/revlog/revlog.rs b/rust/hg-core/src/revlog/revlog.rs --- a/rust/hg-core/src/revlog/revlog.rs +++ b/rust/hg-core/src/revlog/revlog.rs @@ -76,7 +76,8 @@ Some(index_mmap) => { let version = get_version(_mmap)?; if version != 1 { -// A proper new version should have had a repo/store requirement. +// A proper new version should have had a repo/store +// requirement. return Err(HgError::corrupted("corrupted revlog")); } @@ -424,6 +425,6 @@ .with_version(1) .build(); -assert_eq!(get_version().map_err(|_err|()), Ok(1)) +assert_eq!(get_version().map_err(|_err| ()), Ok(1)) } } To: SimonSapin, #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