Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/hg.py @ 3854:4f6db0233606
Merge Benoit's .hg/store support
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 10 Dec 2006 02:11:02 -0600 |
parents | aaeb7f5d1052 c0b449154a90 |
children | ad6f34c83c3d |
comparison
equal
deleted
inserted
replaced
3848:8cbf060f637e | 3854:4f6db0233606 |
---|---|
126 self.dir_ = None | 126 self.dir_ = None |
127 def __del__(self): | 127 def __del__(self): |
128 if self.dir_: | 128 if self.dir_: |
129 self.rmtree(self.dir_, True) | 129 self.rmtree(self.dir_, True) |
130 | 130 |
131 dest_repo = repository(ui, dest, create=True) | |
132 | |
133 dir_cleanup = None | 131 dir_cleanup = None |
134 if dest_repo.local(): | 132 if islocal(dest): |
135 dir_cleanup = DirCleanup(os.path.realpath(dest_repo.root)) | 133 dir_cleanup = DirCleanup(dest) |
136 | 134 |
137 abspath = source | 135 abspath = source |
138 copy = False | 136 copy = False |
139 if src_repo.local() and dest_repo.local(): | 137 if src_repo.local() and islocal(dest): |
140 abspath = os.path.abspath(source) | 138 abspath = os.path.abspath(source) |
141 copy = not pull and not rev | 139 copy = not pull and not rev |
142 | 140 |
143 src_lock, dest_lock = None, None | 141 src_lock, dest_lock = None, None |
144 if copy: | 142 if copy: |
150 src_lock = src_repo.lock() | 148 src_lock = src_repo.lock() |
151 except lock.LockException: | 149 except lock.LockException: |
152 copy = False | 150 copy = False |
153 | 151 |
154 if copy: | 152 if copy: |
153 def force_copy(src, dst): | |
154 try: | |
155 util.copyfiles(src, dst) | |
156 except OSError, inst: | |
157 if inst.errno != errno.ENOENT: | |
158 raise | |
159 | |
160 src_store = os.path.realpath(src_repo.spath) | |
161 if not os.path.exists(dest): | |
162 os.mkdir(dest) | |
163 dest_path = os.path.realpath(os.path.join(dest, ".hg")) | |
164 os.mkdir(dest_path) | |
165 if src_repo.spath != src_repo.path: | |
166 dest_store = os.path.join(dest_path, "store") | |
167 os.mkdir(dest_store) | |
168 else: | |
169 dest_store = dest_path | |
170 # copy the requires file | |
171 force_copy(src_repo.join("requires"), | |
172 os.path.join(dest_path, "requires")) | |
155 # we lock here to avoid premature writing to the target | 173 # we lock here to avoid premature writing to the target |
156 src_store = os.path.realpath(src_repo.spath) | |
157 dest_store = os.path.realpath(dest_repo.spath) | |
158 dest_lock = lock.lock(os.path.join(dest_store, "lock")) | 174 dest_lock = lock.lock(os.path.join(dest_store, "lock")) |
159 | 175 |
160 files = ("data", | 176 files = ("data", |
161 "00manifest.d", "00manifest.i", | 177 "00manifest.d", "00manifest.i", |
162 "00changelog.d", "00changelog.i") | 178 "00changelog.d", "00changelog.i") |
163 for f in files: | 179 for f in files: |
164 src = os.path.join(src_store, f) | 180 src = os.path.join(src_store, f) |
165 dst = os.path.join(dest_store, f) | 181 dst = os.path.join(dest_store, f) |
166 try: | 182 force_copy(src, dst) |
167 util.copyfiles(src, dst) | |
168 except OSError, inst: | |
169 if inst.errno != errno.ENOENT: | |
170 raise | |
171 | 183 |
172 # we need to re-init the repo after manually copying the data | 184 # we need to re-init the repo after manually copying the data |
173 # into it | 185 # into it |
174 dest_repo = repository(ui, dest) | 186 dest_repo = repository(ui, dest) |
175 | 187 |
176 else: | 188 else: |
189 dest_repo = repository(ui, dest, create=True) | |
190 | |
177 revs = None | 191 revs = None |
178 if rev: | 192 if rev: |
179 if 'lookup' not in src_repo.capabilities: | 193 if 'lookup' not in src_repo.capabilities: |
180 raise util.Abort(_("src repository does not support revision " | 194 raise util.Abort(_("src repository does not support revision " |
181 "lookup and so doesn't support clone by " | 195 "lookup and so doesn't support clone by " |