changeset 330:5f8f2fd4fd54

hg_delta_editor: simplify repository instantiation.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Sat, 09 May 2009 14:46:12 +0200
parents 235022089da6
children 75f082b5897e
files hg_delta_editor.py
diffstat 1 files changed, 4 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/hg_delta_editor.py
+++ b/hg_delta_editor.py
@@ -87,13 +87,7 @@ class HgChangeReceiver(delta.Editor):
         if not ui_:
             ui_ = ui.ui()
         self.ui = ui_
-        if repo:
-            self.repo = repo
-            self.__setup_repo(repo)
-            self.path = os.path.normpath(os.path.join(self.repo.path, '..'))
-        elif path:
-            self.path = path
-            self.__setup_repo(path)
+        self.__setup_repo(repo or path)
 
         self.subdir = subdir
         if self.subdir and self.subdir[0] == '/':
@@ -150,8 +144,9 @@ class HgChangeReceiver(delta.Editor):
         the Subversion metadata.
         """
         if isinstance(arg, basestring):
-            self.path = arg
-            self.repo = hg.repository(self.ui, self.path, create=True)
+            self.repo = hg.repository(self.ui, arg,
+                                      create=(not os.path.exists(arg)))
+            self.path = os.path.normpath(os.path.join(arg, '..'))
         elif arg:
             self.repo = arg
             self.path = os.path.normpath(os.path.join(self.repo.path, '..'))