Steve Borho  committed 2a14316

hggtk/thgconfig: simplify specification of user/repo mode on command line

If file list is provided, assume repository configure mode, else assume user configure mode.
This gets rid of a lot of ugly hacks in and the nautilus extension, and prevents
me from adding even uglier hacks to the context menu code.

  • Participants
  • Parent commits 4028d73
  • Branches default

Comments (0)

Files changed (3)

File hggtk/

         self.dirty = False
         return 0
-def run(root='', cmdline=[], **opts):
+def run(root='', cmdline=[], files=[], **opts):
     if '--focusfield' in cmdline:
         field = cmdline[cmdline.index('--focusfield')+1]
         field = None
-    dialog = ConfigDialog(root, '--configrepo' in cmdline, field)
+    dialog = ConfigDialog(root, bool(files), field)
     dialog.connect('response', gtk.main_quit)
 if __name__ == "__main__":
     # example command lines
     # python hggtk/ --focusfield ui.editor
-    # python hggtk/ . --focusfield paths.default --configrepo
+    # python hggtk/ --focusfield paths.default --configrepo
     import sys
     opts = {}
-    opts['root'] = len(sys.argv) > 1 and sys.argv[1] or ''
+    opts['root'] = os.getcwd()
     opts['cmdline'] = sys.argv
+    opts['files'] = '--configrepo' in sys.argv and ['.'] or []
 def get_option(args):
     import getopt
     long_opt_list = ('command=', 'exepath=', 'listfile=', 'title=',
-                      'root=', 'cwd=', 'notify', 'deletelistfile',
-                      'configrepo')
+                      'root=', 'cwd=', 'notify', 'deletelistfile')
     opts, args = getopt.getopt(args, "c:e:l:ndt:R:", long_opt_list)
     # Set default options
     options = {}
             options['root'] = a
         elif o in ("--cwd"):
             options['cwd'] = a
-        elif o in ("--configrepo"):
-            args.append(o)
     if listfile:
         options['files'] = get_list_from_file(listfile)


         self._run_dialog('synch', [vfs_file], filelist=False)
     def _thgconfig_repo_cb(self, window, vfs_file):
-        self._run_dialog('config', [vfs_file], args=['--configrepo'])
+        self._run_dialog('config', [vfs_file])
     def _thgconfig_user_cb(self, window, vfs_file):
         self._run_dialog('config', [vfs_file], filelist=False)
             subprocess.Popen(['hg', 'view'], shell=False, cwd=cwd)
-    def _run_dialog(self, hgcmd, vfs_files, filelist=True, args=[]):
+    def _run_dialog(self, hgcmd, vfs_files, filelist=True):
         hgcmd - hgproc subcommand
         vfs_files - directory, or list of selected files
+        filelist  - bool for whether to generate file list for hgproc
         paths = [self.get_path_for_vfs_file(f) for f in vfs_files]
         if paths[0] is None:
         cmdopts += ['--root', repo.root]
         cmdopts += ['--cwd', cwd]
         cmdopts += ['--command', hgcmd]
-        cmdopts.extend(args)
         if filelist:
             # Use temporary file to store file list (avoid shell command