# HG changeset patch # User Martin Geisler <m...@lazybytes.net> # Date 1270122976 -7200 # Node ID 56616fcabc089b113944c769d1e1b1373e389cb2 # Parent fdb3adb50fc644e57382ee1dc4617f950e7df953 Protect filenames in command lines.
Filenames that start with '--' cause trouble when used as positional arguments on the command line since they are seen as a command line flag. So hg clone foo --foobar fails and result in questions like this: http://stackoverflow.com/questions/2523080/ There is a standard way to indicate that the following command line arguments should be interpreted literally, namely by giving an argument of '--'. So hg clone -- foo --foobar works as expected. diff --git a/tortoisehg/hgtk/archive.py b/tortoisehg/hgtk/archive.py --- a/tortoisehg/hgtk/archive.py +++ b/tortoisehg/hgtk/archive.py @@ -226,6 +226,7 @@ cmdline.append(rev) cmdline.append('-t') cmdline.append(type) + cmdline.append('--') cmdline.append(hglib.fromutf(dest)) # start archiving diff --git a/tortoisehg/hgtk/changeset.py b/tortoisehg/hgtk/changeset.py --- a/tortoisehg/hgtk/changeset.py +++ b/tortoisehg/hgtk/changeset.py @@ -1020,7 +1020,7 @@ (self.curfile, rev)) if dialog.run() == gtk.RESPONSE_NO: return - cmdline = ['hg', 'revert', '--verbose', '--rev', str(rev), self.curfile] + cmdline = ['hg', 'revert', '--verbose', '--rev', str(rev), '--', self.curfile] dlg = hgcmd.CmdDialog(cmdline) dlg.run() dlg.hide() diff --git a/tortoisehg/hgtk/clone.py b/tortoisehg/hgtk/clone.py --- a/tortoisehg/hgtk/clone.py +++ b/tortoisehg/hgtk/clone.py @@ -331,6 +331,7 @@ cmdline.append('--verbose') cmdline.append(hglib.fromutf(src)) if dest: + cmdline.append('--') cmdline.append(hglib.fromutf(dest)) # start cloning diff --git a/tortoisehg/hgtk/commit.py b/tortoisehg/hgtk/commit.py --- a/tortoisehg/hgtk/commit.py +++ b/tortoisehg/hgtk/commit.py @@ -1021,7 +1021,7 @@ # prompts). Problem? self.opts['addremove'] = True if self.qnew or self.qheader is not None: - cmdline = ['hg', 'addremove', '--verbose'] + cmdline = ['hg', 'addremove', '--verbose', '--'] cmdline += [self.repo.wjoin(x) for x in files] self.execute_command(cmdline, force=True) return True @@ -1158,6 +1158,7 @@ cmdline += ['--message', hglib.fromutf(self.opts['message'])] if self.qnew: cmdline += [hglib.fromutf(self.get_qnew_name())] + cmdline.append('--') cmdline += files if autopush: cmdline = (cmdline, ['hg', 'push']) diff --git a/tortoisehg/hgtk/history.py b/tortoisehg/hgtk/history.py --- a/tortoisehg/hgtk/history.py +++ b/tortoisehg/hgtk/history.py @@ -1732,7 +1732,7 @@ # load the rebase extension explicitly hglib.loadextension(self.ui, 'rebase') - cmdline = ['hg'] + cmd + [self.bfile] + cmdline = ['hg'] + cmd + ['--', self.bfile] def callback(return_code, *args): self.remove_overlay('--rebase' in cmd) @@ -1928,7 +1928,7 @@ self).run() self.pathentry.grab_focus() return - cmdline = ['hg'] + cmd + self.get_proxy_args() + [remote_path] + cmdline = ['hg'] + cmd + self.get_proxy_args() + ['--', remote_path] def callback(return_code, *args): if return_code == 0: @@ -2013,7 +2013,7 @@ cmdline = ['hg', 'push'] + self.get_proxy_args() if self.forcepush: cmdline += ['--force'] - cmdline += [remote_path] + cmdline += ['--', remote_path] def callback(return_code, *args): if return_code == 0: @@ -2359,6 +2359,7 @@ status = _('Bundling from %(base)s to %(rev)s...') % data else: status = _('Bundling from %(base)s to tip...') % data + cmdline.append('--') cmdline.append(result) def callback(return_code, *args): @@ -2600,9 +2601,10 @@ node = self.repo[self.currevid].node() rev = str(self.currevid) - cmdline = ['hg', 'push', '--rev', rev, remote_path] + cmdline = ['hg', 'push', '--rev', rev] if self.forcepush: cmdline += ['--force'] + cmdline += ['--', remote_path] def callback(return_code, *args): if return_code == 0: @@ -2631,7 +2633,7 @@ def pull_to(self, menuitem): rev = str(self.currevid) - cmdline = ['hg', 'pull', '--rev', rev, self.bfile] + cmdline = ['hg', 'pull', '--rev', rev, '--', self.bfile] def callback(return_code, *args): if return_code == 0: diff --git a/tortoisehg/hgtk/quickop.py b/tortoisehg/hgtk/quickop.py --- a/tortoisehg/hgtk/quickop.py +++ b/tortoisehg/hgtk/quickop.py @@ -237,9 +237,11 @@ return # prepare command line - cmdline = ['hg', self.command, '--verbose'] + list + cmdline = ['hg', self.command, '--verbose'] if hasattr(self, 'nobackup') and self.nobackup.get_active(): cmdline.append('--no-backup') + cmdline.append('--') + cmdline += list # execute command self.execute_command(cmdline, list) diff --git a/tortoisehg/hgtk/synch.py b/tortoisehg/hgtk/synch.py --- a/tortoisehg/hgtk/synch.py +++ b/tortoisehg/hgtk/synch.py @@ -553,7 +553,7 @@ cmdline += ['--verbose'] if proxy_host and not use_proxy: cmdline += ["--config", "http_proxy.host="] - cmdline += [remote_path] + cmdline += ['--', remote_path] self.lastcmd = cmdline # show command to be executed diff --git a/tortoisehg/hgtk/thgconfig.py b/tortoisehg/hgtk/thgconfig.py --- a/tortoisehg/hgtk/thgconfig.py +++ b/tortoisehg/hgtk/thgconfig.py @@ -1010,7 +1010,7 @@ return if testpath[0] == '~': testpath = os.path.expanduser(testpath) - cmdline = ['hg', 'incoming', '--verbose', testpath] + cmdline = ['hg', 'incoming', '--verbose', '--', testpath] dlg = hgcmd.CmdDialog(cmdline, text='hg incoming') dlg.run() dlg.hide() diff --git a/tortoisehg/hgtk/thgimport.py b/tortoisehg/hgtk/thgimport.py --- a/tortoisehg/hgtk/thgimport.py +++ b/tortoisehg/hgtk/thgimport.py @@ -341,7 +341,7 @@ raise _('unexpected destination name: %s') % dest # prepare command line - cmdline = ['hg', cmd, '--verbose'] + cmdline = ['hg', cmd, '--verbose', '--'] cmdline.extend(files) # start importing diff --git a/tortoisehg/hgtk/thgmq.py b/tortoisehg/hgtk/thgmq.py --- a/tortoisehg/hgtk/thgmq.py +++ b/tortoisehg/hgtk/thgmq.py @@ -298,7 +298,7 @@ """ if not self.is_operable(): return - cmdline = ['hg', 'qgoto', patch] + cmdline = ['hg', 'qgoto', '--', patch] self.cmd.execute(cmdline, self.cmd_done) def qpop(self, all=False): @@ -358,9 +358,11 @@ keep = True else: return - cmdline = ['hg', 'qdelete'] + unapplied + cmdline = ['hg', 'qdelete'] if keep: cmdline.append('--keep') + cmdline.append('--') + cmdline.extned(unapplied) self.cmd.execute(cmdline, self.cmd_done, noemit=True) def qrename(self, name, patch='qtip'): @@ -374,7 +376,7 @@ """ if not name or not self.has_patch(): return - cmdline = ['hg', 'qrename', patch, name] + cmdline = ['hg', 'qrename', '--', patch, name] self.cmd.execute(cmdline, self.cmd_done) def qrename_ui(self, patch='qtip'): @@ -448,7 +450,7 @@ " into the current patch '%(qtip)s'?") % data).run() if ret != gtk.RESPONSE_YES: return - cmdline = ['hg', 'qfold'] + unapplied + cmdline = ['hg', 'qfold', '--'] + unapplied self.cmd.execute(cmdline, self.cmd_done) def qreorder(self, patch, op): diff --git a/tortoisehg/hgtk/thgpbranch.py b/tortoisehg/hgtk/thgpbranch.py --- a/tortoisehg/hgtk/thgpbranch.py +++ b/tortoisehg/hgtk/thgpbranch.py @@ -407,7 +407,7 @@ """ if not patch_name in self.patch_list(): return - cmdline = ['hg', 'peditmessage', patch_name] + cmdline = ['hg', 'peditmessage', '--', patch_name] self.cmd.execute(cmdline, self.cmd_done) def pdiff(self, patch_name): @@ -458,7 +458,7 @@ return cmdline = ['hg', 'pmerge'] if patch_name: - cmdline += [patch_name] + cmdline += ['--', patch_name] else: cmdline += ['--all'] self.cmd.execute(cmdline, self.cmd_done) ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Tortoisehg-develop mailing list Tortoisehg-develop@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tortoisehg-develop