Show More
@@ -1280,19 +1280,32 b' def walkchangerevs(repo, match, opts, pr' | |||||
1280 | yield change(rev) |
|
1280 | yield change(rev) | |
1281 | return iterate() |
|
1281 | return iterate() | |
1282 |
|
1282 | |||
1283 | def add(ui, repo, match, dryrun): |
|
1283 | def add(ui, repo, match, dryrun, listsubrepos, prefix): | |
|
1284 | join = lambda f: os.path.join(prefix, f) | |||
1284 | bad = [] |
|
1285 | bad = [] | |
1285 | oldbad = match.bad |
|
1286 | oldbad = match.bad | |
1286 | match.bad = lambda x, y: bad.append(x) or oldbad(x, y) |
|
1287 | match.bad = lambda x, y: bad.append(x) or oldbad(x, y) | |
1287 | names = [] |
|
1288 | names = [] | |
|
1289 | wctx = repo[None] | |||
1288 | for f in repo.walk(match): |
|
1290 | for f in repo.walk(match): | |
1289 | exact = match.exact(f) |
|
1291 | exact = match.exact(f) | |
1290 | if exact or f not in repo.dirstate: |
|
1292 | if exact or f not in repo.dirstate: | |
1291 | names.append(f) |
|
1293 | names.append(f) | |
1292 | if ui.verbose or not exact: |
|
1294 | if ui.verbose or not exact: | |
1293 | ui.status(_('adding %s\n') % match.rel(f)) |
|
1295 | ui.status(_('adding %s\n') % match.rel(join(f))) | |
|
1296 | ||||
|
1297 | if listsubrepos: | |||
|
1298 | for subpath in wctx.substate: | |||
|
1299 | sub = wctx.sub(subpath) | |||
|
1300 | try: | |||
|
1301 | submatch = matchmod.narrowmatcher(subpath, match) | |||
|
1302 | bad.extend(sub.add(ui, submatch, dryrun, prefix)) | |||
|
1303 | except error.LookupError: | |||
|
1304 | ui.status(_("skipping missing subrepository: %s\n") | |||
|
1305 | % join(subpath)) | |||
|
1306 | ||||
1294 | if not dryrun: |
|
1307 | if not dryrun: | |
1295 |
rejected = |
|
1308 | rejected = wctx.add(names, prefix) | |
1296 | bad.extend(f for f in rejected if f in match.files()) |
|
1309 | bad.extend(f for f in rejected if f in match.files()) | |
1297 | return bad |
|
1310 | return bad | |
1298 |
|
1311 |
@@ -47,7 +47,8 b' def add(ui, repo, *pats, **opts):' | |||||
47 | """ |
|
47 | """ | |
48 |
|
48 | |||
49 | m = cmdutil.match(repo, pats, opts) |
|
49 | m = cmdutil.match(repo, pats, opts) | |
50 |
rejected = cmdutil.add(ui, repo, m, opts.get('dry_run') |
|
50 | rejected = cmdutil.add(ui, repo, m, opts.get('dry_run'), | |
|
51 | opts.get('subrepos'), prefix="") | |||
51 | return rejected and 1 or 0 |
|
52 | return rejected and 1 or 0 | |
52 |
|
53 | |||
53 | def addremove(ui, repo, *pats, **opts): |
|
54 | def addremove(ui, repo, *pats, **opts): | |
@@ -4001,7 +4002,8 b' subrepoopts = [' | |||||
4001 | ] |
|
4002 | ] | |
4002 |
|
4003 | |||
4003 | table = { |
|
4004 | table = { | |
4004 |
"^add": (add, walkopts + dryrunopts, |
|
4005 | "^add": (add, walkopts + subrepoopts + dryrunopts, | |
|
4006 | _('[OPTION]... [FILE]...')), | |||
4005 | "addremove": |
|
4007 | "addremove": | |
4006 | (addremove, similarityopts + walkopts + dryrunopts, |
|
4008 | (addremove, similarityopts + walkopts + dryrunopts, | |
4007 | _('[OPTION]... [FILE]...')), |
|
4009 | _('[OPTION]... [FILE]...')), |
@@ -769,7 +769,8 b' class workingctx(changectx):' | |||||
769 | self.modified() or self.added() or self.removed() or |
|
769 | self.modified() or self.added() or self.removed() or | |
770 | (missing and self.deleted())) |
|
770 | (missing and self.deleted())) | |
771 |
|
771 | |||
772 | def add(self, list): |
|
772 | def add(self, list, prefix=""): | |
|
773 | join = lambda f: os.path.join(prefix, f) | |||
773 | wlock = self._repo.wlock() |
|
774 | wlock = self._repo.wlock() | |
774 | ui, ds = self._repo.ui, self._repo.dirstate |
|
775 | ui, ds = self._repo.ui, self._repo.dirstate | |
775 | try: |
|
776 | try: | |
@@ -779,7 +780,7 b' class workingctx(changectx):' | |||||
779 | try: |
|
780 | try: | |
780 | st = os.lstat(p) |
|
781 | st = os.lstat(p) | |
781 | except: |
|
782 | except: | |
782 | ui.warn(_("%s does not exist!\n") % f) |
|
783 | ui.warn(_("%s does not exist!\n") % join(f)) | |
783 | rejected.append(f) |
|
784 | rejected.append(f) | |
784 | continue |
|
785 | continue | |
785 | if st.st_size > 10000000: |
|
786 | if st.st_size > 10000000: | |
@@ -787,13 +788,13 b' class workingctx(changectx):' | |||||
787 | "to manage this file\n" |
|
788 | "to manage this file\n" | |
788 | "(use 'hg revert %s' to cancel the " |
|
789 | "(use 'hg revert %s' to cancel the " | |
789 | "pending addition)\n") |
|
790 | "pending addition)\n") | |
790 | % (f, 3 * st.st_size // 1000000, f)) |
|
791 | % (f, 3 * st.st_size // 1000000, join(f))) | |
791 | if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)): |
|
792 | if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)): | |
792 | ui.warn(_("%s not added: only files and symlinks " |
|
793 | ui.warn(_("%s not added: only files and symlinks " | |
793 | "supported currently\n") % f) |
|
794 | "supported currently\n") % join(f)) | |
794 | rejected.append(p) |
|
795 | rejected.append(p) | |
795 | elif ds[f] in 'amn': |
|
796 | elif ds[f] in 'amn': | |
796 | ui.warn(_("%s already tracked!\n") % f) |
|
797 | ui.warn(_("%s already tracked!\n") % join(f)) | |
797 | elif ds[f] == 'r': |
|
798 | elif ds[f] == 'r': | |
798 | ds.normallookup(f) |
|
799 | ds.normallookup(f) | |
799 | else: |
|
800 | else: |
@@ -255,6 +255,8 b' class abstractsubrepo(object):' | |||||
255 | """ |
|
255 | """ | |
256 | raise NotImplementedError |
|
256 | raise NotImplementedError | |
257 |
|
257 | |||
|
258 | def add(self, ui, match, dryrun, prefix): | |||
|
259 | return [] | |||
258 |
|
260 | |||
259 | def status(self, rev2, **opts): |
|
261 | def status(self, rev2, **opts): | |
260 | return [], [], [], [], [], [], [] |
|
262 | return [], [], [], [], [], [], [] | |
@@ -291,6 +293,10 b' class hgsubrepo(abstractsubrepo):' | |||||
291 | addpathconfig('default-push', defpushpath) |
|
293 | addpathconfig('default-push', defpushpath) | |
292 | fp.close() |
|
294 | fp.close() | |
293 |
|
295 | |||
|
296 | def add(self, ui, match, dryrun, prefix): | |||
|
297 | return cmdutil.add(ui, self._repo, match, dryrun, True, | |||
|
298 | os.path.join(prefix, self._path)) | |||
|
299 | ||||
294 | def status(self, rev2, **opts): |
|
300 | def status(self, rev2, **opts): | |
295 | try: |
|
301 | try: | |
296 | rev1 = self._state[1] |
|
302 | rev1 = self._state[1] |
@@ -176,7 +176,7 b' Show an error if we use --options with a' | |||||
176 |
|
176 | |||
177 | Show all commands + options |
|
177 | Show all commands + options | |
178 | $ hg debugcommands |
|
178 | $ hg debugcommands | |
179 | add: include, exclude, dry-run |
|
179 | add: include, exclude, subrepos, dry-run | |
180 | annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, include, exclude |
|
180 | annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, include, exclude | |
181 | clone: noupdate, updaterev, rev, branch, pull, uncompressed, ssh, remotecmd |
|
181 | clone: noupdate, updaterev, rev, branch, pull, uncompressed, ssh, remotecmd | |
182 | commit: addremove, close-branch, include, exclude, message, logfile, date, user |
|
182 | commit: addremove, close-branch, include, exclude, message, logfile, date, user |
@@ -274,6 +274,7 b' Test short command list with verbose opt' | |||||
274 |
|
274 | |||
275 | -I --include PATTERN [+] include names matching the given patterns |
|
275 | -I --include PATTERN [+] include names matching the given patterns | |
276 | -X --exclude PATTERN [+] exclude names matching the given patterns |
|
276 | -X --exclude PATTERN [+] exclude names matching the given patterns | |
|
277 | -S --subrepos recurse into subrepositories | |||
277 | -n --dry-run do not perform actions, just print output |
|
278 | -n --dry-run do not perform actions, just print output | |
278 |
|
279 | |||
279 | [+] marked option can be specified multiple times |
|
280 | [+] marked option can be specified multiple times | |
@@ -312,6 +313,7 b' Verbose help for add' | |||||
312 |
|
313 | |||
313 | -I --include PATTERN [+] include names matching the given patterns |
|
314 | -I --include PATTERN [+] include names matching the given patterns | |
314 | -X --exclude PATTERN [+] exclude names matching the given patterns |
|
315 | -X --exclude PATTERN [+] exclude names matching the given patterns | |
|
316 | -S --subrepos recurse into subrepositories | |||
315 | -n --dry-run do not perform actions, just print output |
|
317 | -n --dry-run do not perform actions, just print output | |
316 |
|
318 | |||
317 | global options: |
|
319 | global options: | |
@@ -364,6 +366,7 b' Test help option with version option' | |||||
364 |
|
366 | |||
365 | -I --include PATTERN [+] include names matching the given patterns |
|
367 | -I --include PATTERN [+] include names matching the given patterns | |
366 | -X --exclude PATTERN [+] exclude names matching the given patterns |
|
368 | -X --exclude PATTERN [+] exclude names matching the given patterns | |
|
369 | -S --subrepos recurse into subrepositories | |||
367 | -n --dry-run do not perform actions, just print output |
|
370 | -n --dry-run do not perform actions, just print output | |
368 |
|
371 | |||
369 | [+] marked option can be specified multiple times |
|
372 | [+] marked option can be specified multiple times | |
@@ -391,6 +394,7 b' Test help option with version option' | |||||
391 |
|
394 | |||
392 | -I --include PATTERN [+] include names matching the given patterns |
|
395 | -I --include PATTERN [+] include names matching the given patterns | |
393 | -X --exclude PATTERN [+] exclude names matching the given patterns |
|
396 | -X --exclude PATTERN [+] exclude names matching the given patterns | |
|
397 | -S --subrepos recurse into subrepositories | |||
394 | -n --dry-run do not perform actions, just print output |
|
398 | -n --dry-run do not perform actions, just print output | |
395 |
|
399 | |||
396 | [+] marked option can be specified multiple times |
|
400 | [+] marked option can be specified multiple times |
@@ -8,25 +8,30 b' Create test repository:' | |||||
8 |
|
8 | |||
9 | $ hg init |
|
9 | $ hg init | |
10 | $ echo x1 > x.txt |
|
10 | $ echo x1 > x.txt | |
11 | $ hg add x.txt |
|
|||
12 |
|
11 | |||
13 | $ hg init foo |
|
12 | $ hg init foo | |
14 | $ cd foo |
|
13 | $ cd foo | |
15 | $ echo y1 > y.txt |
|
14 | $ echo y1 > y.txt | |
16 | $ hg add y.txt |
|
|||
17 |
|
15 | |||
18 | $ hg init bar |
|
16 | $ hg init bar | |
19 | $ cd bar |
|
17 | $ cd bar | |
20 | $ echo z1 > z.txt |
|
18 | $ echo z1 > z.txt | |
21 | $ hg add z.txt |
|
|||
22 |
|
19 | |||
23 | $ cd .. |
|
20 | $ cd .. | |
24 | $ echo 'bar = bar' > .hgsub |
|
21 | $ echo 'bar = bar' > .hgsub | |
25 | $ hg add .hgsub |
|
|||
26 |
|
22 | |||
27 | $ cd .. |
|
23 | $ cd .. | |
28 | $ echo 'foo = foo' > .hgsub |
|
24 | $ echo 'foo = foo' > .hgsub | |
29 | $ hg add .hgsub |
|
25 | ||
|
26 | Add files --- .hgsub files must go first to trigger subrepos: | |||
|
27 | ||||
|
28 | $ hg add -S .hgsub | |||
|
29 | $ hg add -S foo/.hgsub | |||
|
30 | $ hg add -S foo/bar | |||
|
31 | adding foo/bar/z.txt | |||
|
32 | $ hg add -S | |||
|
33 | adding x.txt | |||
|
34 | adding foo/y.txt | |||
30 |
|
35 | |||
31 | Test recursive status without committing anything: |
|
36 | Test recursive status without committing anything: | |
32 |
|
37 |
General Comments 0
You need to be logged in to leave comments.
Login now