Show More
@@ -412,7 +412,7 b' def histedit(ui, repo, *parent, **opts):' | |||
|
412 | 412 | ui.status(_('comparing with %s\n') % util.hidepassword(dest)) |
|
413 | 413 | |
|
414 | 414 | revs, checkout = hg.addbranchrevs(repo, repo, revs, None) |
|
415 |
other = hg. |
|
|
415 | other = hg.peer(repo, opts, dest) | |
|
416 | 416 | |
|
417 | 417 | if revs: |
|
418 | 418 | revs = [repo.lookup(rev) for rev in revs] |
@@ -22,9 +22,9 b' class localstore(basestore.basestore):' | |||
|
22 | 22 | the user cache.''' |
|
23 | 23 | |
|
24 | 24 | def __init__(self, ui, repo, remote): |
|
25 | url = os.path.join(remote.path, '.hg', lfutil.longname) | |
|
25 | url = os.path.join(remote.local().path, '.hg', lfutil.longname) | |
|
26 | 26 | super(localstore, self).__init__(ui, repo, util.expandpath(url)) |
|
27 | self.remote = remote | |
|
27 | self.remote = remote.local() | |
|
28 | 28 | |
|
29 | 29 | def put(self, source, hash): |
|
30 | 30 | util.makedirs(os.path.dirname(lfutil.storepath(self.remote, hash))) |
@@ -722,7 +722,7 b' def overrideclone(orig, ui, source, dest' | |||
|
722 | 722 | return True |
|
723 | 723 | if opts.get('all_largefiles'): |
|
724 | 724 | sourcerepo, destrepo = result |
|
725 | success, missing = lfcommands.downloadlfiles(ui, destrepo, None) | |
|
725 | success, missing = lfcommands.downloadlfiles(ui, destrepo.local(), None) | |
|
726 | 726 | return missing != 0 |
|
727 | 727 | return result is None |
|
728 | 728 |
@@ -2245,7 +2245,7 b' def clone(ui, source, dest=None, **opts)' | |||
|
2245 | 2245 | # main repo (destination and sources) |
|
2246 | 2246 | if dest is None: |
|
2247 | 2247 | dest = hg.defaultdest(source) |
|
2248 |
sr = hg. |
|
|
2248 | sr = hg.peer(ui, opts, ui.expandpath(source)) | |
|
2249 | 2249 | |
|
2250 | 2250 | # patches repo (source only) |
|
2251 | 2251 | if opts.get('patches'): |
@@ -2253,18 +2253,19 b' def clone(ui, source, dest=None, **opts)' | |||
|
2253 | 2253 | else: |
|
2254 | 2254 | patchespath = patchdir(sr) |
|
2255 | 2255 | try: |
|
2256 |
hg. |
|
|
2256 | hg.peer(ui, opts, patchespath) | |
|
2257 | 2257 | except error.RepoError: |
|
2258 | 2258 | raise util.Abort(_('versioned patch repository not found' |
|
2259 | 2259 | ' (see init --mq)')) |
|
2260 | 2260 | qbase, destrev = None, None |
|
2261 | 2261 | if sr.local(): |
|
2262 | if sr.mq.applied and sr[qbase].phase() != phases.secret: | |
|
2263 | qbase = sr.mq.applied[0].node | |
|
2262 | repo = sr.local() | |
|
2263 | if repo.mq.applied and repo[qbase].phase() != phases.secret: | |
|
2264 | qbase = repo.mq.applied[0].node | |
|
2264 | 2265 | if not hg.islocal(dest): |
|
2265 |
heads = set( |
|
|
2266 |
destrev = list(heads.difference( |
|
|
2267 |
destrev.append( |
|
|
2266 | heads = set(repo.heads()) | |
|
2267 | destrev = list(heads.difference(repo.heads(qbase))) | |
|
2268 | destrev.append(repo.changelog.parents(qbase)[0]) | |
|
2268 | 2269 | elif sr.capable('lookup'): |
|
2269 | 2270 | try: |
|
2270 | 2271 | qbase = sr.lookup('qbase') |
@@ -2284,13 +2285,14 b' def clone(ui, source, dest=None, **opts)' | |||
|
2284 | 2285 | stream=opts.get('uncompressed')) |
|
2285 | 2286 | |
|
2286 | 2287 | if dr.local(): |
|
2288 | repo = dr.local() | |
|
2287 | 2289 | if qbase: |
|
2288 | 2290 | ui.note(_('stripping applied patches from destination ' |
|
2289 | 2291 | 'repository\n')) |
|
2290 |
|
|
|
2292 | repo.mq.strip(repo, [qbase], update=False, backup=None) | |
|
2291 | 2293 | if not opts.get('noupdate'): |
|
2292 | 2294 | ui.note(_('updating destination repository\n')) |
|
2293 |
hg.update( |
|
|
2295 | hg.update(repo, repo.changelog.tip()) | |
|
2294 | 2296 | |
|
2295 | 2297 | @command("qcommit|qci", |
|
2296 | 2298 | commands.table["^commit|ci"][1], |
@@ -43,8 +43,6 b' def relink(ui, repo, origin=None, **opts' | |||
|
43 | 43 | raise util.Abort(_('hardlinks are not supported on this system')) |
|
44 | 44 | src = hg.repository(ui, ui.expandpath(origin or 'default-relink', |
|
45 | 45 | origin or 'default')) |
|
46 | if not src.local(): | |
|
47 | raise util.Abort(_('must specify local origin repository')) | |
|
48 | 46 | ui.status(_('relinking %s to %s\n') % (src.store.path, repo.store.path)) |
|
49 | 47 | if repo.root == src.root: |
|
50 | 48 | ui.status(_('there is nothing to relink\n')) |
@@ -139,7 +139,7 b' class transplanter(object):' | |||
|
139 | 139 | continue |
|
140 | 140 | if pulls: |
|
141 | 141 | if source != repo: |
|
142 | repo.pull(source, heads=pulls) | |
|
142 | repo.pull(source.peer(), heads=pulls) | |
|
143 | 143 | merge.update(repo, pulls[-1], False, False, None) |
|
144 | 144 | p1, p2 = repo.dirstate.parents() |
|
145 | 145 | pulls = [] |
@@ -203,7 +203,7 b' class transplanter(object):' | |||
|
203 | 203 | os.unlink(patchfile) |
|
204 | 204 | tr.close() |
|
205 | 205 | if pulls: |
|
206 | repo.pull(source, heads=pulls) | |
|
206 | repo.pull(source.peer(), heads=pulls) | |
|
207 | 207 | merge.update(repo, pulls[-1], False, False, None) |
|
208 | 208 | finally: |
|
209 | 209 | self.saveseries(revmap, merges) |
@@ -614,9 +614,9 b' def transplant(ui, repo, *revs, **opts):' | |||
|
614 | 614 | |
|
615 | 615 | sourcerepo = opts.get('source') |
|
616 | 616 | if sourcerepo: |
|
617 |
|
|
|
618 |
branches = map( |
|
|
619 |
source, csets, cleanupfn = bundlerepo.getremotechanges(ui, repo, |
|
|
617 | peer = hg.peer(ui, opts, ui.expandpath(sourcerepo)) | |
|
618 | branches = map(peer.lookup, opts.get('branch', ())) | |
|
619 | source, csets, cleanupfn = bundlerepo.getremotechanges(ui, repo, peer, | |
|
620 | 620 | onlyheads=branches, force=True) |
|
621 | 621 | else: |
|
622 | 622 | source = repo |
@@ -344,8 +344,8 b' def getremotechanges(ui, repo, other, on' | |||
|
344 | 344 | |
|
345 | 345 | bundle = None |
|
346 | 346 | bundlerepo = None |
|
347 | localrepo = other | |
|
348 |
if bundlename or not |
|
|
347 | localrepo = other.local() | |
|
348 | if bundlename or not localrepo: | |
|
349 | 349 | # create a bundle (uncompressed if other repo is not local) |
|
350 | 350 | |
|
351 | 351 | if other.capable('getbundle'): |
@@ -356,12 +356,12 b' def getremotechanges(ui, repo, other, on' | |||
|
356 | 356 | rheads = None |
|
357 | 357 | else: |
|
358 | 358 | cg = other.changegroupsubset(incoming, rheads, 'incoming') |
|
359 |
bundletype = |
|
|
359 | bundletype = localrepo and "HG10BZ" or "HG10UN" | |
|
360 | 360 | fname = bundle = changegroup.writebundle(cg, bundlename, bundletype) |
|
361 | 361 | # keep written bundle? |
|
362 | 362 | if bundlename: |
|
363 | 363 | bundle = None |
|
364 |
if not |
|
|
364 | if not localrepo: | |
|
365 | 365 | # use the created uncompressed bundlerepo |
|
366 | 366 | localrepo = bundlerepo = bundlerepository(ui, repo.root, fname) |
|
367 | 367 | # this repo contains local and other now, so filter out local again |
@@ -1784,7 +1784,7 b' def debugdiscovery(ui, repo, remoteurl="' | |||
|
1784 | 1784 | # make sure tests are repeatable |
|
1785 | 1785 | random.seed(12323) |
|
1786 | 1786 | |
|
1787 | def doit(localheads, remoteheads): | |
|
1787 | def doit(localheads, remoteheads, remote=remote): | |
|
1788 | 1788 | if opts.get('old'): |
|
1789 | 1789 | if localheads: |
|
1790 | 1790 | raise util.Abort('cannot use localheads with old style ' |
@@ -3463,10 +3463,11 b' def identify(ui, repo, source=None, rev=' | |||
|
3463 | 3463 | |
|
3464 | 3464 | if source: |
|
3465 | 3465 | source, branches = hg.parseurl(ui.expandpath(source)) |
|
3466 |
|
|
|
3467 | revs, checkout = hg.addbranchrevs(repo, repo, branches, None) | |
|
3468 | ||
|
3469 | if not repo.local(): | |
|
3466 | peer = hg.peer(ui, opts, source) | |
|
3467 | repo = peer.local() | |
|
3468 | revs, checkout = hg.addbranchrevs(repo, peer, branches, None) | |
|
3469 | ||
|
3470 | if not repo: | |
|
3470 | 3471 | if num or branch or tags: |
|
3471 | 3472 | raise util.Abort( |
|
3472 | 3473 | _("can't query remote revision number, branch, or tags")) |
@@ -3475,16 +3476,16 b' def identify(ui, repo, source=None, rev=' | |||
|
3475 | 3476 | if not rev: |
|
3476 | 3477 | rev = "tip" |
|
3477 | 3478 | |
|
3478 |
remoterev = |
|
|
3479 | remoterev = peer.lookup(rev) | |
|
3479 | 3480 | if default or id: |
|
3480 | 3481 | output = [hexfunc(remoterev)] |
|
3481 | 3482 | |
|
3482 | 3483 | def getbms(): |
|
3483 | 3484 | bms = [] |
|
3484 | 3485 | |
|
3485 |
if 'bookmarks' in |
|
|
3486 | if 'bookmarks' in peer.listkeys('namespaces'): | |
|
3486 | 3487 | hexremoterev = hex(remoterev) |
|
3487 |
bms = [bm for bm, bmr in |
|
|
3488 | bms = [bm for bm, bmr in peer.listkeys('bookmarks').iteritems() | |
|
3488 | 3489 | if bmr == hexremoterev] |
|
3489 | 3490 | |
|
3490 | 3491 | return bms |
@@ -169,7 +169,7 b' def checkheads(repo, remote, outgoing, r' | |||
|
169 | 169 | |
|
170 | 170 | # 2. Check for new branches on the remote. |
|
171 | 171 | if remote.local(): |
|
172 | remotemap = phases.visiblebranchmap(remote) | |
|
172 | remotemap = phases.visiblebranchmap(remote.local()) | |
|
173 | 173 | else: |
|
174 | 174 | remotemap = remote.branchmap() |
|
175 | 175 | newbranches = branches - set(remotemap) |
@@ -20,21 +20,22 b' def _local(path):' | |||
|
20 | 20 | path = util.expandpath(util.urllocalpath(path)) |
|
21 | 21 | return (os.path.isfile(path) and bundlerepo or localrepo) |
|
22 | 22 | |
|
23 |
def addbranchrevs(lrepo, r |
|
|
23 | def addbranchrevs(lrepo, other, branches, revs): | |
|
24 | peer = other.peer() # a courtesy to callers using a localrepo for other | |
|
24 | 25 | hashbranch, branches = branches |
|
25 | 26 | if not hashbranch and not branches: |
|
26 | 27 | return revs or None, revs and revs[0] or None |
|
27 | 28 | revs = revs and list(revs) or [] |
|
28 |
if not |
|
|
29 | if not peer.capable('branchmap'): | |
|
29 | 30 | if branches: |
|
30 | 31 | raise util.Abort(_("remote branch lookup not supported")) |
|
31 | 32 | revs.append(hashbranch) |
|
32 | 33 | return revs, revs[0] |
|
33 |
branchmap = |
|
|
34 | branchmap = peer.branchmap() | |
|
34 | 35 | |
|
35 | 36 | def primary(branch): |
|
36 | 37 | if branch == '.': |
|
37 |
if not lrepo |
|
|
38 | if not lrepo: | |
|
38 | 39 | raise util.Abort(_("dirstate branch not accessible")) |
|
39 | 40 | branch = lrepo.dirstate.branch() |
|
40 | 41 | if branch in branchmap: |
@@ -88,20 +89,29 b' def islocal(repo):' | |||
|
88 | 89 | return False |
|
89 | 90 | return repo.local() |
|
90 | 91 | |
|
91 |
def repo |
|
|
92 | def _peerorrepo(ui, path, create=False): | |
|
92 | 93 | """return a repository object for the specified path""" |
|
93 |
|
|
|
94 |
ui = getattr( |
|
|
94 | obj = _peerlookup(path).instance(ui, path, create) | |
|
95 | ui = getattr(obj, "ui", ui) | |
|
95 | 96 | for name, module in extensions.extensions(): |
|
96 | 97 | hook = getattr(module, 'reposetup', None) |
|
97 | 98 | if hook: |
|
98 |
hook(ui, |
|
|
99 | hook(ui, obj) | |
|
100 | return obj | |
|
101 | ||
|
102 | def repository(ui, path='', create=False): | |
|
103 | """return a repository object for the specified path""" | |
|
104 | peer = _peerorrepo(ui, path, create) | |
|
105 | repo = peer.local() | |
|
106 | if not repo: | |
|
107 | raise util.Abort(_("repository '%s' is not local") % | |
|
108 | (path or peer.url())) | |
|
99 | 109 | return repo |
|
100 | 110 | |
|
101 | 111 | def peer(uiorrepo, opts, path, create=False): |
|
102 | 112 | '''return a repository peer for the specified path''' |
|
103 | 113 | rui = remoteui(uiorrepo, opts) |
|
104 |
return repo |
|
|
114 | return _peerorrepo(rui, path, create).peer() | |
|
105 | 115 | |
|
106 | 116 | def defaultdest(source): |
|
107 | 117 | '''return default destination of clone if none is given''' |
@@ -124,7 +134,7 b' def share(ui, source, dest=None, update=' | |||
|
124 | 134 | srcrepo = repository(ui, source) |
|
125 | 135 | rev, checkout = addbranchrevs(srcrepo, srcrepo, branches, None) |
|
126 | 136 | else: |
|
127 | srcrepo = source | |
|
137 | srcrepo = source.local() | |
|
128 | 138 | origsource = source = srcrepo.url() |
|
129 | 139 | checkout = None |
|
130 | 140 | |
@@ -213,7 +223,7 b' def clone(ui, peeropts, source, dest=Non' | |||
|
213 | 223 | |
|
214 | 224 | Create a copy of an existing repository in a new directory. The |
|
215 | 225 | source and destination are URLs, as passed to the repository |
|
216 |
function. Returns a pair of repository |
|
|
226 | function. Returns a pair of repository peers, the source and | |
|
217 | 227 | newly created destination. |
|
218 | 228 | |
|
219 | 229 | The location of the source is added to the new repository's |
@@ -247,12 +257,12 b' def clone(ui, peeropts, source, dest=Non' | |||
|
247 | 257 | if isinstance(source, str): |
|
248 | 258 | origsource = ui.expandpath(source) |
|
249 | 259 | source, branch = parseurl(origsource, branch) |
|
250 |
src |
|
|
260 | srcpeer = peer(ui, peeropts, source) | |
|
251 | 261 | else: |
|
252 | srcrepo = source | |
|
262 | srcpeer = source.peer() # in case we were called with a localrepo | |
|
253 | 263 | branch = (None, branch or []) |
|
254 |
origsource = source = src |
|
|
255 |
rev, checkout = addbranchrevs(src |
|
|
264 | origsource = source = srcpeer.url() | |
|
265 | rev, checkout = addbranchrevs(srcpeer, srcpeer, branch, rev) | |
|
256 | 266 | |
|
257 | 267 | if dest is None: |
|
258 | 268 | dest = defaultdest(source) |
@@ -282,6 +292,7 b' def clone(ui, peeropts, source, dest=Non' | |||
|
282 | 292 | self.rmtree(self.dir_, True) |
|
283 | 293 | |
|
284 | 294 | srclock = destlock = dircleanup = None |
|
295 | srcrepo = srcpeer.local() | |
|
285 | 296 | try: |
|
286 | 297 | abspath = origsource |
|
287 | 298 | if islocal(origsource): |
@@ -291,7 +302,7 b' def clone(ui, peeropts, source, dest=Non' | |||
|
291 | 302 | dircleanup = DirCleanup(dest) |
|
292 | 303 | |
|
293 | 304 | copy = False |
|
294 |
if src |
|
|
305 | if srcpeer.cancopy() and islocal(dest) and not srcrepo.revs("secret()"): | |
|
295 | 306 | copy = not pull and not rev |
|
296 | 307 | |
|
297 | 308 | if copy: |
@@ -326,13 +337,12 b' def clone(ui, peeropts, source, dest=Non' | |||
|
326 | 337 | |
|
327 | 338 | # we need to re-init the repo after manually copying the data |
|
328 | 339 | # into it |
|
329 |
dest |
|
|
340 | destpeer = peer(ui, peeropts, dest) | |
|
330 | 341 | srcrepo.hook('outgoing', source='clone', |
|
331 | 342 | node=node.hex(node.nullid)) |
|
332 | 343 | else: |
|
333 | 344 | try: |
|
334 |
dest |
|
|
335 | create=True) | |
|
345 | destpeer = peer(ui, peeropts, dest, create=True) | |
|
336 | 346 | except OSError, inst: |
|
337 | 347 | if inst.errno == errno.EEXIST: |
|
338 | 348 | dircleanup.close() |
@@ -342,16 +352,16 b' def clone(ui, peeropts, source, dest=Non' | |||
|
342 | 352 | |
|
343 | 353 | revs = None |
|
344 | 354 | if rev: |
|
345 |
if not src |
|
|
355 | if not srcpeer.capable('lookup'): | |
|
346 | 356 | raise util.Abort(_("src repository does not support " |
|
347 | 357 | "revision lookup and so doesn't " |
|
348 | 358 | "support clone by revision")) |
|
349 |
revs = [src |
|
|
359 | revs = [srcpeer.lookup(r) for r in rev] | |
|
350 | 360 | checkout = revs[0] |
|
351 |
if dest |
|
|
352 |
dest |
|
|
353 |
elif srcrepo |
|
|
354 |
srcrepo.push(dest |
|
|
361 | if destpeer.local(): | |
|
362 | destpeer.local().clone(srcpeer, heads=revs, stream=stream) | |
|
363 | elif srcrepo: | |
|
364 | srcrepo.push(destpeer, revs=revs) | |
|
355 | 365 | else: |
|
356 | 366 | raise util.Abort(_("clone from remote to remote not supported")) |
|
357 | 367 | |
@@ -359,8 +369,9 b' def clone(ui, peeropts, source, dest=Non' | |||
|
359 | 369 | dircleanup.close() |
|
360 | 370 | |
|
361 | 371 | # clone all bookmarks except divergent ones |
|
362 | if destrepo.local() and srcrepo.capable("pushkey"): | |
|
363 | rb = srcrepo.listkeys('bookmarks') | |
|
372 | destrepo = destpeer.local() | |
|
373 | if destrepo and srcpeer.capable("pushkey"): | |
|
374 | rb = srcpeer.listkeys('bookmarks') | |
|
364 | 375 | for k, n in rb.iteritems(): |
|
365 | 376 | try: |
|
366 | 377 | m = destrepo.lookup(n) |
@@ -369,11 +380,11 b' def clone(ui, peeropts, source, dest=Non' | |||
|
369 | 380 | pass |
|
370 | 381 | if rb: |
|
371 | 382 | bookmarks.write(destrepo) |
|
372 |
elif srcrepo |
|
|
383 | elif srcrepo and destpeer.capable("pushkey"): | |
|
373 | 384 | for k, n in srcrepo._bookmarks.iteritems(): |
|
374 |
dest |
|
|
385 | destpeer.pushkey('bookmarks', k, '', hex(n)) | |
|
375 | 386 | |
|
376 |
if destrepo |
|
|
387 | if destrepo: | |
|
377 | 388 | fp = destrepo.opener("hgrc", "w", text=True) |
|
378 | 389 | fp.write("[paths]\n") |
|
379 | 390 | u = util.url(abspath) |
@@ -386,9 +397,7 b' def clone(ui, peeropts, source, dest=Non' | |||
|
386 | 397 | |
|
387 | 398 | if update: |
|
388 | 399 | if update is not True: |
|
389 | checkout = update | |
|
390 | if srcrepo.local(): | |
|
391 | checkout = srcrepo.lookup(update) | |
|
400 | checkout = srcrepo.lookup(update) | |
|
392 | 401 | for test in (checkout, 'default', 'tip'): |
|
393 | 402 | if test is None: |
|
394 | 403 | continue |
@@ -401,13 +410,13 b' def clone(ui, peeropts, source, dest=Non' | |||
|
401 | 410 | destrepo.ui.status(_("updating to branch %s\n") % bn) |
|
402 | 411 | _update(destrepo, uprev) |
|
403 | 412 | |
|
404 |
return src |
|
|
413 | return srcpeer, destpeer | |
|
405 | 414 | finally: |
|
406 | 415 | release(srclock, destlock) |
|
407 | 416 | if dircleanup is not None: |
|
408 | 417 | dircleanup.cleanup() |
|
409 |
if src |
|
|
410 |
src |
|
|
418 | if srcpeer is not None: | |
|
419 | srcpeer.close() | |
|
411 | 420 | |
|
412 | 421 | def _showstats(repo, stats): |
|
413 | 422 | repo.ui.status(_("%d files updated, %d files merged, " |
@@ -33,6 +33,9 b' class repository(object):' | |||
|
33 | 33 | def local(self): |
|
34 | 34 | return False |
|
35 | 35 | |
|
36 | def peer(self): | |
|
37 | return self | |
|
38 | ||
|
36 | 39 | def cancopy(self): |
|
37 | 40 | return self.local() |
|
38 | 41 |
@@ -100,7 +100,7 b' def findcommonheads(ui, local, remote,' | |||
|
100 | 100 | sample = ownheads |
|
101 | 101 | if remote.local(): |
|
102 | 102 | # stopgap until we have a proper localpeer that supports batch() |
|
103 | srvheadhashes = phases.visibleheads(remote) | |
|
103 | srvheadhashes = phases.visibleheads(remote.local()) | |
|
104 | 104 | yesno = remote.known(dag.externalizeall(sample)) |
|
105 | 105 | elif remote.capable('batch'): |
|
106 | 106 | batch = remote.batch() |
@@ -503,9 +503,10 b' class hgsubrepo(abstractsubrepo):' | |||
|
503 | 503 | % (subrelpath(self), srcurl)) |
|
504 | 504 | parentrepo = self._repo._subparent |
|
505 | 505 | shutil.rmtree(self._repo.path) |
|
506 |
other, |
|
|
507 |
|
|
|
508 |
|
|
|
506 | other, cloned = hg.clone(self._repo._subparent.ui, {}, | |
|
507 | other, self._repo.root, | |
|
508 | update=False) | |
|
509 | self._repo = cloned.local() | |
|
509 | 510 | self._initrepo(parentrepo, source, create=True) |
|
510 | 511 | else: |
|
511 | 512 | self._repo.ui.status(_('pulling subrepo %s from %s\n') |
General Comments 0
You need to be logged in to leave comments.
Login now