def __init__(self, ui, repotype, path): converter_sink.__init__(self, ui, repotype, path) commandline.__init__(self, ui, "svn") self.delete = [] self.setexec = [] self.delexec = [] self.copies = [] self.wc = None self.cwd = pycompat.getcwd() created = False if os.path.isfile(os.path.join(path, ".svn", "entries")): self.wc = os.path.realpath(path) self.run0("update") else: if not re.search(r"^(file|http|https|svn|svn\+ssh)\://", path): path = os.path.realpath(path) if os.path.isdir(os.path.dirname(path)): if not os.path.exists(os.path.join(path, "db", "fs-type")): ui.status( _("initializing svn repository %r\n") % os.path.basename(path) ) commandline(ui, "svnadmin").run0("create", path) created = path path = util.normpath(path) if not path.startswith("/"): path = "/" + path path = "file://" + path wcpath = os.path.join(pycompat.getcwd(), os.path.basename(path) + "-wc") ui.status( _("initializing svn working copy %r\n") % os.path.basename(wcpath) ) self.run0("checkout", path, wcpath) self.wc = wcpath self.opener = vfsmod.vfs(self.wc) self.wopener = vfsmod.vfs(self.wc) self.childmap = mapfile(ui, self.join("hg-childmap")) if util.checkexec(self.wc): self.is_exec = util.isexec else: self.is_exec = None if created: hook = os.path.join(created, "hooks", "pre-revprop-change") fp = open(hook, "w") fp.write(pre_revprop_change) fp.close() util.setflags(hook, False, True) output = self.run0("info") self.uuid = self.uuid_re.search(output).group(1).strip()
def geturl(path): try: return svn.client.url_from_path(svn.core.svn_path_canonicalize(path)) except svn.core.SubversionException: # svn.client.url_from_path() fails with local repositories pass if os.path.isdir(path): path = os.path.normpath(os.path.abspath(path)) if pycompat.iswindows: path = "/" + util.normpath(path) # Module URL is later compared with the repository URL returned # by svn API, which is UTF-8. path = encoding.tolocal(path) path = "file://%s" % quote(path) return svn.core.svn_path_canonicalize(path)