Mercurial > hg
changeset 2551:764a54eb8c5a
merge with crew.
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Mon, 03 Jul 2006 10:19:09 -0700 |
parents | 45235e492cc6 (diff) 0229ff95faec (current diff) |
children | bb403d427974 |
files | mercurial/localrepo.py |
diffstat | 5 files changed, 76 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/win32/mercurial.ini Mon Jul 03 19:14:29 2006 +0200 +++ b/contrib/win32/mercurial.ini Mon Jul 03 10:19:09 2006 -0700 @@ -18,7 +18,8 @@ [encode] ; Encode files that don't contain NUL characters. -** = cleverencode: + +; ** = cleverencode: ; Alternatively, you can explicitly specify each file extension that ; you want encoded (any you omit will be left untouched), like this: @@ -28,7 +29,8 @@ [decode] ; Decode files that don't contain NUL characters. -** = cleverdecode: + +; ** = cleverdecode: ; Alternatively, you can explicitly specify each file extension that ; you want decoded (any you omit will be left untouched), like this:
--- a/mercurial/commands.py Mon Jul 03 19:14:29 2006 +0200 +++ b/mercurial/commands.py Mon Jul 03 10:19:09 2006 -0700 @@ -919,13 +919,10 @@ if os.path.exists(dest): raise util.Abort(_("destination '%s' already exists"), dest) - dest = os.path.realpath(dest) - class Dircleanup(object): def __init__(self, dir_): self.rmtree = shutil.rmtree self.dir_ = dir_ - os.mkdir(dir_) def close(self): self.dir_ = None def __del__(self): @@ -938,13 +935,24 @@ ui.setconfig("ui", "remotecmd", opts['remotecmd']) source = ui.expandpath(source) - - d = Dircleanup(dest) + src_repo = hg.repository(ui, source) + + dest_repo = None + try: + dest_repo = hg.repository(ui, dest) + raise util.Abort(_("destination '%s' already exists." % dest)) + except hg.RepoError: + dest_repo = hg.repository(ui, dest, create=1) + + dest_path = None + d = None + if dest_repo.local(): + dest_path = os.path.realpath(dest) + d = Dircleanup(dest_path) + abspath = source - other = hg.repository(ui, source) - copy = False - if other.dev() != -1: + if src_repo.local() and dest_repo.local(): abspath = os.path.abspath(source) if not opts['pull'] and not opts['rev']: copy = True @@ -955,47 +963,57 @@ # can end up with extra data in the cloned revlogs that's # not pointed to by changesets, thus causing verify to # fail - l1 = other.lock() + l1 = src_repo.lock() except lock.LockException: copy = False if copy: # we lock here to avoid premature writing to the target - os.mkdir(os.path.join(dest, ".hg")) - l2 = lock.lock(os.path.join(dest, ".hg", "lock")) - + l2 = lock.lock(os.path.join(dest_path, ".hg", "lock")) + + # we need to remove the (empty) data dir in dest so copyfiles can do it's work + os.rmdir( os.path.join(dest_path, ".hg", "data") ) files = "data 00manifest.d 00manifest.i 00changelog.d 00changelog.i" for f in files.split(): src = os.path.join(source, ".hg", f) - dst = os.path.join(dest, ".hg", f) + dst = os.path.join(dest_path, ".hg", f) try: util.copyfiles(src, dst) except OSError, inst: if inst.errno != errno.ENOENT: raise - repo = hg.repository(ui, dest) + # we need to re-init the repo after manually copying the data into it + dest_repo = hg.repository(ui, dest) else: revs = None if opts['rev']: - if not other.local(): + if not src_repo.local(): error = _("clone -r not supported yet for remote repositories.") raise util.Abort(error) else: - revs = [other.lookup(rev) for rev in opts['rev']] - repo = hg.repository(ui, dest, create=1) - repo.pull(other, heads = revs) - - f = repo.opener("hgrc", "w", text=True) - f.write("[paths]\n") - f.write("default = %s\n" % abspath) - f.close() - - if not opts['noupdate']: - doupdate(repo.ui, repo) - - d.close() + revs = [src_repo.lookup(rev) for rev in opts['rev']] + + if dest_repo.local(): + dest_repo.pull(src_repo, heads = revs) + elif src_repo.local(): + src_repo.push(dest_repo, revs = revs) + else: + error = _("clone from remote to remote not supported.") + raise util.Abort(error) + + if dest_repo.local(): + f = dest_repo.opener("hgrc", "w", text=True) + f.write("[paths]\n") + f.write("default = %s\n" % abspath) + f.close() + + if not opts['noupdate']: + doupdate(dest_repo.ui, dest_repo) + + if d: + d.close() def commit(ui, repo, *pats, **opts): """commit the specified files or all outstanding changes @@ -1905,8 +1923,6 @@ If no directory is given, the current directory is used. """ - if not os.path.exists(dest): - os.mkdir(dest) hg.repository(ui, dest, create=1) def locate(ui, repo, *pats, **opts):
--- a/mercurial/hg.py Mon Jul 03 19:14:29 2006 +0200 +++ b/mercurial/hg.py Mon Jul 03 10:19:09 2006 -0700 @@ -33,6 +33,9 @@ path = path[5:] return localrepo.localrepository(ui, path, create) +def ssh_(ui, path, create=0): + return sshrepo.sshrepository(ui, path, create) + def old_http(ui, path): ui.warn(_("old-http:// syntax is deprecated, " "please use static-http:// instead\n")) @@ -50,7 +53,7 @@ 'http': lambda ui, path: httprepo.httprepository(ui, path), 'https': lambda ui, path: httprepo.httpsrepository(ui, path), 'old-http': old_http, - 'ssh': lambda ui, path: sshrepo.sshrepository(ui, path), + 'ssh': ssh_, 'static-http': static_http, }
--- a/mercurial/localrepo.py Mon Jul 03 19:14:29 2006 +0200 +++ b/mercurial/localrepo.py Mon Jul 03 10:19:09 2006 -0700 @@ -74,6 +74,8 @@ self.transhandle = None if create: + if not os.path.exists(path): + os.mkdir(path) os.mkdir(self.path) os.mkdir(self.join("data"))
--- a/mercurial/sshrepo.py Mon Jul 03 19:14:29 2006 +0200 +++ b/mercurial/sshrepo.py Mon Jul 03 10:19:09 2006 -0700 @@ -12,7 +12,7 @@ demandload(globals(), "hg os re stat util") class sshrepository(remoterepository): - def __init__(self, ui, path): + def __init__(self, ui, path, create=0): self.url = path self.ui = ui @@ -30,6 +30,25 @@ sshcmd = self.ui.config("ui", "ssh", "ssh") remotecmd = self.ui.config("ui", "remotecmd", "hg") + + if create: + try: + self.validate_repo(ui, sshcmd, args, remotecmd) + return # the repo is good, nothing more to do + except hg.RepoError: + pass + + cmd = '%s %s "%s init %s"' + cmd = cmd % (sshcmd, args, remotecmd, self.path) + + ui.note('running %s\n' % cmd) + res = os.system(cmd) + if res != 0: + raise hg.RepoError(_("could not create remote repo")) + + self.validate_repo(ui, sshcmd, args, remotecmd) + + def validate_repo(self, ui, sshcmd, args, remotecmd): cmd = '%s %s "%s -R %s serve --stdio"' cmd = cmd % (sshcmd, args, remotecmd, self.path)