##// END OF EJS Templates
mq: move many error messages to util.Abort
Vadim Gelfer -
r2712:8e5cd8d1 default
parent child Browse files
Show More
@@ -187,8 +187,7 b' class queue:'
187 187 return (err, n)
188 188
189 189 if n is None:
190 self.ui.warn("apply failed for patch %s\n" % patch)
191 sys.exit(1)
190 raise util.Abort(_("apply failed for patch %s") % patch)
192 191
193 192 self.ui.warn("patch didn't work out, merging %s\n" % patch)
194 193
@@ -199,17 +198,14 b' class queue:'
199 198 c = repo.changelog.read(rev)
200 199 ret = repo.update(rev, allow=True, wlock=wlock)
201 200 if ret:
202 self.ui.warn("update returned %d\n" % ret)
203 sys.exit(1)
201 raise util.Abort(_("update returned %d") % ret)
204 202 n = repo.commit(None, c[4], c[1], force=1, wlock=wlock)
205 203 if n == None:
206 self.ui.warn("repo commit failed\n")
207 sys.exit(1)
204 raise util.Abort(_("repo commit failed"))
208 205 try:
209 206 message, comments, user, date, patchfound = mergeq.readheaders(patch)
210 207 except:
211 self.ui.warn("Unable to read %s\n" % patch)
212 sys.exit(1)
208 raise util.Abort(_("unable to read %s") % patch)
213 209
214 210 patchf = self.opener(patch, "w")
215 211 if comments:
@@ -356,8 +352,7 b' class queue:'
356 352 wlock=wlock)
357 353
358 354 if n == None:
359 self.ui.warn("repo commit failed\n")
360 sys.exit(1)
355 raise util.Abort(_("repo commit failed"))
361 356
362 357 if update_status:
363 358 self.applied.append(revlog.hex(n) + ":" + patch)
@@ -383,11 +378,9 b' class queue:'
383 378 patch = self.lookup(patch, strict=True)
384 379 info = self.isapplied(patch)
385 380 if info:
386 self.ui.warn("cannot delete applied patch %s\n" % patch)
387 sys.exit(1)
381 raise util.Abort(_("cannot delete applied patch %s") % patch)
388 382 if patch not in self.series:
389 self.ui.warn("patch %s not in series file\n" % patch)
390 sys.exit(1)
383 raise util.Abort(_("patch %s not in series file") % patch)
391 384 i = self.find_series(patch)
392 385 del self.full_series[i]
393 386 self.read_series(self.full_series)
@@ -399,15 +392,13 b' class queue:'
399 392 top = revlog.bin(top)
400 393 pp = repo.dirstate.parents()
401 394 if top not in pp:
402 self.ui.warn("queue top not at dirstate parents. top %s dirstate %s %s\n" %( revlog.short(top), revlog.short(pp[0]), revlog.short(pp[1])))
403 sys.exit(1)
395 raise util.Abort(_("queue top not at same revision as working directory"))
404 396 return top
405 397 return None
406 398 def check_localchanges(self, repo):
407 399 (c, a, r, d, u) = repo.changes(None, None)
408 400 if c or a or d or r:
409 self.ui.write("Local changes found, refresh first\n")
410 sys.exit(1)
401 raise util.Abort(_("local changes found, refresh first"))
411 402 def new(self, repo, patch, msg=None, force=None):
412 403 if os.path.exists(os.path.join(self.path, patch)):
413 404 raise util.Abort(_('patch "%s" already exists') % patch)
@@ -415,9 +406,8 b' class queue:'
415 406 (c, a, r, d, u) = repo.changes(None, None)
416 407 if c or a or d or r:
417 408 if not force:
418 raise util.Abort(_("Local changes found, refresh first"))
419 else:
420 commitfiles = c + a + r
409 raise util.Abort(_("local changes found, refresh first"))
410 commitfiles = c + a + r
421 411 self.check_toppatch(repo)
422 412 wlock = repo.wlock()
423 413 insert = self.full_series_end()
@@ -428,8 +418,7 b' class queue:'
428 418 n = repo.commit(commitfiles,
429 419 "New patch: %s" % patch, force=True, wlock=wlock)
430 420 if n == None:
431 self.ui.warn("repo commit failed\n")
432 sys.exit(1)
421 raise util.Abort(_("repo commit failed"))
433 422 self.full_series[insert:insert] = [patch]
434 423 self.applied.append(revlog.hex(n) + ":" + patch)
435 424 self.read_series(self.full_series)
@@ -534,7 +523,7 b' class queue:'
534 523 if update:
535 524 (c, a, r, d, u) = repo.changes(None, None)
536 525 if c or a or d or r:
537 raise util.Abort(_("Local changes found"))
526 raise util.Abort(_("local changes found"))
538 527 urev = self.qparents(repo, rev)
539 528 repo.update(urev, allow=False, force=True, wlock=wlock)
540 529 repo.dirstate.write()
@@ -674,8 +663,7 b' class queue:'
674 663 else:
675 664 if i + off < len(self.series):
676 665 return self.series[i + off]
677 self.ui.warn("patch %s not in series\n" % patch)
678 sys.exit(1)
666 raise util.Abort(_("patch %s not in series") % patch)
679 667
680 668 def push(self, repo, patch=None, force=False, list=False,
681 669 mergeq=None, wlock=None):
@@ -683,10 +671,10 b' class queue:'
683 671 wlock = repo.wlock()
684 672 patch = self.lookup(patch)
685 673 if patch and self.isapplied(patch):
686 self.ui.warn("patch %s is already applied\n" % patch)
674 self.ui.warn(_("patch %s is already applied\n") % patch)
687 675 sys.exit(1)
688 676 if self.series_end() == len(self.series):
689 self.ui.warn("File series fully applied\n")
677 self.ui.warn(_("patch series fully applied\n"))
690 678 sys.exit(1)
691 679 if not force:
692 680 self.check_localchanges(repo)
@@ -735,10 +723,9 b' class queue:'
735 723 patch = self.lookup(patch)
736 724 info = self.isapplied(patch)
737 725 if not info:
738 self.ui.warn("patch %s is not applied\n" % patch)
739 sys.exit(1)
726 raise util.Abort(_("patch %s is not applied") % patch)
740 727 if len(self.applied) == 0:
741 self.ui.warn("No patches applied\n")
728 self.ui.warn(_("no patches applied\n"))
742 729 sys.exit(1)
743 730
744 731 if not update:
@@ -912,15 +899,14 b' class queue:'
912 899
913 900 def init(self, repo, create=False):
914 901 if os.path.isdir(self.path):
915 raise util.Abort("patch queue directory already exists")
902 raise util.Abort(_("patch queue directory already exists"))
916 903 os.mkdir(self.path)
917 904 if create:
918 905 return self.qrepo(create=True)
919 906
920 907 def unapplied(self, repo, patch=None):
921 908 if patch and patch not in self.series:
922 self.ui.warn("%s not in the series file\n" % patch)
923 sys.exit(1)
909 raise util.Abort(_("patch %s is not in series file") % patch)
924 910 if not patch:
925 911 start = self.series_end()
926 912 else:
@@ -1072,8 +1058,7 b' class queue:'
1072 1058
1073 1059 def qapplied(self, repo, patch=None):
1074 1060 if patch and patch not in self.series:
1075 self.ui.warn("%s not in the series file\n" % patch)
1076 sys.exit(1)
1061 raise util.Abort(_("patch %s is not in series file") % patch)
1077 1062 if not patch:
1078 1063 end = len(self.applied)
1079 1064 else:
@@ -1119,8 +1104,8 b' class queue:'
1119 1104
1120 1105 def qimport(self, repo, files, patch=None, existing=None, force=None):
1121 1106 if len(files) > 1 and patch:
1122 self.ui.warn("-n option not valid when importing multiple files\n")
1123 sys.exit(1)
1107 raise util.Abort(_('option "-n" not valid when importing multiple '
1108 'files'))
1124 1109 i = 0
1125 1110 added = []
1126 1111 for filename in files:
@@ -1128,17 +1113,15 b' class queue:'
1128 1113 if not patch:
1129 1114 patch = filename
1130 1115 if not os.path.isfile(os.path.join(self.path, patch)):
1131 self.ui.warn("patch %s does not exist\n" % patch)
1132 sys.exit(1)
1116 raise util.Abort(_("patch %s does not exist") % patch)
1133 1117 else:
1134 1118 try:
1135 1119 text = file(filename).read()
1136 1120 except IOError:
1137 self.ui.warn("Unable to read %s\n" % patch)
1138 sys.exit(1)
1121 raise util.Abort(_("unable to read %s") % patch)
1139 1122 if not patch:
1140 1123 patch = os.path.split(filename)[1]
1141 if not force and os.path.isfile(os.path.join(self.path, patch)):
1124 if not force and os.path.exists(os.path.join(self.path, patch)):
1142 1125 raise util.Abort(_('patch "%s" already exists') % patch)
1143 1126 patchf = self.opener(patch, "w")
1144 1127 patchf.write(text)
@@ -1327,13 +1310,11 b' def save(ui, repo, **opts):'
1327 1310 newpath = os.path.join(q.basepath, opts['name'])
1328 1311 if os.path.exists(newpath):
1329 1312 if not os.path.isdir(newpath):
1330 ui.warn("destination %s exists and is not a directory\n" %
1331 newpath)
1332 sys.exit(1)
1313 raise util.Abort(_('destination %s exists and is not '
1314 'a directory') % newpath)
1333 1315 if not opts['force']:
1334 ui.warn("destination %s exists, use -f to force\n" %
1335 newpath)
1336 sys.exit(1)
1316 raise util.Abort(_('destination %s exists, '
1317 'use -f to force') % newpath)
1337 1318 else:
1338 1319 newpath = savename(path)
1339 1320 ui.warn("copy %s to %s\n" % (path, newpath))
General Comments 0
You need to be logged in to leave comments. Login now