##// END OF EJS Templates
hg: use "os.path.join()" to join path components which may be empty (issue4203)...
FUJIWARA Katsunori -
r20825:dda11e79 stable
parent child Browse files
Show More
@@ -1,631 +1,633 b''
1 # hg.py - repository classes for mercurial
1 # hg.py - repository classes for mercurial
2 #
2 #
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
4 # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com>
4 # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com>
5 #
5 #
6 # This software may be used and distributed according to the terms of the
6 # This software may be used and distributed according to the terms of the
7 # GNU General Public License version 2 or any later version.
7 # GNU General Public License version 2 or any later version.
8
8
9 from i18n import _
9 from i18n import _
10 from lock import release
10 from lock import release
11 from node import hex, nullid
11 from node import hex, nullid
12 import localrepo, bundlerepo, unionrepo, httppeer, sshpeer, statichttprepo
12 import localrepo, bundlerepo, unionrepo, httppeer, sshpeer, statichttprepo
13 import bookmarks, lock, util, extensions, error, node, scmutil, phases, url
13 import bookmarks, lock, util, extensions, error, node, scmutil, phases, url
14 import cmdutil, discovery
14 import cmdutil, discovery
15 import merge as mergemod
15 import merge as mergemod
16 import verify as verifymod
16 import verify as verifymod
17 import errno, os, shutil
17 import errno, os, shutil
18
18
19 def _local(path):
19 def _local(path):
20 path = util.expandpath(util.urllocalpath(path))
20 path = util.expandpath(util.urllocalpath(path))
21 return (os.path.isfile(path) and bundlerepo or localrepo)
21 return (os.path.isfile(path) and bundlerepo or localrepo)
22
22
23 def addbranchrevs(lrepo, other, branches, revs):
23 def addbranchrevs(lrepo, other, branches, revs):
24 peer = other.peer() # a courtesy to callers using a localrepo for other
24 peer = other.peer() # a courtesy to callers using a localrepo for other
25 hashbranch, branches = branches
25 hashbranch, branches = branches
26 if not hashbranch and not branches:
26 if not hashbranch and not branches:
27 return revs or None, revs and revs[0] or None
27 return revs or None, revs and revs[0] or None
28 revs = revs and list(revs) or []
28 revs = revs and list(revs) or []
29 if not peer.capable('branchmap'):
29 if not peer.capable('branchmap'):
30 if branches:
30 if branches:
31 raise util.Abort(_("remote branch lookup not supported"))
31 raise util.Abort(_("remote branch lookup not supported"))
32 revs.append(hashbranch)
32 revs.append(hashbranch)
33 return revs, revs[0]
33 return revs, revs[0]
34 branchmap = peer.branchmap()
34 branchmap = peer.branchmap()
35
35
36 def primary(branch):
36 def primary(branch):
37 if branch == '.':
37 if branch == '.':
38 if not lrepo:
38 if not lrepo:
39 raise util.Abort(_("dirstate branch not accessible"))
39 raise util.Abort(_("dirstate branch not accessible"))
40 branch = lrepo.dirstate.branch()
40 branch = lrepo.dirstate.branch()
41 if branch in branchmap:
41 if branch in branchmap:
42 revs.extend(node.hex(r) for r in reversed(branchmap[branch]))
42 revs.extend(node.hex(r) for r in reversed(branchmap[branch]))
43 return True
43 return True
44 else:
44 else:
45 return False
45 return False
46
46
47 for branch in branches:
47 for branch in branches:
48 if not primary(branch):
48 if not primary(branch):
49 raise error.RepoLookupError(_("unknown branch '%s'") % branch)
49 raise error.RepoLookupError(_("unknown branch '%s'") % branch)
50 if hashbranch:
50 if hashbranch:
51 if not primary(hashbranch):
51 if not primary(hashbranch):
52 revs.append(hashbranch)
52 revs.append(hashbranch)
53 return revs, revs[0]
53 return revs, revs[0]
54
54
55 def parseurl(path, branches=None):
55 def parseurl(path, branches=None):
56 '''parse url#branch, returning (url, (branch, branches))'''
56 '''parse url#branch, returning (url, (branch, branches))'''
57
57
58 u = util.url(path)
58 u = util.url(path)
59 branch = None
59 branch = None
60 if u.fragment:
60 if u.fragment:
61 branch = u.fragment
61 branch = u.fragment
62 u.fragment = None
62 u.fragment = None
63 return str(u), (branch, branches or [])
63 return str(u), (branch, branches or [])
64
64
65 schemes = {
65 schemes = {
66 'bundle': bundlerepo,
66 'bundle': bundlerepo,
67 'union': unionrepo,
67 'union': unionrepo,
68 'file': _local,
68 'file': _local,
69 'http': httppeer,
69 'http': httppeer,
70 'https': httppeer,
70 'https': httppeer,
71 'ssh': sshpeer,
71 'ssh': sshpeer,
72 'static-http': statichttprepo,
72 'static-http': statichttprepo,
73 }
73 }
74
74
75 def _peerlookup(path):
75 def _peerlookup(path):
76 u = util.url(path)
76 u = util.url(path)
77 scheme = u.scheme or 'file'
77 scheme = u.scheme or 'file'
78 thing = schemes.get(scheme) or schemes['file']
78 thing = schemes.get(scheme) or schemes['file']
79 try:
79 try:
80 return thing(path)
80 return thing(path)
81 except TypeError:
81 except TypeError:
82 return thing
82 return thing
83
83
84 def islocal(repo):
84 def islocal(repo):
85 '''return true if repo (or path pointing to repo) is local'''
85 '''return true if repo (or path pointing to repo) is local'''
86 if isinstance(repo, str):
86 if isinstance(repo, str):
87 try:
87 try:
88 return _peerlookup(repo).islocal(repo)
88 return _peerlookup(repo).islocal(repo)
89 except AttributeError:
89 except AttributeError:
90 return False
90 return False
91 return repo.local()
91 return repo.local()
92
92
93 def openpath(ui, path):
93 def openpath(ui, path):
94 '''open path with open if local, url.open if remote'''
94 '''open path with open if local, url.open if remote'''
95 pathurl = util.url(path, parsequery=False, parsefragment=False)
95 pathurl = util.url(path, parsequery=False, parsefragment=False)
96 if pathurl.islocal():
96 if pathurl.islocal():
97 return util.posixfile(pathurl.localpath(), 'rb')
97 return util.posixfile(pathurl.localpath(), 'rb')
98 else:
98 else:
99 return url.open(ui, path)
99 return url.open(ui, path)
100
100
101 def _peerorrepo(ui, path, create=False):
101 def _peerorrepo(ui, path, create=False):
102 """return a repository object for the specified path"""
102 """return a repository object for the specified path"""
103 obj = _peerlookup(path).instance(ui, path, create)
103 obj = _peerlookup(path).instance(ui, path, create)
104 ui = getattr(obj, "ui", ui)
104 ui = getattr(obj, "ui", ui)
105 for name, module in extensions.extensions(ui):
105 for name, module in extensions.extensions(ui):
106 hook = getattr(module, 'reposetup', None)
106 hook = getattr(module, 'reposetup', None)
107 if hook:
107 if hook:
108 hook(ui, obj)
108 hook(ui, obj)
109 return obj
109 return obj
110
110
111 def repository(ui, path='', create=False):
111 def repository(ui, path='', create=False):
112 """return a repository object for the specified path"""
112 """return a repository object for the specified path"""
113 peer = _peerorrepo(ui, path, create)
113 peer = _peerorrepo(ui, path, create)
114 repo = peer.local()
114 repo = peer.local()
115 if not repo:
115 if not repo:
116 raise util.Abort(_("repository '%s' is not local") %
116 raise util.Abort(_("repository '%s' is not local") %
117 (path or peer.url()))
117 (path or peer.url()))
118 return repo.filtered('visible')
118 return repo.filtered('visible')
119
119
120 def peer(uiorrepo, opts, path, create=False):
120 def peer(uiorrepo, opts, path, create=False):
121 '''return a repository peer for the specified path'''
121 '''return a repository peer for the specified path'''
122 rui = remoteui(uiorrepo, opts)
122 rui = remoteui(uiorrepo, opts)
123 return _peerorrepo(rui, path, create).peer()
123 return _peerorrepo(rui, path, create).peer()
124
124
125 def defaultdest(source):
125 def defaultdest(source):
126 '''return default destination of clone if none is given'''
126 '''return default destination of clone if none is given'''
127 return os.path.basename(os.path.normpath(util.url(source).path or ''))
127 return os.path.basename(os.path.normpath(util.url(source).path or ''))
128
128
129 def share(ui, source, dest=None, update=True):
129 def share(ui, source, dest=None, update=True):
130 '''create a shared repository'''
130 '''create a shared repository'''
131
131
132 if not islocal(source):
132 if not islocal(source):
133 raise util.Abort(_('can only share local repositories'))
133 raise util.Abort(_('can only share local repositories'))
134
134
135 if not dest:
135 if not dest:
136 dest = defaultdest(source)
136 dest = defaultdest(source)
137 else:
137 else:
138 dest = ui.expandpath(dest)
138 dest = ui.expandpath(dest)
139
139
140 if isinstance(source, str):
140 if isinstance(source, str):
141 origsource = ui.expandpath(source)
141 origsource = ui.expandpath(source)
142 source, branches = parseurl(origsource)
142 source, branches = parseurl(origsource)
143 srcrepo = repository(ui, source)
143 srcrepo = repository(ui, source)
144 rev, checkout = addbranchrevs(srcrepo, srcrepo, branches, None)
144 rev, checkout = addbranchrevs(srcrepo, srcrepo, branches, None)
145 else:
145 else:
146 srcrepo = source.local()
146 srcrepo = source.local()
147 origsource = source = srcrepo.url()
147 origsource = source = srcrepo.url()
148 checkout = None
148 checkout = None
149
149
150 sharedpath = srcrepo.sharedpath # if our source is already sharing
150 sharedpath = srcrepo.sharedpath # if our source is already sharing
151
151
152 root = os.path.realpath(dest)
152 root = os.path.realpath(dest)
153 roothg = os.path.join(root, '.hg')
153 roothg = os.path.join(root, '.hg')
154
154
155 if os.path.exists(roothg):
155 if os.path.exists(roothg):
156 raise util.Abort(_('destination already exists'))
156 raise util.Abort(_('destination already exists'))
157
157
158 if not os.path.isdir(root):
158 if not os.path.isdir(root):
159 os.mkdir(root)
159 os.mkdir(root)
160 util.makedir(roothg, notindexed=True)
160 util.makedir(roothg, notindexed=True)
161
161
162 requirements = ''
162 requirements = ''
163 try:
163 try:
164 requirements = srcrepo.opener.read('requires')
164 requirements = srcrepo.opener.read('requires')
165 except IOError, inst:
165 except IOError, inst:
166 if inst.errno != errno.ENOENT:
166 if inst.errno != errno.ENOENT:
167 raise
167 raise
168
168
169 requirements += 'shared\n'
169 requirements += 'shared\n'
170 util.writefile(os.path.join(roothg, 'requires'), requirements)
170 util.writefile(os.path.join(roothg, 'requires'), requirements)
171 util.writefile(os.path.join(roothg, 'sharedpath'), sharedpath)
171 util.writefile(os.path.join(roothg, 'sharedpath'), sharedpath)
172
172
173 r = repository(ui, root)
173 r = repository(ui, root)
174
174
175 default = srcrepo.ui.config('paths', 'default')
175 default = srcrepo.ui.config('paths', 'default')
176 if default:
176 if default:
177 fp = r.opener("hgrc", "w", text=True)
177 fp = r.opener("hgrc", "w", text=True)
178 fp.write("[paths]\n")
178 fp.write("[paths]\n")
179 fp.write("default = %s\n" % default)
179 fp.write("default = %s\n" % default)
180 fp.close()
180 fp.close()
181
181
182 if update:
182 if update:
183 r.ui.status(_("updating working directory\n"))
183 r.ui.status(_("updating working directory\n"))
184 if update is not True:
184 if update is not True:
185 checkout = update
185 checkout = update
186 for test in (checkout, 'default', 'tip'):
186 for test in (checkout, 'default', 'tip'):
187 if test is None:
187 if test is None:
188 continue
188 continue
189 try:
189 try:
190 uprev = r.lookup(test)
190 uprev = r.lookup(test)
191 break
191 break
192 except error.RepoLookupError:
192 except error.RepoLookupError:
193 continue
193 continue
194 _update(r, uprev)
194 _update(r, uprev)
195
195
196 def copystore(ui, srcrepo, destpath):
196 def copystore(ui, srcrepo, destpath):
197 '''copy files from store of srcrepo in destpath
197 '''copy files from store of srcrepo in destpath
198
198
199 returns destlock
199 returns destlock
200 '''
200 '''
201 destlock = None
201 destlock = None
202 try:
202 try:
203 hardlink = None
203 hardlink = None
204 num = 0
204 num = 0
205 srcpublishing = srcrepo.ui.configbool('phases', 'publish', True)
205 srcpublishing = srcrepo.ui.configbool('phases', 'publish', True)
206 srcvfs = scmutil.vfs(srcrepo.sharedpath)
206 srcvfs = scmutil.vfs(srcrepo.sharedpath)
207 dstvfs = scmutil.vfs(destpath)
207 dstvfs = scmutil.vfs(destpath)
208 for f in srcrepo.store.copylist():
208 for f in srcrepo.store.copylist():
209 if srcpublishing and f.endswith('phaseroots'):
209 if srcpublishing and f.endswith('phaseroots'):
210 continue
210 continue
211 dstbase = os.path.dirname(f)
211 dstbase = os.path.dirname(f)
212 if dstbase and not dstvfs.exists(dstbase):
212 if dstbase and not dstvfs.exists(dstbase):
213 dstvfs.mkdir(dstbase)
213 dstvfs.mkdir(dstbase)
214 if srcvfs.exists(f):
214 if srcvfs.exists(f):
215 if f.endswith('data'):
215 if f.endswith('data'):
216 # 'dstbase' may be empty (e.g. revlog format 0)
217 lockfile = os.path.join(dstbase, "lock")
216 # lock to avoid premature writing to the target
218 # lock to avoid premature writing to the target
217 destlock = lock.lock(dstvfs, dstbase + "/lock")
219 destlock = lock.lock(dstvfs, lockfile)
218 hardlink, n = util.copyfiles(srcvfs.join(f), dstvfs.join(f),
220 hardlink, n = util.copyfiles(srcvfs.join(f), dstvfs.join(f),
219 hardlink)
221 hardlink)
220 num += n
222 num += n
221 if hardlink:
223 if hardlink:
222 ui.debug("linked %d files\n" % num)
224 ui.debug("linked %d files\n" % num)
223 else:
225 else:
224 ui.debug("copied %d files\n" % num)
226 ui.debug("copied %d files\n" % num)
225 return destlock
227 return destlock
226 except: # re-raises
228 except: # re-raises
227 release(destlock)
229 release(destlock)
228 raise
230 raise
229
231
230 def clone(ui, peeropts, source, dest=None, pull=False, rev=None,
232 def clone(ui, peeropts, source, dest=None, pull=False, rev=None,
231 update=True, stream=False, branch=None):
233 update=True, stream=False, branch=None):
232 """Make a copy of an existing repository.
234 """Make a copy of an existing repository.
233
235
234 Create a copy of an existing repository in a new directory. The
236 Create a copy of an existing repository in a new directory. The
235 source and destination are URLs, as passed to the repository
237 source and destination are URLs, as passed to the repository
236 function. Returns a pair of repository peers, the source and
238 function. Returns a pair of repository peers, the source and
237 newly created destination.
239 newly created destination.
238
240
239 The location of the source is added to the new repository's
241 The location of the source is added to the new repository's
240 .hg/hgrc file, as the default to be used for future pulls and
242 .hg/hgrc file, as the default to be used for future pulls and
241 pushes.
243 pushes.
242
244
243 If an exception is raised, the partly cloned/updated destination
245 If an exception is raised, the partly cloned/updated destination
244 repository will be deleted.
246 repository will be deleted.
245
247
246 Arguments:
248 Arguments:
247
249
248 source: repository object or URL
250 source: repository object or URL
249
251
250 dest: URL of destination repository to create (defaults to base
252 dest: URL of destination repository to create (defaults to base
251 name of source repository)
253 name of source repository)
252
254
253 pull: always pull from source repository, even in local case
255 pull: always pull from source repository, even in local case
254
256
255 stream: stream raw data uncompressed from repository (fast over
257 stream: stream raw data uncompressed from repository (fast over
256 LAN, slow over WAN)
258 LAN, slow over WAN)
257
259
258 rev: revision to clone up to (implies pull=True)
260 rev: revision to clone up to (implies pull=True)
259
261
260 update: update working directory after clone completes, if
262 update: update working directory after clone completes, if
261 destination is local repository (True means update to default rev,
263 destination is local repository (True means update to default rev,
262 anything else is treated as a revision)
264 anything else is treated as a revision)
263
265
264 branch: branches to clone
266 branch: branches to clone
265 """
267 """
266
268
267 if isinstance(source, str):
269 if isinstance(source, str):
268 origsource = ui.expandpath(source)
270 origsource = ui.expandpath(source)
269 source, branch = parseurl(origsource, branch)
271 source, branch = parseurl(origsource, branch)
270 srcpeer = peer(ui, peeropts, source)
272 srcpeer = peer(ui, peeropts, source)
271 else:
273 else:
272 srcpeer = source.peer() # in case we were called with a localrepo
274 srcpeer = source.peer() # in case we were called with a localrepo
273 branch = (None, branch or [])
275 branch = (None, branch or [])
274 origsource = source = srcpeer.url()
276 origsource = source = srcpeer.url()
275 rev, checkout = addbranchrevs(srcpeer, srcpeer, branch, rev)
277 rev, checkout = addbranchrevs(srcpeer, srcpeer, branch, rev)
276
278
277 if dest is None:
279 if dest is None:
278 dest = defaultdest(source)
280 dest = defaultdest(source)
279 ui.status(_("destination directory: %s\n") % dest)
281 ui.status(_("destination directory: %s\n") % dest)
280 else:
282 else:
281 dest = ui.expandpath(dest)
283 dest = ui.expandpath(dest)
282
284
283 dest = util.urllocalpath(dest)
285 dest = util.urllocalpath(dest)
284 source = util.urllocalpath(source)
286 source = util.urllocalpath(source)
285
287
286 if not dest:
288 if not dest:
287 raise util.Abort(_("empty destination path is not valid"))
289 raise util.Abort(_("empty destination path is not valid"))
288 if os.path.exists(dest):
290 if os.path.exists(dest):
289 if not os.path.isdir(dest):
291 if not os.path.isdir(dest):
290 raise util.Abort(_("destination '%s' already exists") % dest)
292 raise util.Abort(_("destination '%s' already exists") % dest)
291 elif os.listdir(dest):
293 elif os.listdir(dest):
292 raise util.Abort(_("destination '%s' is not empty") % dest)
294 raise util.Abort(_("destination '%s' is not empty") % dest)
293
295
294 srclock = destlock = cleandir = None
296 srclock = destlock = cleandir = None
295 srcrepo = srcpeer.local()
297 srcrepo = srcpeer.local()
296 try:
298 try:
297 abspath = origsource
299 abspath = origsource
298 if islocal(origsource):
300 if islocal(origsource):
299 abspath = os.path.abspath(util.urllocalpath(origsource))
301 abspath = os.path.abspath(util.urllocalpath(origsource))
300
302
301 if islocal(dest):
303 if islocal(dest):
302 cleandir = dest
304 cleandir = dest
303
305
304 copy = False
306 copy = False
305 if (srcrepo and srcrepo.cancopy() and islocal(dest)
307 if (srcrepo and srcrepo.cancopy() and islocal(dest)
306 and not phases.hassecret(srcrepo)):
308 and not phases.hassecret(srcrepo)):
307 copy = not pull and not rev
309 copy = not pull and not rev
308
310
309 if copy:
311 if copy:
310 try:
312 try:
311 # we use a lock here because if we race with commit, we
313 # we use a lock here because if we race with commit, we
312 # can end up with extra data in the cloned revlogs that's
314 # can end up with extra data in the cloned revlogs that's
313 # not pointed to by changesets, thus causing verify to
315 # not pointed to by changesets, thus causing verify to
314 # fail
316 # fail
315 srclock = srcrepo.lock(wait=False)
317 srclock = srcrepo.lock(wait=False)
316 except error.LockError:
318 except error.LockError:
317 copy = False
319 copy = False
318
320
319 if copy:
321 if copy:
320 srcrepo.hook('preoutgoing', throw=True, source='clone')
322 srcrepo.hook('preoutgoing', throw=True, source='clone')
321 hgdir = os.path.realpath(os.path.join(dest, ".hg"))
323 hgdir = os.path.realpath(os.path.join(dest, ".hg"))
322 if not os.path.exists(dest):
324 if not os.path.exists(dest):
323 os.mkdir(dest)
325 os.mkdir(dest)
324 else:
326 else:
325 # only clean up directories we create ourselves
327 # only clean up directories we create ourselves
326 cleandir = hgdir
328 cleandir = hgdir
327 try:
329 try:
328 destpath = hgdir
330 destpath = hgdir
329 util.makedir(destpath, notindexed=True)
331 util.makedir(destpath, notindexed=True)
330 except OSError, inst:
332 except OSError, inst:
331 if inst.errno == errno.EEXIST:
333 if inst.errno == errno.EEXIST:
332 cleandir = None
334 cleandir = None
333 raise util.Abort(_("destination '%s' already exists")
335 raise util.Abort(_("destination '%s' already exists")
334 % dest)
336 % dest)
335 raise
337 raise
336
338
337 destlock = copystore(ui, srcrepo, destpath)
339 destlock = copystore(ui, srcrepo, destpath)
338
340
339 # Recomputing branch cache might be slow on big repos,
341 # Recomputing branch cache might be slow on big repos,
340 # so just copy it
342 # so just copy it
341 dstcachedir = os.path.join(destpath, 'cache')
343 dstcachedir = os.path.join(destpath, 'cache')
342 srcbranchcache = srcrepo.sjoin('cache/branch2')
344 srcbranchcache = srcrepo.sjoin('cache/branch2')
343 dstbranchcache = os.path.join(dstcachedir, 'branch2')
345 dstbranchcache = os.path.join(dstcachedir, 'branch2')
344 if os.path.exists(srcbranchcache):
346 if os.path.exists(srcbranchcache):
345 if not os.path.exists(dstcachedir):
347 if not os.path.exists(dstcachedir):
346 os.mkdir(dstcachedir)
348 os.mkdir(dstcachedir)
347 util.copyfile(srcbranchcache, dstbranchcache)
349 util.copyfile(srcbranchcache, dstbranchcache)
348
350
349 # we need to re-init the repo after manually copying the data
351 # we need to re-init the repo after manually copying the data
350 # into it
352 # into it
351 destpeer = peer(srcrepo, peeropts, dest)
353 destpeer = peer(srcrepo, peeropts, dest)
352 srcrepo.hook('outgoing', source='clone',
354 srcrepo.hook('outgoing', source='clone',
353 node=node.hex(node.nullid))
355 node=node.hex(node.nullid))
354 else:
356 else:
355 try:
357 try:
356 destpeer = peer(srcrepo or ui, peeropts, dest, create=True)
358 destpeer = peer(srcrepo or ui, peeropts, dest, create=True)
357 # only pass ui when no srcrepo
359 # only pass ui when no srcrepo
358 except OSError, inst:
360 except OSError, inst:
359 if inst.errno == errno.EEXIST:
361 if inst.errno == errno.EEXIST:
360 cleandir = None
362 cleandir = None
361 raise util.Abort(_("destination '%s' already exists")
363 raise util.Abort(_("destination '%s' already exists")
362 % dest)
364 % dest)
363 raise
365 raise
364
366
365 revs = None
367 revs = None
366 if rev:
368 if rev:
367 if not srcpeer.capable('lookup'):
369 if not srcpeer.capable('lookup'):
368 raise util.Abort(_("src repository does not support "
370 raise util.Abort(_("src repository does not support "
369 "revision lookup and so doesn't "
371 "revision lookup and so doesn't "
370 "support clone by revision"))
372 "support clone by revision"))
371 revs = [srcpeer.lookup(r) for r in rev]
373 revs = [srcpeer.lookup(r) for r in rev]
372 checkout = revs[0]
374 checkout = revs[0]
373 if destpeer.local():
375 if destpeer.local():
374 destpeer.local().clone(srcpeer, heads=revs, stream=stream)
376 destpeer.local().clone(srcpeer, heads=revs, stream=stream)
375 elif srcrepo:
377 elif srcrepo:
376 srcrepo.push(destpeer, revs=revs)
378 srcrepo.push(destpeer, revs=revs)
377 else:
379 else:
378 raise util.Abort(_("clone from remote to remote not supported"))
380 raise util.Abort(_("clone from remote to remote not supported"))
379
381
380 cleandir = None
382 cleandir = None
381
383
382 # clone all bookmarks except divergent ones
384 # clone all bookmarks except divergent ones
383 destrepo = destpeer.local()
385 destrepo = destpeer.local()
384 if destrepo and srcpeer.capable("pushkey"):
386 if destrepo and srcpeer.capable("pushkey"):
385 rb = srcpeer.listkeys('bookmarks')
387 rb = srcpeer.listkeys('bookmarks')
386 marks = destrepo._bookmarks
388 marks = destrepo._bookmarks
387 for k, n in rb.iteritems():
389 for k, n in rb.iteritems():
388 try:
390 try:
389 m = destrepo.lookup(n)
391 m = destrepo.lookup(n)
390 marks[k] = m
392 marks[k] = m
391 except error.RepoLookupError:
393 except error.RepoLookupError:
392 pass
394 pass
393 if rb:
395 if rb:
394 marks.write()
396 marks.write()
395 elif srcrepo and destpeer.capable("pushkey"):
397 elif srcrepo and destpeer.capable("pushkey"):
396 for k, n in srcrepo._bookmarks.iteritems():
398 for k, n in srcrepo._bookmarks.iteritems():
397 destpeer.pushkey('bookmarks', k, '', hex(n))
399 destpeer.pushkey('bookmarks', k, '', hex(n))
398
400
399 if destrepo:
401 if destrepo:
400 fp = destrepo.opener("hgrc", "w", text=True)
402 fp = destrepo.opener("hgrc", "w", text=True)
401 fp.write("[paths]\n")
403 fp.write("[paths]\n")
402 u = util.url(abspath)
404 u = util.url(abspath)
403 u.passwd = None
405 u.passwd = None
404 defaulturl = str(u)
406 defaulturl = str(u)
405 fp.write("default = %s\n" % defaulturl)
407 fp.write("default = %s\n" % defaulturl)
406 fp.close()
408 fp.close()
407
409
408 destrepo.ui.setconfig('paths', 'default', defaulturl)
410 destrepo.ui.setconfig('paths', 'default', defaulturl)
409
411
410 if update:
412 if update:
411 if update is not True:
413 if update is not True:
412 checkout = srcpeer.lookup(update)
414 checkout = srcpeer.lookup(update)
413 uprev = None
415 uprev = None
414 status = None
416 status = None
415 if checkout is not None:
417 if checkout is not None:
416 try:
418 try:
417 uprev = destrepo.lookup(checkout)
419 uprev = destrepo.lookup(checkout)
418 except error.RepoLookupError:
420 except error.RepoLookupError:
419 pass
421 pass
420 if uprev is None:
422 if uprev is None:
421 try:
423 try:
422 uprev = destrepo._bookmarks['@']
424 uprev = destrepo._bookmarks['@']
423 update = '@'
425 update = '@'
424 bn = destrepo[uprev].branch()
426 bn = destrepo[uprev].branch()
425 if bn == 'default':
427 if bn == 'default':
426 status = _("updating to bookmark @\n")
428 status = _("updating to bookmark @\n")
427 else:
429 else:
428 status = _("updating to bookmark @ on branch %s\n"
430 status = _("updating to bookmark @ on branch %s\n"
429 % bn)
431 % bn)
430 except KeyError:
432 except KeyError:
431 try:
433 try:
432 uprev = destrepo.branchtip('default')
434 uprev = destrepo.branchtip('default')
433 except error.RepoLookupError:
435 except error.RepoLookupError:
434 uprev = destrepo.lookup('tip')
436 uprev = destrepo.lookup('tip')
435 if not status:
437 if not status:
436 bn = destrepo[uprev].branch()
438 bn = destrepo[uprev].branch()
437 status = _("updating to branch %s\n") % bn
439 status = _("updating to branch %s\n") % bn
438 destrepo.ui.status(status)
440 destrepo.ui.status(status)
439 _update(destrepo, uprev)
441 _update(destrepo, uprev)
440 if update in destrepo._bookmarks:
442 if update in destrepo._bookmarks:
441 bookmarks.setcurrent(destrepo, update)
443 bookmarks.setcurrent(destrepo, update)
442 finally:
444 finally:
443 release(srclock, destlock)
445 release(srclock, destlock)
444 if cleandir is not None:
446 if cleandir is not None:
445 shutil.rmtree(cleandir, True)
447 shutil.rmtree(cleandir, True)
446 if srcpeer is not None:
448 if srcpeer is not None:
447 srcpeer.close()
449 srcpeer.close()
448 return srcpeer, destpeer
450 return srcpeer, destpeer
449
451
450 def _showstats(repo, stats):
452 def _showstats(repo, stats):
451 repo.ui.status(_("%d files updated, %d files merged, "
453 repo.ui.status(_("%d files updated, %d files merged, "
452 "%d files removed, %d files unresolved\n") % stats)
454 "%d files removed, %d files unresolved\n") % stats)
453
455
454 def updaterepo(repo, node, overwrite):
456 def updaterepo(repo, node, overwrite):
455 """Update the working directory to node.
457 """Update the working directory to node.
456
458
457 When overwrite is set, changes are clobbered, merged else
459 When overwrite is set, changes are clobbered, merged else
458
460
459 returns stats (see pydoc mercurial.merge.applyupdates)"""
461 returns stats (see pydoc mercurial.merge.applyupdates)"""
460 return mergemod.update(repo, node, False, overwrite, None)
462 return mergemod.update(repo, node, False, overwrite, None)
461
463
462 def update(repo, node):
464 def update(repo, node):
463 """update the working directory to node, merging linear changes"""
465 """update the working directory to node, merging linear changes"""
464 stats = updaterepo(repo, node, False)
466 stats = updaterepo(repo, node, False)
465 _showstats(repo, stats)
467 _showstats(repo, stats)
466 if stats[3]:
468 if stats[3]:
467 repo.ui.status(_("use 'hg resolve' to retry unresolved file merges\n"))
469 repo.ui.status(_("use 'hg resolve' to retry unresolved file merges\n"))
468 return stats[3] > 0
470 return stats[3] > 0
469
471
470 # naming conflict in clone()
472 # naming conflict in clone()
471 _update = update
473 _update = update
472
474
473 def clean(repo, node, show_stats=True):
475 def clean(repo, node, show_stats=True):
474 """forcibly switch the working directory to node, clobbering changes"""
476 """forcibly switch the working directory to node, clobbering changes"""
475 stats = updaterepo(repo, node, True)
477 stats = updaterepo(repo, node, True)
476 util.unlinkpath(repo.join('graftstate'), ignoremissing=True)
478 util.unlinkpath(repo.join('graftstate'), ignoremissing=True)
477 if show_stats:
479 if show_stats:
478 _showstats(repo, stats)
480 _showstats(repo, stats)
479 return stats[3] > 0
481 return stats[3] > 0
480
482
481 def merge(repo, node, force=None, remind=True):
483 def merge(repo, node, force=None, remind=True):
482 """Branch merge with node, resolving changes. Return true if any
484 """Branch merge with node, resolving changes. Return true if any
483 unresolved conflicts."""
485 unresolved conflicts."""
484 stats = mergemod.update(repo, node, True, force, False)
486 stats = mergemod.update(repo, node, True, force, False)
485 _showstats(repo, stats)
487 _showstats(repo, stats)
486 if stats[3]:
488 if stats[3]:
487 repo.ui.status(_("use 'hg resolve' to retry unresolved file merges "
489 repo.ui.status(_("use 'hg resolve' to retry unresolved file merges "
488 "or 'hg update -C .' to abandon\n"))
490 "or 'hg update -C .' to abandon\n"))
489 elif remind:
491 elif remind:
490 repo.ui.status(_("(branch merge, don't forget to commit)\n"))
492 repo.ui.status(_("(branch merge, don't forget to commit)\n"))
491 return stats[3] > 0
493 return stats[3] > 0
492
494
493 def _incoming(displaychlist, subreporecurse, ui, repo, source,
495 def _incoming(displaychlist, subreporecurse, ui, repo, source,
494 opts, buffered=False):
496 opts, buffered=False):
495 """
497 """
496 Helper for incoming / gincoming.
498 Helper for incoming / gincoming.
497 displaychlist gets called with
499 displaychlist gets called with
498 (remoterepo, incomingchangesetlist, displayer) parameters,
500 (remoterepo, incomingchangesetlist, displayer) parameters,
499 and is supposed to contain only code that can't be unified.
501 and is supposed to contain only code that can't be unified.
500 """
502 """
501 source, branches = parseurl(ui.expandpath(source), opts.get('branch'))
503 source, branches = parseurl(ui.expandpath(source), opts.get('branch'))
502 other = peer(repo, opts, source)
504 other = peer(repo, opts, source)
503 ui.status(_('comparing with %s\n') % util.hidepassword(source))
505 ui.status(_('comparing with %s\n') % util.hidepassword(source))
504 revs, checkout = addbranchrevs(repo, other, branches, opts.get('rev'))
506 revs, checkout = addbranchrevs(repo, other, branches, opts.get('rev'))
505
507
506 if revs:
508 if revs:
507 revs = [other.lookup(rev) for rev in revs]
509 revs = [other.lookup(rev) for rev in revs]
508 other, chlist, cleanupfn = bundlerepo.getremotechanges(ui, repo, other,
510 other, chlist, cleanupfn = bundlerepo.getremotechanges(ui, repo, other,
509 revs, opts["bundle"], opts["force"])
511 revs, opts["bundle"], opts["force"])
510 try:
512 try:
511 if not chlist:
513 if not chlist:
512 ui.status(_("no changes found\n"))
514 ui.status(_("no changes found\n"))
513 return subreporecurse()
515 return subreporecurse()
514
516
515 displayer = cmdutil.show_changeset(ui, other, opts, buffered)
517 displayer = cmdutil.show_changeset(ui, other, opts, buffered)
516 displaychlist(other, chlist, displayer)
518 displaychlist(other, chlist, displayer)
517 displayer.close()
519 displayer.close()
518 finally:
520 finally:
519 cleanupfn()
521 cleanupfn()
520 subreporecurse()
522 subreporecurse()
521 return 0 # exit code is zero since we found incoming changes
523 return 0 # exit code is zero since we found incoming changes
522
524
523 def incoming(ui, repo, source, opts):
525 def incoming(ui, repo, source, opts):
524 def subreporecurse():
526 def subreporecurse():
525 ret = 1
527 ret = 1
526 if opts.get('subrepos'):
528 if opts.get('subrepos'):
527 ctx = repo[None]
529 ctx = repo[None]
528 for subpath in sorted(ctx.substate):
530 for subpath in sorted(ctx.substate):
529 sub = ctx.sub(subpath)
531 sub = ctx.sub(subpath)
530 ret = min(ret, sub.incoming(ui, source, opts))
532 ret = min(ret, sub.incoming(ui, source, opts))
531 return ret
533 return ret
532
534
533 def display(other, chlist, displayer):
535 def display(other, chlist, displayer):
534 limit = cmdutil.loglimit(opts)
536 limit = cmdutil.loglimit(opts)
535 if opts.get('newest_first'):
537 if opts.get('newest_first'):
536 chlist.reverse()
538 chlist.reverse()
537 count = 0
539 count = 0
538 for n in chlist:
540 for n in chlist:
539 if limit is not None and count >= limit:
541 if limit is not None and count >= limit:
540 break
542 break
541 parents = [p for p in other.changelog.parents(n) if p != nullid]
543 parents = [p for p in other.changelog.parents(n) if p != nullid]
542 if opts.get('no_merges') and len(parents) == 2:
544 if opts.get('no_merges') and len(parents) == 2:
543 continue
545 continue
544 count += 1
546 count += 1
545 displayer.show(other[n])
547 displayer.show(other[n])
546 return _incoming(display, subreporecurse, ui, repo, source, opts)
548 return _incoming(display, subreporecurse, ui, repo, source, opts)
547
549
548 def _outgoing(ui, repo, dest, opts):
550 def _outgoing(ui, repo, dest, opts):
549 dest = ui.expandpath(dest or 'default-push', dest or 'default')
551 dest = ui.expandpath(dest or 'default-push', dest or 'default')
550 dest, branches = parseurl(dest, opts.get('branch'))
552 dest, branches = parseurl(dest, opts.get('branch'))
551 ui.status(_('comparing with %s\n') % util.hidepassword(dest))
553 ui.status(_('comparing with %s\n') % util.hidepassword(dest))
552 revs, checkout = addbranchrevs(repo, repo, branches, opts.get('rev'))
554 revs, checkout = addbranchrevs(repo, repo, branches, opts.get('rev'))
553 if revs:
555 if revs:
554 revs = [repo.lookup(rev) for rev in scmutil.revrange(repo, revs)]
556 revs = [repo.lookup(rev) for rev in scmutil.revrange(repo, revs)]
555
557
556 other = peer(repo, opts, dest)
558 other = peer(repo, opts, dest)
557 outgoing = discovery.findcommonoutgoing(repo.unfiltered(), other, revs,
559 outgoing = discovery.findcommonoutgoing(repo.unfiltered(), other, revs,
558 force=opts.get('force'))
560 force=opts.get('force'))
559 o = outgoing.missing
561 o = outgoing.missing
560 if not o:
562 if not o:
561 scmutil.nochangesfound(repo.ui, repo, outgoing.excluded)
563 scmutil.nochangesfound(repo.ui, repo, outgoing.excluded)
562 return None
564 return None
563 return o
565 return o
564
566
565 def outgoing(ui, repo, dest, opts):
567 def outgoing(ui, repo, dest, opts):
566 def recurse():
568 def recurse():
567 ret = 1
569 ret = 1
568 if opts.get('subrepos'):
570 if opts.get('subrepos'):
569 ctx = repo[None]
571 ctx = repo[None]
570 for subpath in sorted(ctx.substate):
572 for subpath in sorted(ctx.substate):
571 sub = ctx.sub(subpath)
573 sub = ctx.sub(subpath)
572 ret = min(ret, sub.outgoing(ui, dest, opts))
574 ret = min(ret, sub.outgoing(ui, dest, opts))
573 return ret
575 return ret
574
576
575 limit = cmdutil.loglimit(opts)
577 limit = cmdutil.loglimit(opts)
576 o = _outgoing(ui, repo, dest, opts)
578 o = _outgoing(ui, repo, dest, opts)
577 if o is None:
579 if o is None:
578 return recurse()
580 return recurse()
579
581
580 if opts.get('newest_first'):
582 if opts.get('newest_first'):
581 o.reverse()
583 o.reverse()
582 displayer = cmdutil.show_changeset(ui, repo, opts)
584 displayer = cmdutil.show_changeset(ui, repo, opts)
583 count = 0
585 count = 0
584 for n in o:
586 for n in o:
585 if limit is not None and count >= limit:
587 if limit is not None and count >= limit:
586 break
588 break
587 parents = [p for p in repo.changelog.parents(n) if p != nullid]
589 parents = [p for p in repo.changelog.parents(n) if p != nullid]
588 if opts.get('no_merges') and len(parents) == 2:
590 if opts.get('no_merges') and len(parents) == 2:
589 continue
591 continue
590 count += 1
592 count += 1
591 displayer.show(repo[n])
593 displayer.show(repo[n])
592 displayer.close()
594 displayer.close()
593 recurse()
595 recurse()
594 return 0 # exit code is zero since we found outgoing changes
596 return 0 # exit code is zero since we found outgoing changes
595
597
596 def revert(repo, node, choose):
598 def revert(repo, node, choose):
597 """revert changes to revision in node without updating dirstate"""
599 """revert changes to revision in node without updating dirstate"""
598 return mergemod.update(repo, node, False, True, choose)[3] > 0
600 return mergemod.update(repo, node, False, True, choose)[3] > 0
599
601
600 def verify(repo):
602 def verify(repo):
601 """verify the consistency of a repository"""
603 """verify the consistency of a repository"""
602 return verifymod.verify(repo)
604 return verifymod.verify(repo)
603
605
604 def remoteui(src, opts):
606 def remoteui(src, opts):
605 'build a remote ui from ui or repo and opts'
607 'build a remote ui from ui or repo and opts'
606 if util.safehasattr(src, 'baseui'): # looks like a repository
608 if util.safehasattr(src, 'baseui'): # looks like a repository
607 dst = src.baseui.copy() # drop repo-specific config
609 dst = src.baseui.copy() # drop repo-specific config
608 src = src.ui # copy target options from repo
610 src = src.ui # copy target options from repo
609 else: # assume it's a global ui object
611 else: # assume it's a global ui object
610 dst = src.copy() # keep all global options
612 dst = src.copy() # keep all global options
611
613
612 # copy ssh-specific options
614 # copy ssh-specific options
613 for o in 'ssh', 'remotecmd':
615 for o in 'ssh', 'remotecmd':
614 v = opts.get(o) or src.config('ui', o)
616 v = opts.get(o) or src.config('ui', o)
615 if v:
617 if v:
616 dst.setconfig("ui", o, v)
618 dst.setconfig("ui", o, v)
617
619
618 # copy bundle-specific options
620 # copy bundle-specific options
619 r = src.config('bundle', 'mainreporoot')
621 r = src.config('bundle', 'mainreporoot')
620 if r:
622 if r:
621 dst.setconfig('bundle', 'mainreporoot', r)
623 dst.setconfig('bundle', 'mainreporoot', r)
622
624
623 # copy selected local settings to the remote ui
625 # copy selected local settings to the remote ui
624 for sect in ('auth', 'hostfingerprints', 'http_proxy'):
626 for sect in ('auth', 'hostfingerprints', 'http_proxy'):
625 for key, val in src.configitems(sect):
627 for key, val in src.configitems(sect):
626 dst.setconfig(sect, key, val)
628 dst.setconfig(sect, key, val)
627 v = src.config('web', 'cacerts')
629 v = src.config('web', 'cacerts')
628 if v:
630 if v:
629 dst.setconfig('web', 'cacerts', util.expandpath(v))
631 dst.setconfig('web', 'cacerts', util.expandpath(v))
630
632
631 return dst
633 return dst
@@ -1,623 +1,637 b''
1 Prepare repo a:
1 Prepare repo a:
2
2
3 $ hg init a
3 $ hg init a
4 $ cd a
4 $ cd a
5 $ echo a > a
5 $ echo a > a
6 $ hg add a
6 $ hg add a
7 $ hg commit -m test
7 $ hg commit -m test
8 $ echo first line > b
8 $ echo first line > b
9 $ hg add b
9 $ hg add b
10
10
11 Create a non-inlined filelog:
11 Create a non-inlined filelog:
12
12
13 $ python -c 'file("data1", "wb").write("".join("%s\n" % x for x in range(10000)))'
13 $ python -c 'file("data1", "wb").write("".join("%s\n" % x for x in range(10000)))'
14 $ for j in 0 1 2 3 4 5 6 7 8 9; do
14 $ for j in 0 1 2 3 4 5 6 7 8 9; do
15 > cat data1 >> b
15 > cat data1 >> b
16 > hg commit -m test
16 > hg commit -m test
17 > done
17 > done
18
18
19 List files in store/data (should show a 'b.d'):
19 List files in store/data (should show a 'b.d'):
20
20
21 $ for i in .hg/store/data/*; do
21 $ for i in .hg/store/data/*; do
22 > echo $i
22 > echo $i
23 > done
23 > done
24 .hg/store/data/a.i
24 .hg/store/data/a.i
25 .hg/store/data/b.d
25 .hg/store/data/b.d
26 .hg/store/data/b.i
26 .hg/store/data/b.i
27
27
28 Default operation:
28 Default operation:
29
29
30 $ hg clone . ../b
30 $ hg clone . ../b
31 updating to branch default
31 updating to branch default
32 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
32 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
33 $ cd ../b
33 $ cd ../b
34 $ cat a
34 $ cat a
35 a
35 a
36 $ hg verify
36 $ hg verify
37 checking changesets
37 checking changesets
38 checking manifests
38 checking manifests
39 crosschecking files in changesets and manifests
39 crosschecking files in changesets and manifests
40 checking files
40 checking files
41 2 files, 11 changesets, 11 total revisions
41 2 files, 11 changesets, 11 total revisions
42
42
43 Invalid dest '' must abort:
43 Invalid dest '' must abort:
44
44
45 $ hg clone . ''
45 $ hg clone . ''
46 abort: empty destination path is not valid
46 abort: empty destination path is not valid
47 [255]
47 [255]
48
48
49 No update, with debug option:
49 No update, with debug option:
50
50
51 #if hardlink
51 #if hardlink
52 $ hg --debug clone -U . ../c
52 $ hg --debug clone -U . ../c
53 linked 8 files
53 linked 8 files
54 listing keys for "bookmarks"
54 listing keys for "bookmarks"
55 #else
55 #else
56 $ hg --debug clone -U . ../c
56 $ hg --debug clone -U . ../c
57 copied 8 files
57 copied 8 files
58 listing keys for "bookmarks"
58 listing keys for "bookmarks"
59 #endif
59 #endif
60 $ cd ../c
60 $ cd ../c
61 $ cat a 2>/dev/null || echo "a not present"
61 $ cat a 2>/dev/null || echo "a not present"
62 a not present
62 a not present
63 $ hg verify
63 $ hg verify
64 checking changesets
64 checking changesets
65 checking manifests
65 checking manifests
66 crosschecking files in changesets and manifests
66 crosschecking files in changesets and manifests
67 checking files
67 checking files
68 2 files, 11 changesets, 11 total revisions
68 2 files, 11 changesets, 11 total revisions
69
69
70 Default destination:
70 Default destination:
71
71
72 $ mkdir ../d
72 $ mkdir ../d
73 $ cd ../d
73 $ cd ../d
74 $ hg clone ../a
74 $ hg clone ../a
75 destination directory: a
75 destination directory: a
76 updating to branch default
76 updating to branch default
77 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
77 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
78 $ cd a
78 $ cd a
79 $ hg cat a
79 $ hg cat a
80 a
80 a
81 $ cd ../..
81 $ cd ../..
82
82
83 Check that we drop the 'file:' from the path before writing the .hgrc:
83 Check that we drop the 'file:' from the path before writing the .hgrc:
84
84
85 $ hg clone file:a e
85 $ hg clone file:a e
86 updating to branch default
86 updating to branch default
87 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
87 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
88 $ grep 'file:' e/.hg/hgrc
88 $ grep 'file:' e/.hg/hgrc
89 [1]
89 [1]
90
90
91 Check that path aliases are expanded:
91 Check that path aliases are expanded:
92
92
93 $ hg clone -q -U --config 'paths.foobar=a#0' foobar f
93 $ hg clone -q -U --config 'paths.foobar=a#0' foobar f
94 $ hg -R f showconfig paths.default
94 $ hg -R f showconfig paths.default
95 $TESTTMP/a#0 (glob)
95 $TESTTMP/a#0 (glob)
96
96
97 Use --pull:
97 Use --pull:
98
98
99 $ hg clone --pull a g
99 $ hg clone --pull a g
100 requesting all changes
100 requesting all changes
101 adding changesets
101 adding changesets
102 adding manifests
102 adding manifests
103 adding file changes
103 adding file changes
104 added 11 changesets with 11 changes to 2 files
104 added 11 changesets with 11 changes to 2 files
105 updating to branch default
105 updating to branch default
106 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
106 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
107 $ hg -R g verify
107 $ hg -R g verify
108 checking changesets
108 checking changesets
109 checking manifests
109 checking manifests
110 crosschecking files in changesets and manifests
110 crosschecking files in changesets and manifests
111 checking files
111 checking files
112 2 files, 11 changesets, 11 total revisions
112 2 files, 11 changesets, 11 total revisions
113
113
114 Invalid dest '' with --pull must abort (issue2528):
114 Invalid dest '' with --pull must abort (issue2528):
115
115
116 $ hg clone --pull a ''
116 $ hg clone --pull a ''
117 abort: empty destination path is not valid
117 abort: empty destination path is not valid
118 [255]
118 [255]
119
119
120 Clone to '.':
120 Clone to '.':
121
121
122 $ mkdir h
122 $ mkdir h
123 $ cd h
123 $ cd h
124 $ hg clone ../a .
124 $ hg clone ../a .
125 updating to branch default
125 updating to branch default
126 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
126 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
127 $ cd ..
127 $ cd ..
128
128
129
129
130 *** Tests for option -u ***
130 *** Tests for option -u ***
131
131
132 Adding some more history to repo a:
132 Adding some more history to repo a:
133
133
134 $ cd a
134 $ cd a
135 $ hg tag ref1
135 $ hg tag ref1
136 $ echo the quick brown fox >a
136 $ echo the quick brown fox >a
137 $ hg ci -m "hacked default"
137 $ hg ci -m "hacked default"
138 $ hg up ref1
138 $ hg up ref1
139 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
139 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
140 $ hg branch stable
140 $ hg branch stable
141 marked working directory as branch stable
141 marked working directory as branch stable
142 (branches are permanent and global, did you want a bookmark?)
142 (branches are permanent and global, did you want a bookmark?)
143 $ echo some text >a
143 $ echo some text >a
144 $ hg ci -m "starting branch stable"
144 $ hg ci -m "starting branch stable"
145 $ hg tag ref2
145 $ hg tag ref2
146 $ echo some more text >a
146 $ echo some more text >a
147 $ hg ci -m "another change for branch stable"
147 $ hg ci -m "another change for branch stable"
148 $ hg up ref2
148 $ hg up ref2
149 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
149 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
150 $ hg parents
150 $ hg parents
151 changeset: 13:e8ece76546a6
151 changeset: 13:e8ece76546a6
152 branch: stable
152 branch: stable
153 tag: ref2
153 tag: ref2
154 parent: 10:a7949464abda
154 parent: 10:a7949464abda
155 user: test
155 user: test
156 date: Thu Jan 01 00:00:00 1970 +0000
156 date: Thu Jan 01 00:00:00 1970 +0000
157 summary: starting branch stable
157 summary: starting branch stable
158
158
159
159
160 Repo a has two heads:
160 Repo a has two heads:
161
161
162 $ hg heads
162 $ hg heads
163 changeset: 15:0aae7cf88f0d
163 changeset: 15:0aae7cf88f0d
164 branch: stable
164 branch: stable
165 tag: tip
165 tag: tip
166 user: test
166 user: test
167 date: Thu Jan 01 00:00:00 1970 +0000
167 date: Thu Jan 01 00:00:00 1970 +0000
168 summary: another change for branch stable
168 summary: another change for branch stable
169
169
170 changeset: 12:f21241060d6a
170 changeset: 12:f21241060d6a
171 user: test
171 user: test
172 date: Thu Jan 01 00:00:00 1970 +0000
172 date: Thu Jan 01 00:00:00 1970 +0000
173 summary: hacked default
173 summary: hacked default
174
174
175
175
176 $ cd ..
176 $ cd ..
177
177
178
178
179 Testing --noupdate with --updaterev (must abort):
179 Testing --noupdate with --updaterev (must abort):
180
180
181 $ hg clone --noupdate --updaterev 1 a ua
181 $ hg clone --noupdate --updaterev 1 a ua
182 abort: cannot specify both --noupdate and --updaterev
182 abort: cannot specify both --noupdate and --updaterev
183 [255]
183 [255]
184
184
185
185
186 Testing clone -u:
186 Testing clone -u:
187
187
188 $ hg clone -u . a ua
188 $ hg clone -u . a ua
189 updating to branch stable
189 updating to branch stable
190 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
190 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
191
191
192 Repo ua has both heads:
192 Repo ua has both heads:
193
193
194 $ hg -R ua heads
194 $ hg -R ua heads
195 changeset: 15:0aae7cf88f0d
195 changeset: 15:0aae7cf88f0d
196 branch: stable
196 branch: stable
197 tag: tip
197 tag: tip
198 user: test
198 user: test
199 date: Thu Jan 01 00:00:00 1970 +0000
199 date: Thu Jan 01 00:00:00 1970 +0000
200 summary: another change for branch stable
200 summary: another change for branch stable
201
201
202 changeset: 12:f21241060d6a
202 changeset: 12:f21241060d6a
203 user: test
203 user: test
204 date: Thu Jan 01 00:00:00 1970 +0000
204 date: Thu Jan 01 00:00:00 1970 +0000
205 summary: hacked default
205 summary: hacked default
206
206
207
207
208 Same revision checked out in repo a and ua:
208 Same revision checked out in repo a and ua:
209
209
210 $ hg -R a parents --template "{node|short}\n"
210 $ hg -R a parents --template "{node|short}\n"
211 e8ece76546a6
211 e8ece76546a6
212 $ hg -R ua parents --template "{node|short}\n"
212 $ hg -R ua parents --template "{node|short}\n"
213 e8ece76546a6
213 e8ece76546a6
214
214
215 $ rm -r ua
215 $ rm -r ua
216
216
217
217
218 Testing clone --pull -u:
218 Testing clone --pull -u:
219
219
220 $ hg clone --pull -u . a ua
220 $ hg clone --pull -u . a ua
221 requesting all changes
221 requesting all changes
222 adding changesets
222 adding changesets
223 adding manifests
223 adding manifests
224 adding file changes
224 adding file changes
225 added 16 changesets with 16 changes to 3 files (+1 heads)
225 added 16 changesets with 16 changes to 3 files (+1 heads)
226 updating to branch stable
226 updating to branch stable
227 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
227 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
228
228
229 Repo ua has both heads:
229 Repo ua has both heads:
230
230
231 $ hg -R ua heads
231 $ hg -R ua heads
232 changeset: 15:0aae7cf88f0d
232 changeset: 15:0aae7cf88f0d
233 branch: stable
233 branch: stable
234 tag: tip
234 tag: tip
235 user: test
235 user: test
236 date: Thu Jan 01 00:00:00 1970 +0000
236 date: Thu Jan 01 00:00:00 1970 +0000
237 summary: another change for branch stable
237 summary: another change for branch stable
238
238
239 changeset: 12:f21241060d6a
239 changeset: 12:f21241060d6a
240 user: test
240 user: test
241 date: Thu Jan 01 00:00:00 1970 +0000
241 date: Thu Jan 01 00:00:00 1970 +0000
242 summary: hacked default
242 summary: hacked default
243
243
244
244
245 Same revision checked out in repo a and ua:
245 Same revision checked out in repo a and ua:
246
246
247 $ hg -R a parents --template "{node|short}\n"
247 $ hg -R a parents --template "{node|short}\n"
248 e8ece76546a6
248 e8ece76546a6
249 $ hg -R ua parents --template "{node|short}\n"
249 $ hg -R ua parents --template "{node|short}\n"
250 e8ece76546a6
250 e8ece76546a6
251
251
252 $ rm -r ua
252 $ rm -r ua
253
253
254
254
255 Testing clone -u <branch>:
255 Testing clone -u <branch>:
256
256
257 $ hg clone -u stable a ua
257 $ hg clone -u stable a ua
258 updating to branch stable
258 updating to branch stable
259 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
259 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
260
260
261 Repo ua has both heads:
261 Repo ua has both heads:
262
262
263 $ hg -R ua heads
263 $ hg -R ua heads
264 changeset: 15:0aae7cf88f0d
264 changeset: 15:0aae7cf88f0d
265 branch: stable
265 branch: stable
266 tag: tip
266 tag: tip
267 user: test
267 user: test
268 date: Thu Jan 01 00:00:00 1970 +0000
268 date: Thu Jan 01 00:00:00 1970 +0000
269 summary: another change for branch stable
269 summary: another change for branch stable
270
270
271 changeset: 12:f21241060d6a
271 changeset: 12:f21241060d6a
272 user: test
272 user: test
273 date: Thu Jan 01 00:00:00 1970 +0000
273 date: Thu Jan 01 00:00:00 1970 +0000
274 summary: hacked default
274 summary: hacked default
275
275
276
276
277 Branch 'stable' is checked out:
277 Branch 'stable' is checked out:
278
278
279 $ hg -R ua parents
279 $ hg -R ua parents
280 changeset: 15:0aae7cf88f0d
280 changeset: 15:0aae7cf88f0d
281 branch: stable
281 branch: stable
282 tag: tip
282 tag: tip
283 user: test
283 user: test
284 date: Thu Jan 01 00:00:00 1970 +0000
284 date: Thu Jan 01 00:00:00 1970 +0000
285 summary: another change for branch stable
285 summary: another change for branch stable
286
286
287
287
288 $ rm -r ua
288 $ rm -r ua
289
289
290
290
291 Testing default checkout:
291 Testing default checkout:
292
292
293 $ hg clone a ua
293 $ hg clone a ua
294 updating to branch default
294 updating to branch default
295 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
295 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
296
296
297 Repo ua has both heads:
297 Repo ua has both heads:
298
298
299 $ hg -R ua heads
299 $ hg -R ua heads
300 changeset: 15:0aae7cf88f0d
300 changeset: 15:0aae7cf88f0d
301 branch: stable
301 branch: stable
302 tag: tip
302 tag: tip
303 user: test
303 user: test
304 date: Thu Jan 01 00:00:00 1970 +0000
304 date: Thu Jan 01 00:00:00 1970 +0000
305 summary: another change for branch stable
305 summary: another change for branch stable
306
306
307 changeset: 12:f21241060d6a
307 changeset: 12:f21241060d6a
308 user: test
308 user: test
309 date: Thu Jan 01 00:00:00 1970 +0000
309 date: Thu Jan 01 00:00:00 1970 +0000
310 summary: hacked default
310 summary: hacked default
311
311
312
312
313 Branch 'default' is checked out:
313 Branch 'default' is checked out:
314
314
315 $ hg -R ua parents
315 $ hg -R ua parents
316 changeset: 12:f21241060d6a
316 changeset: 12:f21241060d6a
317 user: test
317 user: test
318 date: Thu Jan 01 00:00:00 1970 +0000
318 date: Thu Jan 01 00:00:00 1970 +0000
319 summary: hacked default
319 summary: hacked default
320
320
321 Test clone with a branch named "@" (issue3677)
321 Test clone with a branch named "@" (issue3677)
322
322
323 $ hg -R ua branch @
323 $ hg -R ua branch @
324 marked working directory as branch @
324 marked working directory as branch @
325 (branches are permanent and global, did you want a bookmark?)
325 (branches are permanent and global, did you want a bookmark?)
326 $ hg -R ua commit -m 'created branch @'
326 $ hg -R ua commit -m 'created branch @'
327 $ hg clone ua atbranch
327 $ hg clone ua atbranch
328 updating to branch default
328 updating to branch default
329 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
329 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
330 $ hg -R atbranch heads
330 $ hg -R atbranch heads
331 changeset: 16:798b6d97153e
331 changeset: 16:798b6d97153e
332 branch: @
332 branch: @
333 tag: tip
333 tag: tip
334 parent: 12:f21241060d6a
334 parent: 12:f21241060d6a
335 user: test
335 user: test
336 date: Thu Jan 01 00:00:00 1970 +0000
336 date: Thu Jan 01 00:00:00 1970 +0000
337 summary: created branch @
337 summary: created branch @
338
338
339 changeset: 15:0aae7cf88f0d
339 changeset: 15:0aae7cf88f0d
340 branch: stable
340 branch: stable
341 user: test
341 user: test
342 date: Thu Jan 01 00:00:00 1970 +0000
342 date: Thu Jan 01 00:00:00 1970 +0000
343 summary: another change for branch stable
343 summary: another change for branch stable
344
344
345 changeset: 12:f21241060d6a
345 changeset: 12:f21241060d6a
346 user: test
346 user: test
347 date: Thu Jan 01 00:00:00 1970 +0000
347 date: Thu Jan 01 00:00:00 1970 +0000
348 summary: hacked default
348 summary: hacked default
349
349
350 $ hg -R atbranch parents
350 $ hg -R atbranch parents
351 changeset: 12:f21241060d6a
351 changeset: 12:f21241060d6a
352 user: test
352 user: test
353 date: Thu Jan 01 00:00:00 1970 +0000
353 date: Thu Jan 01 00:00:00 1970 +0000
354 summary: hacked default
354 summary: hacked default
355
355
356
356
357 $ rm -r ua atbranch
357 $ rm -r ua atbranch
358
358
359
359
360 Testing #<branch>:
360 Testing #<branch>:
361
361
362 $ hg clone -u . a#stable ua
362 $ hg clone -u . a#stable ua
363 adding changesets
363 adding changesets
364 adding manifests
364 adding manifests
365 adding file changes
365 adding file changes
366 added 14 changesets with 14 changes to 3 files
366 added 14 changesets with 14 changes to 3 files
367 updating to branch stable
367 updating to branch stable
368 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
368 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
369
369
370 Repo ua has branch 'stable' and 'default' (was changed in fd511e9eeea6):
370 Repo ua has branch 'stable' and 'default' (was changed in fd511e9eeea6):
371
371
372 $ hg -R ua heads
372 $ hg -R ua heads
373 changeset: 13:0aae7cf88f0d
373 changeset: 13:0aae7cf88f0d
374 branch: stable
374 branch: stable
375 tag: tip
375 tag: tip
376 user: test
376 user: test
377 date: Thu Jan 01 00:00:00 1970 +0000
377 date: Thu Jan 01 00:00:00 1970 +0000
378 summary: another change for branch stable
378 summary: another change for branch stable
379
379
380 changeset: 10:a7949464abda
380 changeset: 10:a7949464abda
381 user: test
381 user: test
382 date: Thu Jan 01 00:00:00 1970 +0000
382 date: Thu Jan 01 00:00:00 1970 +0000
383 summary: test
383 summary: test
384
384
385
385
386 Same revision checked out in repo a and ua:
386 Same revision checked out in repo a and ua:
387
387
388 $ hg -R a parents --template "{node|short}\n"
388 $ hg -R a parents --template "{node|short}\n"
389 e8ece76546a6
389 e8ece76546a6
390 $ hg -R ua parents --template "{node|short}\n"
390 $ hg -R ua parents --template "{node|short}\n"
391 e8ece76546a6
391 e8ece76546a6
392
392
393 $ rm -r ua
393 $ rm -r ua
394
394
395
395
396 Testing -u -r <branch>:
396 Testing -u -r <branch>:
397
397
398 $ hg clone -u . -r stable a ua
398 $ hg clone -u . -r stable a ua
399 adding changesets
399 adding changesets
400 adding manifests
400 adding manifests
401 adding file changes
401 adding file changes
402 added 14 changesets with 14 changes to 3 files
402 added 14 changesets with 14 changes to 3 files
403 updating to branch stable
403 updating to branch stable
404 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
404 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
405
405
406 Repo ua has branch 'stable' and 'default' (was changed in fd511e9eeea6):
406 Repo ua has branch 'stable' and 'default' (was changed in fd511e9eeea6):
407
407
408 $ hg -R ua heads
408 $ hg -R ua heads
409 changeset: 13:0aae7cf88f0d
409 changeset: 13:0aae7cf88f0d
410 branch: stable
410 branch: stable
411 tag: tip
411 tag: tip
412 user: test
412 user: test
413 date: Thu Jan 01 00:00:00 1970 +0000
413 date: Thu Jan 01 00:00:00 1970 +0000
414 summary: another change for branch stable
414 summary: another change for branch stable
415
415
416 changeset: 10:a7949464abda
416 changeset: 10:a7949464abda
417 user: test
417 user: test
418 date: Thu Jan 01 00:00:00 1970 +0000
418 date: Thu Jan 01 00:00:00 1970 +0000
419 summary: test
419 summary: test
420
420
421
421
422 Same revision checked out in repo a and ua:
422 Same revision checked out in repo a and ua:
423
423
424 $ hg -R a parents --template "{node|short}\n"
424 $ hg -R a parents --template "{node|short}\n"
425 e8ece76546a6
425 e8ece76546a6
426 $ hg -R ua parents --template "{node|short}\n"
426 $ hg -R ua parents --template "{node|short}\n"
427 e8ece76546a6
427 e8ece76546a6
428
428
429 $ rm -r ua
429 $ rm -r ua
430
430
431
431
432 Testing -r <branch>:
432 Testing -r <branch>:
433
433
434 $ hg clone -r stable a ua
434 $ hg clone -r stable a ua
435 adding changesets
435 adding changesets
436 adding manifests
436 adding manifests
437 adding file changes
437 adding file changes
438 added 14 changesets with 14 changes to 3 files
438 added 14 changesets with 14 changes to 3 files
439 updating to branch stable
439 updating to branch stable
440 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
440 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
441
441
442 Repo ua has branch 'stable' and 'default' (was changed in fd511e9eeea6):
442 Repo ua has branch 'stable' and 'default' (was changed in fd511e9eeea6):
443
443
444 $ hg -R ua heads
444 $ hg -R ua heads
445 changeset: 13:0aae7cf88f0d
445 changeset: 13:0aae7cf88f0d
446 branch: stable
446 branch: stable
447 tag: tip
447 tag: tip
448 user: test
448 user: test
449 date: Thu Jan 01 00:00:00 1970 +0000
449 date: Thu Jan 01 00:00:00 1970 +0000
450 summary: another change for branch stable
450 summary: another change for branch stable
451
451
452 changeset: 10:a7949464abda
452 changeset: 10:a7949464abda
453 user: test
453 user: test
454 date: Thu Jan 01 00:00:00 1970 +0000
454 date: Thu Jan 01 00:00:00 1970 +0000
455 summary: test
455 summary: test
456
456
457
457
458 Branch 'stable' is checked out:
458 Branch 'stable' is checked out:
459
459
460 $ hg -R ua parents
460 $ hg -R ua parents
461 changeset: 13:0aae7cf88f0d
461 changeset: 13:0aae7cf88f0d
462 branch: stable
462 branch: stable
463 tag: tip
463 tag: tip
464 user: test
464 user: test
465 date: Thu Jan 01 00:00:00 1970 +0000
465 date: Thu Jan 01 00:00:00 1970 +0000
466 summary: another change for branch stable
466 summary: another change for branch stable
467
467
468
468
469 $ rm -r ua
469 $ rm -r ua
470
470
471
471
472 Issue2267: Error in 1.6 hg.py: TypeError: 'NoneType' object is not
472 Issue2267: Error in 1.6 hg.py: TypeError: 'NoneType' object is not
473 iterable in addbranchrevs()
473 iterable in addbranchrevs()
474
474
475 $ cat <<EOF > simpleclone.py
475 $ cat <<EOF > simpleclone.py
476 > from mercurial import ui, hg
476 > from mercurial import ui, hg
477 > myui = ui.ui()
477 > myui = ui.ui()
478 > repo = hg.repository(myui, 'a')
478 > repo = hg.repository(myui, 'a')
479 > hg.clone(myui, {}, repo, dest="ua")
479 > hg.clone(myui, {}, repo, dest="ua")
480 > EOF
480 > EOF
481
481
482 $ python simpleclone.py
482 $ python simpleclone.py
483 updating to branch default
483 updating to branch default
484 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
484 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
485
485
486 $ rm -r ua
486 $ rm -r ua
487
487
488 $ cat <<EOF > branchclone.py
488 $ cat <<EOF > branchclone.py
489 > from mercurial import ui, hg, extensions
489 > from mercurial import ui, hg, extensions
490 > myui = ui.ui()
490 > myui = ui.ui()
491 > extensions.loadall(myui)
491 > extensions.loadall(myui)
492 > repo = hg.repository(myui, 'a')
492 > repo = hg.repository(myui, 'a')
493 > hg.clone(myui, {}, repo, dest="ua", branch=["stable",])
493 > hg.clone(myui, {}, repo, dest="ua", branch=["stable",])
494 > EOF
494 > EOF
495
495
496 $ python branchclone.py
496 $ python branchclone.py
497 adding changesets
497 adding changesets
498 adding manifests
498 adding manifests
499 adding file changes
499 adding file changes
500 added 14 changesets with 14 changes to 3 files
500 added 14 changesets with 14 changes to 3 files
501 updating to branch stable
501 updating to branch stable
502 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
502 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
503 $ rm -r ua
503 $ rm -r ua
504
504
505
505
506 Test clone with special '@' bookmark:
506 Test clone with special '@' bookmark:
507 $ cd a
507 $ cd a
508 $ hg bookmark -r a7949464abda @ # branch point of stable from default
508 $ hg bookmark -r a7949464abda @ # branch point of stable from default
509 $ hg clone . ../i
509 $ hg clone . ../i
510 updating to bookmark @
510 updating to bookmark @
511 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
511 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
512 $ hg id -i ../i
512 $ hg id -i ../i
513 a7949464abda
513 a7949464abda
514 $ rm -r ../i
514 $ rm -r ../i
515
515
516 $ hg bookmark -f -r stable @
516 $ hg bookmark -f -r stable @
517 $ hg bookmarks
517 $ hg bookmarks
518 @ 15:0aae7cf88f0d
518 @ 15:0aae7cf88f0d
519 $ hg clone . ../i
519 $ hg clone . ../i
520 updating to bookmark @ on branch stable
520 updating to bookmark @ on branch stable
521 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
521 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
522 $ hg id -i ../i
522 $ hg id -i ../i
523 0aae7cf88f0d
523 0aae7cf88f0d
524 $ cd "$TESTTMP"
524 $ cd "$TESTTMP"
525
525
526
526
527 Testing failures:
527 Testing failures:
528
528
529 $ mkdir fail
529 $ mkdir fail
530 $ cd fail
530 $ cd fail
531
531
532 No local source
532 No local source
533
533
534 $ hg clone a b
534 $ hg clone a b
535 abort: repository a not found!
535 abort: repository a not found!
536 [255]
536 [255]
537
537
538 No remote source
538 No remote source
539
539
540 $ hg clone http://127.0.0.1:3121/a b
540 $ hg clone http://127.0.0.1:3121/a b
541 abort: error: *refused* (glob)
541 abort: error: *refused* (glob)
542 [255]
542 [255]
543 $ rm -rf b # work around bug with http clone
543 $ rm -rf b # work around bug with http clone
544
544
545
545
546 #if unix-permissions no-root
546 #if unix-permissions no-root
547
547
548 Inaccessible source
548 Inaccessible source
549
549
550 $ mkdir a
550 $ mkdir a
551 $ chmod 000 a
551 $ chmod 000 a
552 $ hg clone a b
552 $ hg clone a b
553 abort: repository a not found!
553 abort: repository a not found!
554 [255]
554 [255]
555
555
556 Inaccessible destination
556 Inaccessible destination
557
557
558 $ hg init b
558 $ hg init b
559 $ cd b
559 $ cd b
560 $ hg clone . ../a
560 $ hg clone . ../a
561 abort: Permission denied: '../a'
561 abort: Permission denied: '../a'
562 [255]
562 [255]
563 $ cd ..
563 $ cd ..
564 $ chmod 700 a
564 $ chmod 700 a
565 $ rm -r a b
565 $ rm -r a b
566
566
567 #endif
567 #endif
568
568
569
569
570 #if fifo
570 #if fifo
571
571
572 Source of wrong type
572 Source of wrong type
573
573
574 $ mkfifo a
574 $ mkfifo a
575 $ hg clone a b
575 $ hg clone a b
576 abort: repository a not found!
576 abort: repository a not found!
577 [255]
577 [255]
578 $ rm a
578 $ rm a
579
579
580 #endif
580 #endif
581
581
582 Default destination, same directory
582 Default destination, same directory
583
583
584 $ hg init q
584 $ hg init q
585 $ hg clone q
585 $ hg clone q
586 destination directory: q
586 destination directory: q
587 abort: destination 'q' is not empty
587 abort: destination 'q' is not empty
588 [255]
588 [255]
589
589
590 destination directory not empty
590 destination directory not empty
591
591
592 $ mkdir a
592 $ mkdir a
593 $ echo stuff > a/a
593 $ echo stuff > a/a
594 $ hg clone q a
594 $ hg clone q a
595 abort: destination 'a' is not empty
595 abort: destination 'a' is not empty
596 [255]
596 [255]
597
597
598
598
599 #if unix-permissions no-root
599 #if unix-permissions no-root
600
600
601 leave existing directory in place after clone failure
601 leave existing directory in place after clone failure
602
602
603 $ hg init c
603 $ hg init c
604 $ cd c
604 $ cd c
605 $ echo c > c
605 $ echo c > c
606 $ hg commit -A -m test
606 $ hg commit -A -m test
607 adding c
607 adding c
608 $ chmod -rx .hg/store/data
608 $ chmod -rx .hg/store/data
609 $ cd ..
609 $ cd ..
610 $ mkdir d
610 $ mkdir d
611 $ hg clone c d 2> err
611 $ hg clone c d 2> err
612 [255]
612 [255]
613 $ test -d d
613 $ test -d d
614 $ test -d d/.hg
614 $ test -d d/.hg
615 [1]
615 [1]
616
616
617 re-enable perm to allow deletion
617 re-enable perm to allow deletion
618
618
619 $ chmod +rx c/.hg/store/data
619 $ chmod +rx c/.hg/store/data
620
620
621 #endif
621 #endif
622
622
623 $ cd ..
623 $ cd ..
624
625 Test clone from the repository in (emulated) revlog format 0 (issue4203):
626
627 $ mkdir issue4203
628 $ mkdir -p src/.hg
629 $ echo foo > src/foo
630 $ hg -R src add src/foo
631 $ hg -R src commit -m '#0'
632 $ hg -R src log -q
633 0:e1bab28bca43
634 $ hg clone -U -q src dst
635 $ hg -R dst log -q
636 0:e1bab28bca43
637 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now