Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 5688:883d887c6408
commands: add exits(1) if a specified file cannot be added (issue 891)
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Mon, 24 Dec 2007 12:14:43 +0100 |
parents | 9d6ad26fab10 |
children | 14789f30ac11 75c2071385da |
comparison
equal
deleted
inserted
replaced
5687:ca7af19debea | 5688:883d887c6408 |
---|---|
1008 return (modified, added, removed, deleted, unknown, ignored, clean) | 1008 return (modified, added, removed, deleted, unknown, ignored, clean) |
1009 | 1009 |
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" |
1022 " performance problems\n" | 1024 " performance problems\n" |
1023 "(use 'hg revert %s' to unadd the file)\n") | 1025 "(use 'hg revert %s' to unadd the file)\n") |
1024 % (f, f)) | 1026 % (f, f)) |
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 |
1037 def forget(self, list): | 1041 def forget(self, list): |
1038 wlock = self.wlock() | 1042 wlock = self.wlock() |