Show More
@@ -121,10 +121,23 b' bundle <file> <other>::' | |||
|
121 | 121 | Unlike import/export, this exactly preserves all changeset |
|
122 | 122 | contents including permissions, rename data, and revision history. |
|
123 | 123 | |
|
124 | cat <file> [revision]:: | |
|
125 | Output to stdout the given revision for the specified file. | |
|
124 | cat [options] <file ...>:: | |
|
125 | Print the specified files as they were at the given revision. | |
|
126 | If no revision is given then the tip is used. | |
|
127 | ||
|
128 | Output may be to a file, in which case the name of the file is | |
|
129 | given using a format string. The formatting rules are the same as | |
|
130 | for the export command, with the following additions: | |
|
126 | 131 | |
|
127 | If no revision is given then the tip is used. | |
|
132 | %s basename of file being printed | |
|
133 | %d dirname of file being printed, or '.' if in repo root | |
|
134 | %p root-relative path name of file being printed | |
|
135 | ||
|
136 | options: | |
|
137 | -I, --include <pat> include names matching the given patterns | |
|
138 | -X, --exclude <pat> exclude names matching the given patterns | |
|
139 | -o, --output <filespec> print output to file with formatted name | |
|
140 | -r, --rev <rev> print the given revision | |
|
128 | 141 | |
|
129 | 142 | clone [-U] <source> [dest]:: |
|
130 | 143 | Create a copy of an existing repository in a new directory. |
@@ -176,9 +189,11 b' copy <source ...> <dest>::' | |||
|
176 | 189 | This command takes effect in the next commit. |
|
177 | 190 | |
|
178 | 191 | Options: |
|
179 | -A, --after record a copy that has already occurred | |
|
180 | -f, --force forcibly copy over an existing managed file | |
|
181 | -p, --parents append source path to dest | |
|
192 | -A, --after record a copy that has already occurred | |
|
193 | -I, --include <pat> include names matching the given patterns | |
|
194 | -X, --exclude <pat> exclude names matching the given patterns | |
|
195 | -f, --force forcibly copy over an existing managed file | |
|
196 | -p, --parents append source path to dest | |
|
182 | 197 | |
|
183 | 198 | aliases: cp |
|
184 | 199 | |
@@ -226,7 +241,7 b' export [-o filespec] [revision] ...::' | |||
|
226 | 241 | |
|
227 | 242 | options: |
|
228 | 243 | -a, --text treat all files as text |
|
229 |
-o, --output <filespec> print output to file with formatted name |
|
|
244 | -o, --output <filespec> print output to file with formatted name | |
|
230 | 245 | |
|
231 | 246 | forget [options] [files]:: |
|
232 | 247 | Undo an 'hg add' scheduled for the next commit. |
@@ -194,7 +194,7 b' def revrange(ui, repo, revs, revlog=None' | |||
|
194 | 194 | yield str(rev) |
|
195 | 195 | |
|
196 | 196 | def make_filename(repo, r, pat, node=None, |
|
197 | total=None, seqno=None, revwidth=None): | |
|
197 | total=None, seqno=None, revwidth=None, pathname=None): | |
|
198 | 198 | node_expander = { |
|
199 | 199 | 'H': lambda: hex(node), |
|
200 | 200 | 'R': lambda: str(r.rev(node)), |
@@ -216,6 +216,10 b' def make_filename(repo, r, pat, node=Non' | |||
|
216 | 216 | expander['n'] = lambda: str(seqno) |
|
217 | 217 | if total is not None and seqno is not None: |
|
218 | 218 | expander['n'] = lambda:str(seqno).zfill(len(str(total))) |
|
219 | if pathname is not None: | |
|
220 | expander['s'] = lambda: os.path.basename(pathname) | |
|
221 | expander['d'] = lambda: os.path.dirname(pathname) or '.' | |
|
222 | expander['p'] = lambda: pathname | |
|
219 | 223 | |
|
220 | 224 | newname = [] |
|
221 | 225 | patlen = len(pat) |
@@ -234,14 +238,15 b' def make_filename(repo, r, pat, node=Non' | |||
|
234 | 238 | inst.args[0]) |
|
235 | 239 | |
|
236 | 240 | def make_file(repo, r, pat, node=None, |
|
237 | total=None, seqno=None, revwidth=None, mode='wb'): | |
|
241 | total=None, seqno=None, revwidth=None, mode='wb', pathname=None): | |
|
238 | 242 | if not pat or pat == '-': |
|
239 | 243 | return 'w' in mode and sys.stdout or sys.stdin |
|
240 | 244 | if hasattr(pat, 'write') and 'w' in mode: |
|
241 | 245 | return pat |
|
242 | 246 | if hasattr(pat, 'read') and 'r' in mode: |
|
243 | 247 | return pat |
|
244 |
return open(make_filename(repo, r, pat, node, total, seqno, revwidth |
|
|
248 | return open(make_filename(repo, r, pat, node, total, seqno, revwidth, | |
|
249 | pathname), | |
|
245 | 250 | mode) |
|
246 | 251 | |
|
247 | 252 | def dodiff(fp, ui, repo, node1, node2, files=None, match=util.always, |
@@ -569,25 +574,26 b' def bundle(ui, repo, fname, dest="defaul' | |||
|
569 | 574 | except: |
|
570 | 575 | os.unlink(fname) |
|
571 | 576 | |
|
572 |
def cat(ui, repo, file1, |
|
|
573 |
"""output the latest or given revision of |
|
|
574 | r = repo.file(relpath(repo, [file1])[0]) | |
|
575 | if rev: | |
|
576 | try: | |
|
577 | # assume all revision numbers are for changesets | |
|
578 | n = repo.lookup(rev) | |
|
579 | change = repo.changelog.read(n) | |
|
580 | m = repo.manifest.read(change[0]) | |
|
581 | n = m[relpath(repo, [file1])[0]] | |
|
582 | except (hg.RepoError, KeyError): | |
|
577 | def cat(ui, repo, file1, *pats, **opts): | |
|
578 | """output the latest or given revisions of files""" | |
|
579 | mf = {} | |
|
580 | if opts['rev']: | |
|
581 | change = repo.changelog.read(repo.lookup(opts['rev'])) | |
|
582 | mf = repo.manifest.read(change[0]) | |
|
583 | for src, abs, rel, exact in walk(repo, (file1,) + pats, opts): | |
|
584 | r = repo.file(abs) | |
|
585 | if opts['rev']: | |
|
583 | 586 | try: |
|
584 |
n = |
|
|
585 |
except |
|
|
586 | raise util.Abort('cannot find file %s in rev %s', file1, rev) | |
|
587 | else: | |
|
588 | n = r.tip() | |
|
589 | fp = make_file(repo, r, opts['output'], node=n) | |
|
590 | fp.write(r.read(n)) | |
|
587 | n = mf[abs] | |
|
588 | except (hg.RepoError, KeyError): | |
|
589 | try: | |
|
590 | n = r.lookup(rev) | |
|
591 | except KeyError, inst: | |
|
592 | raise util.Abort('cannot find file %s in rev %s', rel, rev) | |
|
593 | else: | |
|
594 | n = r.tip() | |
|
595 | fp = make_file(repo, r, opts['output'], node=n, pathname=abs) | |
|
596 | fp.write(r.read(n)) | |
|
591 | 597 | |
|
592 | 598 | def clone(ui, source, dest=None, **opts): |
|
593 | 599 | """make a copy of an existing repository""" |
@@ -1765,8 +1771,11 b' table = {' | |||
|
1765 | 1771 | 'hg bundle FILE DEST'), |
|
1766 | 1772 | "cat": |
|
1767 | 1773 | (cat, |
|
1768 | [('o', 'output', "", 'output to file')], | |
|
1769 | 'hg cat [-o OUTFILE] FILE [REV]'), | |
|
1774 | [('I', 'include', [], 'include path in search'), | |
|
1775 | ('X', 'exclude', [], 'exclude path from search'), | |
|
1776 | ('o', 'output', "", 'output to file'), | |
|
1777 | ('r', 'rev', '', 'revision')], | |
|
1778 | 'hg cat [OPTION]... FILE...'), | |
|
1770 | 1779 | "^clone": |
|
1771 | 1780 | (clone, |
|
1772 | 1781 | [('U', 'noupdate', None, 'skip update after cloning'), |
@@ -40,7 +40,7 b' list of commands (use "hg help -v" to sh' | |||
|
40 | 40 | addremove add all new files, delete all missing files |
|
41 | 41 | annotate show changeset information per file line |
|
42 | 42 | bundle create a changegroup file |
|
43 |
cat output the latest or given revision of |
|
|
43 | cat output the latest or given revisions of files | |
|
44 | 44 | clone make a copy of an existing repository |
|
45 | 45 | commit commit the specified files or all outstanding changes |
|
46 | 46 | copy mark files as copied for the next commit |
@@ -82,7 +82,7 b' list of commands (use "hg help -v" to sh' | |||
|
82 | 82 | addremove add all new files, delete all missing files |
|
83 | 83 | annotate show changeset information per file line |
|
84 | 84 | bundle create a changegroup file |
|
85 |
cat output the latest or given revision of |
|
|
85 | cat output the latest or given revisions of files | |
|
86 | 86 | clone make a copy of an existing repository |
|
87 | 87 | commit commit the specified files or all outstanding changes |
|
88 | 88 | copy mark files as copied for the next commit |
General Comments 0
You need to be logged in to leave comments.
Login now