##// END OF EJS Templates
hg: remove underscores in clone function
Martin Geisler -
r14463:81f559d1 default
parent child Browse files
Show More
@@ -209,12 +209,12 b' def clone(ui, source, dest=None, pull=Fa'
209 209 if isinstance(source, str):
210 210 origsource = ui.expandpath(source)
211 211 source, branch = parseurl(origsource, branch)
212 src_repo = repository(ui, source)
212 srcrepo = repository(ui, source)
213 213 else:
214 src_repo = source
214 srcrepo = source
215 215 branch = (None, branch or [])
216 origsource = source = src_repo.url()
217 rev, checkout = addbranchrevs(src_repo, src_repo, branch, rev)
216 origsource = source = srcrepo.url()
217 rev, checkout = addbranchrevs(srcrepo, srcrepo, branch, rev)
218 218
219 219 if dest is None:
220 220 dest = defaultdest(source)
@@ -241,17 +241,17 b' def clone(ui, source, dest=None, pull=Fa'
241 241 if self.dir_:
242 242 self.rmtree(self.dir_, True)
243 243
244 src_lock = dest_lock = dir_cleanup = None
244 srclock = destlock = dircleanup = None
245 245 try:
246 246 abspath = origsource
247 247 if islocal(origsource):
248 248 abspath = os.path.abspath(util.localpath(origsource))
249 249
250 250 if islocal(dest):
251 dir_cleanup = DirCleanup(dest)
251 dircleanup = DirCleanup(dest)
252 252
253 253 copy = False
254 if src_repo.cancopy() and islocal(dest):
254 if srcrepo.cancopy() and islocal(dest):
255 255 copy = not pull and not rev
256 256
257 257 if copy:
@@ -260,40 +260,40 b' def clone(ui, source, dest=None, pull=Fa'
260 260 # can end up with extra data in the cloned revlogs that's
261 261 # not pointed to by changesets, thus causing verify to
262 262 # fail
263 src_lock = src_repo.lock(wait=False)
263 srclock = srcrepo.lock(wait=False)
264 264 except error.LockError:
265 265 copy = False
266 266
267 267 if copy:
268 src_repo.hook('preoutgoing', throw=True, source='clone')
268 srcrepo.hook('preoutgoing', throw=True, source='clone')
269 269 hgdir = os.path.realpath(os.path.join(dest, ".hg"))
270 270 if not os.path.exists(dest):
271 271 os.mkdir(dest)
272 272 else:
273 273 # only clean up directories we create ourselves
274 dir_cleanup.dir_ = hgdir
274 dircleanup.dir_ = hgdir
275 275 try:
276 dest_path = hgdir
277 util.makedir(dest_path, notindexed=True)
276 destpath = hgdir
277 util.makedir(destpath, notindexed=True)
278 278 except OSError, inst:
279 279 if inst.errno == errno.EEXIST:
280 dir_cleanup.close()
280 dircleanup.close()
281 281 raise util.Abort(_("destination '%s' already exists")
282 282 % dest)
283 283 raise
284 284
285 285 hardlink = None
286 286 num = 0
287 for f in src_repo.store.copylist():
288 src = os.path.join(src_repo.sharedpath, f)
289 dst = os.path.join(dest_path, f)
287 for f in srcrepo.store.copylist():
288 src = os.path.join(srcrepo.sharedpath, f)
289 dst = os.path.join(destpath, f)
290 290 dstbase = os.path.dirname(dst)
291 291 if dstbase and not os.path.exists(dstbase):
292 292 os.mkdir(dstbase)
293 293 if os.path.exists(src):
294 294 if dst.endswith('data'):
295 295 # lock to avoid premature writing to the target
296 dest_lock = lock.lock(os.path.join(dstbase, "lock"))
296 destlock = lock.lock(os.path.join(dstbase, "lock"))
297 297 hardlink, n = util.copyfiles(src, dst, hardlink)
298 298 num += n
299 299 if hardlink:
@@ -303,82 +303,82 b' def clone(ui, source, dest=None, pull=Fa'
303 303
304 304 # we need to re-init the repo after manually copying the data
305 305 # into it
306 dest_repo = repository(ui, dest)
307 src_repo.hook('outgoing', source='clone',
306 destrepo = repository(ui, dest)
307 srcrepo.hook('outgoing', source='clone',
308 308 node=node.hex(node.nullid))
309 309 else:
310 310 try:
311 dest_repo = repository(ui, dest, create=True)
311 destrepo = repository(ui, dest, create=True)
312 312 except OSError, inst:
313 313 if inst.errno == errno.EEXIST:
314 dir_cleanup.close()
314 dircleanup.close()
315 315 raise util.Abort(_("destination '%s' already exists")
316 316 % dest)
317 317 raise
318 318
319 319 revs = None
320 320 if rev:
321 if 'lookup' not in src_repo.capabilities:
321 if 'lookup' not in srcrepo.capabilities:
322 322 raise util.Abort(_("src repository does not support "
323 323 "revision lookup and so doesn't "
324 324 "support clone by revision"))
325 revs = [src_repo.lookup(r) for r in rev]
325 revs = [srcrepo.lookup(r) for r in rev]
326 326 checkout = revs[0]
327 if dest_repo.local():
328 dest_repo.clone(src_repo, heads=revs, stream=stream)
329 elif src_repo.local():
330 src_repo.push(dest_repo, revs=revs)
327 if destrepo.local():
328 destrepo.clone(srcrepo, heads=revs, stream=stream)
329 elif srcrepo.local():
330 srcrepo.push(destrepo, revs=revs)
331 331 else:
332 332 raise util.Abort(_("clone from remote to remote not supported"))
333 333
334 if dir_cleanup:
335 dir_cleanup.close()
334 if dircleanup:
335 dircleanup.close()
336 336
337 if dest_repo.local():
338 fp = dest_repo.opener("hgrc", "w", text=True)
337 if destrepo.local():
338 fp = destrepo.opener("hgrc", "w", text=True)
339 339 fp.write("[paths]\n")
340 340 fp.write("default = %s\n" % abspath)
341 341 fp.close()
342 342
343 dest_repo.ui.setconfig('paths', 'default', abspath)
343 destrepo.ui.setconfig('paths', 'default', abspath)
344 344
345 345 if update:
346 346 if update is not True:
347 347 checkout = update
348 if src_repo.local():
349 checkout = src_repo.lookup(update)
348 if srcrepo.local():
349 checkout = srcrepo.lookup(update)
350 350 for test in (checkout, 'default', 'tip'):
351 351 if test is None:
352 352 continue
353 353 try:
354 uprev = dest_repo.lookup(test)
354 uprev = destrepo.lookup(test)
355 355 break
356 356 except error.RepoLookupError:
357 357 continue
358 bn = dest_repo[uprev].branch()
359 dest_repo.ui.status(_("updating to branch %s\n") % bn)
360 _update(dest_repo, uprev)
358 bn = destrepo[uprev].branch()
359 destrepo.ui.status(_("updating to branch %s\n") % bn)
360 _update(destrepo, uprev)
361 361
362 362 # clone all bookmarks
363 if dest_repo.local() and src_repo.capable("pushkey"):
364 rb = src_repo.listkeys('bookmarks')
363 if destrepo.local() and srcrepo.capable("pushkey"):
364 rb = srcrepo.listkeys('bookmarks')
365 365 for k, n in rb.iteritems():
366 366 try:
367 m = dest_repo.lookup(n)
368 dest_repo._bookmarks[k] = m
367 m = destrepo.lookup(n)
368 destrepo._bookmarks[k] = m
369 369 except error.RepoLookupError:
370 370 pass
371 371 if rb:
372 bookmarks.write(dest_repo)
373 elif src_repo.local() and dest_repo.capable("pushkey"):
374 for k, n in src_repo._bookmarks.iteritems():
375 dest_repo.pushkey('bookmarks', k, '', hex(n))
372 bookmarks.write(destrepo)
373 elif srcrepo.local() and destrepo.capable("pushkey"):
374 for k, n in srcrepo._bookmarks.iteritems():
375 destrepo.pushkey('bookmarks', k, '', hex(n))
376 376
377 return src_repo, dest_repo
377 return srcrepo, destrepo
378 378 finally:
379 release(src_lock, dest_lock)
380 if dir_cleanup is not None:
381 dir_cleanup.cleanup()
379 release(srclock, destlock)
380 if dircleanup is not None:
381 dircleanup.cleanup()
382 382
383 383 def _showstats(repo, stats):
384 384 repo.ui.status(_("%d files updated, %d files merged, "
General Comments 0
You need to be logged in to leave comments. Login now