##// 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 cat <file> [revision]::
73 cat <file> [revision]::
74 Output the given revision or tip of the specified file to stdout.
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 commit [-A -t -l <file> -t <text> -u <user> -d <datecode>] [files...]::
94 commit [-A -t -l <file> -t <text> -u <user> -d <datecode>] [files...]::
77 Commit all changed files in the working dir to the repository. This uses
95 Commit all changed files in the working dir to the repository. This uses
78 the EDITOR environment variable to bring up an editor to add a commit
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 init [-u] [source]::
152 init [-u] [source]::
135 Initialize a repository in the current directory.
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 If a source is specified, pull that source into the repository.
158 If a source is specified, pull that source into the repository.
138 This source is added to .hg/hgrc as the default for future pulls
159 This source is added to .hg/hgrc as the default for future pulls
139 in this repository.
160 in this repository.
@@ -259,6 +259,50 b' def cat(ui, repo, file, rev = []):'
259 if rev: n = r.lookup(rev)
259 if rev: n = r.lookup(rev)
260 sys.stdout.write(r.read(n))
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 def commit(ui, repo, *files, **opts):
306 def commit(ui, repo, *files, **opts):
263 """commit the specified files or all outstanding changes"""
307 """commit the specified files or all outstanding changes"""
264 text = opts['text']
308 text = opts['text']
@@ -444,42 +488,12 b' def import_(ui, repo, patch1, *patches, '
444 repo.commit(files, text)
488 repo.commit(files, text)
445
489
446 def init(ui, source=None, **opts):
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 if source:
493 if source:
450 paths = {}
494 ui.warn("this use of init is deprecated: use \"hg clone\" instead\n")
451 for name, path in ui.configitems("paths"):
495 opts['no-update'] = not opts['update']
452 paths[name] = path
496 clone(ui, source, None, **opts)
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)
483 else:
497 else:
484 repo = hg.repository(ui, ".", create=1)
498 repo = hg.repository(ui, ".", create=1)
485
499
@@ -707,6 +721,8 b' table = {'
707 ('c', 'changeset', None, 'show changeset')],
721 ('c', 'changeset', None, 'show changeset')],
708 'hg annotate [-u] [-c] [-n] [-r id] [files]'),
722 'hg annotate [-u] [-c] [-n] [-r id] [files]'),
709 "cat": (cat, [], 'hg cat <file> [rev]'),
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 "commit|ci": (commit,
726 "commit|ci": (commit,
711 [('t', 'text', "", 'commit text'),
727 [('t', 'text', "", 'commit text'),
712 ('A', 'addremove', None, 'run add/remove during commit'),
728 ('A', 'addremove', None, 'run add/remove during commit'),
@@ -773,7 +789,7 b' table = {'
773 "version": (show_version, [], 'hg version'),
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 def find(cmd):
794 def find(cmd):
779 for e in table.keys():
795 for e in table.keys():
@@ -1,8 +1,7 b''
1 #!/bin/bash
1 #!/bin/bash
2
2
3 mkdir copy
3 hg clone http://localhost:20059/ copy
4 cd copy
4 cd copy
5 hg init http://localhost:20059/
6 hg verify
5 hg verify
7 hg co
6 hg co
8 cat foo
7 cat foo
@@ -23,9 +22,8 b' EOF'
23
22
24 python dumb.py 2>/dev/null &
23 python dumb.py 2>/dev/null &
25
24
26 mkdir copy2
25 hg clone http://localhost:20059/foo copy2
27 cd copy2
26 cd copy2
28 hg init http://localhost:20059/foo
29 hg verify
27 hg verify
30 hg co
28 hg co
31 cat foo
29 cat foo
@@ -5,6 +5,7 b' hg commands:'
5 addremove add all new files, delete all missing files
5 addremove add all new files, delete all missing files
6 annotate show changeset information per file line
6 annotate show changeset information per file line
7 cat output the latest or given revision of a file
7 cat output the latest or given revision of a file
8 clone make a copy of an existing repository
8 commit commit the specified files or all outstanding changes
9 commit commit the specified files or all outstanding changes
9 copy mark a file as copied or renamed for the next commit
10 copy mark a file as copied or renamed for the next commit
10 diff diff working directory (or selected files)
11 diff diff working directory (or selected files)
@@ -15,7 +16,7 b' hg commands:'
15 history show the changelog history
16 history show the changelog history
16 identify print information about the working copy
17 identify print information about the working copy
17 import import an ordered set of patches
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 log show the revision history of a single file
20 log show the revision history of a single file
20 manifest output the latest or given revision of the project manifest
21 manifest output the latest or given revision of the project manifest
21 parents show the parents of the current working dir
22 parents show the parents of the current working dir
@@ -56,6 +57,7 b' hg commands:'
56 addremove add all new files, delete all missing files
57 addremove add all new files, delete all missing files
57 annotate show changeset information per file line
58 annotate show changeset information per file line
58 cat output the latest or given revision of a file
59 cat output the latest or given revision of a file
60 clone make a copy of an existing repository
59 commit commit the specified files or all outstanding changes
61 commit commit the specified files or all outstanding changes
60 copy mark a file as copied or renamed for the next commit
62 copy mark a file as copied or renamed for the next commit
61 diff diff working directory (or selected files)
63 diff diff working directory (or selected files)
@@ -66,7 +68,7 b' hg commands:'
66 history show the changelog history
68 history show the changelog history
67 identify print information about the working copy
69 identify print information about the working copy
68 import import an ordered set of patches
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 log show the revision history of a single file
72 log show the revision history of a single file
71 manifest output the latest or given revision of the project manifest
73 manifest output the latest or given revision of the project manifest
72 parents show the parents of the current working dir
74 parents show the parents of the current working dir
@@ -10,9 +10,8 b' hg verify'
10 hg serve -p 20059 2>/dev/null &
10 hg serve -p 20059 2>/dev/null &
11 cd ..
11 cd ..
12
12
13 mkdir copy
13 hg clone http://localhost:20059/ copy
14 cd copy
14 cd copy
15 hg init http://localhost:20059/
16 hg verify
15 hg verify
17 hg co
16 hg co
18 cat foo
17 cat foo
@@ -9,11 +9,9 b' hg init'
9 hg addremove
9 hg addremove
10 hg commit -t "1"
10 hg commit -t "1"
11 hg verify
11 hg verify
12 cd ..
13
12
14 mkdir branch
13 hg clone . ../branch
15 cd branch
14 cd ../branch
16 hg init ../test
17 hg co
15 hg co
18 echo bar>>foo
16 echo bar>>foo
19 hg commit -t "2"
17 hg commit -t "2"
@@ -23,4 +21,4 b' hg pull ../branch'
23 hg verify
21 hg verify
24 hg co
22 hg co
25 cat foo
23 cat foo
26 hg manifest No newline at end of file
24 hg manifest
@@ -10,10 +10,8 b' checking manifests'
10 crosschecking files in changesets and manifests
10 crosschecking files in changesets and manifests
11 checking files
11 checking files
12 1 files, 1 changesets, 1 total revisions
12 1 files, 1 changesets, 1 total revisions
13 + cd ..
13 + hg clone . ../branch
14 + mkdir branch
14 + cd ../branch
15 + cd branch
16 + hg init ../test
17 + hg co
15 + hg co
18 + echo bar
16 + echo bar
19 + hg commit -t 2
17 + hg commit -t 2
@@ -43,5 +43,5 b' c8edf04160c7 tip'
43 + hg id
43 + hg id
44 c8edf04160c7+b9154636be93+ tip
44 c8edf04160c7+b9154636be93+ tip
45 + hg status
45 + hg status
46 C .hgtags
46 C a
47 C a
47 C .hgtags
@@ -10,10 +10,8 b' echo a > a'
10 hg addremove
10 hg addremove
11 hg commit -t "1" -u test -d "0 0"
11 hg commit -t "1" -u test -d "0 0"
12
12
13 cd ..
13 hg clone . ../r2
14 mkdir r2
14 cd ../r2
15 cd r2
16 hg init ../r1
17 hg up
15 hg up
18 echo abc > a
16 echo abc > a
19 hg diff > ../d
17 hg diff > ../d
@@ -4,10 +4,8 b''
4 + echo a
4 + echo a
5 + hg addremove
5 + hg addremove
6 + hg commit -t 1 -u test -d '0 0'
6 + hg commit -t 1 -u test -d '0 0'
7 + cd ..
7 + hg clone . ../r2
8 + mkdir r2
8 + cd ../r2
9 + cd r2
10 + hg init ../r1
11 + hg up
9 + hg up
12 + echo abc
10 + echo abc
13 + hg diff
11 + hg diff
General Comments 0
You need to be logged in to leave comments. Login now