Show More
@@ -1,440 +1,440 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 | import localrepo, bundlerepo, httprepo, sshrepo, statichttprepo |
|
11 | import localrepo, bundlerepo, httprepo, sshrepo, statichttprepo | |
12 | import lock, util, extensions, error, encoding, node |
|
12 | import lock, util, extensions, error, encoding, node | |
13 | import merge as mergemod |
|
13 | import merge as mergemod | |
14 | import verify as verifymod |
|
14 | import verify as verifymod | |
15 | import errno, os, shutil |
|
15 | import errno, os, shutil | |
16 |
|
16 | |||
17 | def _local(path): |
|
17 | def _local(path): | |
18 | path = util.expandpath(util.drop_scheme('file', path)) |
|
18 | path = util.expandpath(util.drop_scheme('file', path)) | |
19 | return (os.path.isfile(path) and bundlerepo or localrepo) |
|
19 | return (os.path.isfile(path) and bundlerepo or localrepo) | |
20 |
|
20 | |||
21 | def addbranchrevs(lrepo, repo, branches, revs): |
|
21 | def addbranchrevs(lrepo, repo, branches, revs): | |
22 | hashbranch, branches = branches |
|
22 | hashbranch, branches = branches | |
23 | if not hashbranch and not branches: |
|
23 | if not hashbranch and not branches: | |
24 | return revs or None, revs and revs[0] or None |
|
24 | return revs or None, revs and revs[0] or None | |
25 | revs = revs and list(revs) or [] |
|
25 | revs = revs and list(revs) or [] | |
26 | if not repo.capable('branchmap'): |
|
26 | if not repo.capable('branchmap'): | |
27 | if branches: |
|
27 | if branches: | |
28 | raise util.Abort(_("remote branch lookup not supported")) |
|
28 | raise util.Abort(_("remote branch lookup not supported")) | |
29 | revs.append(hashbranch) |
|
29 | revs.append(hashbranch) | |
30 | return revs, revs[0] |
|
30 | return revs, revs[0] | |
31 | branchmap = repo.branchmap() |
|
31 | branchmap = repo.branchmap() | |
32 |
|
32 | |||
33 | def primary(butf8): |
|
33 | def primary(butf8): | |
34 | if butf8 == '.': |
|
34 | if butf8 == '.': | |
35 | if not lrepo or not lrepo.local(): |
|
35 | if not lrepo or not lrepo.local(): | |
36 | raise util.Abort(_("dirstate branch not accessible")) |
|
36 | raise util.Abort(_("dirstate branch not accessible")) | |
37 | butf8 = lrepo.dirstate.branch() |
|
37 | butf8 = lrepo.dirstate.branch() | |
38 | if butf8 in branchmap: |
|
38 | if butf8 in branchmap: | |
39 | revs.extend(node.hex(r) for r in reversed(branchmap[butf8])) |
|
39 | revs.extend(node.hex(r) for r in reversed(branchmap[butf8])) | |
40 | return True |
|
40 | return True | |
41 | else: |
|
41 | else: | |
42 | return False |
|
42 | return False | |
43 |
|
43 | |||
44 | for branch in branches: |
|
44 | for branch in branches: | |
45 | butf8 = encoding.fromlocal(branch) |
|
45 | butf8 = encoding.fromlocal(branch) | |
46 | if not primary(butf8): |
|
46 | if not primary(butf8): | |
47 | raise error.RepoLookupError(_("unknown branch '%s'") % branch) |
|
47 | raise error.RepoLookupError(_("unknown branch '%s'") % branch) | |
48 | if hashbranch: |
|
48 | if hashbranch: | |
49 | butf8 = encoding.fromlocal(hashbranch) |
|
49 | butf8 = encoding.fromlocal(hashbranch) | |
50 | if not primary(butf8): |
|
50 | if not primary(butf8): | |
51 | revs.append(hashbranch) |
|
51 | revs.append(hashbranch) | |
52 | return revs, revs[0] |
|
52 | return revs, revs[0] | |
53 |
|
53 | |||
54 | def parseurl(url, branches=None): |
|
54 | def parseurl(url, branches=None): | |
55 | '''parse url#branch, returning (url, (branch, branches))''' |
|
55 | '''parse url#branch, returning (url, (branch, branches))''' | |
56 |
|
56 | |||
57 | if '#' not in url: |
|
57 | if '#' not in url: | |
58 | return url, (None, branches or []) |
|
58 | return url, (None, branches or []) | |
59 | url, branch = url.split('#', 1) |
|
59 | url, branch = url.split('#', 1) | |
60 | return url, (branch, branches or []) |
|
60 | return url, (branch, branches or []) | |
61 |
|
61 | |||
62 | schemes = { |
|
62 | schemes = { | |
63 | 'bundle': bundlerepo, |
|
63 | 'bundle': bundlerepo, | |
64 | 'file': _local, |
|
64 | 'file': _local, | |
65 | 'http': httprepo, |
|
65 | 'http': httprepo, | |
66 | 'https': httprepo, |
|
66 | 'https': httprepo, | |
67 | 'ssh': sshrepo, |
|
67 | 'ssh': sshrepo, | |
68 | 'static-http': statichttprepo, |
|
68 | 'static-http': statichttprepo, | |
69 | } |
|
69 | } | |
70 |
|
70 | |||
71 | def _lookup(path): |
|
71 | def _lookup(path): | |
72 | scheme = 'file' |
|
72 | scheme = 'file' | |
73 | if path: |
|
73 | if path: | |
74 | c = path.find(':') |
|
74 | c = path.find(':') | |
75 | if c > 0: |
|
75 | if c > 0: | |
76 | scheme = path[:c] |
|
76 | scheme = path[:c] | |
77 | thing = schemes.get(scheme) or schemes['file'] |
|
77 | thing = schemes.get(scheme) or schemes['file'] | |
78 | try: |
|
78 | try: | |
79 | return thing(path) |
|
79 | return thing(path) | |
80 | except TypeError: |
|
80 | except TypeError: | |
81 | return thing |
|
81 | return thing | |
82 |
|
82 | |||
83 | def islocal(repo): |
|
83 | def islocal(repo): | |
84 | '''return true if repo or path is local''' |
|
84 | '''return true if repo or path is local''' | |
85 | if isinstance(repo, str): |
|
85 | if isinstance(repo, str): | |
86 | try: |
|
86 | try: | |
87 | return _lookup(repo).islocal(repo) |
|
87 | return _lookup(repo).islocal(repo) | |
88 | except AttributeError: |
|
88 | except AttributeError: | |
89 | return False |
|
89 | return False | |
90 | return repo.local() |
|
90 | return repo.local() | |
91 |
|
91 | |||
92 | def repository(ui, path='', create=False): |
|
92 | def repository(ui, path='', create=False): | |
93 | """return a repository object for the specified path""" |
|
93 | """return a repository object for the specified path""" | |
94 | repo = _lookup(path).instance(ui, path, create) |
|
94 | repo = _lookup(path).instance(ui, path, create) | |
95 | ui = getattr(repo, "ui", ui) |
|
95 | ui = getattr(repo, "ui", ui) | |
96 | for name, module in extensions.extensions(): |
|
96 | for name, module in extensions.extensions(): | |
97 | hook = getattr(module, 'reposetup', None) |
|
97 | hook = getattr(module, 'reposetup', None) | |
98 | if hook: |
|
98 | if hook: | |
99 | hook(ui, repo) |
|
99 | hook(ui, repo) | |
100 | return repo |
|
100 | return repo | |
101 |
|
101 | |||
102 | def defaultdest(source): |
|
102 | def defaultdest(source): | |
103 | '''return default destination of clone if none is given''' |
|
103 | '''return default destination of clone if none is given''' | |
104 | return os.path.basename(os.path.normpath(source)) |
|
104 | return os.path.basename(os.path.normpath(source)) | |
105 |
|
105 | |||
106 | def localpath(path): |
|
106 | def localpath(path): | |
107 | if path.startswith('file://localhost/'): |
|
107 | if path.startswith('file://localhost/'): | |
108 | return path[16:] |
|
108 | return path[16:] | |
109 | if path.startswith('file://'): |
|
109 | if path.startswith('file://'): | |
110 | return path[7:] |
|
110 | return path[7:] | |
111 | if path.startswith('file:'): |
|
111 | if path.startswith('file:'): | |
112 | return path[5:] |
|
112 | return path[5:] | |
113 | return path |
|
113 | return path | |
114 |
|
114 | |||
115 | def share(ui, source, dest=None, update=True): |
|
115 | def share(ui, source, dest=None, update=True): | |
116 | '''create a shared repository''' |
|
116 | '''create a shared repository''' | |
117 |
|
117 | |||
118 | if not islocal(source): |
|
118 | if not islocal(source): | |
119 | raise util.Abort(_('can only share local repositories')) |
|
119 | raise util.Abort(_('can only share local repositories')) | |
120 |
|
120 | |||
121 | if not dest: |
|
121 | if not dest: | |
122 | dest = defaultdest(source) |
|
122 | dest = defaultdest(source) | |
123 | else: |
|
123 | else: | |
124 | dest = ui.expandpath(dest) |
|
124 | dest = ui.expandpath(dest) | |
125 |
|
125 | |||
126 | if isinstance(source, str): |
|
126 | if isinstance(source, str): | |
127 | origsource = ui.expandpath(source) |
|
127 | origsource = ui.expandpath(source) | |
128 | source, branches = parseurl(origsource) |
|
128 | source, branches = parseurl(origsource) | |
129 | srcrepo = repository(ui, source) |
|
129 | srcrepo = repository(ui, source) | |
130 | rev, checkout = addbranchrevs(srcrepo, srcrepo, branches, None) |
|
130 | rev, checkout = addbranchrevs(srcrepo, srcrepo, branches, None) | |
131 | else: |
|
131 | else: | |
132 | srcrepo = source |
|
132 | srcrepo = source | |
133 | origsource = source = srcrepo.url() |
|
133 | origsource = source = srcrepo.url() | |
134 | checkout = None |
|
134 | checkout = None | |
135 |
|
135 | |||
136 | sharedpath = srcrepo.sharedpath # if our source is already sharing |
|
136 | sharedpath = srcrepo.sharedpath # if our source is already sharing | |
137 |
|
137 | |||
138 | root = os.path.realpath(dest) |
|
138 | root = os.path.realpath(dest) | |
139 | roothg = os.path.join(root, '.hg') |
|
139 | roothg = os.path.join(root, '.hg') | |
140 |
|
140 | |||
141 | if os.path.exists(roothg): |
|
141 | if os.path.exists(roothg): | |
142 | raise util.Abort(_('destination already exists')) |
|
142 | raise util.Abort(_('destination already exists')) | |
143 |
|
143 | |||
144 | if not os.path.isdir(root): |
|
144 | if not os.path.isdir(root): | |
145 | os.mkdir(root) |
|
145 | os.mkdir(root) | |
146 | os.mkdir(roothg) |
|
146 | os.mkdir(roothg) | |
147 |
|
147 | |||
148 | requirements = '' |
|
148 | requirements = '' | |
149 | try: |
|
149 | try: | |
150 | requirements = srcrepo.opener('requires').read() |
|
150 | requirements = srcrepo.opener('requires').read() | |
151 | except IOError, inst: |
|
151 | except IOError, inst: | |
152 | if inst.errno != errno.ENOENT: |
|
152 | if inst.errno != errno.ENOENT: | |
153 | raise |
|
153 | raise | |
154 |
|
154 | |||
155 | requirements += 'shared\n' |
|
155 | requirements += 'shared\n' | |
156 | file(os.path.join(roothg, 'requires'), 'w').write(requirements) |
|
156 | file(os.path.join(roothg, 'requires'), 'w').write(requirements) | |
157 | file(os.path.join(roothg, 'sharedpath'), 'w').write(sharedpath) |
|
157 | file(os.path.join(roothg, 'sharedpath'), 'w').write(sharedpath) | |
158 |
|
158 | |||
159 | default = srcrepo.ui.config('paths', 'default') |
|
159 | default = srcrepo.ui.config('paths', 'default') | |
160 | if default: |
|
160 | if default: | |
161 | f = file(os.path.join(roothg, 'hgrc'), 'w') |
|
161 | f = file(os.path.join(roothg, 'hgrc'), 'w') | |
162 | f.write('[paths]\ndefault = %s\n' % default) |
|
162 | f.write('[paths]\ndefault = %s\n' % default) | |
163 | f.close() |
|
163 | f.close() | |
164 |
|
164 | |||
165 | r = repository(ui, root) |
|
165 | r = repository(ui, root) | |
166 |
|
166 | |||
167 | if update: |
|
167 | if update: | |
168 | r.ui.status(_("updating working directory\n")) |
|
168 | r.ui.status(_("updating working directory\n")) | |
169 | if update is not True: |
|
169 | if update is not True: | |
170 | checkout = update |
|
170 | checkout = update | |
171 | for test in (checkout, 'default', 'tip'): |
|
171 | for test in (checkout, 'default', 'tip'): | |
172 | if test is None: |
|
172 | if test is None: | |
173 | continue |
|
173 | continue | |
174 | try: |
|
174 | try: | |
175 | uprev = r.lookup(test) |
|
175 | uprev = r.lookup(test) | |
176 | break |
|
176 | break | |
177 | except error.RepoLookupError: |
|
177 | except error.RepoLookupError: | |
178 | continue |
|
178 | continue | |
179 | _update(r, uprev) |
|
179 | _update(r, uprev) | |
180 |
|
180 | |||
181 | def clone(ui, source, dest=None, pull=False, rev=None, update=True, |
|
181 | def clone(ui, source, dest=None, pull=False, rev=None, update=True, | |
182 | stream=False, branch=None): |
|
182 | stream=False, branch=None): | |
183 | """Make a copy of an existing repository. |
|
183 | """Make a copy of an existing repository. | |
184 |
|
184 | |||
185 | Create a copy of an existing repository in a new directory. The |
|
185 | Create a copy of an existing repository in a new directory. The | |
186 | source and destination are URLs, as passed to the repository |
|
186 | source and destination are URLs, as passed to the repository | |
187 | function. Returns a pair of repository objects, the source and |
|
187 | function. Returns a pair of repository objects, the source and | |
188 | newly created destination. |
|
188 | newly created destination. | |
189 |
|
189 | |||
190 | The location of the source is added to the new repository's |
|
190 | The location of the source is added to the new repository's | |
191 | .hg/hgrc file, as the default to be used for future pulls and |
|
191 | .hg/hgrc file, as the default to be used for future pulls and | |
192 | pushes. |
|
192 | pushes. | |
193 |
|
193 | |||
194 | If an exception is raised, the partly cloned/updated destination |
|
194 | If an exception is raised, the partly cloned/updated destination | |
195 | repository will be deleted. |
|
195 | repository will be deleted. | |
196 |
|
196 | |||
197 | Arguments: |
|
197 | Arguments: | |
198 |
|
198 | |||
199 | source: repository object or URL |
|
199 | source: repository object or URL | |
200 |
|
200 | |||
201 | dest: URL of destination repository to create (defaults to base |
|
201 | dest: URL of destination repository to create (defaults to base | |
202 | name of source repository) |
|
202 | name of source repository) | |
203 |
|
203 | |||
204 | pull: always pull from source repository, even in local case |
|
204 | pull: always pull from source repository, even in local case | |
205 |
|
205 | |||
206 | stream: stream raw data uncompressed from repository (fast over |
|
206 | stream: stream raw data uncompressed from repository (fast over | |
207 | LAN, slow over WAN) |
|
207 | LAN, slow over WAN) | |
208 |
|
208 | |||
209 | rev: revision to clone up to (implies pull=True) |
|
209 | rev: revision to clone up to (implies pull=True) | |
210 |
|
210 | |||
211 | update: update working directory after clone completes, if |
|
211 | update: update working directory after clone completes, if | |
212 | destination is local repository (True means update to default rev, |
|
212 | destination is local repository (True means update to default rev, | |
213 | anything else is treated as a revision) |
|
213 | anything else is treated as a revision) | |
214 |
|
214 | |||
215 | branch: branches to clone |
|
215 | branch: branches to clone | |
216 | """ |
|
216 | """ | |
217 |
|
217 | |||
218 | if isinstance(source, str): |
|
218 | if isinstance(source, str): | |
219 | origsource = ui.expandpath(source) |
|
219 | origsource = ui.expandpath(source) | |
220 | source, branch = parseurl(origsource, branch) |
|
220 | source, branch = parseurl(origsource, branch) | |
221 | src_repo = repository(ui, source) |
|
221 | src_repo = repository(ui, source) | |
222 | else: |
|
222 | else: | |
223 | src_repo = source |
|
223 | src_repo = source | |
224 | branch = (None, []) |
|
224 | branch = (None, branch or []) | |
225 | origsource = source = src_repo.url() |
|
225 | origsource = source = src_repo.url() | |
226 | rev, checkout = addbranchrevs(src_repo, src_repo, branch, rev) |
|
226 | rev, checkout = addbranchrevs(src_repo, src_repo, branch, rev) | |
227 |
|
227 | |||
228 | if dest is None: |
|
228 | if dest is None: | |
229 | dest = defaultdest(source) |
|
229 | dest = defaultdest(source) | |
230 | ui.status(_("destination directory: %s\n") % dest) |
|
230 | ui.status(_("destination directory: %s\n") % dest) | |
231 | else: |
|
231 | else: | |
232 | dest = ui.expandpath(dest) |
|
232 | dest = ui.expandpath(dest) | |
233 |
|
233 | |||
234 | dest = localpath(dest) |
|
234 | dest = localpath(dest) | |
235 | source = localpath(source) |
|
235 | source = localpath(source) | |
236 |
|
236 | |||
237 | if os.path.exists(dest): |
|
237 | if os.path.exists(dest): | |
238 | if not os.path.isdir(dest): |
|
238 | if not os.path.isdir(dest): | |
239 | raise util.Abort(_("destination '%s' already exists") % dest) |
|
239 | raise util.Abort(_("destination '%s' already exists") % dest) | |
240 | elif os.listdir(dest): |
|
240 | elif os.listdir(dest): | |
241 | raise util.Abort(_("destination '%s' is not empty") % dest) |
|
241 | raise util.Abort(_("destination '%s' is not empty") % dest) | |
242 |
|
242 | |||
243 | class DirCleanup(object): |
|
243 | class DirCleanup(object): | |
244 | def __init__(self, dir_): |
|
244 | def __init__(self, dir_): | |
245 | self.rmtree = shutil.rmtree |
|
245 | self.rmtree = shutil.rmtree | |
246 | self.dir_ = dir_ |
|
246 | self.dir_ = dir_ | |
247 | def close(self): |
|
247 | def close(self): | |
248 | self.dir_ = None |
|
248 | self.dir_ = None | |
249 | def cleanup(self): |
|
249 | def cleanup(self): | |
250 | if self.dir_: |
|
250 | if self.dir_: | |
251 | self.rmtree(self.dir_, True) |
|
251 | self.rmtree(self.dir_, True) | |
252 |
|
252 | |||
253 | src_lock = dest_lock = dir_cleanup = None |
|
253 | src_lock = dest_lock = dir_cleanup = None | |
254 | try: |
|
254 | try: | |
255 | if islocal(dest): |
|
255 | if islocal(dest): | |
256 | dir_cleanup = DirCleanup(dest) |
|
256 | dir_cleanup = DirCleanup(dest) | |
257 |
|
257 | |||
258 | abspath = origsource |
|
258 | abspath = origsource | |
259 | copy = False |
|
259 | copy = False | |
260 | if src_repo.cancopy() and islocal(dest): |
|
260 | if src_repo.cancopy() and islocal(dest): | |
261 | abspath = os.path.abspath(util.drop_scheme('file', origsource)) |
|
261 | abspath = os.path.abspath(util.drop_scheme('file', origsource)) | |
262 | copy = not pull and not rev |
|
262 | copy = not pull and not rev | |
263 |
|
263 | |||
264 | if copy: |
|
264 | if copy: | |
265 | try: |
|
265 | try: | |
266 | # we use a lock here because if we race with commit, we |
|
266 | # we use a lock here because if we race with commit, we | |
267 | # can end up with extra data in the cloned revlogs that's |
|
267 | # can end up with extra data in the cloned revlogs that's | |
268 | # not pointed to by changesets, thus causing verify to |
|
268 | # not pointed to by changesets, thus causing verify to | |
269 | # fail |
|
269 | # fail | |
270 | src_lock = src_repo.lock(wait=False) |
|
270 | src_lock = src_repo.lock(wait=False) | |
271 | except error.LockError: |
|
271 | except error.LockError: | |
272 | copy = False |
|
272 | copy = False | |
273 |
|
273 | |||
274 | if copy: |
|
274 | if copy: | |
275 | src_repo.hook('preoutgoing', throw=True, source='clone') |
|
275 | src_repo.hook('preoutgoing', throw=True, source='clone') | |
276 | hgdir = os.path.realpath(os.path.join(dest, ".hg")) |
|
276 | hgdir = os.path.realpath(os.path.join(dest, ".hg")) | |
277 | if not os.path.exists(dest): |
|
277 | if not os.path.exists(dest): | |
278 | os.mkdir(dest) |
|
278 | os.mkdir(dest) | |
279 | else: |
|
279 | else: | |
280 | # only clean up directories we create ourselves |
|
280 | # only clean up directories we create ourselves | |
281 | dir_cleanup.dir_ = hgdir |
|
281 | dir_cleanup.dir_ = hgdir | |
282 | try: |
|
282 | try: | |
283 | dest_path = hgdir |
|
283 | dest_path = hgdir | |
284 | os.mkdir(dest_path) |
|
284 | os.mkdir(dest_path) | |
285 | except OSError, inst: |
|
285 | except OSError, inst: | |
286 | if inst.errno == errno.EEXIST: |
|
286 | if inst.errno == errno.EEXIST: | |
287 | dir_cleanup.close() |
|
287 | dir_cleanup.close() | |
288 | raise util.Abort(_("destination '%s' already exists") |
|
288 | raise util.Abort(_("destination '%s' already exists") | |
289 | % dest) |
|
289 | % dest) | |
290 | raise |
|
290 | raise | |
291 |
|
291 | |||
292 | hardlink = None |
|
292 | hardlink = None | |
293 | num = 0 |
|
293 | num = 0 | |
294 | for f in src_repo.store.copylist(): |
|
294 | for f in src_repo.store.copylist(): | |
295 | src = os.path.join(src_repo.sharedpath, f) |
|
295 | src = os.path.join(src_repo.sharedpath, f) | |
296 | dst = os.path.join(dest_path, f) |
|
296 | dst = os.path.join(dest_path, f) | |
297 | dstbase = os.path.dirname(dst) |
|
297 | dstbase = os.path.dirname(dst) | |
298 | if dstbase and not os.path.exists(dstbase): |
|
298 | if dstbase and not os.path.exists(dstbase): | |
299 | os.mkdir(dstbase) |
|
299 | os.mkdir(dstbase) | |
300 | if os.path.exists(src): |
|
300 | if os.path.exists(src): | |
301 | if dst.endswith('data'): |
|
301 | if dst.endswith('data'): | |
302 | # lock to avoid premature writing to the target |
|
302 | # lock to avoid premature writing to the target | |
303 | dest_lock = lock.lock(os.path.join(dstbase, "lock")) |
|
303 | dest_lock = lock.lock(os.path.join(dstbase, "lock")) | |
304 | hardlink, n = util.copyfiles(src, dst, hardlink) |
|
304 | hardlink, n = util.copyfiles(src, dst, hardlink) | |
305 | num += n |
|
305 | num += n | |
306 | if hardlink: |
|
306 | if hardlink: | |
307 | ui.debug("linked %d files\n" % num) |
|
307 | ui.debug("linked %d files\n" % num) | |
308 | else: |
|
308 | else: | |
309 | ui.debug("copied %d files\n" % num) |
|
309 | ui.debug("copied %d files\n" % num) | |
310 |
|
310 | |||
311 | # we need to re-init the repo after manually copying the data |
|
311 | # we need to re-init the repo after manually copying the data | |
312 | # into it |
|
312 | # into it | |
313 | dest_repo = repository(ui, dest) |
|
313 | dest_repo = repository(ui, dest) | |
314 | src_repo.hook('outgoing', source='clone', node='0'*40) |
|
314 | src_repo.hook('outgoing', source='clone', node='0'*40) | |
315 | else: |
|
315 | else: | |
316 | try: |
|
316 | try: | |
317 | dest_repo = repository(ui, dest, create=True) |
|
317 | dest_repo = repository(ui, dest, create=True) | |
318 | except OSError, inst: |
|
318 | except OSError, inst: | |
319 | if inst.errno == errno.EEXIST: |
|
319 | if inst.errno == errno.EEXIST: | |
320 | dir_cleanup.close() |
|
320 | dir_cleanup.close() | |
321 | raise util.Abort(_("destination '%s' already exists") |
|
321 | raise util.Abort(_("destination '%s' already exists") | |
322 | % dest) |
|
322 | % dest) | |
323 | raise |
|
323 | raise | |
324 |
|
324 | |||
325 | revs = None |
|
325 | revs = None | |
326 | if rev: |
|
326 | if rev: | |
327 | if 'lookup' not in src_repo.capabilities: |
|
327 | if 'lookup' not in src_repo.capabilities: | |
328 | raise util.Abort(_("src repository does not support " |
|
328 | raise util.Abort(_("src repository does not support " | |
329 | "revision lookup and so doesn't " |
|
329 | "revision lookup and so doesn't " | |
330 | "support clone by revision")) |
|
330 | "support clone by revision")) | |
331 | revs = [src_repo.lookup(r) for r in rev] |
|
331 | revs = [src_repo.lookup(r) for r in rev] | |
332 | checkout = revs[0] |
|
332 | checkout = revs[0] | |
333 | if dest_repo.local(): |
|
333 | if dest_repo.local(): | |
334 | dest_repo.clone(src_repo, heads=revs, stream=stream) |
|
334 | dest_repo.clone(src_repo, heads=revs, stream=stream) | |
335 | elif src_repo.local(): |
|
335 | elif src_repo.local(): | |
336 | src_repo.push(dest_repo, revs=revs) |
|
336 | src_repo.push(dest_repo, revs=revs) | |
337 | else: |
|
337 | else: | |
338 | raise util.Abort(_("clone from remote to remote not supported")) |
|
338 | raise util.Abort(_("clone from remote to remote not supported")) | |
339 |
|
339 | |||
340 | if dir_cleanup: |
|
340 | if dir_cleanup: | |
341 | dir_cleanup.close() |
|
341 | dir_cleanup.close() | |
342 |
|
342 | |||
343 | if dest_repo.local(): |
|
343 | if dest_repo.local(): | |
344 | fp = dest_repo.opener("hgrc", "w", text=True) |
|
344 | fp = dest_repo.opener("hgrc", "w", text=True) | |
345 | fp.write("[paths]\n") |
|
345 | fp.write("[paths]\n") | |
346 | fp.write("default = %s\n" % abspath) |
|
346 | fp.write("default = %s\n" % abspath) | |
347 | fp.close() |
|
347 | fp.close() | |
348 |
|
348 | |||
349 | dest_repo.ui.setconfig('paths', 'default', abspath) |
|
349 | dest_repo.ui.setconfig('paths', 'default', abspath) | |
350 |
|
350 | |||
351 | if update: |
|
351 | if update: | |
352 | if update is not True: |
|
352 | if update is not True: | |
353 | checkout = update |
|
353 | checkout = update | |
354 | if src_repo.local(): |
|
354 | if src_repo.local(): | |
355 | checkout = src_repo.lookup(update) |
|
355 | checkout = src_repo.lookup(update) | |
356 | for test in (checkout, 'default', 'tip'): |
|
356 | for test in (checkout, 'default', 'tip'): | |
357 | if test is None: |
|
357 | if test is None: | |
358 | continue |
|
358 | continue | |
359 | try: |
|
359 | try: | |
360 | uprev = dest_repo.lookup(test) |
|
360 | uprev = dest_repo.lookup(test) | |
361 | break |
|
361 | break | |
362 | except error.RepoLookupError: |
|
362 | except error.RepoLookupError: | |
363 | continue |
|
363 | continue | |
364 | bn = dest_repo[uprev].branch() |
|
364 | bn = dest_repo[uprev].branch() | |
365 | dest_repo.ui.status(_("updating to branch %s\n") |
|
365 | dest_repo.ui.status(_("updating to branch %s\n") | |
366 | % encoding.tolocal(bn)) |
|
366 | % encoding.tolocal(bn)) | |
367 | _update(dest_repo, uprev) |
|
367 | _update(dest_repo, uprev) | |
368 |
|
368 | |||
369 | return src_repo, dest_repo |
|
369 | return src_repo, dest_repo | |
370 | finally: |
|
370 | finally: | |
371 | release(src_lock, dest_lock) |
|
371 | release(src_lock, dest_lock) | |
372 | if dir_cleanup is not None: |
|
372 | if dir_cleanup is not None: | |
373 | dir_cleanup.cleanup() |
|
373 | dir_cleanup.cleanup() | |
374 |
|
374 | |||
375 | def _showstats(repo, stats): |
|
375 | def _showstats(repo, stats): | |
376 | repo.ui.status(_("%d files updated, %d files merged, " |
|
376 | repo.ui.status(_("%d files updated, %d files merged, " | |
377 | "%d files removed, %d files unresolved\n") % stats) |
|
377 | "%d files removed, %d files unresolved\n") % stats) | |
378 |
|
378 | |||
379 | def update(repo, node): |
|
379 | def update(repo, node): | |
380 | """update the working directory to node, merging linear changes""" |
|
380 | """update the working directory to node, merging linear changes""" | |
381 | stats = mergemod.update(repo, node, False, False, None) |
|
381 | stats = mergemod.update(repo, node, False, False, None) | |
382 | _showstats(repo, stats) |
|
382 | _showstats(repo, stats) | |
383 | if stats[3]: |
|
383 | if stats[3]: | |
384 | repo.ui.status(_("use 'hg resolve' to retry unresolved file merges\n")) |
|
384 | repo.ui.status(_("use 'hg resolve' to retry unresolved file merges\n")) | |
385 | return stats[3] > 0 |
|
385 | return stats[3] > 0 | |
386 |
|
386 | |||
387 | # naming conflict in clone() |
|
387 | # naming conflict in clone() | |
388 | _update = update |
|
388 | _update = update | |
389 |
|
389 | |||
390 | def clean(repo, node, show_stats=True): |
|
390 | def clean(repo, node, show_stats=True): | |
391 | """forcibly switch the working directory to node, clobbering changes""" |
|
391 | """forcibly switch the working directory to node, clobbering changes""" | |
392 | stats = mergemod.update(repo, node, False, True, None) |
|
392 | stats = mergemod.update(repo, node, False, True, None) | |
393 | if show_stats: |
|
393 | if show_stats: | |
394 | _showstats(repo, stats) |
|
394 | _showstats(repo, stats) | |
395 | return stats[3] > 0 |
|
395 | return stats[3] > 0 | |
396 |
|
396 | |||
397 | def merge(repo, node, force=None, remind=True): |
|
397 | def merge(repo, node, force=None, remind=True): | |
398 | """branch merge with node, resolving changes""" |
|
398 | """branch merge with node, resolving changes""" | |
399 | stats = mergemod.update(repo, node, True, force, False) |
|
399 | stats = mergemod.update(repo, node, True, force, False) | |
400 | _showstats(repo, stats) |
|
400 | _showstats(repo, stats) | |
401 | if stats[3]: |
|
401 | if stats[3]: | |
402 | repo.ui.status(_("use 'hg resolve' to retry unresolved file merges " |
|
402 | repo.ui.status(_("use 'hg resolve' to retry unresolved file merges " | |
403 | "or 'hg update -C' to abandon\n")) |
|
403 | "or 'hg update -C' to abandon\n")) | |
404 | elif remind: |
|
404 | elif remind: | |
405 | repo.ui.status(_("(branch merge, don't forget to commit)\n")) |
|
405 | repo.ui.status(_("(branch merge, don't forget to commit)\n")) | |
406 | return stats[3] > 0 |
|
406 | return stats[3] > 0 | |
407 |
|
407 | |||
408 | def revert(repo, node, choose): |
|
408 | def revert(repo, node, choose): | |
409 | """revert changes to revision in node without updating dirstate""" |
|
409 | """revert changes to revision in node without updating dirstate""" | |
410 | return mergemod.update(repo, node, False, True, choose)[3] > 0 |
|
410 | return mergemod.update(repo, node, False, True, choose)[3] > 0 | |
411 |
|
411 | |||
412 | def verify(repo): |
|
412 | def verify(repo): | |
413 | """verify the consistency of a repository""" |
|
413 | """verify the consistency of a repository""" | |
414 | return verifymod.verify(repo) |
|
414 | return verifymod.verify(repo) | |
415 |
|
415 | |||
416 | def remoteui(src, opts): |
|
416 | def remoteui(src, opts): | |
417 | 'build a remote ui from ui or repo and opts' |
|
417 | 'build a remote ui from ui or repo and opts' | |
418 | if hasattr(src, 'baseui'): # looks like a repository |
|
418 | if hasattr(src, 'baseui'): # looks like a repository | |
419 | dst = src.baseui.copy() # drop repo-specific config |
|
419 | dst = src.baseui.copy() # drop repo-specific config | |
420 | src = src.ui # copy target options from repo |
|
420 | src = src.ui # copy target options from repo | |
421 | else: # assume it's a global ui object |
|
421 | else: # assume it's a global ui object | |
422 | dst = src.copy() # keep all global options |
|
422 | dst = src.copy() # keep all global options | |
423 |
|
423 | |||
424 | # copy ssh-specific options |
|
424 | # copy ssh-specific options | |
425 | for o in 'ssh', 'remotecmd': |
|
425 | for o in 'ssh', 'remotecmd': | |
426 | v = opts.get(o) or src.config('ui', o) |
|
426 | v = opts.get(o) or src.config('ui', o) | |
427 | if v: |
|
427 | if v: | |
428 | dst.setconfig("ui", o, v) |
|
428 | dst.setconfig("ui", o, v) | |
429 |
|
429 | |||
430 | # copy bundle-specific options |
|
430 | # copy bundle-specific options | |
431 | r = src.config('bundle', 'mainreporoot') |
|
431 | r = src.config('bundle', 'mainreporoot') | |
432 | if r: |
|
432 | if r: | |
433 | dst.setconfig('bundle', 'mainreporoot', r) |
|
433 | dst.setconfig('bundle', 'mainreporoot', r) | |
434 |
|
434 | |||
435 | # copy auth and http_proxy section settings |
|
435 | # copy auth and http_proxy section settings | |
436 | for sect in ('auth', 'http_proxy'): |
|
436 | for sect in ('auth', 'http_proxy'): | |
437 | for key, val in src.configitems(sect): |
|
437 | for key, val in src.configitems(sect): | |
438 | dst.setconfig(sect, key, val) |
|
438 | dst.setconfig(sect, key, val) | |
439 |
|
439 | |||
440 | return dst |
|
440 | return dst |
@@ -1,433 +1,443 b'' | |||||
1 | Prepare repo a: |
|
1 | Prepare repo a: | |
2 |
|
2 | |||
3 | $ mkdir a |
|
3 | $ mkdir a | |
4 | $ cd a |
|
4 | $ cd a | |
5 | $ hg init |
|
5 | $ hg init | |
6 | $ echo a > a |
|
6 | $ echo a > a | |
7 | $ hg add a |
|
7 | $ hg add a | |
8 | $ hg commit -m test |
|
8 | $ hg commit -m test | |
9 | $ echo first line > b |
|
9 | $ echo first line > b | |
10 | $ hg add b |
|
10 | $ hg add b | |
11 |
|
11 | |||
12 | Create a non-inlined filelog: |
|
12 | Create a non-inlined filelog: | |
13 |
|
13 | |||
14 | $ python -c 'for x in range(10000): print x' >> data1 |
|
14 | $ python -c 'for x in range(10000): print x' >> data1 | |
15 | $ for j in 0 1 2 3 4 5 6 7 8 9; do |
|
15 | $ for j in 0 1 2 3 4 5 6 7 8 9; do | |
16 | > cat data1 >> b |
|
16 | > cat data1 >> b | |
17 | > hg commit -m test |
|
17 | > hg commit -m test | |
18 | > done |
|
18 | > done | |
19 |
|
19 | |||
20 | List files in store/data (should show a 'b.d'): |
|
20 | List files in store/data (should show a 'b.d'): | |
21 |
|
21 | |||
22 | $ for i in .hg/store/data/*; do |
|
22 | $ for i in .hg/store/data/*; do | |
23 | > echo $i |
|
23 | > echo $i | |
24 | > done |
|
24 | > done | |
25 | .hg/store/data/a.i |
|
25 | .hg/store/data/a.i | |
26 | .hg/store/data/b.d |
|
26 | .hg/store/data/b.d | |
27 | .hg/store/data/b.i |
|
27 | .hg/store/data/b.i | |
28 |
|
28 | |||
29 | Default operation: |
|
29 | Default operation: | |
30 |
|
30 | |||
31 | $ hg clone . ../b |
|
31 | $ hg clone . ../b | |
32 | updating to branch default |
|
32 | updating to branch default | |
33 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
33 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
34 | $ cd ../b |
|
34 | $ cd ../b | |
35 | $ cat a |
|
35 | $ cat a | |
36 | a |
|
36 | a | |
37 | $ hg verify |
|
37 | $ hg verify | |
38 | checking changesets |
|
38 | checking changesets | |
39 | checking manifests |
|
39 | checking manifests | |
40 | crosschecking files in changesets and manifests |
|
40 | crosschecking files in changesets and manifests | |
41 | checking files |
|
41 | checking files | |
42 | 2 files, 11 changesets, 11 total revisions |
|
42 | 2 files, 11 changesets, 11 total revisions | |
43 |
|
43 | |||
44 | No update, with debug option: |
|
44 | No update, with debug option: | |
45 |
|
45 | |||
46 | $ hg --debug clone -U . ../c |
|
46 | $ hg --debug clone -U . ../c | |
47 | linked 8 files |
|
47 | linked 8 files | |
48 | $ cd ../c |
|
48 | $ cd ../c | |
49 | $ cat a 2>/dev/null || echo "a not present" |
|
49 | $ cat a 2>/dev/null || echo "a not present" | |
50 | a not present |
|
50 | a not present | |
51 | $ hg verify |
|
51 | $ hg verify | |
52 | checking changesets |
|
52 | checking changesets | |
53 | checking manifests |
|
53 | checking manifests | |
54 | crosschecking files in changesets and manifests |
|
54 | crosschecking files in changesets and manifests | |
55 | checking files |
|
55 | checking files | |
56 | 2 files, 11 changesets, 11 total revisions |
|
56 | 2 files, 11 changesets, 11 total revisions | |
57 |
|
57 | |||
58 | Default destination: |
|
58 | Default destination: | |
59 |
|
59 | |||
60 | $ mkdir ../d |
|
60 | $ mkdir ../d | |
61 | $ cd ../d |
|
61 | $ cd ../d | |
62 | $ hg clone ../a |
|
62 | $ hg clone ../a | |
63 | destination directory: a |
|
63 | destination directory: a | |
64 | updating to branch default |
|
64 | updating to branch default | |
65 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
65 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
66 | $ cd a |
|
66 | $ cd a | |
67 | $ hg cat a |
|
67 | $ hg cat a | |
68 | a |
|
68 | a | |
69 | $ cd ../.. |
|
69 | $ cd ../.. | |
70 |
|
70 | |||
71 | Check that we drop the 'file:' from the path before writing the .hgrc: |
|
71 | Check that we drop the 'file:' from the path before writing the .hgrc: | |
72 |
|
72 | |||
73 | $ hg clone file:a e |
|
73 | $ hg clone file:a e | |
74 | updating to branch default |
|
74 | updating to branch default | |
75 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
75 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
76 | $ grep 'file:' e/.hg/hgrc |
|
76 | $ grep 'file:' e/.hg/hgrc | |
77 |
|
77 | |||
78 | Check that path aliases are expanded: |
|
78 | Check that path aliases are expanded: | |
79 |
|
79 | |||
80 | $ hg clone -q -U --config 'paths.foobar=a#0' foobar f |
|
80 | $ hg clone -q -U --config 'paths.foobar=a#0' foobar f | |
81 | $ hg -R f showconfig paths.default |
|
81 | $ hg -R f showconfig paths.default | |
82 | .*/a#0 |
|
82 | .*/a#0 | |
83 |
|
83 | |||
84 | Use --pull: |
|
84 | Use --pull: | |
85 |
|
85 | |||
86 | $ hg clone --pull a g |
|
86 | $ hg clone --pull a g | |
87 | requesting all changes |
|
87 | requesting all changes | |
88 | adding changesets |
|
88 | adding changesets | |
89 | adding manifests |
|
89 | adding manifests | |
90 | adding file changes |
|
90 | adding file changes | |
91 | added 11 changesets with 11 changes to 2 files |
|
91 | added 11 changesets with 11 changes to 2 files | |
92 | updating to branch default |
|
92 | updating to branch default | |
93 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
93 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
94 | $ hg -R g verify |
|
94 | $ hg -R g verify | |
95 | checking changesets |
|
95 | checking changesets | |
96 | checking manifests |
|
96 | checking manifests | |
97 | crosschecking files in changesets and manifests |
|
97 | crosschecking files in changesets and manifests | |
98 | checking files |
|
98 | checking files | |
99 | 2 files, 11 changesets, 11 total revisions |
|
99 | 2 files, 11 changesets, 11 total revisions | |
100 |
|
100 | |||
101 | Clone to '.': |
|
101 | Clone to '.': | |
102 |
|
102 | |||
103 | $ mkdir h |
|
103 | $ mkdir h | |
104 | $ cd h |
|
104 | $ cd h | |
105 | $ hg clone ../a . |
|
105 | $ hg clone ../a . | |
106 | updating to branch default |
|
106 | updating to branch default | |
107 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
107 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
108 | $ cd .. |
|
108 | $ cd .. | |
109 |
|
109 | |||
110 |
|
110 | |||
111 | *** Tests for option -u *** |
|
111 | *** Tests for option -u *** | |
112 |
|
112 | |||
113 | Adding some more history to repo a: |
|
113 | Adding some more history to repo a: | |
114 |
|
114 | |||
115 | $ cd a |
|
115 | $ cd a | |
116 | $ hg tag ref1 |
|
116 | $ hg tag ref1 | |
117 | $ echo the quick brown fox >a |
|
117 | $ echo the quick brown fox >a | |
118 | $ hg ci -m "hacked default" |
|
118 | $ hg ci -m "hacked default" | |
119 | $ hg up ref1 |
|
119 | $ hg up ref1 | |
120 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
120 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
121 | $ hg branch stable |
|
121 | $ hg branch stable | |
122 | marked working directory as branch stable |
|
122 | marked working directory as branch stable | |
123 | $ echo some text >a |
|
123 | $ echo some text >a | |
124 | $ hg ci -m "starting branch stable" |
|
124 | $ hg ci -m "starting branch stable" | |
125 | $ hg tag ref2 |
|
125 | $ hg tag ref2 | |
126 | $ echo some more text >a |
|
126 | $ echo some more text >a | |
127 | $ hg ci -m "another change for branch stable" |
|
127 | $ hg ci -m "another change for branch stable" | |
128 | $ hg up ref2 |
|
128 | $ hg up ref2 | |
129 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
129 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
130 | $ hg parents |
|
130 | $ hg parents | |
131 | changeset: 13:e8ece76546a6 |
|
131 | changeset: 13:e8ece76546a6 | |
132 | branch: stable |
|
132 | branch: stable | |
133 | tag: ref2 |
|
133 | tag: ref2 | |
134 | parent: 10:a7949464abda |
|
134 | parent: 10:a7949464abda | |
135 | user: test |
|
135 | user: test | |
136 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
136 | date: Thu Jan 01 00:00:00 1970 +0000 | |
137 | summary: starting branch stable |
|
137 | summary: starting branch stable | |
138 |
|
138 | |||
139 |
|
139 | |||
140 | Repo a has two heads: |
|
140 | Repo a has two heads: | |
141 |
|
141 | |||
142 | $ hg heads |
|
142 | $ hg heads | |
143 | changeset: 15:0aae7cf88f0d |
|
143 | changeset: 15:0aae7cf88f0d | |
144 | branch: stable |
|
144 | branch: stable | |
145 | tag: tip |
|
145 | tag: tip | |
146 | user: test |
|
146 | user: test | |
147 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
147 | date: Thu Jan 01 00:00:00 1970 +0000 | |
148 | summary: another change for branch stable |
|
148 | summary: another change for branch stable | |
149 |
|
149 | |||
150 | changeset: 12:f21241060d6a |
|
150 | changeset: 12:f21241060d6a | |
151 | user: test |
|
151 | user: test | |
152 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
152 | date: Thu Jan 01 00:00:00 1970 +0000 | |
153 | summary: hacked default |
|
153 | summary: hacked default | |
154 |
|
154 | |||
155 |
|
155 | |||
156 | $ cd .. |
|
156 | $ cd .. | |
157 |
|
157 | |||
158 |
|
158 | |||
159 | Testing --noupdate with --updaterev (must abort): |
|
159 | Testing --noupdate with --updaterev (must abort): | |
160 |
|
160 | |||
161 | $ hg clone --noupdate --updaterev 1 a ua |
|
161 | $ hg clone --noupdate --updaterev 1 a ua | |
162 | abort: cannot specify both --noupdate and --updaterev |
|
162 | abort: cannot specify both --noupdate and --updaterev | |
163 |
|
163 | |||
164 |
|
164 | |||
165 | Testing clone -u: |
|
165 | Testing clone -u: | |
166 |
|
166 | |||
167 | $ hg clone -u . a ua |
|
167 | $ hg clone -u . a ua | |
168 | updating to branch stable |
|
168 | updating to branch stable | |
169 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
169 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
170 |
|
170 | |||
171 | Repo ua has both heads: |
|
171 | Repo ua has both heads: | |
172 |
|
172 | |||
173 | $ hg -R ua heads |
|
173 | $ hg -R ua heads | |
174 | changeset: 15:0aae7cf88f0d |
|
174 | changeset: 15:0aae7cf88f0d | |
175 | branch: stable |
|
175 | branch: stable | |
176 | tag: tip |
|
176 | tag: tip | |
177 | user: test |
|
177 | user: test | |
178 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
178 | date: Thu Jan 01 00:00:00 1970 +0000 | |
179 | summary: another change for branch stable |
|
179 | summary: another change for branch stable | |
180 |
|
180 | |||
181 | changeset: 12:f21241060d6a |
|
181 | changeset: 12:f21241060d6a | |
182 | user: test |
|
182 | user: test | |
183 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
183 | date: Thu Jan 01 00:00:00 1970 +0000 | |
184 | summary: hacked default |
|
184 | summary: hacked default | |
185 |
|
185 | |||
186 |
|
186 | |||
187 | Same revision checked out in repo a and ua: |
|
187 | Same revision checked out in repo a and ua: | |
188 |
|
188 | |||
189 | $ hg -R a parents --template "{node|short}\n" |
|
189 | $ hg -R a parents --template "{node|short}\n" | |
190 | e8ece76546a6 |
|
190 | e8ece76546a6 | |
191 | $ hg -R ua parents --template "{node|short}\n" |
|
191 | $ hg -R ua parents --template "{node|short}\n" | |
192 | e8ece76546a6 |
|
192 | e8ece76546a6 | |
193 |
|
193 | |||
194 | $ rm -r ua |
|
194 | $ rm -r ua | |
195 |
|
195 | |||
196 |
|
196 | |||
197 | Testing clone --pull -u: |
|
197 | Testing clone --pull -u: | |
198 |
|
198 | |||
199 | $ hg clone --pull -u . a ua |
|
199 | $ hg clone --pull -u . a ua | |
200 | requesting all changes |
|
200 | requesting all changes | |
201 | adding changesets |
|
201 | adding changesets | |
202 | adding manifests |
|
202 | adding manifests | |
203 | adding file changes |
|
203 | adding file changes | |
204 | added 16 changesets with 16 changes to 3 files (+1 heads) |
|
204 | added 16 changesets with 16 changes to 3 files (+1 heads) | |
205 | updating to branch stable |
|
205 | updating to branch stable | |
206 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
206 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
207 |
|
207 | |||
208 | Repo ua has both heads: |
|
208 | Repo ua has both heads: | |
209 |
|
209 | |||
210 | $ hg -R ua heads |
|
210 | $ hg -R ua heads | |
211 | changeset: 15:0aae7cf88f0d |
|
211 | changeset: 15:0aae7cf88f0d | |
212 | branch: stable |
|
212 | branch: stable | |
213 | tag: tip |
|
213 | tag: tip | |
214 | user: test |
|
214 | user: test | |
215 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
215 | date: Thu Jan 01 00:00:00 1970 +0000 | |
216 | summary: another change for branch stable |
|
216 | summary: another change for branch stable | |
217 |
|
217 | |||
218 | changeset: 12:f21241060d6a |
|
218 | changeset: 12:f21241060d6a | |
219 | user: test |
|
219 | user: test | |
220 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
220 | date: Thu Jan 01 00:00:00 1970 +0000 | |
221 | summary: hacked default |
|
221 | summary: hacked default | |
222 |
|
222 | |||
223 |
|
223 | |||
224 | Same revision checked out in repo a and ua: |
|
224 | Same revision checked out in repo a and ua: | |
225 |
|
225 | |||
226 | $ hg -R a parents --template "{node|short}\n" |
|
226 | $ hg -R a parents --template "{node|short}\n" | |
227 | e8ece76546a6 |
|
227 | e8ece76546a6 | |
228 | $ hg -R ua parents --template "{node|short}\n" |
|
228 | $ hg -R ua parents --template "{node|short}\n" | |
229 | e8ece76546a6 |
|
229 | e8ece76546a6 | |
230 |
|
230 | |||
231 | $ rm -r ua |
|
231 | $ rm -r ua | |
232 |
|
232 | |||
233 |
|
233 | |||
234 | Testing clone -u <branch>: |
|
234 | Testing clone -u <branch>: | |
235 |
|
235 | |||
236 | $ hg clone -u stable a ua |
|
236 | $ hg clone -u stable a ua | |
237 | updating to branch stable |
|
237 | updating to branch stable | |
238 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
238 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
239 |
|
239 | |||
240 | Repo ua has both heads: |
|
240 | Repo ua has both heads: | |
241 |
|
241 | |||
242 | $ hg -R ua heads |
|
242 | $ hg -R ua heads | |
243 | changeset: 15:0aae7cf88f0d |
|
243 | changeset: 15:0aae7cf88f0d | |
244 | branch: stable |
|
244 | branch: stable | |
245 | tag: tip |
|
245 | tag: tip | |
246 | user: test |
|
246 | user: test | |
247 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
247 | date: Thu Jan 01 00:00:00 1970 +0000 | |
248 | summary: another change for branch stable |
|
248 | summary: another change for branch stable | |
249 |
|
249 | |||
250 | changeset: 12:f21241060d6a |
|
250 | changeset: 12:f21241060d6a | |
251 | user: test |
|
251 | user: test | |
252 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
252 | date: Thu Jan 01 00:00:00 1970 +0000 | |
253 | summary: hacked default |
|
253 | summary: hacked default | |
254 |
|
254 | |||
255 |
|
255 | |||
256 | Branch 'stable' is checked out: |
|
256 | Branch 'stable' is checked out: | |
257 |
|
257 | |||
258 | $ hg -R ua parents |
|
258 | $ hg -R ua parents | |
259 | changeset: 15:0aae7cf88f0d |
|
259 | changeset: 15:0aae7cf88f0d | |
260 | branch: stable |
|
260 | branch: stable | |
261 | tag: tip |
|
261 | tag: tip | |
262 | user: test |
|
262 | user: test | |
263 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
263 | date: Thu Jan 01 00:00:00 1970 +0000 | |
264 | summary: another change for branch stable |
|
264 | summary: another change for branch stable | |
265 |
|
265 | |||
266 |
|
266 | |||
267 | $ rm -r ua |
|
267 | $ rm -r ua | |
268 |
|
268 | |||
269 |
|
269 | |||
270 | Testing default checkout: |
|
270 | Testing default checkout: | |
271 |
|
271 | |||
272 | $ hg clone a ua |
|
272 | $ hg clone a ua | |
273 | updating to branch default |
|
273 | updating to branch default | |
274 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
274 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
275 |
|
275 | |||
276 | Repo ua has both heads: |
|
276 | Repo ua has both heads: | |
277 |
|
277 | |||
278 | $ hg -R ua heads |
|
278 | $ hg -R ua heads | |
279 | changeset: 15:0aae7cf88f0d |
|
279 | changeset: 15:0aae7cf88f0d | |
280 | branch: stable |
|
280 | branch: stable | |
281 | tag: tip |
|
281 | tag: tip | |
282 | user: test |
|
282 | user: test | |
283 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
283 | date: Thu Jan 01 00:00:00 1970 +0000 | |
284 | summary: another change for branch stable |
|
284 | summary: another change for branch stable | |
285 |
|
285 | |||
286 | changeset: 12:f21241060d6a |
|
286 | changeset: 12:f21241060d6a | |
287 | user: test |
|
287 | user: test | |
288 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
288 | date: Thu Jan 01 00:00:00 1970 +0000 | |
289 | summary: hacked default |
|
289 | summary: hacked default | |
290 |
|
290 | |||
291 |
|
291 | |||
292 | Branch 'default' is checked out: |
|
292 | Branch 'default' is checked out: | |
293 |
|
293 | |||
294 | $ hg -R ua parents |
|
294 | $ hg -R ua parents | |
295 | changeset: 12:f21241060d6a |
|
295 | changeset: 12:f21241060d6a | |
296 | user: test |
|
296 | user: test | |
297 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
297 | date: Thu Jan 01 00:00:00 1970 +0000 | |
298 | summary: hacked default |
|
298 | summary: hacked default | |
299 |
|
299 | |||
300 |
|
300 | |||
301 | $ rm -r ua |
|
301 | $ rm -r ua | |
302 |
|
302 | |||
303 |
|
303 | |||
304 | Testing #<branch>: |
|
304 | Testing #<branch>: | |
305 |
|
305 | |||
306 | $ hg clone -u . a#stable ua |
|
306 | $ hg clone -u . a#stable ua | |
307 | requesting all changes |
|
307 | requesting all changes | |
308 | adding changesets |
|
308 | adding changesets | |
309 | adding manifests |
|
309 | adding manifests | |
310 | adding file changes |
|
310 | adding file changes | |
311 | added 14 changesets with 14 changes to 3 files |
|
311 | added 14 changesets with 14 changes to 3 files | |
312 | updating to branch stable |
|
312 | updating to branch stable | |
313 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
313 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
314 |
|
314 | |||
315 | Repo ua has branch 'stable' and 'default' (was changed in fd511e9eeea6): |
|
315 | Repo ua has branch 'stable' and 'default' (was changed in fd511e9eeea6): | |
316 |
|
316 | |||
317 | $ hg -R ua heads |
|
317 | $ hg -R ua heads | |
318 | changeset: 13:0aae7cf88f0d |
|
318 | changeset: 13:0aae7cf88f0d | |
319 | branch: stable |
|
319 | branch: stable | |
320 | tag: tip |
|
320 | tag: tip | |
321 | user: test |
|
321 | user: test | |
322 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
322 | date: Thu Jan 01 00:00:00 1970 +0000 | |
323 | summary: another change for branch stable |
|
323 | summary: another change for branch stable | |
324 |
|
324 | |||
325 | changeset: 10:a7949464abda |
|
325 | changeset: 10:a7949464abda | |
326 | user: test |
|
326 | user: test | |
327 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
327 | date: Thu Jan 01 00:00:00 1970 +0000 | |
328 | summary: test |
|
328 | summary: test | |
329 |
|
329 | |||
330 |
|
330 | |||
331 | Same revision checked out in repo a and ua: |
|
331 | Same revision checked out in repo a and ua: | |
332 |
|
332 | |||
333 | $ hg -R a parents --template "{node|short}\n" |
|
333 | $ hg -R a parents --template "{node|short}\n" | |
334 | e8ece76546a6 |
|
334 | e8ece76546a6 | |
335 | $ hg -R ua parents --template "{node|short}\n" |
|
335 | $ hg -R ua parents --template "{node|short}\n" | |
336 | e8ece76546a6 |
|
336 | e8ece76546a6 | |
337 |
|
337 | |||
338 | $ rm -r ua |
|
338 | $ rm -r ua | |
339 |
|
339 | |||
340 |
|
340 | |||
341 | Testing -u -r <branch>: |
|
341 | Testing -u -r <branch>: | |
342 |
|
342 | |||
343 | $ hg clone -u . -r stable a ua |
|
343 | $ hg clone -u . -r stable a ua | |
344 | requesting all changes |
|
344 | requesting all changes | |
345 | adding changesets |
|
345 | adding changesets | |
346 | adding manifests |
|
346 | adding manifests | |
347 | adding file changes |
|
347 | adding file changes | |
348 | added 14 changesets with 14 changes to 3 files |
|
348 | added 14 changesets with 14 changes to 3 files | |
349 | updating to branch stable |
|
349 | updating to branch stable | |
350 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
350 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
351 |
|
351 | |||
352 | Repo ua has branch 'stable' and 'default' (was changed in fd511e9eeea6): |
|
352 | Repo ua has branch 'stable' and 'default' (was changed in fd511e9eeea6): | |
353 |
|
353 | |||
354 | $ hg -R ua heads |
|
354 | $ hg -R ua heads | |
355 | changeset: 13:0aae7cf88f0d |
|
355 | changeset: 13:0aae7cf88f0d | |
356 | branch: stable |
|
356 | branch: stable | |
357 | tag: tip |
|
357 | tag: tip | |
358 | user: test |
|
358 | user: test | |
359 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
359 | date: Thu Jan 01 00:00:00 1970 +0000 | |
360 | summary: another change for branch stable |
|
360 | summary: another change for branch stable | |
361 |
|
361 | |||
362 | changeset: 10:a7949464abda |
|
362 | changeset: 10:a7949464abda | |
363 | user: test |
|
363 | user: test | |
364 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
364 | date: Thu Jan 01 00:00:00 1970 +0000 | |
365 | summary: test |
|
365 | summary: test | |
366 |
|
366 | |||
367 |
|
367 | |||
368 | Same revision checked out in repo a and ua: |
|
368 | Same revision checked out in repo a and ua: | |
369 |
|
369 | |||
370 | $ hg -R a parents --template "{node|short}\n" |
|
370 | $ hg -R a parents --template "{node|short}\n" | |
371 | e8ece76546a6 |
|
371 | e8ece76546a6 | |
372 | $ hg -R ua parents --template "{node|short}\n" |
|
372 | $ hg -R ua parents --template "{node|short}\n" | |
373 | e8ece76546a6 |
|
373 | e8ece76546a6 | |
374 |
|
374 | |||
375 | $ rm -r ua |
|
375 | $ rm -r ua | |
376 |
|
376 | |||
377 |
|
377 | |||
378 | Testing -r <branch>: |
|
378 | Testing -r <branch>: | |
379 |
|
379 | |||
380 | $ hg clone -r stable a ua |
|
380 | $ hg clone -r stable a ua | |
381 | requesting all changes |
|
381 | requesting all changes | |
382 | adding changesets |
|
382 | adding changesets | |
383 | adding manifests |
|
383 | adding manifests | |
384 | adding file changes |
|
384 | adding file changes | |
385 | added 14 changesets with 14 changes to 3 files |
|
385 | added 14 changesets with 14 changes to 3 files | |
386 | updating to branch stable |
|
386 | updating to branch stable | |
387 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
387 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
388 |
|
388 | |||
389 | Repo ua has branch 'stable' and 'default' (was changed in fd511e9eeea6): |
|
389 | Repo ua has branch 'stable' and 'default' (was changed in fd511e9eeea6): | |
390 |
|
390 | |||
391 | $ hg -R ua heads |
|
391 | $ hg -R ua heads | |
392 | changeset: 13:0aae7cf88f0d |
|
392 | changeset: 13:0aae7cf88f0d | |
393 | branch: stable |
|
393 | branch: stable | |
394 | tag: tip |
|
394 | tag: tip | |
395 | user: test |
|
395 | user: test | |
396 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
396 | date: Thu Jan 01 00:00:00 1970 +0000 | |
397 | summary: another change for branch stable |
|
397 | summary: another change for branch stable | |
398 |
|
398 | |||
399 | changeset: 10:a7949464abda |
|
399 | changeset: 10:a7949464abda | |
400 | user: test |
|
400 | user: test | |
401 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
401 | date: Thu Jan 01 00:00:00 1970 +0000 | |
402 | summary: test |
|
402 | summary: test | |
403 |
|
403 | |||
404 |
|
404 | |||
405 | Branch 'stable' is checked out: |
|
405 | Branch 'stable' is checked out: | |
406 |
|
406 | |||
407 | $ hg -R ua parents |
|
407 | $ hg -R ua parents | |
408 | changeset: 13:0aae7cf88f0d |
|
408 | changeset: 13:0aae7cf88f0d | |
409 | branch: stable |
|
409 | branch: stable | |
410 | tag: tip |
|
410 | tag: tip | |
411 | user: test |
|
411 | user: test | |
412 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
412 | date: Thu Jan 01 00:00:00 1970 +0000 | |
413 | summary: another change for branch stable |
|
413 | summary: another change for branch stable | |
414 |
|
414 | |||
415 |
|
415 | |||
416 | $ rm -r ua |
|
416 | $ rm -r ua | |
417 |
|
417 | |||
418 |
|
418 | |||
419 | Testing issue2267: |
|
419 | Testing issue2267: | |
420 |
|
420 | |||
421 | $ cat <<EOF > simpleclone.py |
|
421 | $ cat <<EOF > simpleclone.py | |
422 | > from mercurial import ui, hg |
|
422 | > from mercurial import ui, hg | |
423 | > myui = ui.ui() |
|
423 | > myui = ui.ui() | |
424 | > repo = hg.repository(myui, 'a') |
|
424 | > repo = hg.repository(myui, 'a') | |
425 | > hg.clone(myui, repo, dest="ua") |
|
425 | > hg.clone(myui, repo, dest="ua") | |
426 | > EOF |
|
426 | > EOF | |
427 |
|
427 | |||
428 | $ python simpleclone.py |
|
428 | $ python simpleclone.py | |
429 | updating to branch default |
|
429 | updating to branch default | |
430 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
430 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
431 |
|
431 | |||
432 | $ rm -r ua |
|
432 | $ rm -r ua | |
433 |
|
433 | |||
|
434 | cat <<EOF > branchclone.py | |||
|
435 | from mercurial import ui, hg | |||
|
436 | myui = ui.ui() | |||
|
437 | repo = hg.repository(myui, 'a') | |||
|
438 | hg.clone(myui, repo, dest="ua", branch=["stable",]) | |||
|
439 | EOF | |||
|
440 | ||||
|
441 | python branchclone.py | |||
|
442 | rm -r ua | |||
|
443 |
General Comments 0
You need to be logged in to leave comments.
Login now