changeset 3793:f3fbf76d043c

merge with crew
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Tue, 05 Dec 2006 15:21:41 +0100
parents 4670470b97bd (current diff) 8643b9f90b51 (diff)
children 630caaf29815
files
diffstat 5 files changed, 28 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bundlerepo.py	Tue Dec 05 14:58:32 2006 +0100
+++ b/mercurial/bundlerepo.py	Tue Dec 05 15:21:41 2006 +0100
@@ -199,8 +199,8 @@
         else:
             raise util.Abort(_("%s: unknown bundle compression type")
                              % bundlename)
-        self.changelog = bundlechangelog(self.opener, self.bundlefile)
-        self.manifest = bundlemanifest(self.opener, self.bundlefile,
+        self.changelog = bundlechangelog(self.sopener, self.bundlefile)
+        self.manifest = bundlemanifest(self.sopener, self.bundlefile,
                                        self.changelog.rev)
         # dict with the mapping 'filename' -> position in the bundle
         self.bundlefilespos = {}
@@ -223,10 +223,10 @@
             f = f[1:]
         if f in self.bundlefilespos:
             self.bundlefile.seek(self.bundlefilespos[f])
-            return bundlefilelog(self.opener, f, self.bundlefile,
+            return bundlefilelog(self.sopener, f, self.bundlefile,
                                  self.changelog.rev)
         else:
-            return filelog.filelog(self.opener, f)
+            return filelog.filelog(self.sopener, f)
 
     def close(self):
         """Close assigned bundle file immediately."""
--- a/mercurial/hg.py	Tue Dec 05 14:58:32 2006 +0100
+++ b/mercurial/hg.py	Tue Dec 05 15:21:41 2006 +0100
@@ -129,11 +129,9 @@
 
     dest_repo = repository(ui, dest, create=True)
 
-    dest_path = None
     dir_cleanup = None
     if dest_repo.local():
-        dest_path = os.path.realpath(dest_repo.root)
-        dir_cleanup = DirCleanup(dest_path)
+        dir_cleanup = DirCleanup(os.path.realpath(dest_repo.root))
 
     abspath = source
     copy = False
@@ -154,14 +152,16 @@
 
     if copy:
         # we lock here to avoid premature writing to the target
-        dest_lock = lock.lock(os.path.join(dest_path, ".hg", "lock"))
+        src_store = os.path.realpath(src_repo.spath)
+        dest_store = os.path.realpath(dest_repo.spath)
+        dest_lock = lock.lock(os.path.join(dest_store, "lock"))
 
         files = ("data",
                  "00manifest.d", "00manifest.i",
                  "00changelog.d", "00changelog.i")
         for f in files:
-            src = os.path.join(source, ".hg", f)
-            dst = os.path.join(dest_path, ".hg", f)
+            src = os.path.join(src_store, f)
+            dst = os.path.join(dest_store, f)
             try:
                 util.copyfiles(src, dst)
             except OSError, inst:
--- a/mercurial/localrepo.py	Tue Dec 05 14:58:32 2006 +0100
+++ b/mercurial/localrepo.py	Tue Dec 05 15:21:41 2006 +0100
@@ -31,12 +31,15 @@
                                            " here (.hg not found)"))
             path = p
         self.path = os.path.join(path, ".hg")
+        self.spath = self.path
 
         if not os.path.isdir(self.path):
             if create:
                 if not os.path.exists(path):
                     os.mkdir(path)
                 os.mkdir(self.path)
+                if self.spath != self.path:
+                    os.mkdir(self.spath)
             else:
                 raise repo.RepoError(_("repository %s not found") % path)
         elif create:
@@ -46,7 +49,7 @@
         self.origroot = path
         self.ui = ui.ui(parentui=parentui)
         self.opener = util.opener(self.path)
-        self.sopener = util.opener(self.path)
+        self.sopener = util.opener(self.spath)
         self.wopener = util.opener(self.root)
 
         try:
@@ -395,7 +398,7 @@
         return os.path.join(self.path, f)
 
     def sjoin(self, f):
-        return os.path.join(self.path, f)
+        return os.path.join(self.spath, f)
 
     def wjoin(self, f):
         return os.path.join(self.root, f)
@@ -483,9 +486,11 @@
             ds = ""
         self.opener("journal.dirstate", "w").write(ds)
 
+        renames = [(self.sjoin("journal"), self.sjoin("undo")),
+                   (self.join("journal.dirstate"), self.join("undo.dirstate"))]
         tr = transaction.transaction(self.ui.warn, self.sopener,
                                        self.sjoin("journal"),
-                                       aftertrans(self.path))
+                                       aftertrans(renames))
         self.transhandle = tr
         return tr
 
@@ -1897,12 +1902,11 @@
         return self.pull(remote, heads)
 
 # used to avoid circular references so destructors work
-def aftertrans(base):
-    p = base
+def aftertrans(files):
+    renamefiles = [tuple(t) for t in files]
     def a():
-        util.rename(os.path.join(p, "journal"), os.path.join(p, "undo"))
-        util.rename(os.path.join(p, "journal.dirstate"),
-                    os.path.join(p, "undo.dirstate"))
+        for src, dest in renamefiles:
+            util.rename(src, dest)
     return a
 
 def instance(ui, path, create):
--- a/mercurial/statichttprepo.py	Tue Dec 05 14:58:32 2006 +0100
+++ b/mercurial/statichttprepo.py	Tue Dec 05 15:21:41 2006 +0100
@@ -33,12 +33,13 @@
     def __init__(self, ui, path):
         self._url = path
         self.path = (path + "/.hg")
+        self.spath = self.path
         self.ui = ui
         self.revlogversion = 0
         self.opener = opener(self.path)
-        self.sopener = opener(self.path)
-        self.manifest = manifest.manifest(self.opener)
-        self.changelog = changelog.changelog(self.opener)
+        self.sopener = opener(self.spath)
+        self.manifest = manifest.manifest(self.sopener)
+        self.changelog = changelog.changelog(self.sopener)
         self.tagscache = None
         self.nodetagscache = None
         self.encodepats = None
--- a/mercurial/streamclone.py	Tue Dec 05 14:58:32 2006 +0100
+++ b/mercurial/streamclone.py	Tue Dec 05 15:21:41 2006 +0100
@@ -78,7 +78,7 @@
     repo.ui.debug('scanning\n')
     entries = []
     total_bytes = 0
-    for name, size in walkrepo(repo.path):
+    for name, size in walkrepo(repo.spath):
         entries.append((name, size))
         total_bytes += size
     repolock.release()
@@ -89,7 +89,7 @@
     for name, size in entries:
         repo.ui.debug('sending %s (%d bytes)\n' % (name, size))
         fileobj.write('%s\0%d\n' % (name, size))
-        for chunk in util.filechunkiter(repo.opener(name), limit=size):
+        for chunk in util.filechunkiter(repo.sopener(name), limit=size):
             fileobj.write(chunk)
     flush = getattr(fileobj, 'flush', None)
     if flush: flush()