2190 # ignore these |
2190 # ignore these |
2191 pass |
2191 pass |
2192 self.userEditor = MiniEditor(cfgFile, "Properties") |
2192 self.userEditor = MiniEditor(cfgFile, "Properties") |
2193 self.userEditor.show() |
2193 self.userEditor.show() |
2194 |
2194 |
2195 def hgEditConfig(self, name): |
2195 def hgEditConfig(self, name, withLargefiles=True, largefilesData=None): |
2196 """ |
2196 """ |
2197 Public method used to edit the repository configuration file. |
2197 Public method used to edit the repository configuration file. |
2198 |
2198 |
2199 @param name file/directory name (string) |
2199 @param name file/directory name (string) |
|
2200 @param withLargefiles flag indicating to configure the largefiles |
|
2201 section (boolean) |
|
2202 @param largefilesData dictionary with data for the largefiles |
|
2203 section of the data dialog (dict) |
2200 """ |
2204 """ |
2201 dname, fname = self.splitPath(name) |
2205 dname, fname = self.splitPath(name) |
2202 |
2206 |
2203 # find the root of the repo |
2207 # find the root of the repo |
2204 repodir = dname |
2208 repodir = dname |
2208 return |
2212 return |
2209 |
2213 |
2210 cfgFile = os.path.join(repodir, self.adminDir, "hgrc") |
2214 cfgFile = os.path.join(repodir, self.adminDir, "hgrc") |
2211 if not os.path.exists(cfgFile): |
2215 if not os.path.exists(cfgFile): |
2212 # open dialog to enter the initial data |
2216 # open dialog to enter the initial data |
|
2217 withLargefiles = (self.isExtensionActive("largefiles") and |
|
2218 withLargefiles) |
2213 from .HgRepoConfigDataDialog import HgRepoConfigDataDialog |
2219 from .HgRepoConfigDataDialog import HgRepoConfigDataDialog |
2214 dlg = HgRepoConfigDataDialog() |
2220 dlg = HgRepoConfigDataDialog(withLargefiles=withLargefiles, |
|
2221 largefilesData=largefilesData) |
2215 if dlg.exec_() == QDialog.Accepted: |
2222 if dlg.exec_() == QDialog.Accepted: |
2216 createContents = True |
2223 createContents = True |
2217 defaultUrl, defaultPushUrl = dlg.getData() |
2224 defaultUrl, defaultPushUrl = dlg.getData() |
|
2225 if withLargefiles: |
|
2226 lfMinSize, lfPattern = dlg.getLargefilesData() |
2218 else: |
2227 else: |
2219 createContents = False |
2228 createContents = False |
2220 try: |
2229 try: |
2221 cfg = open(cfgFile, "w") |
2230 cfg = open(cfgFile, "w") |
2222 if createContents: |
2231 if createContents: |
2225 if defaultUrl: |
2234 if defaultUrl: |
2226 cfg.write("default = {0}\n".format(defaultUrl)) |
2235 cfg.write("default = {0}\n".format(defaultUrl)) |
2227 if defaultPushUrl: |
2236 if defaultPushUrl: |
2228 cfg.write("default-push = {0}\n".format( |
2237 cfg.write("default-push = {0}\n".format( |
2229 defaultPushUrl)) |
2238 defaultPushUrl)) |
|
2239 if withLargefiles and \ |
|
2240 (lfMinSize, lfPattern) != (None, None): |
|
2241 cfg.write("\n[largefiles]\n") |
|
2242 if lfMinSize is not None: |
|
2243 cfg.write("minsize = {0}\n".format(lfMinSize)) |
|
2244 if lfPattern is not None: |
|
2245 cfg.write("patterns =\n") |
|
2246 cfg.write(" {0}\n".format( |
|
2247 "\n ".join(lfPattern))) |
2230 cfg.close() |
2248 cfg.close() |
2231 self.__monitorRepoIniFile(repodir) |
2249 self.__monitorRepoIniFile(repodir) |
2232 except IOError: |
2250 except IOError: |
2233 pass |
2251 pass |
2234 self.repoEditor = MiniEditor(cfgFile, "Properties") |
2252 self.repoEditor = MiniEditor(cfgFile, "Properties") |