Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHG16a49c778bde: forget: pass around uipathfn and use instead of m.rel() (API)
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | hgext/largefiles/overrides.py (10 lines) | |||
M | mercurial/cmdutil.py (13 lines) | |||
M | mercurial/commands.py (3 lines) | |||
M | mercurial/subrepo.py (6 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Martin von Zweigbergk | Feb 8 2019, 4:08 PM |
Status | Author | Revision | |
---|---|---|---|
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz |
def postcommitstatus(orig, repo, *args, **kwargs): | def postcommitstatus(orig, repo, *args, **kwargs): | ||||
repo.lfstatus = True | repo.lfstatus = True | ||||
try: | try: | ||||
return orig(repo, *args, **kwargs) | return orig(repo, *args, **kwargs) | ||||
finally: | finally: | ||||
repo.lfstatus = False | repo.lfstatus = False | ||||
@eh.wrapfunction(cmdutil, 'forget') | @eh.wrapfunction(cmdutil, 'forget') | ||||
def cmdutilforget(orig, ui, repo, match, prefix, explicitonly, dryrun, | def cmdutilforget(orig, ui, repo, match, prefix, uipathfn, explicitonly, dryrun, | ||||
interactive): | interactive): | ||||
normalmatcher = composenormalfilematcher(match, repo[None].manifest()) | normalmatcher = composenormalfilematcher(match, repo[None].manifest()) | ||||
bad, forgot = orig(ui, repo, normalmatcher, prefix, explicitonly, dryrun, | bad, forgot = orig(ui, repo, normalmatcher, prefix, uipathfn, explicitonly, | ||||
interactive) | dryrun, interactive) | ||||
m = composelargefilematcher(match, repo[None].manifest()) | m = composelargefilematcher(match, repo[None].manifest()) | ||||
try: | try: | ||||
repo.lfstatus = True | repo.lfstatus = True | ||||
s = repo.status(match=m, clean=True) | s = repo.status(match=m, clean=True) | ||||
finally: | finally: | ||||
repo.lfstatus = False | repo.lfstatus = False | ||||
manifest = repo[None].manifest() | manifest = repo[None].manifest() | ||||
forget = sorted(s.modified + s.added + s.deleted + s.clean) | forget = sorted(s.modified + s.added + s.deleted + s.clean) | ||||
forget = [f for f in forget if lfutil.standin(f) in manifest] | forget = [f for f in forget if lfutil.standin(f) in manifest] | ||||
for f in forget: | for f in forget: | ||||
fstandin = lfutil.standin(f) | fstandin = lfutil.standin(f) | ||||
if fstandin not in repo.dirstate and not repo.wvfs.isdir(fstandin): | if fstandin not in repo.dirstate and not repo.wvfs.isdir(fstandin): | ||||
ui.warn(_('not removing %s: file is already untracked\n') | ui.warn(_('not removing %s: file is already untracked\n') | ||||
% m.rel(f)) | % uipathfn(f)) | ||||
bad.append(f) | bad.append(f) | ||||
for f in forget: | for f in forget: | ||||
if ui.verbose or not m.exact(f): | if ui.verbose or not m.exact(f): | ||||
ui.status(_('removing %s\n') % m.rel(f)) | ui.status(_('removing %s\n') % uipathfn(f)) | ||||
# Need to lock because standin files are deleted then removed from the | # Need to lock because standin files are deleted then removed from the | ||||
# repository and we could race in-between. | # repository and we could race in-between. | ||||
with repo.wlock(): | with repo.wlock(): | ||||
lfdirstate = lfutil.openlfdirstate(ui, repo) | lfdirstate = lfutil.openlfdirstate(ui, repo) | ||||
for f in forget: | for f in forget: | ||||
if lfdirstate[f] == 'a': | if lfdirstate[f] == 'a': | ||||
lfdirstate.drop(f) | lfdirstate.drop(f) |
webconf[serverpath] = repo.root | webconf[serverpath] = repo.root | ||||
repo.ui.debug('adding %s = %s\n' % (serverpath, repo.root)) | repo.ui.debug('adding %s = %s\n' % (serverpath, repo.root)) | ||||
for r in repo.revs('filelog("path:.hgsub")'): | for r in repo.revs('filelog("path:.hgsub")'): | ||||
ctx = repo[r] | ctx = repo[r] | ||||
for subpath in ctx.substate: | for subpath in ctx.substate: | ||||
ctx.sub(subpath).addwebdirpath(serverpath, webconf) | ctx.sub(subpath).addwebdirpath(serverpath, webconf) | ||||
def forget(ui, repo, match, prefix, explicitonly, dryrun, interactive): | def forget(ui, repo, match, prefix, uipathfn, explicitonly, dryrun, | ||||
interactive): | |||||
if dryrun and interactive: | if dryrun and interactive: | ||||
raise error.Abort(_("cannot specify both --dry-run and --interactive")) | raise error.Abort(_("cannot specify both --dry-run and --interactive")) | ||||
bad = [] | bad = [] | ||||
badfn = lambda x, y: bad.append(x) or match.bad(x, y) | badfn = lambda x, y: bad.append(x) or match.bad(x, y) | ||||
wctx = repo[None] | wctx = repo[None] | ||||
forgot = [] | forgot = [] | ||||
s = repo.status(match=matchmod.badmatch(match, badfn), clean=True) | s = repo.status(match=matchmod.badmatch(match, badfn), clean=True) | ||||
forget = sorted(s.modified + s.added + s.deleted + s.clean) | forget = sorted(s.modified + s.added + s.deleted + s.clean) | ||||
if explicitonly: | if explicitonly: | ||||
forget = [f for f in forget if match.exact(f)] | forget = [f for f in forget if match.exact(f)] | ||||
for subpath in sorted(wctx.substate): | for subpath in sorted(wctx.substate): | ||||
sub = wctx.sub(subpath) | sub = wctx.sub(subpath) | ||||
submatch = matchmod.subdirmatcher(subpath, match) | submatch = matchmod.subdirmatcher(subpath, match) | ||||
subprefix = repo.wvfs.reljoin(prefix, subpath) | subprefix = repo.wvfs.reljoin(prefix, subpath) | ||||
subuipathfn = scmutil.subdiruipathfn(subpath, uipathfn) | |||||
try: | try: | ||||
subbad, subforgot = sub.forget(submatch, subprefix, dryrun=dryrun, | subbad, subforgot = sub.forget(submatch, subprefix, subuipathfn, | ||||
dryrun=dryrun, | |||||
interactive=interactive) | interactive=interactive) | ||||
bad.extend([subpath + '/' + f for f in subbad]) | bad.extend([subpath + '/' + f for f in subbad]) | ||||
forgot.extend([subpath + '/' + f for f in subforgot]) | forgot.extend([subpath + '/' + f for f in subforgot]) | ||||
except error.LookupError: | except error.LookupError: | ||||
ui.status(_("skipping missing subrepository: %s\n") | ui.status(_("skipping missing subrepository: %s\n") | ||||
% match.rel(subpath)) | % uipathfn(subpath)) | ||||
if not explicitonly: | if not explicitonly: | ||||
for f in match.files(): | for f in match.files(): | ||||
if f not in repo.dirstate and not repo.wvfs.isdir(f): | if f not in repo.dirstate and not repo.wvfs.isdir(f): | ||||
if f not in forgot: | if f not in forgot: | ||||
if repo.wvfs.exists(f): | if repo.wvfs.exists(f): | ||||
# Don't complain if the exact case match wasn't given. | # Don't complain if the exact case match wasn't given. | ||||
# But don't do this until after checking 'forgot', so | # But don't do this until after checking 'forgot', so | ||||
# that subrepo files aren't normalized, and this op is | # that subrepo files aren't normalized, and this op is | ||||
# purely from data cached by the status walk above. | # purely from data cached by the status walk above. | ||||
if repo.dirstate.normalize(f) in repo.dirstate: | if repo.dirstate.normalize(f) in repo.dirstate: | ||||
continue | continue | ||||
ui.warn(_('not removing %s: ' | ui.warn(_('not removing %s: ' | ||||
'file is already untracked\n') | 'file is already untracked\n') | ||||
% match.rel(f)) | % uipathfn(f)) | ||||
bad.append(f) | bad.append(f) | ||||
if interactive: | if interactive: | ||||
responses = _('[Ynsa?]' | responses = _('[Ynsa?]' | ||||
'$$ &Yes, forget this file' | '$$ &Yes, forget this file' | ||||
'$$ &No, skip this file' | '$$ &No, skip this file' | ||||
'$$ &Skip remaining files' | '$$ &Skip remaining files' | ||||
'$$ Include &all remaining files' | '$$ Include &all remaining files' | ||||
fnindex = forget.index(filename) | fnindex = forget.index(filename) | ||||
del forget[fnindex:] | del forget[fnindex:] | ||||
break | break | ||||
elif r == 3: # All | elif r == 3: # All | ||||
break | break | ||||
for f in forget: | for f in forget: | ||||
if ui.verbose or not match.exact(f) or interactive: | if ui.verbose or not match.exact(f) or interactive: | ||||
ui.status(_('removing %s\n') % match.rel(f), | ui.status(_('removing %s\n') % uipathfn(f), | ||||
label='ui.addremove.removed') | label='ui.addremove.removed') | ||||
if not dryrun: | if not dryrun: | ||||
rejected = wctx.forget(forget, prefix) | rejected = wctx.forget(forget, prefix) | ||||
bad.extend(f for f in rejected if f in match.files()) | bad.extend(f for f in rejected if f in match.files()) | ||||
forgot.extend(f for f in forget if f not in rejected) | forgot.extend(f for f in forget if f not in rejected) | ||||
return bad, forgot | return bad, forgot | ||||
""" | """ | ||||
opts = pycompat.byteskwargs(opts) | opts = pycompat.byteskwargs(opts) | ||||
if not pats: | if not pats: | ||||
raise error.Abort(_('no files specified')) | raise error.Abort(_('no files specified')) | ||||
m = scmutil.match(repo[None], pats, opts) | m = scmutil.match(repo[None], pats, opts) | ||||
dryrun, interactive = opts.get('dry_run'), opts.get('interactive') | dryrun, interactive = opts.get('dry_run'), opts.get('interactive') | ||||
rejected = cmdutil.forget(ui, repo, m, prefix="", | uipathfn = scmutil.getuipathfn(repo, forcerelativevalue=True) | ||||
rejected = cmdutil.forget(ui, repo, m, prefix="", uipathfn=uipathfn, | |||||
explicitonly=False, dryrun=dryrun, | explicitonly=False, dryrun=dryrun, | ||||
interactive=interactive)[0] | interactive=interactive)[0] | ||||
return rejected and 1 or 0 | return rejected and 1 or 0 | ||||
@command( | @command( | ||||
'graft', | 'graft', | ||||
[('r', 'rev', [], _('revisions to graft'), _('REV')), | [('r', 'rev', [], _('revisions to graft'), _('REV')), | ||||
('', 'base', '', | ('', 'base', '', |
return total | return total | ||||
def walk(self, match): | def walk(self, match): | ||||
''' | ''' | ||||
walk recursively through the directory tree, finding all files | walk recursively through the directory tree, finding all files | ||||
matched by the match function | matched by the match function | ||||
''' | ''' | ||||
def forget(self, match, prefix, dryrun, interactive): | def forget(self, match, prefix, uipathfn, dryrun, interactive): | ||||
return ([], []) | return ([], []) | ||||
def removefiles(self, matcher, prefix, uipathfn, after, force, subrepos, | def removefiles(self, matcher, prefix, uipathfn, after, force, subrepos, | ||||
dryrun, warnings): | dryrun, warnings): | ||||
"""remove the matched files from the subrepository and the filesystem, | """remove the matched files from the subrepository and the filesystem, | ||||
possibly by force and/or after the file has been removed from the | possibly by force and/or after the file has been removed from the | ||||
filesystem. Return 0 on success, 1 on any warning. | filesystem. Return 0 on success, 1 on any warning. | ||||
""" | """ | ||||
return matchers[0] | return matchers[0] | ||||
return matchmod.unionmatcher(matchers) | return matchmod.unionmatcher(matchers) | ||||
def walk(self, match): | def walk(self, match): | ||||
ctx = self._repo[None] | ctx = self._repo[None] | ||||
return ctx.walk(match) | return ctx.walk(match) | ||||
@annotatesubrepoerror | @annotatesubrepoerror | ||||
def forget(self, match, prefix, dryrun, interactive): | def forget(self, match, prefix, uipathfn, dryrun, interactive): | ||||
return cmdutil.forget(self.ui, self._repo, match, prefix, | return cmdutil.forget(self.ui, self._repo, match, prefix, uipathfn, | ||||
True, dryrun=dryrun, interactive=interactive) | True, dryrun=dryrun, interactive=interactive) | ||||
@annotatesubrepoerror | @annotatesubrepoerror | ||||
def removefiles(self, matcher, prefix, uipathfn, after, force, subrepos, | def removefiles(self, matcher, prefix, uipathfn, after, force, subrepos, | ||||
dryrun, warnings): | dryrun, warnings): | ||||
return cmdutil.remove(self.ui, self._repo, matcher, prefix, uipathfn, | return cmdutil.remove(self.ui, self._repo, matcher, prefix, uipathfn, | ||||
after, force, subrepos, dryrun) | after, force, subrepos, dryrun) | ||||