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