comparison hg_delta_editor.py @ 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
comparison
equal deleted inserted replaced
329:235022089da6 330:5f8f2fd4fd54
85 if repo and repo.ui and not ui_: 85 if repo and repo.ui and not ui_:
86 ui_ = repo.ui 86 ui_ = repo.ui
87 if not ui_: 87 if not ui_:
88 ui_ = ui.ui() 88 ui_ = ui.ui()
89 self.ui = ui_ 89 self.ui = ui_
90 if repo: 90 self.__setup_repo(repo or path)
91 self.repo = repo
92 self.__setup_repo(repo)
93 self.path = os.path.normpath(os.path.join(self.repo.path, '..'))
94 elif path:
95 self.path = path
96 self.__setup_repo(path)
97 91
98 self.subdir = subdir 92 self.subdir = subdir
99 if self.subdir and self.subdir[0] == '/': 93 if self.subdir and self.subdir[0] == '/':
100 self.subdir = self.subdir[1:] 94 self.subdir = self.subdir[1:]
101 self.revmap = {} 95 self.revmap = {}
148 142
149 This method will fail an assertion if the repo exists but doesn't have 143 This method will fail an assertion if the repo exists but doesn't have
150 the Subversion metadata. 144 the Subversion metadata.
151 """ 145 """
152 if isinstance(arg, basestring): 146 if isinstance(arg, basestring):
153 self.path = arg 147 self.repo = hg.repository(self.ui, arg,
154 self.repo = hg.repository(self.ui, self.path, create=True) 148 create=(not os.path.exists(arg)))
149 self.path = os.path.normpath(os.path.join(arg, '..'))
155 elif arg: 150 elif arg:
156 self.repo = arg 151 self.repo = arg
157 self.path = os.path.normpath(os.path.join(self.repo.path, '..')) 152 self.path = os.path.normpath(os.path.join(self.repo.path, '..'))
158 else: #pragma: no cover 153 else: #pragma: no cover
159 raise TypeError("editor requires either a path or a repository " 154 raise TypeError("editor requires either a path or a repository "