##// END OF EJS Templates
narrowmatcher: propagate the rel() method...
Matt Harbison -
r23686:164915e8 default
parent child Browse files
Show More
@@ -1991,7 +1991,7 b' def add(ui, repo, match, dryrun, listsub'
1991 cca(f)
1991 cca(f)
1992 names.append(f)
1992 names.append(f)
1993 if ui.verbose or not exact:
1993 if ui.verbose or not exact:
1994 ui.status(_('adding %s\n') % match.rel(join(f)))
1994 ui.status(_('adding %s\n') % match.rel(f))
1995
1995
1996 for subpath in sorted(wctx.substate):
1996 for subpath in sorted(wctx.substate):
1997 sub = wctx.sub(subpath)
1997 sub = wctx.sub(subpath)
@@ -2042,12 +2042,12 b' def forget(ui, repo, match, prefix, expl'
2042 if repo.wvfs.exists(f):
2042 if repo.wvfs.exists(f):
2043 ui.warn(_('not removing %s: '
2043 ui.warn(_('not removing %s: '
2044 'file is already untracked\n')
2044 'file is already untracked\n')
2045 % match.rel(join(f)))
2045 % match.rel(f))
2046 bad.append(f)
2046 bad.append(f)
2047
2047
2048 for f in forget:
2048 for f in forget:
2049 if ui.verbose or not match.exact(f):
2049 if ui.verbose or not match.exact(f):
2050 ui.status(_('removing %s\n') % match.rel(join(f)))
2050 ui.status(_('removing %s\n') % match.rel(f))
2051
2051
2052 rejected = wctx.forget(forget, prefix)
2052 rejected = wctx.forget(forget, prefix)
2053 bad.extend(f for f in rejected if f in match.files())
2053 bad.extend(f for f in rejected if f in match.files())
@@ -2095,10 +2095,10 b' def remove(ui, repo, m, prefix, after, f'
2095 if repo.wvfs.exists(f):
2095 if repo.wvfs.exists(f):
2096 if repo.wvfs.isdir(f):
2096 if repo.wvfs.isdir(f):
2097 ui.warn(_('not removing %s: no tracked files\n')
2097 ui.warn(_('not removing %s: no tracked files\n')
2098 % m.rel(join(f)))
2098 % m.rel(f))
2099 else:
2099 else:
2100 ui.warn(_('not removing %s: file is untracked\n')
2100 ui.warn(_('not removing %s: file is untracked\n')
2101 % m.rel(join(f)))
2101 % m.rel(f))
2102 # missing files will generate a warning elsewhere
2102 # missing files will generate a warning elsewhere
2103 ret = 1
2103 ret = 1
2104
2104
@@ -2107,22 +2107,22 b' def remove(ui, repo, m, prefix, after, f'
2107 elif after:
2107 elif after:
2108 list = deleted
2108 list = deleted
2109 for f in modified + added + clean:
2109 for f in modified + added + clean:
2110 ui.warn(_('not removing %s: file still exists\n') % m.rel(join(f)))
2110 ui.warn(_('not removing %s: file still exists\n') % m.rel(f))
2111 ret = 1
2111 ret = 1
2112 else:
2112 else:
2113 list = deleted + clean
2113 list = deleted + clean
2114 for f in modified:
2114 for f in modified:
2115 ui.warn(_('not removing %s: file is modified (use -f'
2115 ui.warn(_('not removing %s: file is modified (use -f'
2116 ' to force removal)\n') % m.rel(join(f)))
2116 ' to force removal)\n') % m.rel(f))
2117 ret = 1
2117 ret = 1
2118 for f in added:
2118 for f in added:
2119 ui.warn(_('not removing %s: file has been marked for add'
2119 ui.warn(_('not removing %s: file has been marked for add'
2120 ' (use forget to undo)\n') % m.rel(join(f)))
2120 ' (use forget to undo)\n') % m.rel(f))
2121 ret = 1
2121 ret = 1
2122
2122
2123 for f in sorted(list):
2123 for f in sorted(list):
2124 if ui.verbose or not m.exact(f):
2124 if ui.verbose or not m.exact(f):
2125 ui.status(_('removing %s\n') % m.rel(join(f)))
2125 ui.status(_('removing %s\n') % m.rel(f))
2126
2126
2127 wlock = repo.wlock()
2127 wlock = repo.wlock()
2128 try:
2128 try:
@@ -138,7 +138,7 b' class match(object):'
138 '''Convert repo path to a display path. If patterns or -I/-X were used
138 '''Convert repo path to a display path. If patterns or -I/-X were used
139 to create this matcher, the display path will be relative to cwd.
139 to create this matcher, the display path will be relative to cwd.
140 Otherwise it is relative to the root of the repo.'''
140 Otherwise it is relative to the root of the repo.'''
141 return (self._pathrestricted and self.rel(f)) or f
141 return (self._pathrestricted and self.rel(f)) or self.abs(f)
142
142
143 def files(self):
143 def files(self):
144 '''Explicitly listed files or patterns or roots:
144 '''Explicitly listed files or patterns or roots:
@@ -186,8 +186,8 b' class narrowmatcher(match):'
186 ['b.txt']
186 ['b.txt']
187 >>> m2.exact('b.txt')
187 >>> m2.exact('b.txt')
188 True
188 True
189 >>> m2.rel('b.txt')
189 >>> util.pconvert(m2.rel('b.txt'))
190 'b.txt'
190 'sub/b.txt'
191 >>> def bad(f, msg):
191 >>> def bad(f, msg):
192 ... print "%s: %s" % (f, msg)
192 ... print "%s: %s" % (f, msg)
193 >>> m1.bad = bad
193 >>> m1.bad = bad
@@ -217,6 +217,9 b' class narrowmatcher(match):'
217 def bad(self, f, msg):
217 def bad(self, f, msg):
218 self._matcher.bad(self._path + "/" + f, msg)
218 self._matcher.bad(self._path + "/" + f, msg)
219
219
220 def rel(self, f):
221 return self._matcher.rel(self._path + "/" + f)
222
220 def patkind(pattern, default=None):
223 def patkind(pattern, default=None):
221 '''If pattern is 'kind:pat' with a known kind, return kind.'''
224 '''If pattern is 'kind:pat' with a known kind, return kind.'''
222 return _patsplit(pattern, default)[0]
225 return _patsplit(pattern, default)[0]
@@ -773,9 +773,9 b' def addremove(repo, matcher, prefix, opt'
773 for abs in sorted(toprint):
773 for abs in sorted(toprint):
774 if repo.ui.verbose or not m.exact(abs):
774 if repo.ui.verbose or not m.exact(abs):
775 if abs in unknownset:
775 if abs in unknownset:
776 status = _('adding %s\n') % m.uipath(join(abs))
776 status = _('adding %s\n') % m.uipath(abs)
777 else:
777 else:
778 status = _('removing %s\n') % m.uipath(join(abs))
778 status = _('removing %s\n') % m.uipath(abs)
779 repo.ui.status(status)
779 repo.ui.status(status)
780
780
781 renames = _findrenames(repo, m, added + unknown, removed + deleted,
781 renames = _findrenames(repo, m, added + unknown, removed + deleted,
@@ -107,7 +107,7 b' Check that deep archiving works'
107 $ mkdir sub1/sub2/folder
107 $ mkdir sub1/sub2/folder
108 $ echo 'subfolder' > sub1/sub2/folder/test.txt
108 $ echo 'subfolder' > sub1/sub2/folder/test.txt
109 $ hg ci -ASm "add test.txt"
109 $ hg ci -ASm "add test.txt"
110 adding sub1/sub2/folder/test.txt (glob)
110 adding sub1/sub2/folder/test.txt
111 committing subrepository sub1
111 committing subrepository sub1
112 committing subrepository sub1/sub2 (glob)
112 committing subrepository sub1/sub2 (glob)
113
113
@@ -162,10 +162,10 b' Test relative path printing + subrepos'
162 $ rm sub1/sub2/folder/test.txt
162 $ rm sub1/sub2/folder/test.txt
163 $ rm sub1/sub2/test.txt
163 $ rm sub1/sub2/test.txt
164 $ hg ci -ASm "remove test.txt"
164 $ hg ci -ASm "remove test.txt"
165 adding sub1/sub2/folder/bar (glob)
165 adding sub1/sub2/folder/bar
166 removing sub1/sub2/folder/test.txt (glob)
166 removing sub1/sub2/folder/test.txt
167 removing sub1/sub2/test.txt (glob)
167 removing sub1/sub2/test.txt
168 adding sub1/foo (glob)
168 adding sub1/foo
169 adding foo/bar/abc
169 adding foo/bar/abc
170 committing subrepository sub1
170 committing subrepository sub1
171 committing subrepository sub1/sub2 (glob)
171 committing subrepository sub1/sub2 (glob)
General Comments 0
You need to be logged in to leave comments. Login now