Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.0.1, 1.0.2, and 1.0.3

stable 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.

Changeset 829f55c1ae49

Parent 1e847daf480b

by Martin Geisler

Changes to 10 files · Browse files at 829f55c1ae49 Showing diff from parent 1e847daf480b Diff from another changeset...

 
226
227
228
 
229
230
231
 
226
227
228
229
230
231
232
@@ -226,6 +226,7 @@
  cmdline.append(rev)   cmdline.append('-t')   cmdline.append(type) + cmdline.append('--')   cmdline.append(hglib.fromutf(dest))     # start archiving
 
1007
1008
1009
1010
 
1011
1012
1013
 
1007
1008
1009
 
1010
1011
1012
1013
@@ -1007,7 +1007,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()
 
331
332
333
 
334
335
336
 
331
332
333
334
335
336
337
@@ -331,6 +331,7 @@
  cmdline.append('--verbose')   cmdline.append(hglib.fromutf(src))   if dest: + cmdline.append('--')   cmdline.append(hglib.fromutf(dest))     # start cloning
 
1017
1018
1019
1020
 
1021
1022
1023
 
1146
1147
1148
 
1149
1150
1151
 
1017
1018
1019
 
1020
1021
1022
1023
 
1146
1147
1148
1149
1150
1151
1152
@@ -1017,7 +1017,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 @@ -1146,6 +1146,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'])
 
1660
1661
1662
1663
 
1664
1665
1666
 
1856
1857
1858
1859
 
1860
1861
1862
 
1941
1942
1943
1944
 
1945
1946
1947
 
2285
2286
2287
 
2288
2289
2290
 
2526
2527
2528
2529
 
2530
2531
 
2532
2533
2534
 
2557
2558
2559
2560
 
2561
2562
2563
 
1660
1661
1662
 
1663
1664
1665
1666
 
1856
1857
1858
 
1859
1860
1861
1862
 
1941
1942
1943
 
1944
1945
1946
1947
 
2285
2286
2287
2288
2289
2290
2291
 
2527
2528
2529
 
2530
2531
2532
2533
2534
2535
2536
 
2559
2560
2561
 
2562
2563
2564
2565
@@ -1660,7 +1660,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) @@ -1856,7 +1856,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: @@ -1941,7 +1941,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: @@ -2285,6 +2285,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): @@ -2526,9 +2527,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: @@ -2557,7 +2559,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:
 
237
238
239
240
 
241
242
 
 
243
244
245
 
237
238
239
 
240
241
242
243
244
245
246
247
@@ -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)
 
553
554
555
556
 
557
558
559
 
553
554
555
 
556
557
558
559
@@ -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
 
937
938
939
940
 
941
942
943
 
937
938
939
 
940
941
942
943
@@ -937,7 +937,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()
 
341
342
343
344
 
345
346
347
 
341
342
343
 
344
345
346
347
@@ -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
 
298
299
300
301
 
302
303
304
 
358
359
360
361
 
362
363
 
 
364
365
366
 
374
375
376
377
 
378
379
380
 
448
449
450
451
 
452
453
454
 
298
299
300
 
301
302
303
304
 
358
359
360
 
361
362
363
364
365
366
367
368
 
376
377
378
 
379
380
381
382
 
450
451
452
 
453
454
455
456
@@ -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):