Show More
@@ -26,17 +26,23 b' def add(ui, repo, *pats, **opts):' | |||||
26 | If no names are given, add all files in the repository. |
|
26 | If no names are given, add all files in the repository. | |
27 | """ |
|
27 | """ | |
28 |
|
28 | |||
|
29 | rejected = None | |||
|
30 | exacts = {} | |||
29 | names = [] |
|
31 | names = [] | |
30 |
for src, abs, rel, exact in cmdutil.walk(repo, pats, opts |
|
32 | for src, abs, rel, exact in cmdutil.walk(repo, pats, opts, | |
|
33 | badmatch=util.always): | |||
31 | if exact: |
|
34 | if exact: | |
32 | if ui.verbose: |
|
35 | if ui.verbose: | |
33 | ui.status(_('adding %s\n') % rel) |
|
36 | ui.status(_('adding %s\n') % rel) | |
34 | names.append(abs) |
|
37 | names.append(abs) | |
|
38 | exacts[abs] = 1 | |||
35 | elif abs not in repo.dirstate: |
|
39 | elif abs not in repo.dirstate: | |
36 | ui.status(_('adding %s\n') % rel) |
|
40 | ui.status(_('adding %s\n') % rel) | |
37 | names.append(abs) |
|
41 | names.append(abs) | |
38 | if not opts.get('dry_run'): |
|
42 | if not opts.get('dry_run'): | |
39 | repo.add(names) |
|
43 | rejected = repo.add(names) | |
|
44 | rejected = [p for p in rejected if p in exacts] | |||
|
45 | return rejected and 1 or 0 | |||
40 |
|
46 | |||
41 | def addremove(ui, repo, *pats, **opts): |
|
47 | def addremove(ui, repo, *pats, **opts): | |
42 | """add all new files, delete all missing files |
|
48 | """add all new files, delete all missing files |
@@ -1010,12 +1010,14 b' class localrepository(repo.repository):' | |||||
1010 | def add(self, list): |
|
1010 | def add(self, list): | |
1011 | wlock = self.wlock() |
|
1011 | wlock = self.wlock() | |
1012 | try: |
|
1012 | try: | |
|
1013 | rejected = [] | |||
1013 | for f in list: |
|
1014 | for f in list: | |
1014 | p = self.wjoin(f) |
|
1015 | p = self.wjoin(f) | |
1015 | try: |
|
1016 | try: | |
1016 | st = os.lstat(p) |
|
1017 | st = os.lstat(p) | |
1017 | except: |
|
1018 | except: | |
1018 | self.ui.warn(_("%s does not exist!\n") % f) |
|
1019 | self.ui.warn(_("%s does not exist!\n") % f) | |
|
1020 | rejected.append(f) | |||
1019 | continue |
|
1021 | continue | |
1020 | if st.st_size > 10000000: |
|
1022 | if st.st_size > 10000000: | |
1021 | self.ui.warn(_("%s: files over 10MB may cause memory and" |
|
1023 | self.ui.warn(_("%s: files over 10MB may cause memory and" | |
@@ -1025,12 +1027,14 b' class localrepository(repo.repository):' | |||||
1025 | if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)): |
|
1027 | if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)): | |
1026 | self.ui.warn(_("%s not added: only files and symlinks " |
|
1028 | self.ui.warn(_("%s not added: only files and symlinks " | |
1027 | "supported currently\n") % f) |
|
1029 | "supported currently\n") % f) | |
|
1030 | rejected.append(p) | |||
1028 | elif self.dirstate[f] in 'amn': |
|
1031 | elif self.dirstate[f] in 'amn': | |
1029 | self.ui.warn(_("%s already tracked!\n") % f) |
|
1032 | self.ui.warn(_("%s already tracked!\n") % f) | |
1030 | elif self.dirstate[f] == 'r': |
|
1033 | elif self.dirstate[f] == 'r': | |
1031 | self.dirstate.normallookup(f) |
|
1034 | self.dirstate.normallookup(f) | |
1032 | else: |
|
1035 | else: | |
1033 | self.dirstate.add(f) |
|
1036 | self.dirstate.add(f) | |
|
1037 | return rejected | |||
1034 | finally: |
|
1038 | finally: | |
1035 | del wlock |
|
1039 | del wlock | |
1036 |
|
1040 |
@@ -11,7 +11,7 b' hg st' | |||||
11 | echo b > b |
|
11 | echo b > b | |
12 | hg add -n b |
|
12 | hg add -n b | |
13 | hg st |
|
13 | hg st | |
14 | hg add b |
|
14 | hg add b || echo "failed to add b" | |
15 | hg st |
|
15 | hg st | |
16 | echo % should fail |
|
16 | echo % should fail | |
17 | hg add b |
|
17 | hg add b | |
@@ -40,3 +40,9 b' hg st' | |||||
40 | echo a > a |
|
40 | echo a > a | |
41 | hg add a |
|
41 | hg add a | |
42 | hg st |
|
42 | hg st | |
|
43 | ||||
|
44 | hg add c && echo "unexpected addition of missing file" | |||
|
45 | echo c > c | |||
|
46 | hg add d c && echo "unexpected addition of missing file" | |||
|
47 | hg st | |||
|
48 |
@@ -27,3 +27,7 b' M a' | |||||
27 | % issue683 |
|
27 | % issue683 | |
28 | R a |
|
28 | R a | |
29 | M a |
|
29 | M a | |
|
30 | c does not exist! | |||
|
31 | d does not exist! | |||
|
32 | M a | |||
|
33 | A c |
@@ -1,7 +1,7 b'' | |||||
1 | running: init test1 |
|
1 | running: init test1 | |
2 | result: None |
|
2 | result: None | |
3 | running: add foo |
|
3 | running: add foo | |
4 |
result: |
|
4 | result: 0 | |
5 | running: commit -m commit1 -d 2000-01-01 foo |
|
5 | running: commit -m commit1 -d 2000-01-01 foo | |
6 | result: None |
|
6 | result: None | |
7 | running: commit -m commit2 -d 2000-01-02 foo |
|
7 | running: commit -m commit2 -d 2000-01-02 foo |
@@ -2,5 +2,5 b' Is there an error message when trying to' | |||||
2 | found: No such file or directory |
|
2 | found: No such file or directory | |
3 | not: No such file or directory |
|
3 | not: No such file or directory | |
4 | Is there an error message when trying to add non-existing files? |
|
4 | Is there an error message when trying to add non-existing files? | |
5 | found: No such file or directory |
|
5 | found does not exist! | |
6 | not: No such file or directory |
|
6 | not does not exist! |
General Comments 0
You need to be logged in to leave comments.
Login now