##// END OF EJS Templates
[PATCH] add clone command...
mpm@selenic.com -
r485:c5705ab9 default
parent child Browse files
Show More
@@ -73,6 +73,24 b' annotate [-r <rev> -u -n -c] [files ...]'
73 73 cat <file> [revision]::
74 74 Output the given revision or tip of the specified file to stdout.
75 75
76 clone [-U] <source> [dest]::
77 Create a new copy of an existing repository.
78
79 If the specified source is on the same filesystem, the repository
80 will be copied via hardlinks. This is the fastest and most
81 space-efficient mode of operation.
82
83 If the destination directory is not specified, it defaults to the
84 current directory.
85
86 If the destination is specified, but does not exist, it is created.
87
88 The source is added to .hg/hgrc in the new copy as the default for
89 future pulls.
90
91 options:
92 -U, --no-update do not update the new working directory
93
76 94 commit [-A -t -l <file> -t <text> -u <user> -d <datecode>] [files...]::
77 95 Commit all changed files in the working dir to the repository. This uses
78 96 the EDITOR environment variable to bring up an editor to add a commit
@@ -134,6 +152,9 b' import [-p <n> -b <base> -q] <patches>::'
134 152 init [-u] [source]::
135 153 Initialize a repository in the current directory.
136 154
155 NOTE: The following use is deprecated, and will be removed soon;
156 use the "hg clone" command instead.
157
137 158 If a source is specified, pull that source into the repository.
138 159 This source is added to .hg/hgrc as the default for future pulls
139 160 in this repository.
@@ -259,6 +259,50 b' def cat(ui, repo, file, rev = []):'
259 259 if rev: n = r.lookup(rev)
260 260 sys.stdout.write(r.read(n))
261 261
262 def clone(ui, source, dest = None, **opts):
263 """make a copy of an existing repository"""
264 paths = {}
265 for name, path in ui.configitems("paths"):
266 paths[name] = path
267
268 if source in paths: source = paths[source]
269
270 if dest is None:
271 dest = os.getcwd()
272 elif not os.path.exists(dest):
273 os.makedirs(dest)
274
275 link = 0
276 if not source.startswith("http://"):
277 source = os.path.realpath(source)
278 d1 = os.stat(dest).st_dev
279 d2 = os.stat(source).st_dev
280 if d1 == d2: link = 1
281
282 os.chdir(dest)
283
284 if link:
285 ui.debug("copying by hardlink\n")
286 os.system("cp -al %s/.hg .hg" % source)
287 try:
288 os.remove(".hg/dirstate")
289 except: pass
290
291 repo = hg.repository(ui, ".")
292
293 else:
294 repo = hg.repository(ui, ".", create=1)
295 other = hg.repository(ui, source)
296 cg = repo.getchangegroup(other)
297 repo.addchangegroup(cg)
298
299 f = repo.opener("hgrc", "w")
300 f.write("[paths]\n")
301 f.write("default = %s\n" % source)
302
303 if not opts['no-update']:
304 update(ui, repo)
305
262 306 def commit(ui, repo, *files, **opts):
263 307 """commit the specified files or all outstanding changes"""
264 308 text = opts['text']
@@ -444,42 +488,12 b' def import_(ui, repo, patch1, *patches, '
444 488 repo.commit(files, text)
445 489
446 490 def init(ui, source=None, **opts):
447 """create a new repository or copy an existing one"""
491 """create a new repository or (deprecated, use clone) copy an existing one"""
448 492
449 493 if source:
450 paths = {}
451 for name, path in ui.configitems("paths"):
452 paths[name] = path
453
454 if source in paths: source = paths[source]
455
456 link = 0
457 if not source.startswith("http://"):
458 d1 = os.stat(os.getcwd()).st_dev
459 d2 = os.stat(source).st_dev
460 if d1 == d2: link = 1
461
462 if link:
463 ui.debug("copying by hardlink\n")
464 os.system("cp -al %s/.hg .hg" % source)
465 try:
466 os.remove(".hg/dirstate")
467 except: pass
468
469 repo = hg.repository(ui, ".")
470
471 else:
472 repo = hg.repository(ui, ".", create=1)
473 other = hg.repository(ui, source)
474 cg = repo.getchangegroup(other)
475 repo.addchangegroup(cg)
476
477 f = repo.opener("hgrc", "w")
478 f.write("[paths]\n")
479 f.write("default = %s\n" % source)
480
481 if opts['update']:
482 update(ui, repo)
494 ui.warn("this use of init is deprecated: use \"hg clone\" instead\n")
495 opts['no-update'] = not opts['update']
496 clone(ui, source, None, **opts)
483 497 else:
484 498 repo = hg.repository(ui, ".", create=1)
485 499
@@ -707,6 +721,8 b' table = {'
707 721 ('c', 'changeset', None, 'show changeset')],
708 722 'hg annotate [-u] [-c] [-n] [-r id] [files]'),
709 723 "cat": (cat, [], 'hg cat <file> [rev]'),
724 "clone": (clone, [('U', 'no-update', None, 'skip update after cloning')],
725 'hg clone [options] <source> [dest]'),
710 726 "commit|ci": (commit,
711 727 [('t', 'text', "", 'commit text'),
712 728 ('A', 'addremove', None, 'run add/remove during commit'),
@@ -773,7 +789,7 b' table = {'
773 789 "version": (show_version, [], 'hg version'),
774 790 }
775 791
776 norepo = "init version help debugindex debugindexdot"
792 norepo = "clone init version help debugindex debugindexdot"
777 793
778 794 def find(cmd):
779 795 for e in table.keys():
@@ -1,8 +1,7 b''
1 1 #!/bin/bash
2 2
3 mkdir copy
3 hg clone http://localhost:20059/ copy
4 4 cd copy
5 hg init http://localhost:20059/
6 5 hg verify
7 6 hg co
8 7 cat foo
@@ -23,9 +22,8 b' EOF'
23 22
24 23 python dumb.py 2>/dev/null &
25 24
26 mkdir copy2
25 hg clone http://localhost:20059/foo copy2
27 26 cd copy2
28 hg init http://localhost:20059/foo
29 27 hg verify
30 28 hg co
31 29 cat foo
@@ -5,6 +5,7 b' hg commands:'
5 5 addremove add all new files, delete all missing files
6 6 annotate show changeset information per file line
7 7 cat output the latest or given revision of a file
8 clone make a copy of an existing repository
8 9 commit commit the specified files or all outstanding changes
9 10 copy mark a file as copied or renamed for the next commit
10 11 diff diff working directory (or selected files)
@@ -15,7 +16,7 b' hg commands:'
15 16 history show the changelog history
16 17 identify print information about the working copy
17 18 import import an ordered set of patches
18 init create a new repository or copy an existing one
19 init create a new repository or (deprecated, use clone) copy an existing one
19 20 log show the revision history of a single file
20 21 manifest output the latest or given revision of the project manifest
21 22 parents show the parents of the current working dir
@@ -56,6 +57,7 b' hg commands:'
56 57 addremove add all new files, delete all missing files
57 58 annotate show changeset information per file line
58 59 cat output the latest or given revision of a file
60 clone make a copy of an existing repository
59 61 commit commit the specified files or all outstanding changes
60 62 copy mark a file as copied or renamed for the next commit
61 63 diff diff working directory (or selected files)
@@ -66,7 +68,7 b' hg commands:'
66 68 history show the changelog history
67 69 identify print information about the working copy
68 70 import import an ordered set of patches
69 init create a new repository or copy an existing one
71 init create a new repository or (deprecated, use clone) copy an existing one
70 72 log show the revision history of a single file
71 73 manifest output the latest or given revision of the project manifest
72 74 parents show the parents of the current working dir
@@ -10,9 +10,8 b' hg verify'
10 10 hg serve -p 20059 2>/dev/null &
11 11 cd ..
12 12
13 mkdir copy
13 hg clone http://localhost:20059/ copy
14 14 cd copy
15 hg init http://localhost:20059/
16 15 hg verify
17 16 hg co
18 17 cat foo
@@ -9,11 +9,9 b' hg init'
9 9 hg addremove
10 10 hg commit -t "1"
11 11 hg verify
12 cd ..
13 12
14 mkdir branch
15 cd branch
16 hg init ../test
13 hg clone . ../branch
14 cd ../branch
17 15 hg co
18 16 echo bar>>foo
19 17 hg commit -t "2"
@@ -23,4 +21,4 b' hg pull ../branch'
23 21 hg verify
24 22 hg co
25 23 cat foo
26 hg manifest No newline at end of file
24 hg manifest
@@ -10,10 +10,8 b' checking manifests'
10 10 crosschecking files in changesets and manifests
11 11 checking files
12 12 1 files, 1 changesets, 1 total revisions
13 + cd ..
14 + mkdir branch
15 + cd branch
16 + hg init ../test
13 + hg clone . ../branch
14 + cd ../branch
17 15 + hg co
18 16 + echo bar
19 17 + hg commit -t 2
@@ -43,5 +43,5 b' c8edf04160c7 tip'
43 43 + hg id
44 44 c8edf04160c7+b9154636be93+ tip
45 45 + hg status
46 C .hgtags
46 47 C a
47 C .hgtags
@@ -10,10 +10,8 b' echo a > a'
10 10 hg addremove
11 11 hg commit -t "1" -u test -d "0 0"
12 12
13 cd ..
14 mkdir r2
15 cd r2
16 hg init ../r1
13 hg clone . ../r2
14 cd ../r2
17 15 hg up
18 16 echo abc > a
19 17 hg diff > ../d
@@ -4,10 +4,8 b''
4 4 + echo a
5 5 + hg addremove
6 6 + hg commit -t 1 -u test -d '0 0'
7 + cd ..
8 + mkdir r2
9 + cd r2
10 + hg init ../r1
7 + hg clone . ../r2
8 + cd ../r2
11 9 + hg up
12 10 + echo abc
13 11 + hg diff
General Comments 0
You need to be logged in to leave comments. Login now