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