Mercurial > hg
comparison hgext/largefiles/overrides.py @ 17576:e0081bb5450e stable
largefiles: exit from remove with 1 on warnings
This maintains the exit codes documented in commands.py.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sun, 09 Sep 2012 20:18:08 -0400 |
parents | 98d6a10bc401 |
children | 0f39e9355d3c |
comparison
equal
deleted
inserted
replaced
17575:98d6a10bc401 | 17576:e0081bb5450e |
---|---|
139 | 139 |
140 def warn(files, reason): | 140 def warn(files, reason): |
141 for f in files: | 141 for f in files: |
142 ui.warn(_('not removing %s: %s (use forget to undo)\n') | 142 ui.warn(_('not removing %s: %s (use forget to undo)\n') |
143 % (m.rel(f), reason)) | 143 % (m.rel(f), reason)) |
144 return int(len(files) > 0) | |
145 | |
146 result = 0 | |
144 | 147 |
145 if after: | 148 if after: |
146 remove, forget = deleted, [] | 149 remove, forget = deleted, [] |
147 warn(modified + added + clean, _('file still exists')) | 150 result = warn(modified + added + clean, _('file still exists')) |
148 else: | 151 else: |
149 remove, forget = deleted + clean, [] | 152 remove, forget = deleted + clean, [] |
150 warn(modified, _('file is modified')) | 153 result = warn(modified, _('file is modified')) |
151 warn(added, _('file has been marked for add')) | 154 result = warn(added, _('file has been marked for add')) or result |
152 | 155 |
153 for f in sorted(remove + forget): | 156 for f in sorted(remove + forget): |
154 if ui.verbose or not m.exact(f): | 157 if ui.verbose or not m.exact(f): |
155 ui.status(_('removing %s\n') % m.rel(f)) | 158 ui.status(_('removing %s\n') % m.rel(f)) |
156 | 159 |
179 else: | 182 else: |
180 lfutil.reporemove(repo, remove, unlink=False) | 183 lfutil.reporemove(repo, remove, unlink=False) |
181 finally: | 184 finally: |
182 wlock.release() | 185 wlock.release() |
183 | 186 |
187 return result | |
188 | |
184 # For overriding mercurial.hgweb.webcommands so that largefiles will | 189 # For overriding mercurial.hgweb.webcommands so that largefiles will |
185 # appear at their right place in the manifests. | 190 # appear at their right place in the manifests. |
186 def decodepath(orig, path): | 191 def decodepath(orig, path): |
187 return lfutil.splitstandin(path) or path | 192 return lfutil.splitstandin(path) or path |
188 | 193 |
205 | 210 |
206 return (result == 1 or bad) and 1 or 0 | 211 return (result == 1 or bad) and 1 or 0 |
207 | 212 |
208 def overrideremove(orig, ui, repo, *pats, **opts): | 213 def overrideremove(orig, ui, repo, *pats, **opts): |
209 installnormalfilesmatchfn(repo[None].manifest()) | 214 installnormalfilesmatchfn(repo[None].manifest()) |
210 orig(ui, repo, *pats, **opts) | 215 result = orig(ui, repo, *pats, **opts) |
211 restorematchfn() | 216 restorematchfn() |
212 removelargefiles(ui, repo, *pats, **opts) | 217 return removelargefiles(ui, repo, *pats, **opts) or result |
213 | 218 |
214 def overridestatusfn(orig, repo, rev2, **opts): | 219 def overridestatusfn(orig, repo, rev2, **opts): |
215 try: | 220 try: |
216 repo._repo.lfstatus = True | 221 repo._repo.lfstatus = True |
217 return orig(repo, rev2, **opts) | 222 return orig(repo, rev2, **opts) |