Show More
@@ -52,7 +52,7 b' def pygmentize(web, field, fctx, tmpl):' | |||||
52 | filenameonly = web.configbool(b'web', b'highlightonlymatchfilename', False) |
|
52 | filenameonly = web.configbool(b'web', b'highlightonlymatchfilename', False) | |
53 |
|
53 | |||
54 | ctx = fctx.changectx() |
|
54 | ctx = fctx.changectx() | |
55 | m = ctx.matchfileset(expr) |
|
55 | m = ctx.matchfileset(fctx.repo().root, expr) | |
56 | if m(fctx.path()): |
|
56 | if m(fctx.path()): | |
57 | highlight.pygmentize( |
|
57 | highlight.pygmentize( | |
58 | field, fctx, style, tmpl, guessfilenameonly=filenameonly |
|
58 | field, fctx, style, tmpl, guessfilenameonly=filenameonly |
@@ -200,8 +200,8 b' class basectx(object):' | |||||
200 | def mutable(self): |
|
200 | def mutable(self): | |
201 | return self.phase() > phases.public |
|
201 | return self.phase() > phases.public | |
202 |
|
202 | |||
203 | def matchfileset(self, expr, badfn=None): |
|
203 | def matchfileset(self, cwd, expr, badfn=None): | |
204 | return fileset.match(self, expr, badfn=badfn) |
|
204 | return fileset.match(self, cwd, expr, badfn=badfn) | |
205 |
|
205 | |||
206 | def obsolete(self): |
|
206 | def obsolete(self): | |
207 | """True if the changeset is obsolete""" |
|
207 | """True if the changeset is obsolete""" | |
@@ -328,11 +328,14 b' class basectx(object):' | |||||
328 | default=b'glob', |
|
328 | default=b'glob', | |
329 | listsubrepos=False, |
|
329 | listsubrepos=False, | |
330 | badfn=None, |
|
330 | badfn=None, | |
|
331 | cwd=None, | |||
331 | ): |
|
332 | ): | |
332 | r = self._repo |
|
333 | r = self._repo | |
|
334 | if not cwd: | |||
|
335 | cwd = r.getcwd() | |||
333 | return matchmod.match( |
|
336 | return matchmod.match( | |
334 | r.root, |
|
337 | r.root, | |
335 |
|
|
338 | cwd, | |
336 | pats, |
|
339 | pats, | |
337 | include, |
|
340 | include, | |
338 | exclude, |
|
341 | exclude, | |
@@ -1694,15 +1697,18 b' class workingctx(committablectx):' | |||||
1694 | default=b'glob', |
|
1697 | default=b'glob', | |
1695 | listsubrepos=False, |
|
1698 | listsubrepos=False, | |
1696 | badfn=None, |
|
1699 | badfn=None, | |
|
1700 | cwd=None, | |||
1697 | ): |
|
1701 | ): | |
1698 | r = self._repo |
|
1702 | r = self._repo | |
|
1703 | if not cwd: | |||
|
1704 | cwd = r.getcwd() | |||
1699 |
|
1705 | |||
1700 | # Only a case insensitive filesystem needs magic to translate user input |
|
1706 | # Only a case insensitive filesystem needs magic to translate user input | |
1701 | # to actual case in the filesystem. |
|
1707 | # to actual case in the filesystem. | |
1702 | icasefs = not util.fscasesensitive(r.root) |
|
1708 | icasefs = not util.fscasesensitive(r.root) | |
1703 | return matchmod.match( |
|
1709 | return matchmod.match( | |
1704 | r.root, |
|
1710 | r.root, | |
1705 |
|
|
1711 | cwd, | |
1706 | pats, |
|
1712 | pats, | |
1707 | include, |
|
1713 | include, | |
1708 | exclude, |
|
1714 | exclude, |
@@ -1171,7 +1171,7 b' def debugfileset(ui, repo, expr, **opts)' | |||||
1171 | files.update(ctx.files()) |
|
1171 | files.update(ctx.files()) | |
1172 | files.update(ctx.substate) |
|
1172 | files.update(ctx.substate) | |
1173 |
|
1173 | |||
1174 | m = ctx.matchfileset(expr) |
|
1174 | m = ctx.matchfileset(repo.getcwd(), expr) | |
1175 | if opts[b'show_matcher'] or (opts[b'show_matcher'] is None and ui.verbose): |
|
1175 | if opts[b'show_matcher'] or (opts[b'show_matcher'] is None and ui.verbose): | |
1176 | ui.writenoi18n(b'* matcher:\n', stringutil.prettyrepr(m), b'\n') |
|
1176 | ui.writenoi18n(b'* matcher:\n', stringutil.prettyrepr(m), b'\n') | |
1177 | for f in sorted(files): |
|
1177 | for f in sorted(files): |
@@ -520,29 +520,30 b' methods = {' | |||||
520 |
|
520 | |||
521 |
|
521 | |||
522 | class matchctx(object): |
|
522 | class matchctx(object): | |
523 | def __init__(self, basectx, ctx, badfn=None): |
|
523 | def __init__(self, basectx, ctx, cwd, badfn=None): | |
524 | self._basectx = basectx |
|
524 | self._basectx = basectx | |
525 | self.ctx = ctx |
|
525 | self.ctx = ctx | |
526 | self._badfn = badfn |
|
526 | self._badfn = badfn | |
527 | self._match = None |
|
527 | self._match = None | |
528 | self._status = None |
|
528 | self._status = None | |
|
529 | self.cwd = cwd | |||
529 |
|
530 | |||
530 | def narrowed(self, match): |
|
531 | def narrowed(self, match): | |
531 | """Create matchctx for a sub-tree narrowed by the given matcher""" |
|
532 | """Create matchctx for a sub-tree narrowed by the given matcher""" | |
532 | mctx = matchctx(self._basectx, self.ctx, self._badfn) |
|
533 | mctx = matchctx(self._basectx, self.ctx, self.cwd, self._badfn) | |
533 | mctx._match = match |
|
534 | mctx._match = match | |
534 | # leave wider status which we don't have to care |
|
535 | # leave wider status which we don't have to care | |
535 | mctx._status = self._status |
|
536 | mctx._status = self._status | |
536 | return mctx |
|
537 | return mctx | |
537 |
|
538 | |||
538 | def switch(self, basectx, ctx): |
|
539 | def switch(self, basectx, ctx): | |
539 | mctx = matchctx(basectx, ctx, self._badfn) |
|
540 | mctx = matchctx(basectx, ctx, self.cwd, self._badfn) | |
540 | mctx._match = self._match |
|
541 | mctx._match = self._match | |
541 | return mctx |
|
542 | return mctx | |
542 |
|
543 | |||
543 | def withstatus(self, keys): |
|
544 | def withstatus(self, keys): | |
544 | """Create matchctx which has precomputed status specified by the keys""" |
|
545 | """Create matchctx which has precomputed status specified by the keys""" | |
545 | mctx = matchctx(self._basectx, self.ctx, self._badfn) |
|
546 | mctx = matchctx(self._basectx, self.ctx, self.cwd, self._badfn) | |
546 | mctx._match = self._match |
|
547 | mctx._match = self._match | |
547 | mctx._buildstatus(keys) |
|
548 | mctx._buildstatus(keys) | |
548 | return mctx |
|
549 | return mctx | |
@@ -560,7 +561,7 b' class matchctx(object):' | |||||
560 | return self._status |
|
561 | return self._status | |
561 |
|
562 | |||
562 | def matcher(self, patterns): |
|
563 | def matcher(self, patterns): | |
563 | return self.ctx.match(patterns, badfn=self._badfn) |
|
564 | return self.ctx.match(patterns, badfn=self._badfn, cwd=self.cwd) | |
564 |
|
565 | |||
565 | def predicate(self, predfn, predrepr=None, cache=False): |
|
566 | def predicate(self, predfn, predrepr=None, cache=False): | |
566 | """Create a matcher to select files by predfn(filename)""" |
|
567 | """Create a matcher to select files by predfn(filename)""" | |
@@ -617,12 +618,12 b' class matchctx(object):' | |||||
617 | return matchmod.never(badfn=self._badfn) |
|
618 | return matchmod.never(badfn=self._badfn) | |
618 |
|
619 | |||
619 |
|
620 | |||
620 | def match(ctx, expr, badfn=None): |
|
621 | def match(ctx, cwd, expr, badfn=None): | |
621 | """Create a matcher for a single fileset expression""" |
|
622 | """Create a matcher for a single fileset expression""" | |
622 | tree = filesetlang.parse(expr) |
|
623 | tree = filesetlang.parse(expr) | |
623 | tree = filesetlang.analyze(tree) |
|
624 | tree = filesetlang.analyze(tree) | |
624 | tree = filesetlang.optimize(tree) |
|
625 | tree = filesetlang.optimize(tree) | |
625 | mctx = matchctx(ctx.p1(), ctx, badfn=badfn) |
|
626 | mctx = matchctx(ctx.p1(), ctx, cwd, badfn=badfn) | |
626 | return getmatch(mctx, tree) |
|
627 | return getmatch(mctx, tree) | |
627 |
|
628 | |||
628 |
|
629 |
@@ -57,7 +57,7 b' def _rematcher(regex):' | |||||
57 | return m.match |
|
57 | return m.match | |
58 |
|
58 | |||
59 |
|
59 | |||
60 | def _expandsets(kindpats, ctx=None, listsubrepos=False, badfn=None): |
|
60 | def _expandsets(cwd, kindpats, ctx=None, listsubrepos=False, badfn=None): | |
61 | '''Returns the kindpats list with the 'set' patterns expanded to matchers''' |
|
61 | '''Returns the kindpats list with the 'set' patterns expanded to matchers''' | |
62 | matchers = [] |
|
62 | matchers = [] | |
63 | other = [] |
|
63 | other = [] | |
@@ -68,11 +68,11 b' def _expandsets(kindpats, ctx=None, list' | |||||
68 | raise error.ProgrammingError( |
|
68 | raise error.ProgrammingError( | |
69 | b"fileset expression with no context" |
|
69 | b"fileset expression with no context" | |
70 | ) |
|
70 | ) | |
71 | matchers.append(ctx.matchfileset(pat, badfn=badfn)) |
|
71 | matchers.append(ctx.matchfileset(cwd, pat, badfn=badfn)) | |
72 |
|
72 | |||
73 | if listsubrepos: |
|
73 | if listsubrepos: | |
74 | for subpath in ctx.substate: |
|
74 | for subpath in ctx.substate: | |
75 | sm = ctx.sub(subpath).matchfileset(pat, badfn=badfn) |
|
75 | sm = ctx.sub(subpath).matchfileset(cwd, pat, badfn=badfn) | |
76 | pm = prefixdirmatcher(subpath, sm, badfn=badfn) |
|
76 | pm = prefixdirmatcher(subpath, sm, badfn=badfn) | |
77 | matchers.append(pm) |
|
77 | matchers.append(pm) | |
78 |
|
78 | |||
@@ -117,11 +117,11 b' def _kindpatsalwaysmatch(kindpats):' | |||||
117 |
|
117 | |||
118 |
|
118 | |||
119 | def _buildkindpatsmatcher( |
|
119 | def _buildkindpatsmatcher( | |
120 | matchercls, root, kindpats, ctx=None, listsubrepos=False, badfn=None |
|
120 | matchercls, root, cwd, kindpats, ctx=None, listsubrepos=False, badfn=None, | |
121 | ): |
|
121 | ): | |
122 | matchers = [] |
|
122 | matchers = [] | |
123 | fms, kindpats = _expandsets( |
|
123 | fms, kindpats = _expandsets( | |
124 | kindpats, ctx=ctx, listsubrepos=listsubrepos, badfn=badfn |
|
124 | cwd, kindpats, ctx=ctx, listsubrepos=listsubrepos, badfn=badfn, | |
125 | ) |
|
125 | ) | |
126 | if kindpats: |
|
126 | if kindpats: | |
127 | m = matchercls(root, kindpats, badfn=badfn) |
|
127 | m = matchercls(root, kindpats, badfn=badfn) | |
@@ -261,6 +261,7 b' def match(' | |||||
261 | m = _buildkindpatsmatcher( |
|
261 | m = _buildkindpatsmatcher( | |
262 | patternmatcher, |
|
262 | patternmatcher, | |
263 | root, |
|
263 | root, | |
|
264 | cwd, | |||
264 | kindpats, |
|
265 | kindpats, | |
265 | ctx=ctx, |
|
266 | ctx=ctx, | |
266 | listsubrepos=listsubrepos, |
|
267 | listsubrepos=listsubrepos, | |
@@ -276,6 +277,7 b' def match(' | |||||
276 | im = _buildkindpatsmatcher( |
|
277 | im = _buildkindpatsmatcher( | |
277 | includematcher, |
|
278 | includematcher, | |
278 | root, |
|
279 | root, | |
|
280 | cwd, | |||
279 | kindpats, |
|
281 | kindpats, | |
280 | ctx=ctx, |
|
282 | ctx=ctx, | |
281 | listsubrepos=listsubrepos, |
|
283 | listsubrepos=listsubrepos, | |
@@ -287,6 +289,7 b' def match(' | |||||
287 | em = _buildkindpatsmatcher( |
|
289 | em = _buildkindpatsmatcher( | |
288 | includematcher, |
|
290 | includematcher, | |
289 | root, |
|
291 | root, | |
|
292 | cwd, | |||
290 | kindpats, |
|
293 | kindpats, | |
291 | ctx=ctx, |
|
294 | ctx=ctx, | |
292 | listsubrepos=listsubrepos, |
|
295 | listsubrepos=listsubrepos, |
@@ -355,7 +355,7 b' class abstractsubrepo(object):' | |||||
355 | """return file flags""" |
|
355 | """return file flags""" | |
356 | return b'' |
|
356 | return b'' | |
357 |
|
357 | |||
358 | def matchfileset(self, expr, badfn=None): |
|
358 | def matchfileset(self, cwd, expr, badfn=None): | |
359 | """Resolve the fileset expression for this repo""" |
|
359 | """Resolve the fileset expression for this repo""" | |
360 | return matchmod.never(badfn=badfn) |
|
360 | return matchmod.never(badfn=badfn) | |
361 |
|
361 | |||
@@ -896,20 +896,20 b' class hgsubrepo(abstractsubrepo):' | |||||
896 | return cmdutil.files(ui, ctx, m, uipathfn, fm, fmt, subrepos) |
|
896 | return cmdutil.files(ui, ctx, m, uipathfn, fm, fmt, subrepos) | |
897 |
|
897 | |||
898 | @annotatesubrepoerror |
|
898 | @annotatesubrepoerror | |
899 | def matchfileset(self, expr, badfn=None): |
|
899 | def matchfileset(self, cwd, expr, badfn=None): | |
900 | if self._ctx.rev() is None: |
|
900 | if self._ctx.rev() is None: | |
901 | ctx = self._repo[None] |
|
901 | ctx = self._repo[None] | |
902 | else: |
|
902 | else: | |
903 | rev = self._state[1] |
|
903 | rev = self._state[1] | |
904 | ctx = self._repo[rev] |
|
904 | ctx = self._repo[rev] | |
905 |
|
905 | |||
906 | matchers = [ctx.matchfileset(expr, badfn=badfn)] |
|
906 | matchers = [ctx.matchfileset(cwd, expr, badfn=badfn)] | |
907 |
|
907 | |||
908 | for subpath in ctx.substate: |
|
908 | for subpath in ctx.substate: | |
909 | sub = ctx.sub(subpath) |
|
909 | sub = ctx.sub(subpath) | |
910 |
|
910 | |||
911 | try: |
|
911 | try: | |
912 | sm = sub.matchfileset(expr, badfn=badfn) |
|
912 | sm = sub.matchfileset(cwd, expr, badfn=badfn) | |
913 | pm = matchmod.prefixdirmatcher(subpath, sm, badfn=badfn) |
|
913 | pm = matchmod.prefixdirmatcher(subpath, sm, badfn=badfn) | |
914 | matchers.append(pm) |
|
914 | matchers.append(pm) | |
915 | except error.LookupError: |
|
915 | except error.LookupError: |
@@ -1335,24 +1335,20 b' reasonable with that.' | |||||
1335 | Apparently fixing p1() and its descendants doesn't include wdir() unless |
|
1335 | Apparently fixing p1() and its descendants doesn't include wdir() unless | |
1336 | explicitly stated. |
|
1336 | explicitly stated. | |
1337 |
|
1337 | |||
1338 | BROKEN: fileset matches aren't relative to repo.root for commits |
|
|||
1339 |
|
||||
1340 |
$ hg fix -r ' |
|
1338 | $ hg fix -r '.::' | |
1341 | $ hg cat -r . ../quux |
|
1339 | $ hg cat -r . ../quux | |
1342 | quux |
|
1340 | quux | |
1343 | $ hg cat -r tip ../quux |
|
1341 | $ hg cat -r tip ../quux | |
1344 | quux |
|
1342 | fs: $TESTTMP/subprocesscwd | |
1345 | $ cat ../quux |
|
1343 | $ cat ../quux | |
1346 | quux |
|
1344 | quux | |
1347 |
|
1345 | |||
1348 | Clean files are not fixed unless explicitly named |
|
1346 | Clean files are not fixed unless explicitly named | |
1349 |
|
|
1347 | $ echo 'dirty' > ../quux | |
1350 |
|
1348 | |||
1351 | BROKEN: fileset matches aren't relative to repo.root for wdir |
|
|||
1352 |
|
||||
1353 | $ hg fix --working-dir |
|
1349 | $ hg fix --working-dir | |
1354 | $ cat ../quux |
|
1350 | $ cat ../quux | |
1355 | dirty |
|
1351 | fs: $TESTTMP/subprocesscwd | |
1356 |
|
1352 | |||
1357 | $ cd ../.. |
|
1353 | $ cd ../.. | |
1358 |
|
1354 |
General Comments 0
You need to be logged in to leave comments.
Login now