# HG changeset patch
# User Yuki KODAMA <endflow.net@gmail.com>
# Date 1246647661 -32400
# Node ID f0fe3320dce04cb9b7954530728c7cb755e14528
# Parent  2c2a1a6337359280261005909bc933262c6aabd8
synch, thgconfig: set remote path as 'default' from synch tool

fixes for issue #364

diff --git a/hggtk/synch.py b/hggtk/synch.py
--- a/hggtk/synch.py
+++ b/hggtk/synch.py
@@ -453,7 +453,7 @@
         dlg = thgconfig.ConfigDialog(True)
         dlg.show_all()
         if newpath:
-            dlg.new_path(newpath)
+            dlg.new_path(newpath, 'default')
         else:
             dlg.focus_field('tortoisehg.postpull')
         dlg.run()
diff --git a/hggtk/thgconfig.py b/hggtk/thgconfig.py
--- a/hggtk/thgconfig.py
+++ b/hggtk/thgconfig.py
@@ -573,14 +573,15 @@
                     widgets[w].grab_focus()
                     return
 
-    def new_path(self, newpath):
+    def new_path(self, newpath, alias='new'):
         '''Add a new path to [paths], give default name, focus'''
         i = self.pathdata.insert_before(None, None)
         safepath = url.hidepassword(newpath)
-        alias, num = 'new', 0
-        while len([row for row in self.pathdata if row[0] == alias]) > 0:
-            num += 1
-            alias = 'new_%d' % num
+        if alias in [row[0] for row in self.pathdata]:
+            num = 0
+            while len([row for row in self.pathdata if row[0] == alias]) > 0:
+                num += 1
+                alias = 'new_%d' % num
         self.pathdata.set_value(i, 0, alias)
         self.pathdata.set_value(i, 1, '%s' % hglib.toutf(safepath))
         self.pathdata.set_value(i, 2, '%s' % hglib.toutf(newpath))
