comparison hgext/mq.py @ 2710:ca97be5babf8

mq: do not allow to qnew a patch twice
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Thu, 27 Jul 2006 16:08:56 -0700
parents f8bcaf5696d5
children 8e5cd8d11b51
comparison
equal deleted inserted replaced
2709:e475fe2a6029 2710:ca97be5babf8
407 (c, a, r, d, u) = repo.changes(None, None) 407 (c, a, r, d, u) = repo.changes(None, None)
408 if c or a or d or r: 408 if c or a or d or r:
409 self.ui.write("Local changes found, refresh first\n") 409 self.ui.write("Local changes found, refresh first\n")
410 sys.exit(1) 410 sys.exit(1)
411 def new(self, repo, patch, msg=None, force=None): 411 def new(self, repo, patch, msg=None, force=None):
412 if os.path.exists(os.path.join(self.path, patch)):
413 raise util.Abort(_('patch "%s" already exists') % patch)
412 commitfiles = [] 414 commitfiles = []
413 (c, a, r, d, u) = repo.changes(None, None) 415 (c, a, r, d, u) = repo.changes(None, None)
414 if c or a or d or r: 416 if c or a or d or r:
415 if not force: 417 if not force:
416 raise util.Abort(_("Local changes found, refresh first")) 418 raise util.Abort(_("Local changes found, refresh first"))
1135 self.ui.warn("Unable to read %s\n" % patch) 1137 self.ui.warn("Unable to read %s\n" % patch)
1136 sys.exit(1) 1138 sys.exit(1)
1137 if not patch: 1139 if not patch:
1138 patch = os.path.split(filename)[1] 1140 patch = os.path.split(filename)[1]
1139 if not force and os.path.isfile(os.path.join(self.path, patch)): 1141 if not force and os.path.isfile(os.path.join(self.path, patch)):
1140 self.ui.warn("patch %s already exists\n" % patch) 1142 raise util.Abort(_('patch "%s" already exists') % patch)
1141 sys.exit(1)
1142 patchf = self.opener(patch, "w") 1143 patchf = self.opener(patch, "w")
1143 patchf.write(text) 1144 patchf.write(text)
1144 if patch in self.series: 1145 if patch in self.series:
1145 self.ui.warn("patch %s is already in the series file\n" % patch) 1146 raise util.Abort(_('patch %s is already in the series file')
1146 sys.exit(1) 1147 % patch)
1147 index = self.full_series_end() + i 1148 index = self.full_series_end() + i
1148 self.full_series[index:index] = [patch] 1149 self.full_series[index:index] = [patch]
1149 self.read_series(self.full_series) 1150 self.read_series(self.full_series)
1150 self.ui.warn("adding %s to series file\n" % patch) 1151 self.ui.warn("adding %s to series file\n" % patch)
1151 i += 1 1152 i += 1