comparison mercurial/cmdutil.py @ 23686:164915e8ef7b

narrowmatcher: propagate the rel() method The full path is propagated to the original match object since this is often used directly for printing a file name to the user. This is cleaner than requiring each caller to join the prefix with the file name prior to calling it, and will lead to not having to pass the prefix around separately. It is also consistent with the bad() and abs() methods in terms of the required input. The uipath() method now inherits this path building property. There is no visible change in path style for rel() because it ultimately calls util.pathto(), which returns an os.sep based path. (The previous os.path.join() was violating the documented usage of util.pathto(), that its third parameter be '/' separated.) The doctest needed to be normalized to '/' separators to avoid test differences on Windows, now that a full path is returned for a short filename. The test changes are to drop globs that are no longer necessary when printing an absolute file in a subrepo, as returned from match.uipath(). Previously when os.path.join() was used to add the prefix, the absolute path to a file in a subrepo was printed with a mix of '/' and '\'. The absolute path for a file not in a subrepo, as returned from match.uipath(), is still purely '/' based.
author Matt Harbison <matt_harbison@yahoo.com>
date Thu, 27 Nov 2014 10:16:56 -0500
parents 6e36b9fc7869
children e41bcb019633
comparison
equal deleted inserted replaced
23685:5b1eac343ccd 23686:164915e8ef7b
1989 if exact or not explicitonly and f not in wctx and repo.wvfs.lexists(f): 1989 if exact or not explicitonly and f not in wctx and repo.wvfs.lexists(f):
1990 if cca: 1990 if cca:
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)
1998 try: 1998 try:
1999 submatch = matchmod.narrowmatcher(subpath, match) 1999 submatch = matchmod.narrowmatcher(subpath, match)
2040 if f not in repo.dirstate and not repo.wvfs.isdir(f): 2040 if f not in repo.dirstate and not repo.wvfs.isdir(f):
2041 if f not in forgot: 2041 if f not in forgot:
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())
2054 forgot.extend(forget) 2054 forgot.extend(forget)
2055 return bad, forgot 2055 return bad, forgot
2093 continue 2093 continue
2094 2094
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
2105 if force: 2105 if force:
2106 list = modified + deleted + clean + added 2106 list = modified + deleted + clean + added
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:
2129 if not after: 2129 if not after:
2130 for f in list: 2130 for f in list: