591 pass |
591 pass |
592 elif self.gitmode in (b'yes', b'no'): |
592 elif self.gitmode in (b'yes', b'no'): |
593 diffopts.git = self.gitmode == b'yes' |
593 diffopts.git = self.gitmode == b'yes' |
594 else: |
594 else: |
595 raise error.Abort( |
595 raise error.Abort( |
596 _(b'mq.git option can be auto/keep/yes/no' b' got %s') |
596 _(b'mq.git option can be auto/keep/yes/no got %s') |
597 % self.gitmode |
597 % self.gitmode |
598 ) |
598 ) |
599 if patchfn: |
599 if patchfn: |
600 diffopts = self.patchopts(diffopts, patchfn) |
600 diffopts = self.patchopts(diffopts, patchfn) |
601 return diffopts |
601 return diffopts |
1212 phases.advanceboundary(repo, tr, tphase, qfinished) |
1212 phases.advanceboundary(repo, tr, tphase, qfinished) |
1213 |
1213 |
1214 def delete(self, repo, patches, opts): |
1214 def delete(self, repo, patches, opts): |
1215 if not patches and not opts.get(b'rev'): |
1215 if not patches and not opts.get(b'rev'): |
1216 raise error.Abort( |
1216 raise error.Abort( |
1217 _(b'qdelete requires at least one revision or ' b'patch name') |
1217 _(b'qdelete requires at least one revision or patch name') |
1218 ) |
1218 ) |
1219 |
1219 |
1220 realpatches = [] |
1220 realpatches = [] |
1221 for patch in patches: |
1221 for patch in patches: |
1222 patch = self.lookup(patch, strict=True) |
1222 patch = self.lookup(patch, strict=True) |
1293 _(b'"%s" cannot be used as the name of a patch') % name |
1293 _(b'"%s" cannot be used as the name of a patch') % name |
1294 ) |
1294 ) |
1295 if name != name.strip(): |
1295 if name != name.strip(): |
1296 # whitespace is stripped by parseseries() |
1296 # whitespace is stripped by parseseries() |
1297 raise error.Abort( |
1297 raise error.Abort( |
1298 _(b'patch name cannot begin or end with ' b'whitespace') |
1298 _(b'patch name cannot begin or end with whitespace') |
1299 ) |
1299 ) |
1300 for prefix in (b'.hg', b'.mq'): |
1300 for prefix in (b'.hg', b'.mq'): |
1301 if name.startswith(prefix): |
1301 if name.startswith(prefix): |
1302 raise error.Abort( |
1302 raise error.Abort( |
1303 _(b'patch name cannot begin with "%s"') % prefix |
1303 _(b'patch name cannot begin with "%s"') % prefix |
1627 raise error.Abort( |
1627 raise error.Abort( |
1628 _(b"cannot use --exact and --keep-changes together") |
1628 _(b"cannot use --exact and --keep-changes together") |
1629 ) |
1629 ) |
1630 if move: |
1630 if move: |
1631 raise error.Abort( |
1631 raise error.Abort( |
1632 _(b'cannot use --exact and --move ' b'together') |
1632 _(b'cannot use --exact and --move together') |
1633 ) |
1633 ) |
1634 if self.applied: |
1634 if self.applied: |
1635 raise error.Abort( |
1635 raise error.Abort( |
1636 _(b'cannot push --exact with applied ' b'patches') |
1636 _(b'cannot push --exact with applied patches') |
1637 ) |
1637 ) |
1638 root = self.series[start] |
1638 root = self.series[start] |
1639 target = patchheader(self.join(root), self.plainmode).parent |
1639 target = patchheader(self.join(root), self.plainmode).parent |
1640 if not target: |
1640 if not target: |
1641 raise error.Abort( |
1641 raise error.Abort( |
2388 ) |
2388 ) |
2389 |
2389 |
2390 if rev: |
2390 if rev: |
2391 if files: |
2391 if files: |
2392 raise error.Abort( |
2392 raise error.Abort( |
2393 _(b'option "-r" not valid when importing ' b'files') |
2393 _(b'option "-r" not valid when importing files') |
2394 ) |
2394 ) |
2395 rev = scmutil.revrange(repo, rev) |
2395 rev = scmutil.revrange(repo, rev) |
2396 rev.sort(reverse=True) |
2396 rev.sort(reverse=True) |
2397 elif not files: |
2397 elif not files: |
2398 raise error.Abort(_(b'no files or revisions specified')) |
2398 raise error.Abort(_(b'no files or revisions specified')) |
2399 if (len(files) > 1 or len(rev) > 1) and patchname: |
2399 if (len(files) > 1 or len(rev) > 1) and patchname: |
2400 raise error.Abort( |
2400 raise error.Abort( |
2401 _(b'option "-n" not valid when importing multiple ' b'patches') |
2401 _(b'option "-n" not valid when importing multiple patches') |
2402 ) |
2402 ) |
2403 imported = [] |
2403 imported = [] |
2404 if rev: |
2404 if rev: |
2405 # If mq patches are applied, we can only import revisions |
2405 # If mq patches are applied, we can only import revisions |
2406 # that form a linear path to qbase. |
2406 # that form a linear path to qbase. |
2407 # Otherwise, they should form a linear path to a head. |
2407 # Otherwise, they should form a linear path to a head. |
2408 heads = repo.changelog.heads(repo.changelog.node(rev.first())) |
2408 heads = repo.changelog.heads(repo.changelog.node(rev.first())) |
2409 if len(heads) > 1: |
2409 if len(heads) > 1: |
2410 raise error.Abort( |
2410 raise error.Abort( |
2411 _(b'revision %d is the root of more than one ' b'branch') |
2411 _(b'revision %d is the root of more than one branch') |
2412 % rev.last() |
2412 % rev.last() |
2413 ) |
2413 ) |
2414 if self.applied: |
2414 if self.applied: |
2415 base = repo.changelog.node(rev.first()) |
2415 base = repo.changelog.node(rev.first()) |
2416 if base in [n.node for n in self.applied]: |
2416 if base in [n.node for n in self.applied]: |
2417 raise error.Abort( |
2417 raise error.Abort( |
2418 _(b'revision %d is already managed') % rev.first() |
2418 _(b'revision %d is already managed') % rev.first() |
2419 ) |
2419 ) |
2420 if heads != [self.applied[-1].node]: |
2420 if heads != [self.applied[-1].node]: |
2421 raise error.Abort( |
2421 raise error.Abort( |
2422 _(b'revision %d is not the parent of ' b'the queue') |
2422 _(b'revision %d is not the parent of the queue') |
2423 % rev.first() |
2423 % rev.first() |
2424 ) |
2424 ) |
2425 base = repo.changelog.rev(self.applied[0].node) |
2425 base = repo.changelog.rev(self.applied[0].node) |
2426 lastparent = repo.changelog.parentrevs(base)[0] |
2426 lastparent = repo.changelog.parentrevs(base)[0] |
2427 else: |
2427 else: |
2847 patchespath = patchdir(sr) |
2847 patchespath = patchdir(sr) |
2848 try: |
2848 try: |
2849 hg.peer(ui, opts, patchespath) |
2849 hg.peer(ui, opts, patchespath) |
2850 except error.RepoError: |
2850 except error.RepoError: |
2851 raise error.Abort( |
2851 raise error.Abort( |
2852 _(b'versioned patch repository not found' b' (see init --mq)') |
2852 _(b'versioned patch repository not found (see init --mq)') |
2853 ) |
2853 ) |
2854 qbase, destrev = None, None |
2854 qbase, destrev = None, None |
2855 if sr.local(): |
2855 if sr.local(): |
2856 repo = sr.local() |
2856 repo = sr.local() |
2857 if repo.mq.applied and repo[qbase].phase() != phases.secret: |
2857 if repo.mq.applied and repo[qbase].phase() != phases.secret: |
3357 patch = None |
3357 patch = None |
3358 args = list(args) |
3358 args = list(args) |
3359 if opts.get(r'list'): |
3359 if opts.get(r'list'): |
3360 if args or opts.get(r'none'): |
3360 if args or opts.get(r'none'): |
3361 raise error.Abort( |
3361 raise error.Abort( |
3362 _(b'cannot mix -l/--list with options or ' b'arguments') |
3362 _(b'cannot mix -l/--list with options or arguments') |
3363 ) |
3363 ) |
3364 for i in pycompat.xrange(len(q.series)): |
3364 for i in pycompat.xrange(len(q.series)): |
3365 status(i) |
3365 status(i) |
3366 return |
3366 return |
3367 if not args or args[0][0:1] in b'-+': |
3367 if not args or args[0][0:1] in b'-+': |
3669 if opts.get(b'name'): |
3669 if opts.get(b'name'): |
3670 newpath = os.path.join(q.basepath, opts.get(b'name')) |
3670 newpath = os.path.join(q.basepath, opts.get(b'name')) |
3671 if os.path.exists(newpath): |
3671 if os.path.exists(newpath): |
3672 if not os.path.isdir(newpath): |
3672 if not os.path.isdir(newpath): |
3673 raise error.Abort( |
3673 raise error.Abort( |
3674 _(b'destination %s exists and is not ' b'a directory') |
3674 _(b'destination %s exists and is not a directory') |
3675 % newpath |
3675 % newpath |
3676 ) |
3676 ) |
3677 if not opts.get(b'force'): |
3677 if not opts.get(b'force'): |
3678 raise error.Abort( |
3678 raise error.Abort( |
3679 _(b'destination %s exists, ' b'use -f to force') |
3679 _(b'destination %s exists, use -f to force') % newpath |
3680 % newpath |
|
3681 ) |
3680 ) |
3682 else: |
3681 else: |
3683 newpath = savename(path) |
3682 newpath = savename(path) |
3684 ui.warn(_(b"copy %s to %s\n") % (path, newpath)) |
3683 ui.warn(_(b"copy %s to %s\n") % (path, newpath)) |
3685 util.copyfiles(path, newpath) |
3684 util.copyfiles(path, newpath) |
4155 mqtags.append((self.changelog.parents(mqtags[0][0])[0], b'qparent')) |
4154 mqtags.append((self.changelog.parents(mqtags[0][0])[0], b'qparent')) |
4156 tags = result[0] |
4155 tags = result[0] |
4157 for patch in mqtags: |
4156 for patch in mqtags: |
4158 if patch[1] in tags: |
4157 if patch[1] in tags: |
4159 self.ui.warn( |
4158 self.ui.warn( |
4160 _(b'tag %s overrides mq patch of the same ' b'name\n') |
4159 _(b'tag %s overrides mq patch of the same name\n') |
4161 % patch[1] |
4160 % patch[1] |
4162 ) |
4161 ) |
4163 else: |
4162 else: |
4164 tags[patch[1]] = patch[0] |
4163 tags[patch[1]] = patch[0] |
4165 |
4164 |
4189 |
4188 |
4190 if args: |
4189 if args: |
4191 repopath = args[0] |
4190 repopath = args[0] |
4192 if not hg.islocal(repopath): |
4191 if not hg.islocal(repopath): |
4193 raise error.Abort( |
4192 raise error.Abort( |
4194 _(b'only a local queue repository ' b'may be initialized') |
4193 _(b'only a local queue repository may be initialized') |
4195 ) |
4194 ) |
4196 else: |
4195 else: |
4197 repopath = cmdutil.findrepo(encoding.getcwd()) |
4196 repopath = cmdutil.findrepo(encoding.getcwd()) |
4198 if not repopath: |
4197 if not repopath: |
4199 raise error.Abort( |
4198 raise error.Abort( |
4200 _(b'there is no Mercurial repository here ' b'(.hg not found)') |
4199 _(b'there is no Mercurial repository here (.hg not found)') |
4201 ) |
4200 ) |
4202 repo = hg.repository(ui, repopath) |
4201 repo = hg.repository(ui, repopath) |
4203 return qinit(ui, repo, True) |
4202 return qinit(ui, repo, True) |
4204 |
4203 |
4205 |
4204 |