Show More
@@ -235,15 +235,15 b' def overrideadd(orig, ui, repo, *pats, *' | |||||
235 | return orig(ui, repo, *pats, **opts) |
|
235 | return orig(ui, repo, *pats, **opts) | |
236 |
|
236 | |||
237 | @eh.wrapfunction(cmdutil, 'add') |
|
237 | @eh.wrapfunction(cmdutil, 'add') | |
238 | def cmdutiladd(orig, ui, repo, matcher, prefix, explicitonly, **opts): |
|
238 | def cmdutiladd(orig, ui, repo, matcher, prefix, uipathfn, explicitonly, **opts): | |
239 | # The --normal flag short circuits this override |
|
239 | # The --normal flag short circuits this override | |
240 | if opts.get(r'normal'): |
|
240 | if opts.get(r'normal'): | |
241 | return orig(ui, repo, matcher, prefix, explicitonly, **opts) |
|
241 | return orig(ui, repo, matcher, prefix, uipathfn, explicitonly, **opts) | |
242 |
|
242 | |||
243 | ladded, lbad = addlargefiles(ui, repo, False, matcher, **opts) |
|
243 | ladded, lbad = addlargefiles(ui, repo, False, matcher, **opts) | |
244 | normalmatcher = composenormalfilematcher(matcher, repo[None].manifest(), |
|
244 | normalmatcher = composenormalfilematcher(matcher, repo[None].manifest(), | |
245 | ladded) |
|
245 | ladded) | |
246 | bad = orig(ui, repo, normalmatcher, prefix, explicitonly, **opts) |
|
246 | bad = orig(ui, repo, normalmatcher, prefix, uipathfn, explicitonly, **opts) | |
247 |
|
247 | |||
248 | bad.extend(f for f in lbad) |
|
248 | bad.extend(f for f in lbad) | |
249 | return bad |
|
249 | return bad |
@@ -2027,7 +2027,7 b' def walkchangerevs(repo, match, opts, pr' | |||||
2027 |
|
2027 | |||
2028 | return iterate() |
|
2028 | return iterate() | |
2029 |
|
2029 | |||
2030 | def add(ui, repo, match, prefix, explicitonly, **opts): |
|
2030 | def add(ui, repo, match, prefix, uipathfn, explicitonly, **opts): | |
2031 | bad = [] |
|
2031 | bad = [] | |
2032 |
|
2032 | |||
2033 | badfn = lambda x, y: bad.append(x) or match.bad(x, y) |
|
2033 | badfn = lambda x, y: bad.append(x) or match.bad(x, y) | |
@@ -2051,7 +2051,7 b' def add(ui, repo, match, prefix, explici' | |||||
2051 | cca(f) |
|
2051 | cca(f) | |
2052 | names.append(f) |
|
2052 | names.append(f) | |
2053 | if ui.verbose or not exact: |
|
2053 | if ui.verbose or not exact: | |
2054 |
ui.status(_('adding %s\n') % |
|
2054 | ui.status(_('adding %s\n') % uipathfn(f), | |
2055 | label='ui.addremove.added') |
|
2055 | label='ui.addremove.added') | |
2056 |
|
2056 | |||
2057 | for subpath in sorted(wctx.substate): |
|
2057 | for subpath in sorted(wctx.substate): | |
@@ -2059,13 +2059,16 b' def add(ui, repo, match, prefix, explici' | |||||
2059 | try: |
|
2059 | try: | |
2060 | submatch = matchmod.subdirmatcher(subpath, match) |
|
2060 | submatch = matchmod.subdirmatcher(subpath, match) | |
2061 | subprefix = repo.wvfs.reljoin(prefix, subpath) |
|
2061 | subprefix = repo.wvfs.reljoin(prefix, subpath) | |
|
2062 | subuipathfn = scmutil.subdiruipathfn(subpath, uipathfn) | |||
2062 | if opts.get(r'subrepos'): |
|
2063 | if opts.get(r'subrepos'): | |
2063 |
bad.extend(sub.add(ui, submatch, subprefix, False, |
|
2064 | bad.extend(sub.add(ui, submatch, subprefix, subuipathfn, False, | |
|
2065 | **opts)) | |||
2064 | else: |
|
2066 | else: | |
2065 |
bad.extend(sub.add(ui, submatch, subprefix, True, |
|
2067 | bad.extend(sub.add(ui, submatch, subprefix, subuipathfn, True, | |
|
2068 | **opts)) | |||
2066 | except error.LookupError: |
|
2069 | except error.LookupError: | |
2067 | ui.status(_("skipping missing subrepository: %s\n") |
|
2070 | ui.status(_("skipping missing subrepository: %s\n") | |
2068 |
% |
|
2071 | % uipathfn(subpath)) | |
2069 |
|
2072 | |||
2070 | if not opts.get(r'dry_run'): |
|
2073 | if not opts.get(r'dry_run'): | |
2071 | rejected = wctx.add(names, prefix) |
|
2074 | rejected = wctx.add(names, prefix) |
@@ -180,7 +180,8 b' def add(ui, repo, *pats, **opts):' | |||||
180 | """ |
|
180 | """ | |
181 |
|
181 | |||
182 | m = scmutil.match(repo[None], pats, pycompat.byteskwargs(opts)) |
|
182 | m = scmutil.match(repo[None], pats, pycompat.byteskwargs(opts)) | |
183 | rejected = cmdutil.add(ui, repo, m, "", False, **opts) |
|
183 | uipathfn = scmutil.getuipathfn(repo, forcerelativevalue=True) | |
|
184 | rejected = cmdutil.add(ui, repo, m, "", uipathfn, False, **opts) | |||
184 | return rejected and 1 or 0 |
|
185 | return rejected and 1 or 0 | |
185 |
|
186 | |||
186 | @command('addremove', |
|
187 | @command('addremove', |
@@ -11,6 +11,7 b' import errno' | |||||
11 | import glob |
|
11 | import glob | |
12 | import hashlib |
|
12 | import hashlib | |
13 | import os |
|
13 | import os | |
|
14 | import posixpath | |||
14 | import re |
|
15 | import re | |
15 | import subprocess |
|
16 | import subprocess | |
16 | import weakref |
|
17 | import weakref | |
@@ -758,6 +759,10 b' def getuipathfn(repo, legacyrelativevalu' | |||||
758 | else: |
|
759 | else: | |
759 | return lambda f: f |
|
760 | return lambda f: f | |
760 |
|
761 | |||
|
762 | def subdiruipathfn(subpath, uipathfn): | |||
|
763 | '''Create a new uipathfn that treats the file as relative to subpath.''' | |||
|
764 | return lambda f: uipathfn(posixpath.join(subpath, f)) | |||
|
765 | ||||
761 | def expandpats(pats): |
|
766 | def expandpats(pats): | |
762 | '''Expand bare globs when running on windows. |
|
767 | '''Expand bare globs when running on windows. | |
763 | On posix we assume it already has already been done by sh.''' |
|
768 | On posix we assume it already has already been done by sh.''' |
@@ -287,7 +287,7 b' class abstractsubrepo(object):' | |||||
287 | """ |
|
287 | """ | |
288 | raise NotImplementedError |
|
288 | raise NotImplementedError | |
289 |
|
289 | |||
290 | def add(self, ui, match, prefix, explicitonly, **opts): |
|
290 | def add(self, ui, match, prefix, uipathfn, explicitonly, **opts): | |
291 | return [] |
|
291 | return [] | |
292 |
|
292 | |||
293 | def addremove(self, matcher, prefix, opts): |
|
293 | def addremove(self, matcher, prefix, opts): | |
@@ -516,8 +516,9 b' class hgsubrepo(abstractsubrepo):' | |||||
516 | self._repo.vfs.write('hgrc', util.tonativeeol(''.join(lines))) |
|
516 | self._repo.vfs.write('hgrc', util.tonativeeol(''.join(lines))) | |
517 |
|
517 | |||
518 | @annotatesubrepoerror |
|
518 | @annotatesubrepoerror | |
519 | def add(self, ui, match, prefix, explicitonly, **opts): |
|
519 | def add(self, ui, match, prefix, uipathfn, explicitonly, **opts): | |
520 |
return cmdutil.add(ui, self._repo, match, prefix, |
|
520 | return cmdutil.add(ui, self._repo, match, prefix, uipathfn, | |
|
521 | explicitonly, **opts) | |||
521 |
|
522 | |||
522 | @annotatesubrepoerror |
|
523 | @annotatesubrepoerror | |
523 | def addremove(self, m, prefix, opts): |
|
524 | def addremove(self, m, prefix, opts): | |
@@ -1590,7 +1591,7 b' class gitsubrepo(abstractsubrepo):' | |||||
1590 | return False |
|
1591 | return False | |
1591 |
|
1592 | |||
1592 | @annotatesubrepoerror |
|
1593 | @annotatesubrepoerror | |
1593 | def add(self, ui, match, prefix, explicitonly, **opts): |
|
1594 | def add(self, ui, match, prefix, uipathfn, explicitonly, **opts): | |
1594 | if self._gitmissing(): |
|
1595 | if self._gitmissing(): | |
1595 | return [] |
|
1596 | return [] | |
1596 |
|
1597 | |||
@@ -1614,7 +1615,7 b' class gitsubrepo(abstractsubrepo):' | |||||
1614 | if exact: |
|
1615 | if exact: | |
1615 | command.append("-f") #should be added, even if ignored |
|
1616 | command.append("-f") #should be added, even if ignored | |
1616 | if ui.verbose or not exact: |
|
1617 | if ui.verbose or not exact: | |
1617 |
ui.status(_('adding %s\n') % |
|
1618 | ui.status(_('adding %s\n') % uipathfn(f)) | |
1618 |
|
1619 | |||
1619 | if f in tracked: # hg prints 'adding' even if already tracked |
|
1620 | if f in tracked: # hg prints 'adding' even if already tracked | |
1620 | if exact: |
|
1621 | if exact: | |
@@ -1624,7 +1625,7 b' class gitsubrepo(abstractsubrepo):' | |||||
1624 | self._gitcommand(command + [f]) |
|
1625 | self._gitcommand(command + [f]) | |
1625 |
|
1626 | |||
1626 | for f in rejected: |
|
1627 | for f in rejected: | |
1627 |
ui.warn(_("%s already tracked!\n") % |
|
1628 | ui.warn(_("%s already tracked!\n") % uipathfn(f)) | |
1628 |
|
1629 | |||
1629 | return rejected |
|
1630 | return rejected | |
1630 |
|
1631 |
General Comments 0
You need to be logged in to leave comments.
Login now