D6416: changelog: optionally store added and removed files in changeset extras
This revision was automatically updated to reflect the committed changes. Closed by commit rHGf385ba70e4af: changelog: optionally store added and removed files in changeset extras (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D6416?vs=15231=15323 REVISION DETAIL https://phab.mercurial-scm.org/D6416 AFFECTED FILES mercurial/changelog.py mercurial/localrepo.py tests/test-copies-in-changeset.t tests/test-copies.t CHANGE DETAILS diff --git a/tests/test-copies.t b/tests/test-copies.t --- a/tests/test-copies.t +++ b/tests/test-copies.t @@ -551,14 +551,15 @@ $ hg up 2 -q $ hg graft -r 4 --base 3 --hidden - grafting 4:af28412ec03c "added d, modified b" (tip) + grafting 4:af28412ec03c "added d, modified b" (tip) (no-changeset !) + grafting 4:6325ca0b7a1c "added d, modified b" (tip) (changeset !) merging b1 and b to b1 $ hg l -l1 -p @ 5 added d, modified b | b1 ~ diff -r 5a4825cc2926 -r 94a2f1a0e8e2 b1 (no-changeset !) - ~ diff -r f5474f5023a8 -r ef7c02d69f3d b1 (changeset !) + ~ diff -r df722b7fe2d5 -r ba3ddbbdfd96 b1 (changeset !) --- a/b1 Thu Jan 01 00:00:00 1970 + +++ b/b1 Thu Jan 01 00:00:00 1970 + @@ -1,1 +1,2 @@ @@ -618,7 +619,8 @@ a $ hg rebase -r . -d 2 -t :other - rebasing 5:5018b1509e94 "added willconflict and d" (tip) + rebasing 5:5018b1509e94 "added willconflict and d" (tip) (no-changeset !) + rebasing 5:619047c26bf8 "added willconflict and d" (tip) (changeset !) $ hg up 3 -q $ hg l --hidden @@ -641,4 +643,5 @@ neither of the merging csets will be a descendant of the base revision: $ hg graft -r 6 --base 4 --hidden -t :other - grafting 6:99802e4f1e46 "added willconflict and d" (tip) + grafting 6:99802e4f1e46 "added willconflict and d" (tip) (no-changeset !) + grafting 6:9ddc6fb3b691 "added willconflict and d" (tip) (changeset !) diff --git a/tests/test-copies-in-changeset.t b/tests/test-copies-in-changeset.t --- a/tests/test-copies-in-changeset.t +++ b/tests/test-copies-in-changeset.t @@ -5,6 +5,7 @@ > copies.read-from=changeset-only > [alias] > changesetcopies = log -r . -T 'files: {files} + > {extras % "{ifcontains("files", key, "{key}: {value}\n")}"} > {extras % "{ifcontains("copies", key, "{key}: {value}\n")}"}' > showcopies = log -r . -T '{file_copies % "{source} -> {name}\n"}' > [extensions] @@ -24,6 +25,8 @@ $ hg ci -m 'copy a to b, c, and d' $ hg changesetcopies files: b c d + filesadded: 0\x001\x002 (esc) + p1copies: b\x00a (esc) c\x00a (esc) d\x00a (esc) @@ -43,6 +46,9 @@ $ hg ci -m 'rename b to b2' $ hg changesetcopies files: b b2 + filesadded: 1 + filesremoved: 0 + p1copies: b2\x00b (esc) $ hg showcopies b -> b2 @@ -60,6 +66,7 @@ $ hg ci -m 'move b onto d' $ hg changesetcopies files: c + p1copies: c\x00b2 (esc) $ hg showcopies b2 -> c @@ -88,6 +95,8 @@ $ hg ci -m 'merge' $ hg changesetcopies files: g h i + filesadded: 0\x001\x002 (esc) + p1copies: g\x00a (esc) i\x00f (esc) p2copies: h\x00d (esc) @@ -102,6 +111,9 @@ $ hg ci -m 'copy a to j' --config experimental.copies.write-to=compatibility $ hg changesetcopies files: j + filesadded: 0 + filesremoved: + p1copies: j\x00a (esc) p2copies: $ hg debugdata j 0 @@ -122,6 +134,9 @@ $ hg ci -m 'modify j' --config experimental.copies.write-to=compatibility $ hg changesetcopies files: j + filesadded: + filesremoved: + p1copies: p2copies: @@ -131,6 +146,7 @@ $ hg ci -m 'copy a to k' --config experimental.copies.write-to=filelog-only $ hg changesetcopies files: k + $ hg debugdata k 0 \x01 (esc) copy: a @@ -157,9 +173,9 @@ $ hg mv a b $ hg ci -qm 'rename a to b' $ hg rebase -d 1 --config rebase.experimental.inmemory=yes - rebasing 2:55d0b405c1b2 "rename a to b" (tip) + rebasing 2:acfc33f3aa6d "rename a to b" (tip) merging a and b to b - saved backup bundle to $TESTTMP/rebase-rename/.hg/strip-backup/55d0b405c1b2-78df867e-rebase.hg + saved backup bundle to $TESTTMP/rebase-rename/.hg/strip-backup/acfc33f3aa6d-81d0180d-rebase.hg $ hg st --change . --copies A b a diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -2589,18 +2589,24 @@ writecopiesto = self.ui.config('experimental', 'copies.write-to') writefilecopymeta = writecopiesto != 'changeset-only' +writechangesetcopy = (writecopiesto in + ('changeset-only', 'compatibility')) p1copies, p2copies = None, None -if writecopiesto in ('changeset-only', 'compatibility'): +if writechangesetcopy: p1copies = ctx.p1copies() p2copies = ctx.p2copies() +filesadded, filesremoved = None, None with self.lock(), self.transaction("commit") as
D6417: context: get filesadded() and filesremoved() from changeset if configured
This revision was automatically updated to reflect the committed changes. Closed by commit rHG602469a91550: context: get filesadded() and filesremoved() from changeset if configured (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D6417?vs=15275=15324 REVISION DETAIL https://phab.mercurial-scm.org/D6417 AFFECTED FILES mercurial/changelog.py mercurial/context.py CHANGE DETAILS diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -469,12 +469,24 @@ modified.difference_update(self.filesremoved()) return sorted(modified) def filesadded(self): +source = self._repo.ui.config('experimental', 'copies.read-from') +if (source == 'changeset-only' or +(source == 'compatibility' and + self._changeset.filesadded is not None)): +return self._changeset.filesadded or [] + added = [] for f in self.files(): if not any(f in p for p in self.parents()): added.append(f) return added def filesremoved(self): +source = self._repo.ui.config('experimental', 'copies.read-from') +if (source == 'changeset-only' or +(source == 'compatibility' and + self._changeset.filesremoved is not None)): +return self._changeset.filesremoved or [] + removed = [] for f in self.files(): if f not in self: diff --git a/mercurial/changelog.py b/mercurial/changelog.py --- a/mercurial/changelog.py +++ b/mercurial/changelog.py @@ -107,6 +107,20 @@ indices.append('%d' % i) return '\0'.join(indices) +def decodefileindices(files, data): +try: +subset = [] +for strindex in data.split('\0'): +i = int(strindex) +if i < 0 or i >= len(files): +return None +subset.append(files[i]) +return subset +except (ValueError, IndexError): +# Perhaps someone had chosen the same key name (e.g. "added") and +# used different syntax for the value. +return None + def stripdesc(desc): """strip trailing whitespace and leading and trailing empty lines""" return '\n'.join([l.rstrip() for l in desc.splitlines()]).strip('\n') @@ -202,6 +216,8 @@ user = attr.ib(default='') date = attr.ib(default=(0, 0)) files = attr.ib(default=attr.Factory(list)) +filesadded = attr.ib(default=None) +filesremoved = attr.ib(default=None) p1copies = attr.ib(default=None) p2copies = attr.ib(default=None) description = attr.ib(default='') @@ -308,6 +324,16 @@ return self._text[off[2] + 1:off[3]].split('\n') @property +def filesadded(self): +rawindices = self.extra.get('filesadded') +return rawindices and decodefileindices(self.files, rawindices) + +@property +def filesremoved(self): +rawindices = self.extra.get('filesremoved') +return rawindices and decodefileindices(self.files, rawindices) + +@property def p1copies(self): rawcopies = self.extra.get('p1copies') return rawcopies and decodecopies(rawcopies) To: martinvonz, #hg-reviewers Cc: marmoute, yuja, indygreg, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D6369: templatekw: make {file_*} compare to both merge parents (issue4292)
This revision was automatically updated to reflect the committed changes. Closed by commit rHG0c72eddb4be5: templatekw: make {file_*} compare to both merge parents (issue4292) (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D6369?vs=15274=15322 REVISION DETAIL https://phab.mercurial-scm.org/D6369 AFFECTED FILES mercurial/templatekw.py relnotes/next tests/test-convert-bzr-merges.t tests/test-convert-bzr.t tests/test-template-keywords.t CHANGE DETAILS diff --git a/tests/test-template-keywords.t b/tests/test-template-keywords.t --- a/tests/test-template-keywords.t +++ b/tests/test-template-keywords.t @@ -809,9 +809,9 @@ $ hg log -l1 -T '{files}\n' a fourth $ hg log -l1 -T '{file_mods}\n' - third + $ hg log -l1 -T '{file_adds}\n' - b fifth + $ hg log -l1 -T '{file_dels}\n' a fourth diff --git a/tests/test-convert-bzr.t b/tests/test-convert-bzr.t --- a/tests/test-convert-bzr.t +++ b/tests/test-convert-bzr.t @@ -147,7 +147,7 @@ 1 Editing b 0 Merged improve branch $ glog -R source-hg - o3@source "Merged improve branch" files+: [], files-: [], files: [b] + o3@source "Merged improve branch" files+: [], files-: [], files: [] |\ | o 2@source-improve "Editing b" files+: [], files-: [], files: [b] | | diff --git a/tests/test-convert-bzr-merges.t b/tests/test-convert-bzr-merges.t --- a/tests/test-convert-bzr-merges.t +++ b/tests/test-convert-bzr-merges.t @@ -59,7 +59,7 @@ $ glog -R source-hg o5@source "(octopus merge fixup)" files+: [], files-: [], files: [renamed] |\ - | o4@source "Merged branches" files+: [file-branch1 file-branch2 renamed], files-: [rename_me], files: [file] + | o4@source "Merged branches" files+: [file-branch2 renamed], files-: [rename_me], files: [] | |\ o---+ 3@source-branch2 "Added brach2 file" files+: [file-branch2 renamed], files-: [rename_me], files: [] / / @@ -154,7 +154,7 @@ $ glog -R hg2hg @5@source "(octopus merge fixup)" files+: [], files-: [], files: [] |\ - | o4@source "Merged branches" files+: [file-branch1 file-branch2 renamed], files-: [rename_me], files: [file] + | o4@source "Merged branches" files+: [file-branch2 renamed], files-: [rename_me], files: [] | |\ o---+ 3@source-branch2 "Added brach2 file" files+: [file-branch2 renamed], files-: [rename_me], files: [] / / diff --git a/relnotes/next b/relnotes/next --- a/relnotes/next +++ b/relnotes/next @@ -15,6 +15,10 @@ == Bug Fixes == + * issue4292: "hg log and {files} {file_adds} {file_mods} {file_dels} + in template show wrong files on merged revision". See details in + "Backwards Compatibility Changes". + == Backwards Compatibility Changes == @@ -31,6 +35,16 @@ previously replace files *in* the configured directory by subdirectories. +* Template keyword `{file_mods}`, `{file_adds}`, and `{file_dels}` + have changed behavior on merge commits. They used to be relative to + the first parent, but they now consider both parents. `{file_adds}` + shows files that exists in the commit but did not exist in either + parent. `{file_dels}` shows files that do not exist in the commit + but existed in either parent. `{file_mods}` show the remaining + files from `{files}` that were not in the other two + sets. + + == Internal API Changes == * Matchers are no longer iterable. Use `match.files()` instead. diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py --- a/mercurial/templatekw.py +++ b/mercurial/templatekw.py @@ -290,11 +290,6 @@ statmap.update((f, char) for f in files) return revcache['filestatusmap'] # {path: statchar} -def _showfilesbystat(context, mapping, name, index): -stat = _getfilestatus(context, mapping) -files = stat[index] -return templateutil.compatfileslist(context, mapping, name, files) - @templatekeyword('file_copies', requires={'repo', 'ctx', 'cache', 'revcache'}) def showfilecopies(context, mapping): @@ -332,17 +327,23 @@ @templatekeyword('file_adds', requires={'ctx', 'revcache'}) def showfileadds(context, mapping): """List of strings. Files added by this changeset.""" -return _showfilesbystat(context, mapping, 'file_add', 1) +ctx = context.resource(mapping, 'ctx') +return templateutil.compatfileslist(context, mapping, 'file_add', +ctx.filesadded()) @templatekeyword('file_dels', requires={'ctx', 'revcache'}) def showfiledels(context, mapping): """List of strings. Files removed by this changeset.""" -return _showfilesbystat(context, mapping, 'file_del', 2) +ctx = context.resource(mapping, 'ctx') +return templateutil.compatfileslist(context, mapping, 'file_del', +ctx.filesremoved()) @templatekeyword('file_mods', requires={'ctx', 'revcache'}) def showfilemods(context,
D6465: narrowspec: use vfs.tryread() instead of reimplementing
This revision was automatically updated to reflect the committed changes. Closed by commit rHG0c0a22f5b0b5: narrowspec: use vfs.tryread() instead of reimplementing (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D6465?vs=15311=15321 REVISION DETAIL https://phab.mercurial-scm.org/D6465 AFFECTED FILES mercurial/narrowspec.py CHANGE DETAILS diff --git a/mercurial/narrowspec.py b/mercurial/narrowspec.py --- a/mercurial/narrowspec.py +++ b/mercurial/narrowspec.py @@ -7,8 +7,6 @@ from __future__ import absolute_import -import errno - from .i18n import _ from . import ( error, @@ -145,15 +143,9 @@ return includepats, excludepats def load(repo): -try: -spec = repo.svfs.read(FILENAME) -except IOError as e: -# Treat "narrowspec does not exist" the same as "narrowspec file exists -# and is empty". -if e.errno == errno.ENOENT: -return set(), set() -raise - +# Treat "narrowspec does not exist" the same as "narrowspec file exists +# and is empty". +spec = repo.svfs.tryread(FILENAME) return parseconfig(repo.ui, spec) def save(repo, includepats, excludepats): To: martinvonz, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D6467: doc: fix description of "predecessors" to match reality
av6 added a comment. This change looks good, but I have doubts about "visible" in the docstring. https://phab.mercurial-scm.org/rHG1858fc2327ef7b631941e37550738f1fc4217bfb does say that this template keyword respects repo filtering, but I've encountered instances where it shows hidden predecessors (that need --hidden to be seen). REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D6467 To: joerg.sonnenberger, #hg-reviewers Cc: av6, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D6472: merge: simplify initialization of "pas"
martinvonz created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D6472 AFFECTED FILES mercurial/merge.py CHANGE DETAILS diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -1978,10 +1978,9 @@ pl = wc.parents() p1 = pl[0] p2 = repo[node] -pas = [None] if ancestor is not None: pas = [repo[ancestor]] -if pas[0] is None: +else: if repo.ui.configlist('merge', 'preferancestor') == ['*']: cahs = repo.changelog.commonancestorsheads(p1.node(), p2.node()) pas = [repo[anc] for anc in (sorted(cahs) or [nullid])] To: martinvonz, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D6471: merge: reorder some initialization to make more sense
martinvonz created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY This puts the closely related definitions of "pl", "p1", "p2", "pas" close together, and moves the definition of "overwrite" away and closer to where it's first used. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D6471 AFFECTED FILES mercurial/merge.py CHANGE DETAILS diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -1977,13 +1977,10 @@ wc = repo[None] pl = wc.parents() p1 = pl[0] +p2 = repo[node] pas = [None] if ancestor is not None: pas = [repo[ancestor]] - -overwrite = force and not branchmerge - -p2 = repo[node] if pas[0] is None: if repo.ui.configlist('merge', 'preferancestor') == ['*']: cahs = repo.changelog.commonancestorsheads(p1.node(), p2.node()) @@ -1993,6 +1990,7 @@ fp1, fp2, xp1, xp2 = p1.node(), p2.node(), bytes(p1), bytes(p2) +overwrite = force and not branchmerge ### check phase if not overwrite: if len(pl) > 1: To: martinvonz, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D6470: mixedrepostorecache: fix a silly redundant updating of set
martinvonz created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D6470 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 @@ -128,8 +128,7 @@ # scmutil.filecache only uses the path for passing back into our # join(), so we can safely pass a list of paths and locations super(mixedrepostorecache, self).__init__(*pathsandlocations) -for path, location in pathsandlocations: -_cachedfiles.update(pathsandlocations) +_cachedfiles.update(pathsandlocations) def join(self, obj, fnameandlocation): fname, location = fnameandlocation To: martinvonz, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel