Mercurial > hg
changeset 2711: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 | e475fe2a6029 |
children | 8e5cd8d11b51 |
files | hgext/mq.py tests/test-mq-qnew-twice tests/test-mq-qnew-twice.out |
diffstat | 3 files changed, 19 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/mq.py Thu Jul 27 15:53:08 2006 -0700 +++ b/hgext/mq.py Thu Jul 27 16:08:56 2006 -0700 @@ -409,6 +409,8 @@ self.ui.write("Local changes found, refresh first\n") sys.exit(1) def new(self, repo, patch, msg=None, force=None): + if os.path.exists(os.path.join(self.path, patch)): + raise util.Abort(_('patch "%s" already exists') % patch) commitfiles = [] (c, a, r, d, u) = repo.changes(None, None) if c or a or d or r: @@ -1137,13 +1139,12 @@ if not patch: patch = os.path.split(filename)[1] if not force and os.path.isfile(os.path.join(self.path, patch)): - self.ui.warn("patch %s already exists\n" % patch) - sys.exit(1) + raise util.Abort(_('patch "%s" already exists') % patch) patchf = self.opener(patch, "w") patchf.write(text) if patch in self.series: - self.ui.warn("patch %s is already in the series file\n" % patch) - sys.exit(1) + raise util.Abort(_('patch %s is already in the series file') + % patch) index = self.full_series_end() + i self.full_series[index:index] = [patch] self.read_series(self.full_series)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-mq-qnew-twice Thu Jul 27 16:08:56 2006 -0700 @@ -0,0 +1,13 @@ +#!/bin/sh + +HGRCPATH=$HGTMP/.hgrc; export HGRCPATH +echo "[extensions]" >> $HGTMP/.hgrc +echo "mq=" >> $HGTMP/.hgrc + +hg init a +cd a +hg qnew first.patch +hg qnew first.patch + +touch ../first.patch +hg qimport ../first.patch