Show More
@@ -1,2923 +1,2923 | |||||
1 | # commands.py - command processing for mercurial |
|
1 | # commands.py - command processing for mercurial | |
2 | # |
|
2 | # | |
3 | # Copyright 2005 Matt Mackall <mpm@selenic.com> |
|
3 | # Copyright 2005 Matt Mackall <mpm@selenic.com> | |
4 | # |
|
4 | # | |
5 | # This software may be used and distributed according to the terms |
|
5 | # This software may be used and distributed according to the terms | |
6 | # of the GNU General Public License, incorporated herein by reference. |
|
6 | # of the GNU General Public License, incorporated herein by reference. | |
7 |
|
7 | |||
8 | from demandload import demandload |
|
8 | from demandload import demandload | |
9 | from node import * |
|
9 | from node import * | |
10 | from i18n import gettext as _ |
|
10 | from i18n import gettext as _ | |
11 | demandload(globals(), "os re sys signal shutil imp urllib pdb") |
|
11 | demandload(globals(), "os re sys signal shutil imp urllib pdb") | |
12 | demandload(globals(), "fancyopts ui hg util lock revlog") |
|
12 | demandload(globals(), "fancyopts ui hg util lock revlog") | |
13 | demandload(globals(), "fnmatch hgweb mdiff random signal time traceback") |
|
13 | demandload(globals(), "fnmatch hgweb mdiff random signal time traceback") | |
14 | demandload(globals(), "errno socket version struct atexit sets bz2") |
|
14 | demandload(globals(), "errno socket version struct atexit sets bz2") | |
15 |
|
15 | |||
16 | class UnknownCommand(Exception): |
|
16 | class UnknownCommand(Exception): | |
17 | """Exception raised if command is not in the command table.""" |
|
17 | """Exception raised if command is not in the command table.""" | |
18 | class AmbiguousCommand(Exception): |
|
18 | class AmbiguousCommand(Exception): | |
19 | """Exception raised if command shortcut matches more than one command.""" |
|
19 | """Exception raised if command shortcut matches more than one command.""" | |
20 |
|
20 | |||
21 | def filterfiles(filters, files): |
|
21 | def filterfiles(filters, files): | |
22 | l = [x for x in files if x in filters] |
|
22 | l = [x for x in files if x in filters] | |
23 |
|
23 | |||
24 | for t in filters: |
|
24 | for t in filters: | |
25 | if t and t[-1] != "/": |
|
25 | if t and t[-1] != "/": | |
26 | t += "/" |
|
26 | t += "/" | |
27 | l += [x for x in files if x.startswith(t)] |
|
27 | l += [x for x in files if x.startswith(t)] | |
28 | return l |
|
28 | return l | |
29 |
|
29 | |||
30 | def relpath(repo, args): |
|
30 | def relpath(repo, args): | |
31 | cwd = repo.getcwd() |
|
31 | cwd = repo.getcwd() | |
32 | if cwd: |
|
32 | if cwd: | |
33 | return [util.normpath(os.path.join(cwd, x)) for x in args] |
|
33 | return [util.normpath(os.path.join(cwd, x)) for x in args] | |
34 | return args |
|
34 | return args | |
35 |
|
35 | |||
36 | def matchpats(repo, pats=[], opts={}, head=''): |
|
36 | def matchpats(repo, pats=[], opts={}, head=''): | |
37 | cwd = repo.getcwd() |
|
37 | cwd = repo.getcwd() | |
38 | if not pats and cwd: |
|
38 | if not pats and cwd: | |
39 | opts['include'] = [os.path.join(cwd, i) for i in opts['include']] |
|
39 | opts['include'] = [os.path.join(cwd, i) for i in opts['include']] | |
40 | opts['exclude'] = [os.path.join(cwd, x) for x in opts['exclude']] |
|
40 | opts['exclude'] = [os.path.join(cwd, x) for x in opts['exclude']] | |
41 | cwd = '' |
|
41 | cwd = '' | |
42 | return util.cmdmatcher(repo.root, cwd, pats or ['.'], opts.get('include'), |
|
42 | return util.cmdmatcher(repo.root, cwd, pats or ['.'], opts.get('include'), | |
43 | opts.get('exclude'), head) |
|
43 | opts.get('exclude'), head) | |
44 |
|
44 | |||
45 | def makewalk(repo, pats, opts, node=None, head=''): |
|
45 | def makewalk(repo, pats, opts, node=None, head=''): | |
46 | files, matchfn, anypats = matchpats(repo, pats, opts, head) |
|
46 | files, matchfn, anypats = matchpats(repo, pats, opts, head) | |
47 | exact = dict(zip(files, files)) |
|
47 | exact = dict(zip(files, files)) | |
48 | def walk(): |
|
48 | def walk(): | |
49 | for src, fn in repo.walk(node=node, files=files, match=matchfn): |
|
49 | for src, fn in repo.walk(node=node, files=files, match=matchfn): | |
50 | yield src, fn, util.pathto(repo.getcwd(), fn), fn in exact |
|
50 | yield src, fn, util.pathto(repo.getcwd(), fn), fn in exact | |
51 | return files, matchfn, walk() |
|
51 | return files, matchfn, walk() | |
52 |
|
52 | |||
53 | def walk(repo, pats, opts, node=None, head=''): |
|
53 | def walk(repo, pats, opts, node=None, head=''): | |
54 | files, matchfn, results = makewalk(repo, pats, opts, node, head) |
|
54 | files, matchfn, results = makewalk(repo, pats, opts, node, head) | |
55 | for r in results: |
|
55 | for r in results: | |
56 | yield r |
|
56 | yield r | |
57 |
|
57 | |||
58 | def walkchangerevs(ui, repo, pats, opts): |
|
58 | def walkchangerevs(ui, repo, pats, opts): | |
59 | '''Iterate over files and the revs they changed in. |
|
59 | '''Iterate over files and the revs they changed in. | |
60 |
|
60 | |||
61 | Callers most commonly need to iterate backwards over the history |
|
61 | Callers most commonly need to iterate backwards over the history | |
62 | it is interested in. Doing so has awful (quadratic-looking) |
|
62 | it is interested in. Doing so has awful (quadratic-looking) | |
63 | performance, so we use iterators in a "windowed" way. |
|
63 | performance, so we use iterators in a "windowed" way. | |
64 |
|
64 | |||
65 | We walk a window of revisions in the desired order. Within the |
|
65 | We walk a window of revisions in the desired order. Within the | |
66 | window, we first walk forwards to gather data, then in the desired |
|
66 | window, we first walk forwards to gather data, then in the desired | |
67 | order (usually backwards) to display it. |
|
67 | order (usually backwards) to display it. | |
68 |
|
68 | |||
69 | This function returns an (iterator, getchange, matchfn) tuple. The |
|
69 | This function returns an (iterator, getchange, matchfn) tuple. The | |
70 | getchange function returns the changelog entry for a numeric |
|
70 | getchange function returns the changelog entry for a numeric | |
71 | revision. The iterator yields 3-tuples. They will be of one of |
|
71 | revision. The iterator yields 3-tuples. They will be of one of | |
72 | the following forms: |
|
72 | the following forms: | |
73 |
|
73 | |||
74 | "window", incrementing, lastrev: stepping through a window, |
|
74 | "window", incrementing, lastrev: stepping through a window, | |
75 | positive if walking forwards through revs, last rev in the |
|
75 | positive if walking forwards through revs, last rev in the | |
76 | sequence iterated over - use to reset state for the current window |
|
76 | sequence iterated over - use to reset state for the current window | |
77 |
|
77 | |||
78 | "add", rev, fns: out-of-order traversal of the given file names |
|
78 | "add", rev, fns: out-of-order traversal of the given file names | |
79 | fns, which changed during revision rev - use to gather data for |
|
79 | fns, which changed during revision rev - use to gather data for | |
80 | possible display |
|
80 | possible display | |
81 |
|
81 | |||
82 | "iter", rev, None: in-order traversal of the revs earlier iterated |
|
82 | "iter", rev, None: in-order traversal of the revs earlier iterated | |
83 | over with "add" - use to display data''' |
|
83 | over with "add" - use to display data''' | |
84 |
|
84 | |||
85 | def increasing_windows(start, end, windowsize=8, sizelimit=512): |
|
85 | def increasing_windows(start, end, windowsize=8, sizelimit=512): | |
86 | if start < end: |
|
86 | if start < end: | |
87 | while start < end: |
|
87 | while start < end: | |
88 | yield start, min(windowsize, end-start) |
|
88 | yield start, min(windowsize, end-start) | |
89 | start += windowsize |
|
89 | start += windowsize | |
90 | if windowsize < sizelimit: |
|
90 | if windowsize < sizelimit: | |
91 | windowsize *= 2 |
|
91 | windowsize *= 2 | |
92 | else: |
|
92 | else: | |
93 | while start > end: |
|
93 | while start > end: | |
94 | yield start, min(windowsize, start-end-1) |
|
94 | yield start, min(windowsize, start-end-1) | |
95 | start -= windowsize |
|
95 | start -= windowsize | |
96 | if windowsize < sizelimit: |
|
96 | if windowsize < sizelimit: | |
97 | windowsize *= 2 |
|
97 | windowsize *= 2 | |
98 |
|
98 | |||
99 |
|
99 | |||
100 | files, matchfn, anypats = matchpats(repo, pats, opts) |
|
100 | files, matchfn, anypats = matchpats(repo, pats, opts) | |
101 |
|
101 | |||
102 | if repo.changelog.count() == 0: |
|
102 | if repo.changelog.count() == 0: | |
103 | return [], False, matchfn |
|
103 | return [], False, matchfn | |
104 |
|
104 | |||
105 | revs = map(int, revrange(ui, repo, opts['rev'] or ['tip:0'])) |
|
105 | revs = map(int, revrange(ui, repo, opts['rev'] or ['tip:0'])) | |
106 | wanted = {} |
|
106 | wanted = {} | |
107 | slowpath = anypats |
|
107 | slowpath = anypats | |
108 | fncache = {} |
|
108 | fncache = {} | |
109 |
|
109 | |||
110 | chcache = {} |
|
110 | chcache = {} | |
111 | def getchange(rev): |
|
111 | def getchange(rev): | |
112 | ch = chcache.get(rev) |
|
112 | ch = chcache.get(rev) | |
113 | if ch is None: |
|
113 | if ch is None: | |
114 | chcache[rev] = ch = repo.changelog.read(repo.lookup(str(rev))) |
|
114 | chcache[rev] = ch = repo.changelog.read(repo.lookup(str(rev))) | |
115 | return ch |
|
115 | return ch | |
116 |
|
116 | |||
117 | if not slowpath and not files: |
|
117 | if not slowpath and not files: | |
118 | # No files, no patterns. Display all revs. |
|
118 | # No files, no patterns. Display all revs. | |
119 | wanted = dict(zip(revs, revs)) |
|
119 | wanted = dict(zip(revs, revs)) | |
120 | if not slowpath: |
|
120 | if not slowpath: | |
121 | # Only files, no patterns. Check the history of each file. |
|
121 | # Only files, no patterns. Check the history of each file. | |
122 | def filerevgen(filelog): |
|
122 | def filerevgen(filelog): | |
123 | for i, window in increasing_windows(filelog.count()-1, -1): |
|
123 | for i, window in increasing_windows(filelog.count()-1, -1): | |
124 | revs = [] |
|
124 | revs = [] | |
125 | for j in xrange(i - window, i + 1): |
|
125 | for j in xrange(i - window, i + 1): | |
126 | revs.append(filelog.linkrev(filelog.node(j))) |
|
126 | revs.append(filelog.linkrev(filelog.node(j))) | |
127 | revs.reverse() |
|
127 | revs.reverse() | |
128 | for rev in revs: |
|
128 | for rev in revs: | |
129 | yield rev |
|
129 | yield rev | |
130 |
|
130 | |||
131 | minrev, maxrev = min(revs), max(revs) |
|
131 | minrev, maxrev = min(revs), max(revs) | |
132 | for file_ in files: |
|
132 | for file_ in files: | |
133 | filelog = repo.file(file_) |
|
133 | filelog = repo.file(file_) | |
134 | # A zero count may be a directory or deleted file, so |
|
134 | # A zero count may be a directory or deleted file, so | |
135 | # try to find matching entries on the slow path. |
|
135 | # try to find matching entries on the slow path. | |
136 | if filelog.count() == 0: |
|
136 | if filelog.count() == 0: | |
137 | slowpath = True |
|
137 | slowpath = True | |
138 | break |
|
138 | break | |
139 | for rev in filerevgen(filelog): |
|
139 | for rev in filerevgen(filelog): | |
140 | if rev <= maxrev: |
|
140 | if rev <= maxrev: | |
141 | if rev < minrev: |
|
141 | if rev < minrev: | |
142 | break |
|
142 | break | |
143 | fncache.setdefault(rev, []) |
|
143 | fncache.setdefault(rev, []) | |
144 | fncache[rev].append(file_) |
|
144 | fncache[rev].append(file_) | |
145 | wanted[rev] = 1 |
|
145 | wanted[rev] = 1 | |
146 | if slowpath: |
|
146 | if slowpath: | |
147 | # The slow path checks files modified in every changeset. |
|
147 | # The slow path checks files modified in every changeset. | |
148 | def changerevgen(): |
|
148 | def changerevgen(): | |
149 | for i, window in increasing_windows(repo.changelog.count()-1, -1): |
|
149 | for i, window in increasing_windows(repo.changelog.count()-1, -1): | |
150 | for j in xrange(i - window, i + 1): |
|
150 | for j in xrange(i - window, i + 1): | |
151 | yield j, getchange(j)[3] |
|
151 | yield j, getchange(j)[3] | |
152 |
|
152 | |||
153 | for rev, changefiles in changerevgen(): |
|
153 | for rev, changefiles in changerevgen(): | |
154 | matches = filter(matchfn, changefiles) |
|
154 | matches = filter(matchfn, changefiles) | |
155 | if matches: |
|
155 | if matches: | |
156 | fncache[rev] = matches |
|
156 | fncache[rev] = matches | |
157 | wanted[rev] = 1 |
|
157 | wanted[rev] = 1 | |
158 |
|
158 | |||
159 | def iterate(): |
|
159 | def iterate(): | |
160 | for i, window in increasing_windows(0, len(revs)): |
|
160 | for i, window in increasing_windows(0, len(revs)): | |
161 | yield 'window', revs[0] < revs[-1], revs[-1] |
|
161 | yield 'window', revs[0] < revs[-1], revs[-1] | |
162 | nrevs = [rev for rev in revs[i:i+window] |
|
162 | nrevs = [rev for rev in revs[i:i+window] | |
163 | if rev in wanted] |
|
163 | if rev in wanted] | |
164 | srevs = list(nrevs) |
|
164 | srevs = list(nrevs) | |
165 | srevs.sort() |
|
165 | srevs.sort() | |
166 | for rev in srevs: |
|
166 | for rev in srevs: | |
167 | fns = fncache.get(rev) or filter(matchfn, getchange(rev)[3]) |
|
167 | fns = fncache.get(rev) or filter(matchfn, getchange(rev)[3]) | |
168 | yield 'add', rev, fns |
|
168 | yield 'add', rev, fns | |
169 | for rev in nrevs: |
|
169 | for rev in nrevs: | |
170 | yield 'iter', rev, None |
|
170 | yield 'iter', rev, None | |
171 | return iterate(), getchange, matchfn |
|
171 | return iterate(), getchange, matchfn | |
172 |
|
172 | |||
173 | revrangesep = ':' |
|
173 | revrangesep = ':' | |
174 |
|
174 | |||
175 | def revrange(ui, repo, revs, revlog=None): |
|
175 | def revrange(ui, repo, revs, revlog=None): | |
176 | """Yield revision as strings from a list of revision specifications.""" |
|
176 | """Yield revision as strings from a list of revision specifications.""" | |
177 | if revlog is None: |
|
177 | if revlog is None: | |
178 | revlog = repo.changelog |
|
178 | revlog = repo.changelog | |
179 | revcount = revlog.count() |
|
179 | revcount = revlog.count() | |
180 | def fix(val, defval): |
|
180 | def fix(val, defval): | |
181 | if not val: |
|
181 | if not val: | |
182 | return defval |
|
182 | return defval | |
183 | try: |
|
183 | try: | |
184 | num = int(val) |
|
184 | num = int(val) | |
185 | if str(num) != val: |
|
185 | if str(num) != val: | |
186 | raise ValueError |
|
186 | raise ValueError | |
187 | if num < 0: |
|
187 | if num < 0: | |
188 | num += revcount |
|
188 | num += revcount | |
189 | if num < 0: |
|
189 | if num < 0: | |
190 | num = 0 |
|
190 | num = 0 | |
191 | elif num >= revcount: |
|
191 | elif num >= revcount: | |
192 | raise ValueError |
|
192 | raise ValueError | |
193 | except ValueError: |
|
193 | except ValueError: | |
194 | try: |
|
194 | try: | |
195 | num = repo.changelog.rev(repo.lookup(val)) |
|
195 | num = repo.changelog.rev(repo.lookup(val)) | |
196 | except KeyError: |
|
196 | except KeyError: | |
197 | try: |
|
197 | try: | |
198 | num = revlog.rev(revlog.lookup(val)) |
|
198 | num = revlog.rev(revlog.lookup(val)) | |
199 | except KeyError: |
|
199 | except KeyError: | |
200 | raise util.Abort(_('invalid revision identifier %s'), val) |
|
200 | raise util.Abort(_('invalid revision identifier %s'), val) | |
201 | return num |
|
201 | return num | |
202 | seen = {} |
|
202 | seen = {} | |
203 | for spec in revs: |
|
203 | for spec in revs: | |
204 | if spec.find(revrangesep) >= 0: |
|
204 | if spec.find(revrangesep) >= 0: | |
205 | start, end = spec.split(revrangesep, 1) |
|
205 | start, end = spec.split(revrangesep, 1) | |
206 | start = fix(start, 0) |
|
206 | start = fix(start, 0) | |
207 | end = fix(end, revcount - 1) |
|
207 | end = fix(end, revcount - 1) | |
208 | step = start > end and -1 or 1 |
|
208 | step = start > end and -1 or 1 | |
209 | for rev in xrange(start, end+step, step): |
|
209 | for rev in xrange(start, end+step, step): | |
210 | if rev in seen: |
|
210 | if rev in seen: | |
211 | continue |
|
211 | continue | |
212 | seen[rev] = 1 |
|
212 | seen[rev] = 1 | |
213 | yield str(rev) |
|
213 | yield str(rev) | |
214 | else: |
|
214 | else: | |
215 | rev = fix(spec, None) |
|
215 | rev = fix(spec, None) | |
216 | if rev in seen: |
|
216 | if rev in seen: | |
217 | continue |
|
217 | continue | |
218 | seen[rev] = 1 |
|
218 | seen[rev] = 1 | |
219 | yield str(rev) |
|
219 | yield str(rev) | |
220 |
|
220 | |||
221 | def make_filename(repo, r, pat, node=None, |
|
221 | def make_filename(repo, r, pat, node=None, | |
222 | total=None, seqno=None, revwidth=None, pathname=None): |
|
222 | total=None, seqno=None, revwidth=None, pathname=None): | |
223 | node_expander = { |
|
223 | node_expander = { | |
224 | 'H': lambda: hex(node), |
|
224 | 'H': lambda: hex(node), | |
225 | 'R': lambda: str(r.rev(node)), |
|
225 | 'R': lambda: str(r.rev(node)), | |
226 | 'h': lambda: short(node), |
|
226 | 'h': lambda: short(node), | |
227 | } |
|
227 | } | |
228 | expander = { |
|
228 | expander = { | |
229 | '%': lambda: '%', |
|
229 | '%': lambda: '%', | |
230 | 'b': lambda: os.path.basename(repo.root), |
|
230 | 'b': lambda: os.path.basename(repo.root), | |
231 | } |
|
231 | } | |
232 |
|
232 | |||
233 | try: |
|
233 | try: | |
234 | if node: |
|
234 | if node: | |
235 | expander.update(node_expander) |
|
235 | expander.update(node_expander) | |
236 | if node and revwidth is not None: |
|
236 | if node and revwidth is not None: | |
237 | expander['r'] = lambda: str(r.rev(node)).zfill(revwidth) |
|
237 | expander['r'] = lambda: str(r.rev(node)).zfill(revwidth) | |
238 | if total is not None: |
|
238 | if total is not None: | |
239 | expander['N'] = lambda: str(total) |
|
239 | expander['N'] = lambda: str(total) | |
240 | if seqno is not None: |
|
240 | if seqno is not None: | |
241 | expander['n'] = lambda: str(seqno) |
|
241 | expander['n'] = lambda: str(seqno) | |
242 | if total is not None and seqno is not None: |
|
242 | if total is not None and seqno is not None: | |
243 | expander['n'] = lambda:str(seqno).zfill(len(str(total))) |
|
243 | expander['n'] = lambda:str(seqno).zfill(len(str(total))) | |
244 | if pathname is not None: |
|
244 | if pathname is not None: | |
245 | expander['s'] = lambda: os.path.basename(pathname) |
|
245 | expander['s'] = lambda: os.path.basename(pathname) | |
246 | expander['d'] = lambda: os.path.dirname(pathname) or '.' |
|
246 | expander['d'] = lambda: os.path.dirname(pathname) or '.' | |
247 | expander['p'] = lambda: pathname |
|
247 | expander['p'] = lambda: pathname | |
248 |
|
248 | |||
249 | newname = [] |
|
249 | newname = [] | |
250 | patlen = len(pat) |
|
250 | patlen = len(pat) | |
251 | i = 0 |
|
251 | i = 0 | |
252 | while i < patlen: |
|
252 | while i < patlen: | |
253 | c = pat[i] |
|
253 | c = pat[i] | |
254 | if c == '%': |
|
254 | if c == '%': | |
255 | i += 1 |
|
255 | i += 1 | |
256 | c = pat[i] |
|
256 | c = pat[i] | |
257 | c = expander[c]() |
|
257 | c = expander[c]() | |
258 | newname.append(c) |
|
258 | newname.append(c) | |
259 | i += 1 |
|
259 | i += 1 | |
260 | return ''.join(newname) |
|
260 | return ''.join(newname) | |
261 | except KeyError, inst: |
|
261 | except KeyError, inst: | |
262 | raise util.Abort(_("invalid format spec '%%%s' in output file name"), |
|
262 | raise util.Abort(_("invalid format spec '%%%s' in output file name"), | |
263 | inst.args[0]) |
|
263 | inst.args[0]) | |
264 |
|
264 | |||
265 | def make_file(repo, r, pat, node=None, |
|
265 | def make_file(repo, r, pat, node=None, | |
266 | total=None, seqno=None, revwidth=None, mode='wb', pathname=None): |
|
266 | total=None, seqno=None, revwidth=None, mode='wb', pathname=None): | |
267 | if not pat or pat == '-': |
|
267 | if not pat or pat == '-': | |
268 | return 'w' in mode and sys.stdout or sys.stdin |
|
268 | return 'w' in mode and sys.stdout or sys.stdin | |
269 | if hasattr(pat, 'write') and 'w' in mode: |
|
269 | if hasattr(pat, 'write') and 'w' in mode: | |
270 | return pat |
|
270 | return pat | |
271 | if hasattr(pat, 'read') and 'r' in mode: |
|
271 | if hasattr(pat, 'read') and 'r' in mode: | |
272 | return pat |
|
272 | return pat | |
273 | return open(make_filename(repo, r, pat, node, total, seqno, revwidth, |
|
273 | return open(make_filename(repo, r, pat, node, total, seqno, revwidth, | |
274 | pathname), |
|
274 | pathname), | |
275 | mode) |
|
275 | mode) | |
276 |
|
276 | |||
277 | def dodiff(fp, ui, repo, node1, node2, files=None, match=util.always, |
|
277 | def dodiff(fp, ui, repo, node1, node2, files=None, match=util.always, | |
278 | changes=None, text=False, opts={}): |
|
278 | changes=None, text=False, opts={}): | |
279 | if not node1: |
|
279 | if not node1: | |
280 | node1 = repo.dirstate.parents()[0] |
|
280 | node1 = repo.dirstate.parents()[0] | |
281 | # reading the data for node1 early allows it to play nicely |
|
281 | # reading the data for node1 early allows it to play nicely | |
282 | # with repo.changes and the revlog cache. |
|
282 | # with repo.changes and the revlog cache. | |
283 | change = repo.changelog.read(node1) |
|
283 | change = repo.changelog.read(node1) | |
284 | mmap = repo.manifest.read(change[0]) |
|
284 | mmap = repo.manifest.read(change[0]) | |
285 | date1 = util.datestr(change[2]) |
|
285 | date1 = util.datestr(change[2]) | |
286 |
|
286 | |||
287 | if not changes: |
|
287 | if not changes: | |
288 | changes = repo.changes(node1, node2, files, match=match) |
|
288 | changes = repo.changes(node1, node2, files, match=match) | |
289 | modified, added, removed, deleted, unknown = changes |
|
289 | modified, added, removed, deleted, unknown = changes | |
290 | if files: |
|
290 | if files: | |
291 | modified, added, removed = map(lambda x: filterfiles(files, x), |
|
291 | modified, added, removed = map(lambda x: filterfiles(files, x), | |
292 | (modified, added, removed)) |
|
292 | (modified, added, removed)) | |
293 |
|
293 | |||
294 | if not modified and not added and not removed: |
|
294 | if not modified and not added and not removed: | |
295 | return |
|
295 | return | |
296 |
|
296 | |||
297 | if node2: |
|
297 | if node2: | |
298 | change = repo.changelog.read(node2) |
|
298 | change = repo.changelog.read(node2) | |
299 | mmap2 = repo.manifest.read(change[0]) |
|
299 | mmap2 = repo.manifest.read(change[0]) | |
300 | date2 = util.datestr(change[2]) |
|
300 | date2 = util.datestr(change[2]) | |
301 | def read(f): |
|
301 | def read(f): | |
302 | return repo.file(f).read(mmap2[f]) |
|
302 | return repo.file(f).read(mmap2[f]) | |
303 | else: |
|
303 | else: | |
304 | date2 = util.datestr() |
|
304 | date2 = util.datestr() | |
305 | def read(f): |
|
305 | def read(f): | |
306 | return repo.wread(f) |
|
306 | return repo.wread(f) | |
307 |
|
307 | |||
308 | if ui.quiet: |
|
308 | if ui.quiet: | |
309 | r = None |
|
309 | r = None | |
310 | else: |
|
310 | else: | |
311 | hexfunc = ui.verbose and hex or short |
|
311 | hexfunc = ui.verbose and hex or short | |
312 | r = [hexfunc(node) for node in [node1, node2] if node] |
|
312 | r = [hexfunc(node) for node in [node1, node2] if node] | |
313 |
|
313 | |||
314 | diffopts = ui.diffopts() |
|
314 | diffopts = ui.diffopts() | |
315 | showfunc = opts.get('show_function') or diffopts['showfunc'] |
|
315 | showfunc = opts.get('show_function') or diffopts['showfunc'] | |
316 | ignorews = opts.get('ignore_all_space') or diffopts['ignorews'] |
|
316 | ignorews = opts.get('ignore_all_space') or diffopts['ignorews'] | |
317 | for f in modified: |
|
317 | for f in modified: | |
318 | to = None |
|
318 | to = None | |
319 | if f in mmap: |
|
319 | if f in mmap: | |
320 | to = repo.file(f).read(mmap[f]) |
|
320 | to = repo.file(f).read(mmap[f]) | |
321 | tn = read(f) |
|
321 | tn = read(f) | |
322 | fp.write(mdiff.unidiff(to, date1, tn, date2, f, r, text=text, |
|
322 | fp.write(mdiff.unidiff(to, date1, tn, date2, f, r, text=text, | |
323 | showfunc=showfunc, ignorews=ignorews)) |
|
323 | showfunc=showfunc, ignorews=ignorews)) | |
324 | for f in added: |
|
324 | for f in added: | |
325 | to = None |
|
325 | to = None | |
326 | tn = read(f) |
|
326 | tn = read(f) | |
327 | fp.write(mdiff.unidiff(to, date1, tn, date2, f, r, text=text, |
|
327 | fp.write(mdiff.unidiff(to, date1, tn, date2, f, r, text=text, | |
328 | showfunc=showfunc, ignorews=ignorews)) |
|
328 | showfunc=showfunc, ignorews=ignorews)) | |
329 | for f in removed: |
|
329 | for f in removed: | |
330 | to = repo.file(f).read(mmap[f]) |
|
330 | to = repo.file(f).read(mmap[f]) | |
331 | tn = None |
|
331 | tn = None | |
332 | fp.write(mdiff.unidiff(to, date1, tn, date2, f, r, text=text, |
|
332 | fp.write(mdiff.unidiff(to, date1, tn, date2, f, r, text=text, | |
333 | showfunc=showfunc, ignorews=ignorews)) |
|
333 | showfunc=showfunc, ignorews=ignorews)) | |
334 |
|
334 | |||
335 | def trimuser(ui, name, rev, revcache): |
|
335 | def trimuser(ui, name, rev, revcache): | |
336 | """trim the name of the user who committed a change""" |
|
336 | """trim the name of the user who committed a change""" | |
337 | user = revcache.get(rev) |
|
337 | user = revcache.get(rev) | |
338 | if user is None: |
|
338 | if user is None: | |
339 | user = revcache[rev] = ui.shortuser(name) |
|
339 | user = revcache[rev] = ui.shortuser(name) | |
340 | return user |
|
340 | return user | |
341 |
|
341 | |||
342 | def show_changeset(ui, repo, rev=0, changenode=None, brinfo=None): |
|
342 | def show_changeset(ui, repo, rev=0, changenode=None, brinfo=None): | |
343 | """show a single changeset or file revision""" |
|
343 | """show a single changeset or file revision""" | |
344 | log = repo.changelog |
|
344 | log = repo.changelog | |
345 | if changenode is None: |
|
345 | if changenode is None: | |
346 | changenode = log.node(rev) |
|
346 | changenode = log.node(rev) | |
347 | elif not rev: |
|
347 | elif not rev: | |
348 | rev = log.rev(changenode) |
|
348 | rev = log.rev(changenode) | |
349 |
|
349 | |||
350 | if ui.quiet: |
|
350 | if ui.quiet: | |
351 | ui.write("%d:%s\n" % (rev, short(changenode))) |
|
351 | ui.write("%d:%s\n" % (rev, short(changenode))) | |
352 | return |
|
352 | return | |
353 |
|
353 | |||
354 | changes = log.read(changenode) |
|
354 | changes = log.read(changenode) | |
355 | date = util.datestr(changes[2]) |
|
355 | date = util.datestr(changes[2]) | |
356 |
|
356 | |||
357 | parents = [(log.rev(p), ui.verbose and hex(p) or short(p)) |
|
357 | parents = [(log.rev(p), ui.verbose and hex(p) or short(p)) | |
358 | for p in log.parents(changenode) |
|
358 | for p in log.parents(changenode) | |
359 | if ui.debugflag or p != nullid] |
|
359 | if ui.debugflag or p != nullid] | |
360 | if not ui.debugflag and len(parents) == 1 and parents[0][0] == rev-1: |
|
360 | if not ui.debugflag and len(parents) == 1 and parents[0][0] == rev-1: | |
361 | parents = [] |
|
361 | parents = [] | |
362 |
|
362 | |||
363 | if ui.verbose: |
|
363 | if ui.verbose: | |
364 | ui.write(_("changeset: %d:%s\n") % (rev, hex(changenode))) |
|
364 | ui.write(_("changeset: %d:%s\n") % (rev, hex(changenode))) | |
365 | else: |
|
365 | else: | |
366 | ui.write(_("changeset: %d:%s\n") % (rev, short(changenode))) |
|
366 | ui.write(_("changeset: %d:%s\n") % (rev, short(changenode))) | |
367 |
|
367 | |||
368 | for tag in repo.nodetags(changenode): |
|
368 | for tag in repo.nodetags(changenode): | |
369 | ui.status(_("tag: %s\n") % tag) |
|
369 | ui.status(_("tag: %s\n") % tag) | |
370 | for parent in parents: |
|
370 | for parent in parents: | |
371 | ui.write(_("parent: %d:%s\n") % parent) |
|
371 | ui.write(_("parent: %d:%s\n") % parent) | |
372 |
|
372 | |||
373 | if brinfo and changenode in brinfo: |
|
373 | if brinfo and changenode in brinfo: | |
374 | br = brinfo[changenode] |
|
374 | br = brinfo[changenode] | |
375 | ui.write(_("branch: %s\n") % " ".join(br)) |
|
375 | ui.write(_("branch: %s\n") % " ".join(br)) | |
376 |
|
376 | |||
377 | ui.debug(_("manifest: %d:%s\n") % (repo.manifest.rev(changes[0]), |
|
377 | ui.debug(_("manifest: %d:%s\n") % (repo.manifest.rev(changes[0]), | |
378 | hex(changes[0]))) |
|
378 | hex(changes[0]))) | |
379 | ui.status(_("user: %s\n") % changes[1]) |
|
379 | ui.status(_("user: %s\n") % changes[1]) | |
380 | ui.status(_("date: %s\n") % date) |
|
380 | ui.status(_("date: %s\n") % date) | |
381 |
|
381 | |||
382 | if ui.debugflag: |
|
382 | if ui.debugflag: | |
383 | files = repo.changes(log.parents(changenode)[0], changenode) |
|
383 | files = repo.changes(log.parents(changenode)[0], changenode) | |
384 | for key, value in zip([_("files:"), _("files+:"), _("files-:")], files): |
|
384 | for key, value in zip([_("files:"), _("files+:"), _("files-:")], files): | |
385 | if value: |
|
385 | if value: | |
386 | ui.note("%-12s %s\n" % (key, " ".join(value))) |
|
386 | ui.note("%-12s %s\n" % (key, " ".join(value))) | |
387 | else: |
|
387 | else: | |
388 | ui.note(_("files: %s\n") % " ".join(changes[3])) |
|
388 | ui.note(_("files: %s\n") % " ".join(changes[3])) | |
389 |
|
389 | |||
390 | description = changes[4].strip() |
|
390 | description = changes[4].strip() | |
391 | if description: |
|
391 | if description: | |
392 | if ui.verbose: |
|
392 | if ui.verbose: | |
393 | ui.status(_("description:\n")) |
|
393 | ui.status(_("description:\n")) | |
394 | ui.status(description) |
|
394 | ui.status(description) | |
395 | ui.status("\n\n") |
|
395 | ui.status("\n\n") | |
396 | else: |
|
396 | else: | |
397 | ui.status(_("summary: %s\n") % description.splitlines()[0]) |
|
397 | ui.status(_("summary: %s\n") % description.splitlines()[0]) | |
398 | ui.status("\n") |
|
398 | ui.status("\n") | |
399 |
|
399 | |||
400 | def show_version(ui): |
|
400 | def show_version(ui): | |
401 | """output version and copyright information""" |
|
401 | """output version and copyright information""" | |
402 | ui.write(_("Mercurial Distributed SCM (version %s)\n") |
|
402 | ui.write(_("Mercurial Distributed SCM (version %s)\n") | |
403 | % version.get_version()) |
|
403 | % version.get_version()) | |
404 | ui.status(_( |
|
404 | ui.status(_( | |
405 | "\nCopyright (C) 2005 Matt Mackall <mpm@selenic.com>\n" |
|
405 | "\nCopyright (C) 2005 Matt Mackall <mpm@selenic.com>\n" | |
406 | "This is free software; see the source for copying conditions. " |
|
406 | "This is free software; see the source for copying conditions. " | |
407 | "There is NO\nwarranty; " |
|
407 | "There is NO\nwarranty; " | |
408 | "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n" |
|
408 | "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n" | |
409 | )) |
|
409 | )) | |
410 |
|
410 | |||
411 | def help_(ui, cmd=None, with_version=False): |
|
411 | def help_(ui, cmd=None, with_version=False): | |
412 | """show help for a given command or all commands""" |
|
412 | """show help for a given command or all commands""" | |
413 | option_lists = [] |
|
413 | option_lists = [] | |
414 | if cmd and cmd != 'shortlist': |
|
414 | if cmd and cmd != 'shortlist': | |
415 | if with_version: |
|
415 | if with_version: | |
416 | show_version(ui) |
|
416 | show_version(ui) | |
417 | ui.write('\n') |
|
417 | ui.write('\n') | |
418 | aliases, i = find(cmd) |
|
418 | aliases, i = find(cmd) | |
419 | # synopsis |
|
419 | # synopsis | |
420 | ui.write("%s\n\n" % i[2]) |
|
420 | ui.write("%s\n\n" % i[2]) | |
421 |
|
421 | |||
422 | # description |
|
422 | # description | |
423 | doc = i[0].__doc__ |
|
423 | doc = i[0].__doc__ | |
424 | if not doc: |
|
424 | if not doc: | |
425 | doc = _("(No help text available)") |
|
425 | doc = _("(No help text available)") | |
426 | if ui.quiet: |
|
426 | if ui.quiet: | |
427 | doc = doc.splitlines(0)[0] |
|
427 | doc = doc.splitlines(0)[0] | |
428 | ui.write("%s\n" % doc.rstrip()) |
|
428 | ui.write("%s\n" % doc.rstrip()) | |
429 |
|
429 | |||
430 | if not ui.quiet: |
|
430 | if not ui.quiet: | |
431 | # aliases |
|
431 | # aliases | |
432 | if len(aliases) > 1: |
|
432 | if len(aliases) > 1: | |
433 | ui.write(_("\naliases: %s\n") % ', '.join(aliases[1:])) |
|
433 | ui.write(_("\naliases: %s\n") % ', '.join(aliases[1:])) | |
434 |
|
434 | |||
435 | # options |
|
435 | # options | |
436 | if i[1]: |
|
436 | if i[1]: | |
437 | option_lists.append(("options", i[1])) |
|
437 | option_lists.append(("options", i[1])) | |
438 |
|
438 | |||
439 | else: |
|
439 | else: | |
440 | # program name |
|
440 | # program name | |
441 | if ui.verbose or with_version: |
|
441 | if ui.verbose or with_version: | |
442 | show_version(ui) |
|
442 | show_version(ui) | |
443 | else: |
|
443 | else: | |
444 | ui.status(_("Mercurial Distributed SCM\n")) |
|
444 | ui.status(_("Mercurial Distributed SCM\n")) | |
445 | ui.status('\n') |
|
445 | ui.status('\n') | |
446 |
|
446 | |||
447 | # list of commands |
|
447 | # list of commands | |
448 | if cmd == "shortlist": |
|
448 | if cmd == "shortlist": | |
449 | ui.status(_('basic commands (use "hg help" ' |
|
449 | ui.status(_('basic commands (use "hg help" ' | |
450 | 'for the full list or option "-v" for details):\n\n')) |
|
450 | 'for the full list or option "-v" for details):\n\n')) | |
451 | elif ui.verbose: |
|
451 | elif ui.verbose: | |
452 | ui.status(_('list of commands:\n\n')) |
|
452 | ui.status(_('list of commands:\n\n')) | |
453 | else: |
|
453 | else: | |
454 | ui.status(_('list of commands (use "hg help -v" ' |
|
454 | ui.status(_('list of commands (use "hg help -v" ' | |
455 | 'to show aliases and global options):\n\n')) |
|
455 | 'to show aliases and global options):\n\n')) | |
456 |
|
456 | |||
457 | h = {} |
|
457 | h = {} | |
458 | cmds = {} |
|
458 | cmds = {} | |
459 | for c, e in table.items(): |
|
459 | for c, e in table.items(): | |
460 | f = c.split("|")[0] |
|
460 | f = c.split("|")[0] | |
461 | if cmd == "shortlist" and not f.startswith("^"): |
|
461 | if cmd == "shortlist" and not f.startswith("^"): | |
462 | continue |
|
462 | continue | |
463 | f = f.lstrip("^") |
|
463 | f = f.lstrip("^") | |
464 | if not ui.debugflag and f.startswith("debug"): |
|
464 | if not ui.debugflag and f.startswith("debug"): | |
465 | continue |
|
465 | continue | |
466 | doc = e[0].__doc__ |
|
466 | doc = e[0].__doc__ | |
467 | if not doc: |
|
467 | if not doc: | |
468 | doc = _("(No help text available)") |
|
468 | doc = _("(No help text available)") | |
469 | h[f] = doc.splitlines(0)[0].rstrip() |
|
469 | h[f] = doc.splitlines(0)[0].rstrip() | |
470 | cmds[f] = c.lstrip("^") |
|
470 | cmds[f] = c.lstrip("^") | |
471 |
|
471 | |||
472 | fns = h.keys() |
|
472 | fns = h.keys() | |
473 | fns.sort() |
|
473 | fns.sort() | |
474 | m = max(map(len, fns)) |
|
474 | m = max(map(len, fns)) | |
475 | for f in fns: |
|
475 | for f in fns: | |
476 | if ui.verbose: |
|
476 | if ui.verbose: | |
477 | commands = cmds[f].replace("|",", ") |
|
477 | commands = cmds[f].replace("|",", ") | |
478 | ui.write(" %s:\n %s\n"%(commands, h[f])) |
|
478 | ui.write(" %s:\n %s\n"%(commands, h[f])) | |
479 | else: |
|
479 | else: | |
480 | ui.write(' %-*s %s\n' % (m, f, h[f])) |
|
480 | ui.write(' %-*s %s\n' % (m, f, h[f])) | |
481 |
|
481 | |||
482 | # global options |
|
482 | # global options | |
483 | if ui.verbose: |
|
483 | if ui.verbose: | |
484 | option_lists.append(("global options", globalopts)) |
|
484 | option_lists.append(("global options", globalopts)) | |
485 |
|
485 | |||
486 | # list all option lists |
|
486 | # list all option lists | |
487 | opt_output = [] |
|
487 | opt_output = [] | |
488 | for title, options in option_lists: |
|
488 | for title, options in option_lists: | |
489 | opt_output.append(("\n%s:\n" % title, None)) |
|
489 | opt_output.append(("\n%s:\n" % title, None)) | |
490 | for shortopt, longopt, default, desc in options: |
|
490 | for shortopt, longopt, default, desc in options: | |
491 | opt_output.append(("%2s%s" % (shortopt and "-%s" % shortopt, |
|
491 | opt_output.append(("%2s%s" % (shortopt and "-%s" % shortopt, | |
492 | longopt and " --%s" % longopt), |
|
492 | longopt and " --%s" % longopt), | |
493 | "%s%s" % (desc, |
|
493 | "%s%s" % (desc, | |
494 | default |
|
494 | default | |
495 | and _(" (default: %s)") % default |
|
495 | and _(" (default: %s)") % default | |
496 | or ""))) |
|
496 | or ""))) | |
497 |
|
497 | |||
498 | if opt_output: |
|
498 | if opt_output: | |
499 | opts_len = max([len(line[0]) for line in opt_output if line[1]]) |
|
499 | opts_len = max([len(line[0]) for line in opt_output if line[1]]) | |
500 | for first, second in opt_output: |
|
500 | for first, second in opt_output: | |
501 | if second: |
|
501 | if second: | |
502 | ui.write(" %-*s %s\n" % (opts_len, first, second)) |
|
502 | ui.write(" %-*s %s\n" % (opts_len, first, second)) | |
503 | else: |
|
503 | else: | |
504 | ui.write("%s\n" % first) |
|
504 | ui.write("%s\n" % first) | |
505 |
|
505 | |||
506 | # Commands start here, listed alphabetically |
|
506 | # Commands start here, listed alphabetically | |
507 |
|
507 | |||
508 | def add(ui, repo, *pats, **opts): |
|
508 | def add(ui, repo, *pats, **opts): | |
509 | """add the specified files on the next commit |
|
509 | """add the specified files on the next commit | |
510 |
|
510 | |||
511 | Schedule files to be version controlled and added to the repository. |
|
511 | Schedule files to be version controlled and added to the repository. | |
512 |
|
512 | |||
513 | The files will be added to the repository at the next commit. |
|
513 | The files will be added to the repository at the next commit. | |
514 |
|
514 | |||
515 | If no names are given, add all files in the repository. |
|
515 | If no names are given, add all files in the repository. | |
516 | """ |
|
516 | """ | |
517 |
|
517 | |||
518 | names = [] |
|
518 | names = [] | |
519 | for src, abs, rel, exact in walk(repo, pats, opts): |
|
519 | for src, abs, rel, exact in walk(repo, pats, opts): | |
520 | if exact: |
|
520 | if exact: | |
521 | if ui.verbose: |
|
521 | if ui.verbose: | |
522 | ui.status(_('adding %s\n') % rel) |
|
522 | ui.status(_('adding %s\n') % rel) | |
523 | names.append(abs) |
|
523 | names.append(abs) | |
524 | elif repo.dirstate.state(abs) == '?': |
|
524 | elif repo.dirstate.state(abs) == '?': | |
525 | ui.status(_('adding %s\n') % rel) |
|
525 | ui.status(_('adding %s\n') % rel) | |
526 | names.append(abs) |
|
526 | names.append(abs) | |
527 | repo.add(names) |
|
527 | repo.add(names) | |
528 |
|
528 | |||
529 | def addremove(ui, repo, *pats, **opts): |
|
529 | def addremove(ui, repo, *pats, **opts): | |
530 | """add all new files, delete all missing files |
|
530 | """add all new files, delete all missing files | |
531 |
|
531 | |||
532 | Add all new files and remove all missing files from the repository. |
|
532 | Add all new files and remove all missing files from the repository. | |
533 |
|
533 | |||
534 | New files are ignored if they match any of the patterns in .hgignore. As |
|
534 | New files are ignored if they match any of the patterns in .hgignore. As | |
535 | with add, these changes take effect at the next commit. |
|
535 | with add, these changes take effect at the next commit. | |
536 | """ |
|
536 | """ | |
537 | return addremove_lock(ui, repo, pats, opts) |
|
537 | return addremove_lock(ui, repo, pats, opts) | |
538 |
|
538 | |||
539 | def addremove_lock(ui, repo, pats, opts, wlock=None): |
|
539 | def addremove_lock(ui, repo, pats, opts, wlock=None): | |
540 | add, remove = [], [] |
|
540 | add, remove = [], [] | |
541 | for src, abs, rel, exact in walk(repo, pats, opts): |
|
541 | for src, abs, rel, exact in walk(repo, pats, opts): | |
542 | if src == 'f' and repo.dirstate.state(abs) == '?': |
|
542 | if src == 'f' and repo.dirstate.state(abs) == '?': | |
543 | add.append(abs) |
|
543 | add.append(abs) | |
544 | if ui.verbose or not exact: |
|
544 | if ui.verbose or not exact: | |
545 | ui.status(_('adding %s\n') % ((pats and rel) or abs)) |
|
545 | ui.status(_('adding %s\n') % ((pats and rel) or abs)) | |
546 | if repo.dirstate.state(abs) != 'r' and not os.path.exists(rel): |
|
546 | if repo.dirstate.state(abs) != 'r' and not os.path.exists(rel): | |
547 | remove.append(abs) |
|
547 | remove.append(abs) | |
548 | if ui.verbose or not exact: |
|
548 | if ui.verbose or not exact: | |
549 | ui.status(_('removing %s\n') % ((pats and rel) or abs)) |
|
549 | ui.status(_('removing %s\n') % ((pats and rel) or abs)) | |
550 | repo.add(add, wlock=wlock) |
|
550 | repo.add(add, wlock=wlock) | |
551 | repo.remove(remove, wlock=wlock) |
|
551 | repo.remove(remove, wlock=wlock) | |
552 |
|
552 | |||
553 | def annotate(ui, repo, *pats, **opts): |
|
553 | def annotate(ui, repo, *pats, **opts): | |
554 | """show changeset information per file line |
|
554 | """show changeset information per file line | |
555 |
|
555 | |||
556 | List changes in files, showing the revision id responsible for each line |
|
556 | List changes in files, showing the revision id responsible for each line | |
557 |
|
557 | |||
558 | This command is useful to discover who did a change or when a change took |
|
558 | This command is useful to discover who did a change or when a change took | |
559 | place. |
|
559 | place. | |
560 |
|
560 | |||
561 | Without the -a option, annotate will avoid processing files it |
|
561 | Without the -a option, annotate will avoid processing files it | |
562 | detects as binary. With -a, annotate will generate an annotation |
|
562 | detects as binary. With -a, annotate will generate an annotation | |
563 | anyway, probably with undesirable results. |
|
563 | anyway, probably with undesirable results. | |
564 | """ |
|
564 | """ | |
565 | def getnode(rev): |
|
565 | def getnode(rev): | |
566 | return short(repo.changelog.node(rev)) |
|
566 | return short(repo.changelog.node(rev)) | |
567 |
|
567 | |||
568 | ucache = {} |
|
568 | ucache = {} | |
569 | def getname(rev): |
|
569 | def getname(rev): | |
570 | cl = repo.changelog.read(repo.changelog.node(rev)) |
|
570 | cl = repo.changelog.read(repo.changelog.node(rev)) | |
571 | return trimuser(ui, cl[1], rev, ucache) |
|
571 | return trimuser(ui, cl[1], rev, ucache) | |
572 |
|
572 | |||
573 | dcache = {} |
|
573 | dcache = {} | |
574 | def getdate(rev): |
|
574 | def getdate(rev): | |
575 | datestr = dcache.get(rev) |
|
575 | datestr = dcache.get(rev) | |
576 | if datestr is None: |
|
576 | if datestr is None: | |
577 | cl = repo.changelog.read(repo.changelog.node(rev)) |
|
577 | cl = repo.changelog.read(repo.changelog.node(rev)) | |
578 | datestr = dcache[rev] = util.datestr(cl[2]) |
|
578 | datestr = dcache[rev] = util.datestr(cl[2]) | |
579 | return datestr |
|
579 | return datestr | |
580 |
|
580 | |||
581 | if not pats: |
|
581 | if not pats: | |
582 | raise util.Abort(_('at least one file name or pattern required')) |
|
582 | raise util.Abort(_('at least one file name or pattern required')) | |
583 |
|
583 | |||
584 | opmap = [['user', getname], ['number', str], ['changeset', getnode], |
|
584 | opmap = [['user', getname], ['number', str], ['changeset', getnode], | |
585 | ['date', getdate]] |
|
585 | ['date', getdate]] | |
586 | if not opts['user'] and not opts['changeset'] and not opts['date']: |
|
586 | if not opts['user'] and not opts['changeset'] and not opts['date']: | |
587 | opts['number'] = 1 |
|
587 | opts['number'] = 1 | |
588 |
|
588 | |||
589 | if opts['rev']: |
|
589 | if opts['rev']: | |
590 | node = repo.changelog.lookup(opts['rev']) |
|
590 | node = repo.changelog.lookup(opts['rev']) | |
591 | else: |
|
591 | else: | |
592 | node = repo.dirstate.parents()[0] |
|
592 | node = repo.dirstate.parents()[0] | |
593 | change = repo.changelog.read(node) |
|
593 | change = repo.changelog.read(node) | |
594 | mmap = repo.manifest.read(change[0]) |
|
594 | mmap = repo.manifest.read(change[0]) | |
595 |
|
595 | |||
596 | for src, abs, rel, exact in walk(repo, pats, opts): |
|
596 | for src, abs, rel, exact in walk(repo, pats, opts): | |
597 | if abs not in mmap: |
|
597 | if abs not in mmap: | |
598 | ui.warn(_("warning: %s is not in the repository!\n") % |
|
598 | ui.warn(_("warning: %s is not in the repository!\n") % | |
599 | ((pats and rel) or abs)) |
|
599 | ((pats and rel) or abs)) | |
600 | continue |
|
600 | continue | |
601 |
|
601 | |||
602 | f = repo.file(abs) |
|
602 | f = repo.file(abs) | |
603 | if not opts['text'] and util.binary(f.read(mmap[abs])): |
|
603 | if not opts['text'] and util.binary(f.read(mmap[abs])): | |
604 | ui.write(_("%s: binary file\n") % ((pats and rel) or abs)) |
|
604 | ui.write(_("%s: binary file\n") % ((pats and rel) or abs)) | |
605 | continue |
|
605 | continue | |
606 |
|
606 | |||
607 | lines = f.annotate(mmap[abs]) |
|
607 | lines = f.annotate(mmap[abs]) | |
608 | pieces = [] |
|
608 | pieces = [] | |
609 |
|
609 | |||
610 | for o, f in opmap: |
|
610 | for o, f in opmap: | |
611 | if opts[o]: |
|
611 | if opts[o]: | |
612 | l = [f(n) for n, dummy in lines] |
|
612 | l = [f(n) for n, dummy in lines] | |
613 | if l: |
|
613 | if l: | |
614 | m = max(map(len, l)) |
|
614 | m = max(map(len, l)) | |
615 | pieces.append(["%*s" % (m, x) for x in l]) |
|
615 | pieces.append(["%*s" % (m, x) for x in l]) | |
616 |
|
616 | |||
617 | if pieces: |
|
617 | if pieces: | |
618 | for p, l in zip(zip(*pieces), lines): |
|
618 | for p, l in zip(zip(*pieces), lines): | |
619 | ui.write("%s: %s" % (" ".join(p), l[1])) |
|
619 | ui.write("%s: %s" % (" ".join(p), l[1])) | |
620 |
|
620 | |||
621 | def bundle(ui, repo, fname, dest="default-push", **opts): |
|
621 | def bundle(ui, repo, fname, dest="default-push", **opts): | |
622 | """create a changegroup file |
|
622 | """create a changegroup file | |
623 |
|
623 | |||
624 | Generate a compressed changegroup file collecting all changesets |
|
624 | Generate a compressed changegroup file collecting all changesets | |
625 | not found in the other repository. |
|
625 | not found in the other repository. | |
626 |
|
626 | |||
627 | This file can then be transferred using conventional means and |
|
627 | This file can then be transferred using conventional means and | |
628 | applied to another repository with the unbundle command. This is |
|
628 | applied to another repository with the unbundle command. This is | |
629 | useful when native push and pull are not available or when |
|
629 | useful when native push and pull are not available or when | |
630 | exporting an entire repository is undesirable. The standard file |
|
630 | exporting an entire repository is undesirable. The standard file | |
631 | extension is ".hg". |
|
631 | extension is ".hg". | |
632 |
|
632 | |||
633 | Unlike import/export, this exactly preserves all changeset |
|
633 | Unlike import/export, this exactly preserves all changeset | |
634 | contents including permissions, rename data, and revision history. |
|
634 | contents including permissions, rename data, and revision history. | |
635 | """ |
|
635 | """ | |
636 | f = open(fname, "wb") |
|
636 | f = open(fname, "wb") | |
637 | dest = ui.expandpath(dest, repo.root) |
|
637 | dest = ui.expandpath(dest, repo.root) | |
638 | other = hg.repository(ui, dest) |
|
638 | other = hg.repository(ui, dest) | |
639 | o = repo.findoutgoing(other) |
|
639 | o = repo.findoutgoing(other) | |
640 | cg = repo.changegroup(o, 'bundle') |
|
640 | cg = repo.changegroup(o, 'bundle') | |
641 |
|
641 | |||
642 | try: |
|
642 | try: | |
643 | f.write("HG10") |
|
643 | f.write("HG10") | |
644 | z = bz2.BZ2Compressor(9) |
|
644 | z = bz2.BZ2Compressor(9) | |
645 | while 1: |
|
645 | while 1: | |
646 | chunk = cg.read(4096) |
|
646 | chunk = cg.read(4096) | |
647 | if not chunk: |
|
647 | if not chunk: | |
648 | break |
|
648 | break | |
649 | f.write(z.compress(chunk)) |
|
649 | f.write(z.compress(chunk)) | |
650 | f.write(z.flush()) |
|
650 | f.write(z.flush()) | |
651 | except: |
|
651 | except: | |
652 | os.unlink(fname) |
|
652 | os.unlink(fname) | |
653 | raise |
|
653 | raise | |
654 |
|
654 | |||
655 | def cat(ui, repo, file1, *pats, **opts): |
|
655 | def cat(ui, repo, file1, *pats, **opts): | |
656 | """output the latest or given revisions of files |
|
656 | """output the latest or given revisions of files | |
657 |
|
657 | |||
658 | Print the specified files as they were at the given revision. |
|
658 | Print the specified files as they were at the given revision. | |
659 | If no revision is given then the tip is used. |
|
659 | If no revision is given then the tip is used. | |
660 |
|
660 | |||
661 | Output may be to a file, in which case the name of the file is |
|
661 | Output may be to a file, in which case the name of the file is | |
662 | given using a format string. The formatting rules are the same as |
|
662 | given using a format string. The formatting rules are the same as | |
663 | for the export command, with the following additions: |
|
663 | for the export command, with the following additions: | |
664 |
|
664 | |||
665 | %s basename of file being printed |
|
665 | %s basename of file being printed | |
666 | %d dirname of file being printed, or '.' if in repo root |
|
666 | %d dirname of file being printed, or '.' if in repo root | |
667 | %p root-relative path name of file being printed |
|
667 | %p root-relative path name of file being printed | |
668 | """ |
|
668 | """ | |
669 | mf = {} |
|
669 | mf = {} | |
670 | rev = opts['rev'] |
|
670 | rev = opts['rev'] | |
671 | if rev: |
|
671 | if rev: | |
672 | node = repo.lookup(rev) |
|
672 | node = repo.lookup(rev) | |
673 | else: |
|
673 | else: | |
674 | node = repo.changelog.tip() |
|
674 | node = repo.changelog.tip() | |
675 | change = repo.changelog.read(node) |
|
675 | change = repo.changelog.read(node) | |
676 | mf = repo.manifest.read(change[0]) |
|
676 | mf = repo.manifest.read(change[0]) | |
677 | for src, abs, rel, exact in walk(repo, (file1,) + pats, opts, node): |
|
677 | for src, abs, rel, exact in walk(repo, (file1,) + pats, opts, node): | |
678 | r = repo.file(abs) |
|
678 | r = repo.file(abs) | |
679 | n = mf[abs] |
|
679 | n = mf[abs] | |
680 | fp = make_file(repo, r, opts['output'], node=n, pathname=abs) |
|
680 | fp = make_file(repo, r, opts['output'], node=n, pathname=abs) | |
681 | fp.write(r.read(n)) |
|
681 | fp.write(r.read(n)) | |
682 |
|
682 | |||
683 | def clone(ui, source, dest=None, **opts): |
|
683 | def clone(ui, source, dest=None, **opts): | |
684 | """make a copy of an existing repository |
|
684 | """make a copy of an existing repository | |
685 |
|
685 | |||
686 | Create a copy of an existing repository in a new directory. |
|
686 | Create a copy of an existing repository in a new directory. | |
687 |
|
687 | |||
688 | If no destination directory name is specified, it defaults to the |
|
688 | If no destination directory name is specified, it defaults to the | |
689 | basename of the source. |
|
689 | basename of the source. | |
690 |
|
690 | |||
691 | The location of the source is added to the new repository's |
|
691 | The location of the source is added to the new repository's | |
692 | .hg/hgrc file, as the default to be used for future pulls. |
|
692 | .hg/hgrc file, as the default to be used for future pulls. | |
693 |
|
693 | |||
694 | For efficiency, hardlinks are used for cloning whenever the source |
|
694 | For efficiency, hardlinks are used for cloning whenever the source | |
695 | and destination are on the same filesystem. Some filesystems, |
|
695 | and destination are on the same filesystem. Some filesystems, | |
696 | such as AFS, implement hardlinking incorrectly, but do not report |
|
696 | such as AFS, implement hardlinking incorrectly, but do not report | |
697 | errors. In these cases, use the --pull option to avoid |
|
697 | errors. In these cases, use the --pull option to avoid | |
698 | hardlinking. |
|
698 | hardlinking. | |
699 |
|
699 | |||
700 | See pull for valid source format details. |
|
700 | See pull for valid source format details. | |
701 | """ |
|
701 | """ | |
702 | if dest is None: |
|
702 | if dest is None: | |
703 | dest = os.path.basename(os.path.normpath(source)) |
|
703 | dest = os.path.basename(os.path.normpath(source)) | |
704 |
|
704 | |||
705 | if os.path.exists(dest): |
|
705 | if os.path.exists(dest): | |
706 | raise util.Abort(_("destination '%s' already exists"), dest) |
|
706 | raise util.Abort(_("destination '%s' already exists"), dest) | |
707 |
|
707 | |||
708 | dest = os.path.realpath(dest) |
|
708 | dest = os.path.realpath(dest) | |
709 |
|
709 | |||
710 | class Dircleanup(object): |
|
710 | class Dircleanup(object): | |
711 | def __init__(self, dir_): |
|
711 | def __init__(self, dir_): | |
712 | self.rmtree = shutil.rmtree |
|
712 | self.rmtree = shutil.rmtree | |
713 | self.dir_ = dir_ |
|
713 | self.dir_ = dir_ | |
714 | os.mkdir(dir_) |
|
714 | os.mkdir(dir_) | |
715 | def close(self): |
|
715 | def close(self): | |
716 | self.dir_ = None |
|
716 | self.dir_ = None | |
717 | def __del__(self): |
|
717 | def __del__(self): | |
718 | if self.dir_: |
|
718 | if self.dir_: | |
719 | self.rmtree(self.dir_, True) |
|
719 | self.rmtree(self.dir_, True) | |
720 |
|
720 | |||
721 | if opts['ssh']: |
|
721 | if opts['ssh']: | |
722 | ui.setconfig("ui", "ssh", opts['ssh']) |
|
722 | ui.setconfig("ui", "ssh", opts['ssh']) | |
723 | if opts['remotecmd']: |
|
723 | if opts['remotecmd']: | |
724 | ui.setconfig("ui", "remotecmd", opts['remotecmd']) |
|
724 | ui.setconfig("ui", "remotecmd", opts['remotecmd']) | |
725 |
|
725 | |||
726 | if not os.path.exists(source): |
|
726 | if not os.path.exists(source): | |
727 | source = ui.expandpath(source) |
|
727 | source = ui.expandpath(source) | |
728 |
|
728 | |||
729 | d = Dircleanup(dest) |
|
729 | d = Dircleanup(dest) | |
730 | abspath = source |
|
730 | abspath = source | |
731 | other = hg.repository(ui, source) |
|
731 | other = hg.repository(ui, source) | |
732 |
|
732 | |||
733 | copy = False |
|
733 | copy = False | |
734 | if other.dev() != -1: |
|
734 | if other.dev() != -1: | |
735 | abspath = os.path.abspath(source) |
|
735 | abspath = os.path.abspath(source) | |
736 | if not opts['pull'] and not opts['rev']: |
|
736 | if not opts['pull'] and not opts['rev']: | |
737 | copy = True |
|
737 | copy = True | |
738 |
|
738 | |||
739 | if copy: |
|
739 | if copy: | |
740 | try: |
|
740 | try: | |
741 | # we use a lock here because if we race with commit, we |
|
741 | # we use a lock here because if we race with commit, we | |
742 | # can end up with extra data in the cloned revlogs that's |
|
742 | # can end up with extra data in the cloned revlogs that's | |
743 | # not pointed to by changesets, thus causing verify to |
|
743 | # not pointed to by changesets, thus causing verify to | |
744 | # fail |
|
744 | # fail | |
745 | l1 = other.lock() |
|
745 | l1 = other.lock() | |
746 | except lock.LockException: |
|
746 | except lock.LockException: | |
747 | copy = False |
|
747 | copy = False | |
748 |
|
748 | |||
749 | if copy: |
|
749 | if copy: | |
750 | # we lock here to avoid premature writing to the target |
|
750 | # we lock here to avoid premature writing to the target | |
751 | os.mkdir(os.path.join(dest, ".hg")) |
|
751 | os.mkdir(os.path.join(dest, ".hg")) | |
752 | l2 = lock.lock(os.path.join(dest, ".hg", "lock")) |
|
752 | l2 = lock.lock(os.path.join(dest, ".hg", "lock")) | |
753 |
|
753 | |||
754 | files = "data 00manifest.d 00manifest.i 00changelog.d 00changelog.i" |
|
754 | files = "data 00manifest.d 00manifest.i 00changelog.d 00changelog.i" | |
755 | for f in files.split(): |
|
755 | for f in files.split(): | |
756 | src = os.path.join(source, ".hg", f) |
|
756 | src = os.path.join(source, ".hg", f) | |
757 | dst = os.path.join(dest, ".hg", f) |
|
757 | dst = os.path.join(dest, ".hg", f) | |
758 | try: |
|
758 | try: | |
759 | util.copyfiles(src, dst) |
|
759 | util.copyfiles(src, dst) | |
760 | except OSError, inst: |
|
760 | except OSError, inst: | |
761 | if inst.errno != errno.ENOENT: |
|
761 | if inst.errno != errno.ENOENT: | |
762 | raise |
|
762 | raise | |
763 |
|
763 | |||
764 | repo = hg.repository(ui, dest) |
|
764 | repo = hg.repository(ui, dest) | |
765 |
|
765 | |||
766 | else: |
|
766 | else: | |
767 | revs = None |
|
767 | revs = None | |
768 | if opts['rev']: |
|
768 | if opts['rev']: | |
769 | if not other.local(): |
|
769 | if not other.local(): | |
770 | error = _("clone -r not supported yet for remote repositories.") |
|
770 | error = _("clone -r not supported yet for remote repositories.") | |
771 | raise util.Abort(error) |
|
771 | raise util.Abort(error) | |
772 | else: |
|
772 | else: | |
773 | revs = [other.lookup(rev) for rev in opts['rev']] |
|
773 | revs = [other.lookup(rev) for rev in opts['rev']] | |
774 | repo = hg.repository(ui, dest, create=1) |
|
774 | repo = hg.repository(ui, dest, create=1) | |
775 | repo.pull(other, heads = revs) |
|
775 | repo.pull(other, heads = revs) | |
776 |
|
776 | |||
777 | f = repo.opener("hgrc", "w", text=True) |
|
777 | f = repo.opener("hgrc", "w", text=True) | |
778 | f.write("[paths]\n") |
|
778 | f.write("[paths]\n") | |
779 | f.write("default = %s\n" % abspath) |
|
779 | f.write("default = %s\n" % abspath) | |
780 | f.close() |
|
780 | f.close() | |
781 |
|
781 | |||
782 | if not opts['noupdate']: |
|
782 | if not opts['noupdate']: | |
783 | update(ui, repo) |
|
783 | update(ui, repo) | |
784 |
|
784 | |||
785 | d.close() |
|
785 | d.close() | |
786 |
|
786 | |||
787 | def commit(ui, repo, *pats, **opts): |
|
787 | def commit(ui, repo, *pats, **opts): | |
788 | """commit the specified files or all outstanding changes |
|
788 | """commit the specified files or all outstanding changes | |
789 |
|
789 | |||
790 | Commit changes to the given files into the repository. |
|
790 | Commit changes to the given files into the repository. | |
791 |
|
791 | |||
792 | If a list of files is omitted, all changes reported by "hg status" |
|
792 | If a list of files is omitted, all changes reported by "hg status" | |
793 | will be commited. |
|
793 | will be commited. | |
794 |
|
794 | |||
795 | The HGEDITOR or EDITOR environment variables are used to start an |
|
795 | The HGEDITOR or EDITOR environment variables are used to start an | |
796 | editor to add a commit comment. |
|
796 | editor to add a commit comment. | |
797 | """ |
|
797 | """ | |
798 | message = opts['message'] |
|
798 | message = opts['message'] | |
799 | logfile = opts['logfile'] |
|
799 | logfile = opts['logfile'] | |
800 |
|
800 | |||
801 | if message and logfile: |
|
801 | if message and logfile: | |
802 | raise util.Abort(_('options --message and --logfile are mutually ' |
|
802 | raise util.Abort(_('options --message and --logfile are mutually ' | |
803 | 'exclusive')) |
|
803 | 'exclusive')) | |
804 | if not message and logfile: |
|
804 | if not message and logfile: | |
805 | try: |
|
805 | try: | |
806 | if logfile == '-': |
|
806 | if logfile == '-': | |
807 | message = sys.stdin.read() |
|
807 | message = sys.stdin.read() | |
808 | else: |
|
808 | else: | |
809 | message = open(logfile).read() |
|
809 | message = open(logfile).read() | |
810 | except IOError, inst: |
|
810 | except IOError, inst: | |
811 | raise util.Abort(_("can't read commit message '%s': %s") % |
|
811 | raise util.Abort(_("can't read commit message '%s': %s") % | |
812 | (logfile, inst.strerror)) |
|
812 | (logfile, inst.strerror)) | |
813 |
|
813 | |||
814 | if opts['addremove']: |
|
814 | if opts['addremove']: | |
815 | addremove(ui, repo, *pats, **opts) |
|
815 | addremove(ui, repo, *pats, **opts) | |
816 | fns, match, anypats = matchpats(repo, pats, opts) |
|
816 | fns, match, anypats = matchpats(repo, pats, opts) | |
817 | if pats: |
|
817 | if pats: | |
818 | modified, added, removed, deleted, unknown = ( |
|
818 | modified, added, removed, deleted, unknown = ( | |
819 | repo.changes(files=fns, match=match)) |
|
819 | repo.changes(files=fns, match=match)) | |
820 | files = modified + added + removed |
|
820 | files = modified + added + removed | |
821 | else: |
|
821 | else: | |
822 | files = [] |
|
822 | files = [] | |
823 | try: |
|
823 | try: | |
824 | repo.commit(files, message, opts['user'], opts['date'], match) |
|
824 | repo.commit(files, message, opts['user'], opts['date'], match) | |
825 | except ValueError, inst: |
|
825 | except ValueError, inst: | |
826 | raise util.Abort(str(inst)) |
|
826 | raise util.Abort(str(inst)) | |
827 |
|
827 | |||
828 | def docopy(ui, repo, pats, opts): |
|
828 | def docopy(ui, repo, pats, opts): | |
829 | cwd = repo.getcwd() |
|
829 | cwd = repo.getcwd() | |
830 | errors = 0 |
|
830 | errors = 0 | |
831 | copied = [] |
|
831 | copied = [] | |
832 | targets = {} |
|
832 | targets = {} | |
833 |
|
833 | |||
834 | def okaytocopy(abs, rel, exact): |
|
834 | def okaytocopy(abs, rel, exact): | |
835 | reasons = {'?': _('is not managed'), |
|
835 | reasons = {'?': _('is not managed'), | |
836 | 'a': _('has been marked for add'), |
|
836 | 'a': _('has been marked for add'), | |
837 | 'r': _('has been marked for remove')} |
|
837 | 'r': _('has been marked for remove')} | |
838 | state = repo.dirstate.state(abs) |
|
838 | state = repo.dirstate.state(abs) | |
839 | reason = reasons.get(state) |
|
839 | reason = reasons.get(state) | |
840 | if reason: |
|
840 | if reason: | |
841 | if state == 'a': |
|
841 | if state == 'a': | |
842 | origsrc = repo.dirstate.copied(abs) |
|
842 | origsrc = repo.dirstate.copied(abs) | |
843 | if origsrc is not None: |
|
843 | if origsrc is not None: | |
844 | return origsrc |
|
844 | return origsrc | |
845 | if exact: |
|
845 | if exact: | |
846 | ui.warn(_('%s: not copying - file %s\n') % (rel, reason)) |
|
846 | ui.warn(_('%s: not copying - file %s\n') % (rel, reason)) | |
847 | else: |
|
847 | else: | |
848 | return abs |
|
848 | return abs | |
849 |
|
849 | |||
850 | def copy(origsrc, abssrc, relsrc, target, exact): |
|
850 | def copy(origsrc, abssrc, relsrc, target, exact): | |
851 | abstarget = util.canonpath(repo.root, cwd, target) |
|
851 | abstarget = util.canonpath(repo.root, cwd, target) | |
852 | reltarget = util.pathto(cwd, abstarget) |
|
852 | reltarget = util.pathto(cwd, abstarget) | |
853 | prevsrc = targets.get(abstarget) |
|
853 | prevsrc = targets.get(abstarget) | |
854 | if prevsrc is not None: |
|
854 | if prevsrc is not None: | |
855 | ui.warn(_('%s: not overwriting - %s collides with %s\n') % |
|
855 | ui.warn(_('%s: not overwriting - %s collides with %s\n') % | |
856 | (reltarget, abssrc, prevsrc)) |
|
856 | (reltarget, abssrc, prevsrc)) | |
857 | return |
|
857 | return | |
858 | if (not opts['after'] and os.path.exists(reltarget) or |
|
858 | if (not opts['after'] and os.path.exists(reltarget) or | |
859 | opts['after'] and repo.dirstate.state(abstarget) not in '?r'): |
|
859 | opts['after'] and repo.dirstate.state(abstarget) not in '?r'): | |
860 | if not opts['force']: |
|
860 | if not opts['force']: | |
861 | ui.warn(_('%s: not overwriting - file exists\n') % |
|
861 | ui.warn(_('%s: not overwriting - file exists\n') % | |
862 | reltarget) |
|
862 | reltarget) | |
863 | return |
|
863 | return | |
864 | if not opts['after']: |
|
864 | if not opts['after']: | |
865 | os.unlink(reltarget) |
|
865 | os.unlink(reltarget) | |
866 | if opts['after']: |
|
866 | if opts['after']: | |
867 | if not os.path.exists(reltarget): |
|
867 | if not os.path.exists(reltarget): | |
868 | return |
|
868 | return | |
869 | else: |
|
869 | else: | |
870 | targetdir = os.path.dirname(reltarget) or '.' |
|
870 | targetdir = os.path.dirname(reltarget) or '.' | |
871 | if not os.path.isdir(targetdir): |
|
871 | if not os.path.isdir(targetdir): | |
872 | os.makedirs(targetdir) |
|
872 | os.makedirs(targetdir) | |
873 | try: |
|
873 | try: | |
874 | shutil.copyfile(relsrc, reltarget) |
|
874 | shutil.copyfile(relsrc, reltarget) | |
875 | shutil.copymode(relsrc, reltarget) |
|
875 | shutil.copymode(relsrc, reltarget) | |
876 | except shutil.Error, inst: |
|
876 | except shutil.Error, inst: | |
877 | raise util.Abort(str(inst)) |
|
877 | raise util.Abort(str(inst)) | |
878 | except IOError, inst: |
|
878 | except IOError, inst: | |
879 | if inst.errno == errno.ENOENT: |
|
879 | if inst.errno == errno.ENOENT: | |
880 | ui.warn(_('%s: deleted in working copy\n') % relsrc) |
|
880 | ui.warn(_('%s: deleted in working copy\n') % relsrc) | |
881 | else: |
|
881 | else: | |
882 | ui.warn(_('%s: cannot copy - %s\n') % |
|
882 | ui.warn(_('%s: cannot copy - %s\n') % | |
883 | (relsrc, inst.strerror)) |
|
883 | (relsrc, inst.strerror)) | |
884 | errors += 1 |
|
884 | errors += 1 | |
885 | return |
|
885 | return | |
886 | if ui.verbose or not exact: |
|
886 | if ui.verbose or not exact: | |
887 | ui.status(_('copying %s to %s\n') % (relsrc, reltarget)) |
|
887 | ui.status(_('copying %s to %s\n') % (relsrc, reltarget)) | |
888 | targets[abstarget] = abssrc |
|
888 | targets[abstarget] = abssrc | |
889 | repo.copy(origsrc, abstarget) |
|
889 | repo.copy(origsrc, abstarget) | |
890 | copied.append((abssrc, relsrc, exact)) |
|
890 | copied.append((abssrc, relsrc, exact)) | |
891 |
|
891 | |||
892 | def targetpathfn(pat, dest, srcs): |
|
892 | def targetpathfn(pat, dest, srcs): | |
893 | if os.path.isdir(pat): |
|
893 | if os.path.isdir(pat): | |
894 | abspfx = util.canonpath(repo.root, cwd, pat) |
|
894 | abspfx = util.canonpath(repo.root, cwd, pat) | |
895 | if destdirexists: |
|
895 | if destdirexists: | |
896 | striplen = len(os.path.split(abspfx)[0]) |
|
896 | striplen = len(os.path.split(abspfx)[0]) | |
897 | else: |
|
897 | else: | |
898 | striplen = len(abspfx) |
|
898 | striplen = len(abspfx) | |
899 | if striplen: |
|
899 | if striplen: | |
900 | striplen += len(os.sep) |
|
900 | striplen += len(os.sep) | |
901 | res = lambda p: os.path.join(dest, p[striplen:]) |
|
901 | res = lambda p: os.path.join(dest, p[striplen:]) | |
902 | elif destdirexists: |
|
902 | elif destdirexists: | |
903 | res = lambda p: os.path.join(dest, os.path.basename(p)) |
|
903 | res = lambda p: os.path.join(dest, os.path.basename(p)) | |
904 | else: |
|
904 | else: | |
905 | res = lambda p: dest |
|
905 | res = lambda p: dest | |
906 | return res |
|
906 | return res | |
907 |
|
907 | |||
908 | def targetpathafterfn(pat, dest, srcs): |
|
908 | def targetpathafterfn(pat, dest, srcs): | |
909 | if util.patkind(pat, None)[0]: |
|
909 | if util.patkind(pat, None)[0]: | |
910 | # a mercurial pattern |
|
910 | # a mercurial pattern | |
911 | res = lambda p: os.path.join(dest, os.path.basename(p)) |
|
911 | res = lambda p: os.path.join(dest, os.path.basename(p)) | |
912 | else: |
|
912 | else: | |
913 | abspfx = util.canonpath(repo.root, cwd, pat) |
|
913 | abspfx = util.canonpath(repo.root, cwd, pat) | |
914 | if len(abspfx) < len(srcs[0][0]): |
|
914 | if len(abspfx) < len(srcs[0][0]): | |
915 | # A directory. Either the target path contains the last |
|
915 | # A directory. Either the target path contains the last | |
916 | # component of the source path or it does not. |
|
916 | # component of the source path or it does not. | |
917 | def evalpath(striplen): |
|
917 | def evalpath(striplen): | |
918 | score = 0 |
|
918 | score = 0 | |
919 | for s in srcs: |
|
919 | for s in srcs: | |
920 | t = os.path.join(dest, s[0][striplen:]) |
|
920 | t = os.path.join(dest, s[0][striplen:]) | |
921 | if os.path.exists(t): |
|
921 | if os.path.exists(t): | |
922 | score += 1 |
|
922 | score += 1 | |
923 | return score |
|
923 | return score | |
924 |
|
924 | |||
925 | striplen = len(abspfx) |
|
925 | striplen = len(abspfx) | |
926 | if striplen: |
|
926 | if striplen: | |
927 | striplen += len(os.sep) |
|
927 | striplen += len(os.sep) | |
928 | if os.path.isdir(os.path.join(dest, os.path.split(abspfx)[1])): |
|
928 | if os.path.isdir(os.path.join(dest, os.path.split(abspfx)[1])): | |
929 | score = evalpath(striplen) |
|
929 | score = evalpath(striplen) | |
930 | striplen1 = len(os.path.split(abspfx)[0]) |
|
930 | striplen1 = len(os.path.split(abspfx)[0]) | |
931 | if striplen1: |
|
931 | if striplen1: | |
932 | striplen1 += len(os.sep) |
|
932 | striplen1 += len(os.sep) | |
933 | if evalpath(striplen1) > score: |
|
933 | if evalpath(striplen1) > score: | |
934 | striplen = striplen1 |
|
934 | striplen = striplen1 | |
935 | res = lambda p: os.path.join(dest, p[striplen:]) |
|
935 | res = lambda p: os.path.join(dest, p[striplen:]) | |
936 | else: |
|
936 | else: | |
937 | # a file |
|
937 | # a file | |
938 | if destdirexists: |
|
938 | if destdirexists: | |
939 | res = lambda p: os.path.join(dest, os.path.basename(p)) |
|
939 | res = lambda p: os.path.join(dest, os.path.basename(p)) | |
940 | else: |
|
940 | else: | |
941 | res = lambda p: dest |
|
941 | res = lambda p: dest | |
942 | return res |
|
942 | return res | |
943 |
|
943 | |||
944 |
|
944 | |||
945 | pats = list(pats) |
|
945 | pats = list(pats) | |
946 | if not pats: |
|
946 | if not pats: | |
947 | raise util.Abort(_('no source or destination specified')) |
|
947 | raise util.Abort(_('no source or destination specified')) | |
948 | if len(pats) == 1: |
|
948 | if len(pats) == 1: | |
949 | raise util.Abort(_('no destination specified')) |
|
949 | raise util.Abort(_('no destination specified')) | |
950 | dest = pats.pop() |
|
950 | dest = pats.pop() | |
951 | destdirexists = os.path.isdir(dest) |
|
951 | destdirexists = os.path.isdir(dest) | |
952 | if (len(pats) > 1 or util.patkind(pats[0], None)[0]) and not destdirexists: |
|
952 | if (len(pats) > 1 or util.patkind(pats[0], None)[0]) and not destdirexists: | |
953 | raise util.Abort(_('with multiple sources, destination must be an ' |
|
953 | raise util.Abort(_('with multiple sources, destination must be an ' | |
954 | 'existing directory')) |
|
954 | 'existing directory')) | |
955 | if opts['after']: |
|
955 | if opts['after']: | |
956 | tfn = targetpathafterfn |
|
956 | tfn = targetpathafterfn | |
957 | else: |
|
957 | else: | |
958 | tfn = targetpathfn |
|
958 | tfn = targetpathfn | |
959 | copylist = [] |
|
959 | copylist = [] | |
960 | for pat in pats: |
|
960 | for pat in pats: | |
961 | srcs = [] |
|
961 | srcs = [] | |
962 | for tag, abssrc, relsrc, exact in walk(repo, [pat], opts): |
|
962 | for tag, abssrc, relsrc, exact in walk(repo, [pat], opts): | |
963 | origsrc = okaytocopy(abssrc, relsrc, exact) |
|
963 | origsrc = okaytocopy(abssrc, relsrc, exact) | |
964 | if origsrc: |
|
964 | if origsrc: | |
965 | srcs.append((origsrc, abssrc, relsrc, exact)) |
|
965 | srcs.append((origsrc, abssrc, relsrc, exact)) | |
966 | if not srcs: |
|
966 | if not srcs: | |
967 | continue |
|
967 | continue | |
968 | copylist.append((tfn(pat, dest, srcs), srcs)) |
|
968 | copylist.append((tfn(pat, dest, srcs), srcs)) | |
969 | if not copylist: |
|
969 | if not copylist: | |
970 | raise util.Abort(_('no files to copy')) |
|
970 | raise util.Abort(_('no files to copy')) | |
971 |
|
971 | |||
972 | for targetpath, srcs in copylist: |
|
972 | for targetpath, srcs in copylist: | |
973 | for origsrc, abssrc, relsrc, exact in srcs: |
|
973 | for origsrc, abssrc, relsrc, exact in srcs: | |
974 | copy(origsrc, abssrc, relsrc, targetpath(abssrc), exact) |
|
974 | copy(origsrc, abssrc, relsrc, targetpath(abssrc), exact) | |
975 |
|
975 | |||
976 | if errors: |
|
976 | if errors: | |
977 | ui.warn(_('(consider using --after)\n')) |
|
977 | ui.warn(_('(consider using --after)\n')) | |
978 | return errors, copied |
|
978 | return errors, copied | |
979 |
|
979 | |||
980 | def copy(ui, repo, *pats, **opts): |
|
980 | def copy(ui, repo, *pats, **opts): | |
981 | """mark files as copied for the next commit |
|
981 | """mark files as copied for the next commit | |
982 |
|
982 | |||
983 | Mark dest as having copies of source files. If dest is a |
|
983 | Mark dest as having copies of source files. If dest is a | |
984 | directory, copies are put in that directory. If dest is a file, |
|
984 | directory, copies are put in that directory. If dest is a file, | |
985 | there can only be one source. |
|
985 | there can only be one source. | |
986 |
|
986 | |||
987 | By default, this command copies the contents of files as they |
|
987 | By default, this command copies the contents of files as they | |
988 | stand in the working directory. If invoked with --after, the |
|
988 | stand in the working directory. If invoked with --after, the | |
989 | operation is recorded, but no copying is performed. |
|
989 | operation is recorded, but no copying is performed. | |
990 |
|
990 | |||
991 | This command takes effect in the next commit. |
|
991 | This command takes effect in the next commit. | |
992 |
|
992 | |||
993 | NOTE: This command should be treated as experimental. While it |
|
993 | NOTE: This command should be treated as experimental. While it | |
994 | should properly record copied files, this information is not yet |
|
994 | should properly record copied files, this information is not yet | |
995 | fully used by merge, nor fully reported by log. |
|
995 | fully used by merge, nor fully reported by log. | |
996 | """ |
|
996 | """ | |
997 | errs, copied = docopy(ui, repo, pats, opts) |
|
997 | errs, copied = docopy(ui, repo, pats, opts) | |
998 | return errs |
|
998 | return errs | |
999 |
|
999 | |||
1000 | def debugancestor(ui, index, rev1, rev2): |
|
1000 | def debugancestor(ui, index, rev1, rev2): | |
1001 | """find the ancestor revision of two revisions in a given index""" |
|
1001 | """find the ancestor revision of two revisions in a given index""" | |
1002 | r = revlog.revlog(util.opener(os.getcwd()), index, "") |
|
1002 | r = revlog.revlog(util.opener(os.getcwd()), index, "") | |
1003 | a = r.ancestor(r.lookup(rev1), r.lookup(rev2)) |
|
1003 | a = r.ancestor(r.lookup(rev1), r.lookup(rev2)) | |
1004 | ui.write("%d:%s\n" % (r.rev(a), hex(a))) |
|
1004 | ui.write("%d:%s\n" % (r.rev(a), hex(a))) | |
1005 |
|
1005 | |||
1006 | def debugrebuildstate(ui, repo, rev=None): |
|
1006 | def debugrebuildstate(ui, repo, rev=None): | |
1007 | """rebuild the dirstate as it would look like for the given revision""" |
|
1007 | """rebuild the dirstate as it would look like for the given revision""" | |
1008 | if not rev: |
|
1008 | if not rev: | |
1009 | rev = repo.changelog.tip() |
|
1009 | rev = repo.changelog.tip() | |
1010 | else: |
|
1010 | else: | |
1011 | rev = repo.lookup(rev) |
|
1011 | rev = repo.lookup(rev) | |
1012 | change = repo.changelog.read(rev) |
|
1012 | change = repo.changelog.read(rev) | |
1013 | n = change[0] |
|
1013 | n = change[0] | |
1014 | files = repo.manifest.readflags(n) |
|
1014 | files = repo.manifest.readflags(n) | |
1015 | wlock = repo.wlock() |
|
1015 | wlock = repo.wlock() | |
1016 | repo.dirstate.rebuild(rev, files.iteritems()) |
|
1016 | repo.dirstate.rebuild(rev, files.iteritems()) | |
1017 |
|
1017 | |||
1018 | def debugcheckstate(ui, repo): |
|
1018 | def debugcheckstate(ui, repo): | |
1019 | """validate the correctness of the current dirstate""" |
|
1019 | """validate the correctness of the current dirstate""" | |
1020 | parent1, parent2 = repo.dirstate.parents() |
|
1020 | parent1, parent2 = repo.dirstate.parents() | |
1021 | repo.dirstate.read() |
|
1021 | repo.dirstate.read() | |
1022 | dc = repo.dirstate.map |
|
1022 | dc = repo.dirstate.map | |
1023 | keys = dc.keys() |
|
1023 | keys = dc.keys() | |
1024 | keys.sort() |
|
1024 | keys.sort() | |
1025 | m1n = repo.changelog.read(parent1)[0] |
|
1025 | m1n = repo.changelog.read(parent1)[0] | |
1026 | m2n = repo.changelog.read(parent2)[0] |
|
1026 | m2n = repo.changelog.read(parent2)[0] | |
1027 | m1 = repo.manifest.read(m1n) |
|
1027 | m1 = repo.manifest.read(m1n) | |
1028 | m2 = repo.manifest.read(m2n) |
|
1028 | m2 = repo.manifest.read(m2n) | |
1029 | errors = 0 |
|
1029 | errors = 0 | |
1030 | for f in dc: |
|
1030 | for f in dc: | |
1031 | state = repo.dirstate.state(f) |
|
1031 | state = repo.dirstate.state(f) | |
1032 | if state in "nr" and f not in m1: |
|
1032 | if state in "nr" and f not in m1: | |
1033 | ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state)) |
|
1033 | ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state)) | |
1034 | errors += 1 |
|
1034 | errors += 1 | |
1035 | if state in "a" and f in m1: |
|
1035 | if state in "a" and f in m1: | |
1036 | ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state)) |
|
1036 | ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state)) | |
1037 | errors += 1 |
|
1037 | errors += 1 | |
1038 | if state in "m" and f not in m1 and f not in m2: |
|
1038 | if state in "m" and f not in m1 and f not in m2: | |
1039 | ui.warn(_("%s in state %s, but not in either manifest\n") % |
|
1039 | ui.warn(_("%s in state %s, but not in either manifest\n") % | |
1040 | (f, state)) |
|
1040 | (f, state)) | |
1041 | errors += 1 |
|
1041 | errors += 1 | |
1042 | for f in m1: |
|
1042 | for f in m1: | |
1043 | state = repo.dirstate.state(f) |
|
1043 | state = repo.dirstate.state(f) | |
1044 | if state not in "nrm": |
|
1044 | if state not in "nrm": | |
1045 | ui.warn(_("%s in manifest1, but listed as state %s") % (f, state)) |
|
1045 | ui.warn(_("%s in manifest1, but listed as state %s") % (f, state)) | |
1046 | errors += 1 |
|
1046 | errors += 1 | |
1047 | if errors: |
|
1047 | if errors: | |
1048 | error = _(".hg/dirstate inconsistent with current parent's manifest") |
|
1048 | error = _(".hg/dirstate inconsistent with current parent's manifest") | |
1049 | raise util.Abort(error) |
|
1049 | raise util.Abort(error) | |
1050 |
|
1050 | |||
1051 | def debugconfig(ui): |
|
1051 | def debugconfig(ui): | |
1052 | """show combined config settings from all hgrc files""" |
|
1052 | """show combined config settings from all hgrc files""" | |
1053 | try: |
|
1053 | try: | |
1054 | repo = hg.repository(ui) |
|
1054 | repo = hg.repository(ui) | |
1055 | except hg.RepoError: |
|
1055 | except hg.RepoError: | |
1056 | pass |
|
1056 | pass | |
1057 | for section, name, value in ui.walkconfig(): |
|
1057 | for section, name, value in ui.walkconfig(): | |
1058 | ui.write('%s.%s=%s\n' % (section, name, value)) |
|
1058 | ui.write('%s.%s=%s\n' % (section, name, value)) | |
1059 |
|
1059 | |||
1060 | def debugsetparents(ui, repo, rev1, rev2=None): |
|
1060 | def debugsetparents(ui, repo, rev1, rev2=None): | |
1061 | """manually set the parents of the current working directory |
|
1061 | """manually set the parents of the current working directory | |
1062 |
|
1062 | |||
1063 | This is useful for writing repository conversion tools, but should |
|
1063 | This is useful for writing repository conversion tools, but should | |
1064 | be used with care. |
|
1064 | be used with care. | |
1065 | """ |
|
1065 | """ | |
1066 |
|
1066 | |||
1067 | if not rev2: |
|
1067 | if not rev2: | |
1068 | rev2 = hex(nullid) |
|
1068 | rev2 = hex(nullid) | |
1069 |
|
1069 | |||
1070 | repo.dirstate.setparents(repo.lookup(rev1), repo.lookup(rev2)) |
|
1070 | repo.dirstate.setparents(repo.lookup(rev1), repo.lookup(rev2)) | |
1071 |
|
1071 | |||
1072 | def debugstate(ui, repo): |
|
1072 | def debugstate(ui, repo): | |
1073 | """show the contents of the current dirstate""" |
|
1073 | """show the contents of the current dirstate""" | |
1074 | repo.dirstate.read() |
|
1074 | repo.dirstate.read() | |
1075 | dc = repo.dirstate.map |
|
1075 | dc = repo.dirstate.map | |
1076 | keys = dc.keys() |
|
1076 | keys = dc.keys() | |
1077 | keys.sort() |
|
1077 | keys.sort() | |
1078 | for file_ in keys: |
|
1078 | for file_ in keys: | |
1079 | ui.write("%c %3o %10d %s %s\n" |
|
1079 | ui.write("%c %3o %10d %s %s\n" | |
1080 | % (dc[file_][0], dc[file_][1] & 0777, dc[file_][2], |
|
1080 | % (dc[file_][0], dc[file_][1] & 0777, dc[file_][2], | |
1081 | time.strftime("%x %X", |
|
1081 | time.strftime("%x %X", | |
1082 | time.localtime(dc[file_][3])), file_)) |
|
1082 | time.localtime(dc[file_][3])), file_)) | |
1083 | for f in repo.dirstate.copies: |
|
1083 | for f in repo.dirstate.copies: | |
1084 | ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copies[f], f)) |
|
1084 | ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copies[f], f)) | |
1085 |
|
1085 | |||
1086 | def debugdata(ui, file_, rev): |
|
1086 | def debugdata(ui, file_, rev): | |
1087 | """dump the contents of an data file revision""" |
|
1087 | """dump the contents of an data file revision""" | |
1088 | r = revlog.revlog(util.opener(os.getcwd()), file_[:-2] + ".i", file_) |
|
1088 | r = revlog.revlog(util.opener(os.getcwd()), file_[:-2] + ".i", file_) | |
1089 | try: |
|
1089 | try: | |
1090 | ui.write(r.revision(r.lookup(rev))) |
|
1090 | ui.write(r.revision(r.lookup(rev))) | |
1091 | except KeyError: |
|
1091 | except KeyError: | |
1092 | raise util.Abort(_('invalid revision identifier %s'), rev) |
|
1092 | raise util.Abort(_('invalid revision identifier %s'), rev) | |
1093 |
|
1093 | |||
1094 | def debugindex(ui, file_): |
|
1094 | def debugindex(ui, file_): | |
1095 | """dump the contents of an index file""" |
|
1095 | """dump the contents of an index file""" | |
1096 | r = revlog.revlog(util.opener(os.getcwd()), file_, "") |
|
1096 | r = revlog.revlog(util.opener(os.getcwd()), file_, "") | |
1097 | ui.write(" rev offset length base linkrev" + |
|
1097 | ui.write(" rev offset length base linkrev" + | |
1098 | " nodeid p1 p2\n") |
|
1098 | " nodeid p1 p2\n") | |
1099 | for i in range(r.count()): |
|
1099 | for i in range(r.count()): | |
1100 | e = r.index[i] |
|
1100 | e = r.index[i] | |
1101 | ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % ( |
|
1101 | ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % ( | |
1102 | i, e[0], e[1], e[2], e[3], |
|
1102 | i, e[0], e[1], e[2], e[3], | |
1103 | short(e[6]), short(e[4]), short(e[5]))) |
|
1103 | short(e[6]), short(e[4]), short(e[5]))) | |
1104 |
|
1104 | |||
1105 | def debugindexdot(ui, file_): |
|
1105 | def debugindexdot(ui, file_): | |
1106 | """dump an index DAG as a .dot file""" |
|
1106 | """dump an index DAG as a .dot file""" | |
1107 | r = revlog.revlog(util.opener(os.getcwd()), file_, "") |
|
1107 | r = revlog.revlog(util.opener(os.getcwd()), file_, "") | |
1108 | ui.write("digraph G {\n") |
|
1108 | ui.write("digraph G {\n") | |
1109 | for i in range(r.count()): |
|
1109 | for i in range(r.count()): | |
1110 | e = r.index[i] |
|
1110 | e = r.index[i] | |
1111 | ui.write("\t%d -> %d\n" % (r.rev(e[4]), i)) |
|
1111 | ui.write("\t%d -> %d\n" % (r.rev(e[4]), i)) | |
1112 | if e[5] != nullid: |
|
1112 | if e[5] != nullid: | |
1113 | ui.write("\t%d -> %d\n" % (r.rev(e[5]), i)) |
|
1113 | ui.write("\t%d -> %d\n" % (r.rev(e[5]), i)) | |
1114 | ui.write("}\n") |
|
1114 | ui.write("}\n") | |
1115 |
|
1115 | |||
1116 | def debugrename(ui, repo, file, rev=None): |
|
1116 | def debugrename(ui, repo, file, rev=None): | |
1117 | """dump rename information""" |
|
1117 | """dump rename information""" | |
1118 | r = repo.file(relpath(repo, [file])[0]) |
|
1118 | r = repo.file(relpath(repo, [file])[0]) | |
1119 | if rev: |
|
1119 | if rev: | |
1120 | try: |
|
1120 | try: | |
1121 | # assume all revision numbers are for changesets |
|
1121 | # assume all revision numbers are for changesets | |
1122 | n = repo.lookup(rev) |
|
1122 | n = repo.lookup(rev) | |
1123 | change = repo.changelog.read(n) |
|
1123 | change = repo.changelog.read(n) | |
1124 | m = repo.manifest.read(change[0]) |
|
1124 | m = repo.manifest.read(change[0]) | |
1125 | n = m[relpath(repo, [file])[0]] |
|
1125 | n = m[relpath(repo, [file])[0]] | |
1126 | except (hg.RepoError, KeyError): |
|
1126 | except (hg.RepoError, KeyError): | |
1127 | n = r.lookup(rev) |
|
1127 | n = r.lookup(rev) | |
1128 | else: |
|
1128 | else: | |
1129 | n = r.tip() |
|
1129 | n = r.tip() | |
1130 | m = r.renamed(n) |
|
1130 | m = r.renamed(n) | |
1131 | if m: |
|
1131 | if m: | |
1132 | ui.write(_("renamed from %s:%s\n") % (m[0], hex(m[1]))) |
|
1132 | ui.write(_("renamed from %s:%s\n") % (m[0], hex(m[1]))) | |
1133 | else: |
|
1133 | else: | |
1134 | ui.write(_("not renamed\n")) |
|
1134 | ui.write(_("not renamed\n")) | |
1135 |
|
1135 | |||
1136 | def debugwalk(ui, repo, *pats, **opts): |
|
1136 | def debugwalk(ui, repo, *pats, **opts): | |
1137 | """show how files match on given patterns""" |
|
1137 | """show how files match on given patterns""" | |
1138 | items = list(walk(repo, pats, opts)) |
|
1138 | items = list(walk(repo, pats, opts)) | |
1139 | if not items: |
|
1139 | if not items: | |
1140 | return |
|
1140 | return | |
1141 | fmt = '%%s %%-%ds %%-%ds %%s' % ( |
|
1141 | fmt = '%%s %%-%ds %%-%ds %%s' % ( | |
1142 | max([len(abs) for (src, abs, rel, exact) in items]), |
|
1142 | max([len(abs) for (src, abs, rel, exact) in items]), | |
1143 | max([len(rel) for (src, abs, rel, exact) in items])) |
|
1143 | max([len(rel) for (src, abs, rel, exact) in items])) | |
1144 | for src, abs, rel, exact in items: |
|
1144 | for src, abs, rel, exact in items: | |
1145 | line = fmt % (src, abs, rel, exact and 'exact' or '') |
|
1145 | line = fmt % (src, abs, rel, exact and 'exact' or '') | |
1146 | ui.write("%s\n" % line.rstrip()) |
|
1146 | ui.write("%s\n" % line.rstrip()) | |
1147 |
|
1147 | |||
1148 | def diff(ui, repo, *pats, **opts): |
|
1148 | def diff(ui, repo, *pats, **opts): | |
1149 | """diff repository (or selected files) |
|
1149 | """diff repository (or selected files) | |
1150 |
|
1150 | |||
1151 | Show differences between revisions for the specified files. |
|
1151 | Show differences between revisions for the specified files. | |
1152 |
|
1152 | |||
1153 | Differences between files are shown using the unified diff format. |
|
1153 | Differences between files are shown using the unified diff format. | |
1154 |
|
1154 | |||
1155 | When two revision arguments are given, then changes are shown |
|
1155 | When two revision arguments are given, then changes are shown | |
1156 | between those revisions. If only one revision is specified then |
|
1156 | between those revisions. If only one revision is specified then | |
1157 | that revision is compared to the working directory, and, when no |
|
1157 | that revision is compared to the working directory, and, when no | |
1158 | revisions are specified, the working directory files are compared |
|
1158 | revisions are specified, the working directory files are compared | |
1159 | to its parent. |
|
1159 | to its parent. | |
1160 |
|
1160 | |||
1161 | Without the -a option, diff will avoid generating diffs of files |
|
1161 | Without the -a option, diff will avoid generating diffs of files | |
1162 | it detects as binary. With -a, diff will generate a diff anyway, |
|
1162 | it detects as binary. With -a, diff will generate a diff anyway, | |
1163 | probably with undesirable results. |
|
1163 | probably with undesirable results. | |
1164 | """ |
|
1164 | """ | |
1165 | node1, node2 = None, None |
|
1165 | node1, node2 = None, None | |
1166 | revs = [repo.lookup(x) for x in opts['rev']] |
|
1166 | revs = [repo.lookup(x) for x in opts['rev']] | |
1167 |
|
1167 | |||
1168 | if len(revs) > 0: |
|
1168 | if len(revs) > 0: | |
1169 | node1 = revs[0] |
|
1169 | node1 = revs[0] | |
1170 | if len(revs) > 1: |
|
1170 | if len(revs) > 1: | |
1171 | node2 = revs[1] |
|
1171 | node2 = revs[1] | |
1172 | if len(revs) > 2: |
|
1172 | if len(revs) > 2: | |
1173 | raise util.Abort(_("too many revisions to diff")) |
|
1173 | raise util.Abort(_("too many revisions to diff")) | |
1174 |
|
1174 | |||
1175 | fns, matchfn, anypats = matchpats(repo, pats, opts) |
|
1175 | fns, matchfn, anypats = matchpats(repo, pats, opts) | |
1176 |
|
1176 | |||
1177 | dodiff(sys.stdout, ui, repo, node1, node2, fns, match=matchfn, |
|
1177 | dodiff(sys.stdout, ui, repo, node1, node2, fns, match=matchfn, | |
1178 | text=opts['text'], opts=opts) |
|
1178 | text=opts['text'], opts=opts) | |
1179 |
|
1179 | |||
1180 | def doexport(ui, repo, changeset, seqno, total, revwidth, opts): |
|
1180 | def doexport(ui, repo, changeset, seqno, total, revwidth, opts): | |
1181 | node = repo.lookup(changeset) |
|
1181 | node = repo.lookup(changeset) | |
1182 | parents = [p for p in repo.changelog.parents(node) if p != nullid] |
|
1182 | parents = [p for p in repo.changelog.parents(node) if p != nullid] | |
1183 | if opts['switch_parent']: |
|
1183 | if opts['switch_parent']: | |
1184 | parents.reverse() |
|
1184 | parents.reverse() | |
1185 | prev = (parents and parents[0]) or nullid |
|
1185 | prev = (parents and parents[0]) or nullid | |
1186 | change = repo.changelog.read(node) |
|
1186 | change = repo.changelog.read(node) | |
1187 |
|
1187 | |||
1188 | fp = make_file(repo, repo.changelog, opts['output'], |
|
1188 | fp = make_file(repo, repo.changelog, opts['output'], | |
1189 | node=node, total=total, seqno=seqno, |
|
1189 | node=node, total=total, seqno=seqno, | |
1190 | revwidth=revwidth) |
|
1190 | revwidth=revwidth) | |
1191 | if fp != sys.stdout: |
|
1191 | if fp != sys.stdout: | |
1192 | ui.note("%s\n" % fp.name) |
|
1192 | ui.note("%s\n" % fp.name) | |
1193 |
|
1193 | |||
1194 | fp.write("# HG changeset patch\n") |
|
1194 | fp.write("# HG changeset patch\n") | |
1195 | fp.write("# User %s\n" % change[1]) |
|
1195 | fp.write("# User %s\n" % change[1]) | |
1196 | fp.write("# Node ID %s\n" % hex(node)) |
|
1196 | fp.write("# Node ID %s\n" % hex(node)) | |
1197 | fp.write("# Parent %s\n" % hex(prev)) |
|
1197 | fp.write("# Parent %s\n" % hex(prev)) | |
1198 | if len(parents) > 1: |
|
1198 | if len(parents) > 1: | |
1199 | fp.write("# Parent %s\n" % hex(parents[1])) |
|
1199 | fp.write("# Parent %s\n" % hex(parents[1])) | |
1200 | fp.write(change[4].rstrip()) |
|
1200 | fp.write(change[4].rstrip()) | |
1201 | fp.write("\n\n") |
|
1201 | fp.write("\n\n") | |
1202 |
|
1202 | |||
1203 | dodiff(fp, ui, repo, prev, node, text=opts['text']) |
|
1203 | dodiff(fp, ui, repo, prev, node, text=opts['text']) | |
1204 | if fp != sys.stdout: |
|
1204 | if fp != sys.stdout: | |
1205 | fp.close() |
|
1205 | fp.close() | |
1206 |
|
1206 | |||
1207 | def export(ui, repo, *changesets, **opts): |
|
1207 | def export(ui, repo, *changesets, **opts): | |
1208 | """dump the header and diffs for one or more changesets |
|
1208 | """dump the header and diffs for one or more changesets | |
1209 |
|
1209 | |||
1210 | Print the changeset header and diffs for one or more revisions. |
|
1210 | Print the changeset header and diffs for one or more revisions. | |
1211 |
|
1211 | |||
1212 | The information shown in the changeset header is: author, |
|
1212 | The information shown in the changeset header is: author, | |
1213 | changeset hash, parent and commit comment. |
|
1213 | changeset hash, parent and commit comment. | |
1214 |
|
1214 | |||
1215 | Output may be to a file, in which case the name of the file is |
|
1215 | Output may be to a file, in which case the name of the file is | |
1216 | given using a format string. The formatting rules are as follows: |
|
1216 | given using a format string. The formatting rules are as follows: | |
1217 |
|
1217 | |||
1218 | %% literal "%" character |
|
1218 | %% literal "%" character | |
1219 | %H changeset hash (40 bytes of hexadecimal) |
|
1219 | %H changeset hash (40 bytes of hexadecimal) | |
1220 | %N number of patches being generated |
|
1220 | %N number of patches being generated | |
1221 | %R changeset revision number |
|
1221 | %R changeset revision number | |
1222 | %b basename of the exporting repository |
|
1222 | %b basename of the exporting repository | |
1223 | %h short-form changeset hash (12 bytes of hexadecimal) |
|
1223 | %h short-form changeset hash (12 bytes of hexadecimal) | |
1224 | %n zero-padded sequence number, starting at 1 |
|
1224 | %n zero-padded sequence number, starting at 1 | |
1225 | %r zero-padded changeset revision number |
|
1225 | %r zero-padded changeset revision number | |
1226 |
|
1226 | |||
1227 | Without the -a option, export will avoid generating diffs of files |
|
1227 | Without the -a option, export will avoid generating diffs of files | |
1228 | it detects as binary. With -a, export will generate a diff anyway, |
|
1228 | it detects as binary. With -a, export will generate a diff anyway, | |
1229 | probably with undesirable results. |
|
1229 | probably with undesirable results. | |
1230 |
|
1230 | |||
1231 | With the --switch-parent option, the diff will be against the second |
|
1231 | With the --switch-parent option, the diff will be against the second | |
1232 | parent. It can be useful to review a merge. |
|
1232 | parent. It can be useful to review a merge. | |
1233 | """ |
|
1233 | """ | |
1234 | if not changesets: |
|
1234 | if not changesets: | |
1235 | raise util.Abort(_("export requires at least one changeset")) |
|
1235 | raise util.Abort(_("export requires at least one changeset")) | |
1236 | seqno = 0 |
|
1236 | seqno = 0 | |
1237 | revs = list(revrange(ui, repo, changesets)) |
|
1237 | revs = list(revrange(ui, repo, changesets)) | |
1238 | total = len(revs) |
|
1238 | total = len(revs) | |
1239 | revwidth = max(map(len, revs)) |
|
1239 | revwidth = max(map(len, revs)) | |
1240 | msg = len(revs) > 1 and _("Exporting patches:\n") or _("Exporting patch:\n") |
|
1240 | msg = len(revs) > 1 and _("Exporting patches:\n") or _("Exporting patch:\n") | |
1241 | ui.note(msg) |
|
1241 | ui.note(msg) | |
1242 | for cset in revs: |
|
1242 | for cset in revs: | |
1243 | seqno += 1 |
|
1243 | seqno += 1 | |
1244 | doexport(ui, repo, cset, seqno, total, revwidth, opts) |
|
1244 | doexport(ui, repo, cset, seqno, total, revwidth, opts) | |
1245 |
|
1245 | |||
1246 | def forget(ui, repo, *pats, **opts): |
|
1246 | def forget(ui, repo, *pats, **opts): | |
1247 | """don't add the specified files on the next commit |
|
1247 | """don't add the specified files on the next commit | |
1248 |
|
1248 | |||
1249 | Undo an 'hg add' scheduled for the next commit. |
|
1249 | Undo an 'hg add' scheduled for the next commit. | |
1250 | """ |
|
1250 | """ | |
1251 | forget = [] |
|
1251 | forget = [] | |
1252 | for src, abs, rel, exact in walk(repo, pats, opts): |
|
1252 | for src, abs, rel, exact in walk(repo, pats, opts): | |
1253 | if repo.dirstate.state(abs) == 'a': |
|
1253 | if repo.dirstate.state(abs) == 'a': | |
1254 | forget.append(abs) |
|
1254 | forget.append(abs) | |
1255 | if ui.verbose or not exact: |
|
1255 | if ui.verbose or not exact: | |
1256 | ui.status(_('forgetting %s\n') % ((pats and rel) or abs)) |
|
1256 | ui.status(_('forgetting %s\n') % ((pats and rel) or abs)) | |
1257 | repo.forget(forget) |
|
1257 | repo.forget(forget) | |
1258 |
|
1258 | |||
1259 | def grep(ui, repo, pattern, *pats, **opts): |
|
1259 | def grep(ui, repo, pattern, *pats, **opts): | |
1260 | """search for a pattern in specified files and revisions |
|
1260 | """search for a pattern in specified files and revisions | |
1261 |
|
1261 | |||
1262 | Search revisions of files for a regular expression. |
|
1262 | Search revisions of files for a regular expression. | |
1263 |
|
1263 | |||
1264 | This command behaves differently than Unix grep. It only accepts |
|
1264 | This command behaves differently than Unix grep. It only accepts | |
1265 | Python/Perl regexps. It searches repository history, not the |
|
1265 | Python/Perl regexps. It searches repository history, not the | |
1266 | working directory. It always prints the revision number in which |
|
1266 | working directory. It always prints the revision number in which | |
1267 | a match appears. |
|
1267 | a match appears. | |
1268 |
|
1268 | |||
1269 | By default, grep only prints output for the first revision of a |
|
1269 | By default, grep only prints output for the first revision of a | |
1270 | file in which it finds a match. To get it to print every revision |
|
1270 | file in which it finds a match. To get it to print every revision | |
1271 | that contains a change in match status ("-" for a match that |
|
1271 | that contains a change in match status ("-" for a match that | |
1272 | becomes a non-match, or "+" for a non-match that becomes a match), |
|
1272 | becomes a non-match, or "+" for a non-match that becomes a match), | |
1273 | use the --all flag. |
|
1273 | use the --all flag. | |
1274 | """ |
|
1274 | """ | |
1275 | reflags = 0 |
|
1275 | reflags = 0 | |
1276 | if opts['ignore_case']: |
|
1276 | if opts['ignore_case']: | |
1277 | reflags |= re.I |
|
1277 | reflags |= re.I | |
1278 | regexp = re.compile(pattern, reflags) |
|
1278 | regexp = re.compile(pattern, reflags) | |
1279 | sep, eol = ':', '\n' |
|
1279 | sep, eol = ':', '\n' | |
1280 | if opts['print0']: |
|
1280 | if opts['print0']: | |
1281 | sep = eol = '\0' |
|
1281 | sep = eol = '\0' | |
1282 |
|
1282 | |||
1283 | fcache = {} |
|
1283 | fcache = {} | |
1284 | def getfile(fn): |
|
1284 | def getfile(fn): | |
1285 | if fn not in fcache: |
|
1285 | if fn not in fcache: | |
1286 | fcache[fn] = repo.file(fn) |
|
1286 | fcache[fn] = repo.file(fn) | |
1287 | return fcache[fn] |
|
1287 | return fcache[fn] | |
1288 |
|
1288 | |||
1289 | def matchlines(body): |
|
1289 | def matchlines(body): | |
1290 | begin = 0 |
|
1290 | begin = 0 | |
1291 | linenum = 0 |
|
1291 | linenum = 0 | |
1292 | while True: |
|
1292 | while True: | |
1293 | match = regexp.search(body, begin) |
|
1293 | match = regexp.search(body, begin) | |
1294 | if not match: |
|
1294 | if not match: | |
1295 | break |
|
1295 | break | |
1296 | mstart, mend = match.span() |
|
1296 | mstart, mend = match.span() | |
1297 | linenum += body.count('\n', begin, mstart) + 1 |
|
1297 | linenum += body.count('\n', begin, mstart) + 1 | |
1298 | lstart = body.rfind('\n', begin, mstart) + 1 or begin |
|
1298 | lstart = body.rfind('\n', begin, mstart) + 1 or begin | |
1299 | lend = body.find('\n', mend) |
|
1299 | lend = body.find('\n', mend) | |
1300 | yield linenum, mstart - lstart, mend - lstart, body[lstart:lend] |
|
1300 | yield linenum, mstart - lstart, mend - lstart, body[lstart:lend] | |
1301 | begin = lend + 1 |
|
1301 | begin = lend + 1 | |
1302 |
|
1302 | |||
1303 | class linestate(object): |
|
1303 | class linestate(object): | |
1304 | def __init__(self, line, linenum, colstart, colend): |
|
1304 | def __init__(self, line, linenum, colstart, colend): | |
1305 | self.line = line |
|
1305 | self.line = line | |
1306 | self.linenum = linenum |
|
1306 | self.linenum = linenum | |
1307 | self.colstart = colstart |
|
1307 | self.colstart = colstart | |
1308 | self.colend = colend |
|
1308 | self.colend = colend | |
1309 | def __eq__(self, other): |
|
1309 | def __eq__(self, other): | |
1310 | return self.line == other.line |
|
1310 | return self.line == other.line | |
1311 | def __hash__(self): |
|
1311 | def __hash__(self): | |
1312 | return hash(self.line) |
|
1312 | return hash(self.line) | |
1313 |
|
1313 | |||
1314 | matches = {} |
|
1314 | matches = {} | |
1315 | def grepbody(fn, rev, body): |
|
1315 | def grepbody(fn, rev, body): | |
1316 | matches[rev].setdefault(fn, {}) |
|
1316 | matches[rev].setdefault(fn, {}) | |
1317 | m = matches[rev][fn] |
|
1317 | m = matches[rev][fn] | |
1318 | for lnum, cstart, cend, line in matchlines(body): |
|
1318 | for lnum, cstart, cend, line in matchlines(body): | |
1319 | s = linestate(line, lnum, cstart, cend) |
|
1319 | s = linestate(line, lnum, cstart, cend) | |
1320 | m[s] = s |
|
1320 | m[s] = s | |
1321 |
|
1321 | |||
1322 | # FIXME: prev isn't used, why ? |
|
1322 | # FIXME: prev isn't used, why ? | |
1323 | prev = {} |
|
1323 | prev = {} | |
1324 | ucache = {} |
|
1324 | ucache = {} | |
1325 | def display(fn, rev, states, prevstates): |
|
1325 | def display(fn, rev, states, prevstates): | |
1326 | diff = list(sets.Set(states).symmetric_difference(sets.Set(prevstates))) |
|
1326 | diff = list(sets.Set(states).symmetric_difference(sets.Set(prevstates))) | |
1327 | diff.sort(lambda x, y: cmp(x.linenum, y.linenum)) |
|
1327 | diff.sort(lambda x, y: cmp(x.linenum, y.linenum)) | |
1328 | counts = {'-': 0, '+': 0} |
|
1328 | counts = {'-': 0, '+': 0} | |
1329 | filerevmatches = {} |
|
1329 | filerevmatches = {} | |
1330 | for l in diff: |
|
1330 | for l in diff: | |
1331 | if incrementing or not opts['all']: |
|
1331 | if incrementing or not opts['all']: | |
1332 | change = ((l in prevstates) and '-') or '+' |
|
1332 | change = ((l in prevstates) and '-') or '+' | |
1333 | r = rev |
|
1333 | r = rev | |
1334 | else: |
|
1334 | else: | |
1335 | change = ((l in states) and '-') or '+' |
|
1335 | change = ((l in states) and '-') or '+' | |
1336 | r = prev[fn] |
|
1336 | r = prev[fn] | |
1337 | cols = [fn, str(rev)] |
|
1337 | cols = [fn, str(rev)] | |
1338 | if opts['line_number']: |
|
1338 | if opts['line_number']: | |
1339 | cols.append(str(l.linenum)) |
|
1339 | cols.append(str(l.linenum)) | |
1340 | if opts['all']: |
|
1340 | if opts['all']: | |
1341 | cols.append(change) |
|
1341 | cols.append(change) | |
1342 | if opts['user']: |
|
1342 | if opts['user']: | |
1343 | cols.append(trimuser(ui, getchange(rev)[1], rev, |
|
1343 | cols.append(trimuser(ui, getchange(rev)[1], rev, | |
1344 | ucache)) |
|
1344 | ucache)) | |
1345 | if opts['files_with_matches']: |
|
1345 | if opts['files_with_matches']: | |
1346 | c = (fn, rev) |
|
1346 | c = (fn, rev) | |
1347 | if c in filerevmatches: |
|
1347 | if c in filerevmatches: | |
1348 | continue |
|
1348 | continue | |
1349 | filerevmatches[c] = 1 |
|
1349 | filerevmatches[c] = 1 | |
1350 | else: |
|
1350 | else: | |
1351 | cols.append(l.line) |
|
1351 | cols.append(l.line) | |
1352 | ui.write(sep.join(cols), eol) |
|
1352 | ui.write(sep.join(cols), eol) | |
1353 | counts[change] += 1 |
|
1353 | counts[change] += 1 | |
1354 | return counts['+'], counts['-'] |
|
1354 | return counts['+'], counts['-'] | |
1355 |
|
1355 | |||
1356 | fstate = {} |
|
1356 | fstate = {} | |
1357 | skip = {} |
|
1357 | skip = {} | |
1358 | changeiter, getchange, matchfn = walkchangerevs(ui, repo, pats, opts) |
|
1358 | changeiter, getchange, matchfn = walkchangerevs(ui, repo, pats, opts) | |
1359 | count = 0 |
|
1359 | count = 0 | |
1360 | incrementing = False |
|
1360 | incrementing = False | |
1361 | for st, rev, fns in changeiter: |
|
1361 | for st, rev, fns in changeiter: | |
1362 | if st == 'window': |
|
1362 | if st == 'window': | |
1363 | incrementing = rev |
|
1363 | incrementing = rev | |
1364 | matches.clear() |
|
1364 | matches.clear() | |
1365 | elif st == 'add': |
|
1365 | elif st == 'add': | |
1366 | change = repo.changelog.read(repo.lookup(str(rev))) |
|
1366 | change = repo.changelog.read(repo.lookup(str(rev))) | |
1367 | mf = repo.manifest.read(change[0]) |
|
1367 | mf = repo.manifest.read(change[0]) | |
1368 | matches[rev] = {} |
|
1368 | matches[rev] = {} | |
1369 | for fn in fns: |
|
1369 | for fn in fns: | |
1370 | if fn in skip: |
|
1370 | if fn in skip: | |
1371 | continue |
|
1371 | continue | |
1372 | fstate.setdefault(fn, {}) |
|
1372 | fstate.setdefault(fn, {}) | |
1373 | try: |
|
1373 | try: | |
1374 | grepbody(fn, rev, getfile(fn).read(mf[fn])) |
|
1374 | grepbody(fn, rev, getfile(fn).read(mf[fn])) | |
1375 | except KeyError: |
|
1375 | except KeyError: | |
1376 | pass |
|
1376 | pass | |
1377 | elif st == 'iter': |
|
1377 | elif st == 'iter': | |
1378 | states = matches[rev].items() |
|
1378 | states = matches[rev].items() | |
1379 | states.sort() |
|
1379 | states.sort() | |
1380 | for fn, m in states: |
|
1380 | for fn, m in states: | |
1381 | if fn in skip: |
|
1381 | if fn in skip: | |
1382 | continue |
|
1382 | continue | |
1383 | if incrementing or not opts['all'] or fstate[fn]: |
|
1383 | if incrementing or not opts['all'] or fstate[fn]: | |
1384 | pos, neg = display(fn, rev, m, fstate[fn]) |
|
1384 | pos, neg = display(fn, rev, m, fstate[fn]) | |
1385 | count += pos + neg |
|
1385 | count += pos + neg | |
1386 | if pos and not opts['all']: |
|
1386 | if pos and not opts['all']: | |
1387 | skip[fn] = True |
|
1387 | skip[fn] = True | |
1388 | fstate[fn] = m |
|
1388 | fstate[fn] = m | |
1389 | prev[fn] = rev |
|
1389 | prev[fn] = rev | |
1390 |
|
1390 | |||
1391 | if not incrementing: |
|
1391 | if not incrementing: | |
1392 | fstate = fstate.items() |
|
1392 | fstate = fstate.items() | |
1393 | fstate.sort() |
|
1393 | fstate.sort() | |
1394 | for fn, state in fstate: |
|
1394 | for fn, state in fstate: | |
1395 | if fn in skip: |
|
1395 | if fn in skip: | |
1396 | continue |
|
1396 | continue | |
1397 | display(fn, rev, {}, state) |
|
1397 | display(fn, rev, {}, state) | |
1398 | return (count == 0 and 1) or 0 |
|
1398 | return (count == 0 and 1) or 0 | |
1399 |
|
1399 | |||
1400 | def heads(ui, repo, **opts): |
|
1400 | def heads(ui, repo, **opts): | |
1401 | """show current repository heads |
|
1401 | """show current repository heads | |
1402 |
|
1402 | |||
1403 | Show all repository head changesets. |
|
1403 | Show all repository head changesets. | |
1404 |
|
1404 | |||
1405 | Repository "heads" are changesets that don't have children |
|
1405 | Repository "heads" are changesets that don't have children | |
1406 | changesets. They are where development generally takes place and |
|
1406 | changesets. They are where development generally takes place and | |
1407 | are the usual targets for update and merge operations. |
|
1407 | are the usual targets for update and merge operations. | |
1408 | """ |
|
1408 | """ | |
1409 | if opts['rev']: |
|
1409 | if opts['rev']: | |
1410 | heads = repo.heads(repo.lookup(opts['rev'])) |
|
1410 | heads = repo.heads(repo.lookup(opts['rev'])) | |
1411 | else: |
|
1411 | else: | |
1412 | heads = repo.heads() |
|
1412 | heads = repo.heads() | |
1413 | br = None |
|
1413 | br = None | |
1414 | if opts['branches']: |
|
1414 | if opts['branches']: | |
1415 | br = repo.branchlookup(heads) |
|
1415 | br = repo.branchlookup(heads) | |
1416 | for n in heads: |
|
1416 | for n in heads: | |
1417 | show_changeset(ui, repo, changenode=n, brinfo=br) |
|
1417 | show_changeset(ui, repo, changenode=n, brinfo=br) | |
1418 |
|
1418 | |||
1419 | def identify(ui, repo): |
|
1419 | def identify(ui, repo): | |
1420 | """print information about the working copy |
|
1420 | """print information about the working copy | |
1421 |
|
1421 | |||
1422 | Print a short summary of the current state of the repo. |
|
1422 | Print a short summary of the current state of the repo. | |
1423 |
|
1423 | |||
1424 | This summary identifies the repository state using one or two parent |
|
1424 | This summary identifies the repository state using one or two parent | |
1425 | hash identifiers, followed by a "+" if there are uncommitted changes |
|
1425 | hash identifiers, followed by a "+" if there are uncommitted changes | |
1426 | in the working directory, followed by a list of tags for this revision. |
|
1426 | in the working directory, followed by a list of tags for this revision. | |
1427 | """ |
|
1427 | """ | |
1428 | parents = [p for p in repo.dirstate.parents() if p != nullid] |
|
1428 | parents = [p for p in repo.dirstate.parents() if p != nullid] | |
1429 | if not parents: |
|
1429 | if not parents: | |
1430 | ui.write(_("unknown\n")) |
|
1430 | ui.write(_("unknown\n")) | |
1431 | return |
|
1431 | return | |
1432 |
|
1432 | |||
1433 | hexfunc = ui.verbose and hex or short |
|
1433 | hexfunc = ui.verbose and hex or short | |
1434 | modified, added, removed, deleted, unknown = repo.changes() |
|
1434 | modified, added, removed, deleted, unknown = repo.changes() | |
1435 | output = ["%s%s" % |
|
1435 | output = ["%s%s" % | |
1436 | ('+'.join([hexfunc(parent) for parent in parents]), |
|
1436 | ('+'.join([hexfunc(parent) for parent in parents]), | |
1437 | (modified or added or removed or deleted) and "+" or "")] |
|
1437 | (modified or added or removed or deleted) and "+" or "")] | |
1438 |
|
1438 | |||
1439 | if not ui.quiet: |
|
1439 | if not ui.quiet: | |
1440 | # multiple tags for a single parent separated by '/' |
|
1440 | # multiple tags for a single parent separated by '/' | |
1441 | parenttags = ['/'.join(tags) |
|
1441 | parenttags = ['/'.join(tags) | |
1442 | for tags in map(repo.nodetags, parents) if tags] |
|
1442 | for tags in map(repo.nodetags, parents) if tags] | |
1443 | # tags for multiple parents separated by ' + ' |
|
1443 | # tags for multiple parents separated by ' + ' | |
1444 | if parenttags: |
|
1444 | if parenttags: | |
1445 | output.append(' + '.join(parenttags)) |
|
1445 | output.append(' + '.join(parenttags)) | |
1446 |
|
1446 | |||
1447 | ui.write("%s\n" % ' '.join(output)) |
|
1447 | ui.write("%s\n" % ' '.join(output)) | |
1448 |
|
1448 | |||
1449 | def import_(ui, repo, patch1, *patches, **opts): |
|
1449 | def import_(ui, repo, patch1, *patches, **opts): | |
1450 | """import an ordered set of patches |
|
1450 | """import an ordered set of patches | |
1451 |
|
1451 | |||
1452 | Import a list of patches and commit them individually. |
|
1452 | Import a list of patches and commit them individually. | |
1453 |
|
1453 | |||
1454 | If there are outstanding changes in the working directory, import |
|
1454 | If there are outstanding changes in the working directory, import | |
1455 | will abort unless given the -f flag. |
|
1455 | will abort unless given the -f flag. | |
1456 |
|
1456 | |||
1457 | If a patch looks like a mail message (its first line starts with |
|
1457 | If a patch looks like a mail message (its first line starts with | |
1458 | "From " or looks like an RFC822 header), it will not be applied |
|
1458 | "From " or looks like an RFC822 header), it will not be applied | |
1459 | unless the -f option is used. The importer neither parses nor |
|
1459 | unless the -f option is used. The importer neither parses nor | |
1460 | discards mail headers, so use -f only to override the "mailness" |
|
1460 | discards mail headers, so use -f only to override the "mailness" | |
1461 | safety check, not to import a real mail message. |
|
1461 | safety check, not to import a real mail message. | |
1462 | """ |
|
1462 | """ | |
1463 | patches = (patch1,) + patches |
|
1463 | patches = (patch1,) + patches | |
1464 |
|
1464 | |||
1465 | if not opts['force']: |
|
1465 | if not opts['force']: | |
1466 | modified, added, removed, deleted, unknown = repo.changes() |
|
1466 | modified, added, removed, deleted, unknown = repo.changes() | |
1467 | if modified or added or removed or deleted: |
|
1467 | if modified or added or removed or deleted: | |
1468 | raise util.Abort(_("outstanding uncommitted changes")) |
|
1468 | raise util.Abort(_("outstanding uncommitted changes")) | |
1469 |
|
1469 | |||
1470 | d = opts["base"] |
|
1470 | d = opts["base"] | |
1471 | strip = opts["strip"] |
|
1471 | strip = opts["strip"] | |
1472 |
|
1472 | |||
1473 | mailre = re.compile(r'(?:From |[\w-]+:)') |
|
1473 | mailre = re.compile(r'(?:From |[\w-]+:)') | |
1474 |
|
1474 | |||
1475 | # attempt to detect the start of a patch |
|
1475 | # attempt to detect the start of a patch | |
1476 | # (this heuristic is borrowed from quilt) |
|
1476 | # (this heuristic is borrowed from quilt) | |
1477 | diffre = re.compile(r'(?:Index:[ \t]|diff[ \t]|RCS file: |' + |
|
1477 | diffre = re.compile(r'(?:Index:[ \t]|diff[ \t]|RCS file: |' + | |
1478 | 'retrieving revision [0-9]+(\.[0-9]+)*$|' + |
|
1478 | 'retrieving revision [0-9]+(\.[0-9]+)*$|' + | |
1479 | '(---|\*\*\*)[ \t])') |
|
1479 | '(---|\*\*\*)[ \t])') | |
1480 |
|
1480 | |||
1481 | for patch in patches: |
|
1481 | for patch in patches: | |
1482 | ui.status(_("applying %s\n") % patch) |
|
1482 | ui.status(_("applying %s\n") % patch) | |
1483 | pf = os.path.join(d, patch) |
|
1483 | pf = os.path.join(d, patch) | |
1484 |
|
1484 | |||
1485 | message = [] |
|
1485 | message = [] | |
1486 | user = None |
|
1486 | user = None | |
1487 | hgpatch = False |
|
1487 | hgpatch = False | |
1488 | for line in file(pf): |
|
1488 | for line in file(pf): | |
1489 | line = line.rstrip() |
|
1489 | line = line.rstrip() | |
1490 | if (not message and not hgpatch and |
|
1490 | if (not message and not hgpatch and | |
1491 | mailre.match(line) and not opts['force']): |
|
1491 | mailre.match(line) and not opts['force']): | |
1492 | if len(line) > 35: |
|
1492 | if len(line) > 35: | |
1493 | line = line[:32] + '...' |
|
1493 | line = line[:32] + '...' | |
1494 | raise util.Abort(_('first line looks like a ' |
|
1494 | raise util.Abort(_('first line looks like a ' | |
1495 | 'mail header: ') + line) |
|
1495 | 'mail header: ') + line) | |
1496 | if diffre.match(line): |
|
1496 | if diffre.match(line): | |
1497 | break |
|
1497 | break | |
1498 | elif hgpatch: |
|
1498 | elif hgpatch: | |
1499 | # parse values when importing the result of an hg export |
|
1499 | # parse values when importing the result of an hg export | |
1500 | if line.startswith("# User "): |
|
1500 | if line.startswith("# User "): | |
1501 | user = line[7:] |
|
1501 | user = line[7:] | |
1502 | ui.debug(_('User: %s\n') % user) |
|
1502 | ui.debug(_('User: %s\n') % user) | |
1503 | elif not line.startswith("# ") and line: |
|
1503 | elif not line.startswith("# ") and line: | |
1504 | message.append(line) |
|
1504 | message.append(line) | |
1505 | hgpatch = False |
|
1505 | hgpatch = False | |
1506 | elif line == '# HG changeset patch': |
|
1506 | elif line == '# HG changeset patch': | |
1507 | hgpatch = True |
|
1507 | hgpatch = True | |
1508 | message = [] # We may have collected garbage |
|
1508 | message = [] # We may have collected garbage | |
1509 | else: |
|
1509 | else: | |
1510 | message.append(line) |
|
1510 | message.append(line) | |
1511 |
|
1511 | |||
1512 | # make sure message isn't empty |
|
1512 | # make sure message isn't empty | |
1513 | if not message: |
|
1513 | if not message: | |
1514 | message = _("imported patch %s\n") % patch |
|
1514 | message = _("imported patch %s\n") % patch | |
1515 | else: |
|
1515 | else: | |
1516 | message = "%s\n" % '\n'.join(message) |
|
1516 | message = "%s\n" % '\n'.join(message) | |
1517 | ui.debug(_('message:\n%s\n') % message) |
|
1517 | ui.debug(_('message:\n%s\n') % message) | |
1518 |
|
1518 | |||
1519 | files = util.patch(strip, pf, ui) |
|
1519 | files = util.patch(strip, pf, ui) | |
1520 |
|
1520 | |||
1521 | if len(files) > 0: |
|
1521 | if len(files) > 0: | |
1522 | addremove(ui, repo, *files) |
|
1522 | addremove(ui, repo, *files) | |
1523 | repo.commit(files, message, user) |
|
1523 | repo.commit(files, message, user) | |
1524 |
|
1524 | |||
1525 | def incoming(ui, repo, source="default", **opts): |
|
1525 | def incoming(ui, repo, source="default", **opts): | |
1526 | """show new changesets found in source |
|
1526 | """show new changesets found in source | |
1527 |
|
1527 | |||
1528 | Show new changesets found in the specified repo or the default |
|
1528 | Show new changesets found in the specified repo or the default | |
1529 | pull repo. These are the changesets that would be pulled if a pull |
|
1529 | pull repo. These are the changesets that would be pulled if a pull | |
1530 | was requested. |
|
1530 | was requested. | |
1531 |
|
1531 | |||
1532 | Currently only local repositories are supported. |
|
1532 | Currently only local repositories are supported. | |
1533 | """ |
|
1533 | """ | |
1534 | source = ui.expandpath(source, repo.root) |
|
1534 | source = ui.expandpath(source, repo.root) | |
1535 | other = hg.repository(ui, source) |
|
1535 | other = hg.repository(ui, source) | |
1536 | if not other.local(): |
|
1536 | if not other.local(): | |
1537 | raise util.Abort(_("incoming doesn't work for remote repositories yet")) |
|
1537 | raise util.Abort(_("incoming doesn't work for remote repositories yet")) | |
1538 | o = repo.findincoming(other) |
|
1538 | o = repo.findincoming(other) | |
1539 | if not o: |
|
1539 | if not o: | |
1540 | return |
|
1540 | return | |
1541 | o = other.changelog.nodesbetween(o)[0] |
|
1541 | o = other.changelog.nodesbetween(o)[0] | |
1542 | if opts['newest_first']: |
|
1542 | if opts['newest_first']: | |
1543 | o.reverse() |
|
1543 | o.reverse() | |
1544 | for n in o: |
|
1544 | for n in o: | |
1545 | parents = [p for p in other.changelog.parents(n) if p != nullid] |
|
1545 | parents = [p for p in other.changelog.parents(n) if p != nullid] | |
1546 | if opts['no_merges'] and len(parents) == 2: |
|
1546 | if opts['no_merges'] and len(parents) == 2: | |
1547 | continue |
|
1547 | continue | |
1548 | show_changeset(ui, other, changenode=n) |
|
1548 | show_changeset(ui, other, changenode=n) | |
1549 | if opts['patch']: |
|
1549 | if opts['patch']: | |
1550 | prev = (parents and parents[0]) or nullid |
|
1550 | prev = (parents and parents[0]) or nullid | |
1551 | dodiff(ui, ui, other, prev, n) |
|
1551 | dodiff(ui, ui, other, prev, n) | |
1552 | ui.write("\n") |
|
1552 | ui.write("\n") | |
1553 |
|
1553 | |||
1554 | def init(ui, dest="."): |
|
1554 | def init(ui, dest="."): | |
1555 | """create a new repository in the given directory |
|
1555 | """create a new repository in the given directory | |
1556 |
|
1556 | |||
1557 | Initialize a new repository in the given directory. If the given |
|
1557 | Initialize a new repository in the given directory. If the given | |
1558 | directory does not exist, it is created. |
|
1558 | directory does not exist, it is created. | |
1559 |
|
1559 | |||
1560 | If no directory is given, the current directory is used. |
|
1560 | If no directory is given, the current directory is used. | |
1561 | """ |
|
1561 | """ | |
1562 | if not os.path.exists(dest): |
|
1562 | if not os.path.exists(dest): | |
1563 | os.mkdir(dest) |
|
1563 | os.mkdir(dest) | |
1564 | hg.repository(ui, dest, create=1) |
|
1564 | hg.repository(ui, dest, create=1) | |
1565 |
|
1565 | |||
1566 | def locate(ui, repo, *pats, **opts): |
|
1566 | def locate(ui, repo, *pats, **opts): | |
1567 | """locate files matching specific patterns |
|
1567 | """locate files matching specific patterns | |
1568 |
|
1568 | |||
1569 | Print all files under Mercurial control whose names match the |
|
1569 | Print all files under Mercurial control whose names match the | |
1570 | given patterns. |
|
1570 | given patterns. | |
1571 |
|
1571 | |||
1572 | This command searches the current directory and its |
|
1572 | This command searches the current directory and its | |
1573 | subdirectories. To search an entire repository, move to the root |
|
1573 | subdirectories. To search an entire repository, move to the root | |
1574 | of the repository. |
|
1574 | of the repository. | |
1575 |
|
1575 | |||
1576 | If no patterns are given to match, this command prints all file |
|
1576 | If no patterns are given to match, this command prints all file | |
1577 | names. |
|
1577 | names. | |
1578 |
|
1578 | |||
1579 | If you want to feed the output of this command into the "xargs" |
|
1579 | If you want to feed the output of this command into the "xargs" | |
1580 | command, use the "-0" option to both this command and "xargs". |
|
1580 | command, use the "-0" option to both this command and "xargs". | |
1581 | This will avoid the problem of "xargs" treating single filenames |
|
1581 | This will avoid the problem of "xargs" treating single filenames | |
1582 | that contain white space as multiple filenames. |
|
1582 | that contain white space as multiple filenames. | |
1583 | """ |
|
1583 | """ | |
1584 | end = opts['print0'] and '\0' or '\n' |
|
1584 | end = opts['print0'] and '\0' or '\n' | |
1585 | rev = opts['rev'] |
|
1585 | rev = opts['rev'] | |
1586 | if rev: |
|
1586 | if rev: | |
1587 | node = repo.lookup(rev) |
|
1587 | node = repo.lookup(rev) | |
1588 | else: |
|
1588 | else: | |
1589 | node = None |
|
1589 | node = None | |
1590 |
|
1590 | |||
1591 | for src, abs, rel, exact in walk(repo, pats, opts, node=node, |
|
1591 | for src, abs, rel, exact in walk(repo, pats, opts, node=node, | |
1592 | head='(?:.*/|)'): |
|
1592 | head='(?:.*/|)'): | |
1593 | if not node and repo.dirstate.state(abs) == '?': |
|
1593 | if not node and repo.dirstate.state(abs) == '?': | |
1594 | continue |
|
1594 | continue | |
1595 | if opts['fullpath']: |
|
1595 | if opts['fullpath']: | |
1596 | ui.write(os.path.join(repo.root, abs), end) |
|
1596 | ui.write(os.path.join(repo.root, abs), end) | |
1597 | else: |
|
1597 | else: | |
1598 | ui.write(((pats and rel) or abs), end) |
|
1598 | ui.write(((pats and rel) or abs), end) | |
1599 |
|
1599 | |||
1600 | def log(ui, repo, *pats, **opts): |
|
1600 | def log(ui, repo, *pats, **opts): | |
1601 | """show revision history of entire repository or files |
|
1601 | """show revision history of entire repository or files | |
1602 |
|
1602 | |||
1603 | Print the revision history of the specified files or the entire project. |
|
1603 | Print the revision history of the specified files or the entire project. | |
1604 |
|
1604 | |||
1605 | By default this command outputs: changeset id and hash, tags, |
|
1605 | By default this command outputs: changeset id and hash, tags, | |
1606 | non-trivial parents, user, date and time, and a summary for each |
|
1606 | non-trivial parents, user, date and time, and a summary for each | |
1607 | commit. When the -v/--verbose switch is used, the list of changed |
|
1607 | commit. When the -v/--verbose switch is used, the list of changed | |
1608 | files and full commit message is shown. |
|
1608 | files and full commit message is shown. | |
1609 | """ |
|
1609 | """ | |
1610 | class dui(object): |
|
1610 | class dui(object): | |
1611 | # Implement and delegate some ui protocol. Save hunks of |
|
1611 | # Implement and delegate some ui protocol. Save hunks of | |
1612 | # output for later display in the desired order. |
|
1612 | # output for later display in the desired order. | |
1613 | def __init__(self, ui): |
|
1613 | def __init__(self, ui): | |
1614 | self.ui = ui |
|
1614 | self.ui = ui | |
1615 | self.hunk = {} |
|
1615 | self.hunk = {} | |
1616 | def bump(self, rev): |
|
1616 | def bump(self, rev): | |
1617 | self.rev = rev |
|
1617 | self.rev = rev | |
1618 | self.hunk[rev] = [] |
|
1618 | self.hunk[rev] = [] | |
1619 | def note(self, *args): |
|
1619 | def note(self, *args): | |
1620 | if self.verbose: |
|
1620 | if self.verbose: | |
1621 | self.write(*args) |
|
1621 | self.write(*args) | |
1622 | def status(self, *args): |
|
1622 | def status(self, *args): | |
1623 | if not self.quiet: |
|
1623 | if not self.quiet: | |
1624 | self.write(*args) |
|
1624 | self.write(*args) | |
1625 | def write(self, *args): |
|
1625 | def write(self, *args): | |
1626 | self.hunk[self.rev].append(args) |
|
1626 | self.hunk[self.rev].append(args) | |
1627 | def debug(self, *args): |
|
1627 | def debug(self, *args): | |
1628 | if self.debugflag: |
|
1628 | if self.debugflag: | |
1629 | self.write(*args) |
|
1629 | self.write(*args) | |
1630 | def __getattr__(self, key): |
|
1630 | def __getattr__(self, key): | |
1631 | return getattr(self.ui, key) |
|
1631 | return getattr(self.ui, key) | |
1632 |
|
1632 | |||
1633 | changeiter, getchange, matchfn = walkchangerevs(ui, repo, pats, opts) |
|
1633 | changeiter, getchange, matchfn = walkchangerevs(ui, repo, pats, opts) | |
1634 |
|
1634 | |||
1635 | if opts['limit']: |
|
1635 | if opts['limit']: | |
1636 | try: |
|
1636 | try: | |
1637 | limit = int(opts['limit']) |
|
1637 | limit = int(opts['limit']) | |
1638 | except ValueError: |
|
1638 | except ValueError: | |
1639 | raise util.Abort(_('limit must be a positive integer')) |
|
1639 | raise util.Abort(_('limit must be a positive integer')) | |
1640 | if limit <= 0: raise util.Abort(_('limit must be positive')) |
|
1640 | if limit <= 0: raise util.Abort(_('limit must be positive')) | |
1641 | else: |
|
1641 | else: | |
1642 | limit = sys.maxint |
|
1642 | limit = sys.maxint | |
1643 | count = 0 |
|
1643 | count = 0 | |
1644 |
|
1644 | |||
1645 | for st, rev, fns in changeiter: |
|
1645 | for st, rev, fns in changeiter: | |
1646 | if st == 'window': |
|
1646 | if st == 'window': | |
1647 | du = dui(ui) |
|
1647 | du = dui(ui) | |
1648 | elif st == 'add': |
|
1648 | elif st == 'add': | |
1649 | du.bump(rev) |
|
1649 | du.bump(rev) | |
1650 | changenode = repo.changelog.node(rev) |
|
1650 | changenode = repo.changelog.node(rev) | |
1651 | parents = [p for p in repo.changelog.parents(changenode) |
|
1651 | parents = [p for p in repo.changelog.parents(changenode) | |
1652 | if p != nullid] |
|
1652 | if p != nullid] | |
1653 | if opts['no_merges'] and len(parents) == 2: |
|
1653 | if opts['no_merges'] and len(parents) == 2: | |
1654 | continue |
|
1654 | continue | |
1655 | if opts['only_merges'] and len(parents) != 2: |
|
1655 | if opts['only_merges'] and len(parents) != 2: | |
1656 | continue |
|
1656 | continue | |
1657 |
|
1657 | |||
1658 | if opts['keyword']: |
|
1658 | if opts['keyword']: | |
1659 | changes = getchange(rev) |
|
1659 | changes = getchange(rev) | |
1660 | miss = 0 |
|
1660 | miss = 0 | |
1661 | for k in [kw.lower() for kw in opts['keyword']]: |
|
1661 | for k in [kw.lower() for kw in opts['keyword']]: | |
1662 | if not (k in changes[1].lower() or |
|
1662 | if not (k in changes[1].lower() or | |
1663 | k in changes[4].lower() or |
|
1663 | k in changes[4].lower() or | |
1664 | k in " ".join(changes[3][:20]).lower()): |
|
1664 | k in " ".join(changes[3][:20]).lower()): | |
1665 | miss = 1 |
|
1665 | miss = 1 | |
1666 | break |
|
1666 | break | |
1667 | if miss: |
|
1667 | if miss: | |
1668 | continue |
|
1668 | continue | |
1669 |
|
1669 | |||
1670 | br = None |
|
1670 | br = None | |
1671 | if opts['branches']: |
|
1671 | if opts['branches']: | |
1672 | br = repo.branchlookup([repo.changelog.node(rev)]) |
|
1672 | br = repo.branchlookup([repo.changelog.node(rev)]) | |
1673 |
|
1673 | |||
1674 | show_changeset(du, repo, rev, brinfo=br) |
|
1674 | show_changeset(du, repo, rev, brinfo=br) | |
1675 | if opts['patch']: |
|
1675 | if opts['patch']: | |
1676 | prev = (parents and parents[0]) or nullid |
|
1676 | prev = (parents and parents[0]) or nullid | |
1677 | dodiff(du, du, repo, prev, changenode, match=matchfn) |
|
1677 | dodiff(du, du, repo, prev, changenode, match=matchfn) | |
1678 | du.write("\n\n") |
|
1678 | du.write("\n\n") | |
1679 | elif st == 'iter': |
|
1679 | elif st == 'iter': | |
1680 | if count == limit: break |
|
1680 | if count == limit: break | |
1681 | if du.hunk[rev]: |
|
1681 | if du.hunk[rev]: | |
1682 | count += 1 |
|
1682 | count += 1 | |
1683 | for args in du.hunk[rev]: |
|
1683 | for args in du.hunk[rev]: | |
1684 | ui.write(*args) |
|
1684 | ui.write(*args) | |
1685 |
|
1685 | |||
1686 | def manifest(ui, repo, rev=None): |
|
1686 | def manifest(ui, repo, rev=None): | |
1687 | """output the latest or given revision of the project manifest |
|
1687 | """output the latest or given revision of the project manifest | |
1688 |
|
1688 | |||
1689 | Print a list of version controlled files for the given revision. |
|
1689 | Print a list of version controlled files for the given revision. | |
1690 |
|
1690 | |||
1691 | The manifest is the list of files being version controlled. If no revision |
|
1691 | The manifest is the list of files being version controlled. If no revision | |
1692 | is given then the tip is used. |
|
1692 | is given then the tip is used. | |
1693 | """ |
|
1693 | """ | |
1694 | if rev: |
|
1694 | if rev: | |
1695 | try: |
|
1695 | try: | |
1696 | # assume all revision numbers are for changesets |
|
1696 | # assume all revision numbers are for changesets | |
1697 | n = repo.lookup(rev) |
|
1697 | n = repo.lookup(rev) | |
1698 | change = repo.changelog.read(n) |
|
1698 | change = repo.changelog.read(n) | |
1699 | n = change[0] |
|
1699 | n = change[0] | |
1700 | except hg.RepoError: |
|
1700 | except hg.RepoError: | |
1701 | n = repo.manifest.lookup(rev) |
|
1701 | n = repo.manifest.lookup(rev) | |
1702 | else: |
|
1702 | else: | |
1703 | n = repo.manifest.tip() |
|
1703 | n = repo.manifest.tip() | |
1704 | m = repo.manifest.read(n) |
|
1704 | m = repo.manifest.read(n) | |
1705 | mf = repo.manifest.readflags(n) |
|
1705 | mf = repo.manifest.readflags(n) | |
1706 | files = m.keys() |
|
1706 | files = m.keys() | |
1707 | files.sort() |
|
1707 | files.sort() | |
1708 |
|
1708 | |||
1709 | for f in files: |
|
1709 | for f in files: | |
1710 | ui.write("%40s %3s %s\n" % (hex(m[f]), mf[f] and "755" or "644", f)) |
|
1710 | ui.write("%40s %3s %s\n" % (hex(m[f]), mf[f] and "755" or "644", f)) | |
1711 |
|
1711 | |||
1712 | def outgoing(ui, repo, dest="default-push", **opts): |
|
1712 | def outgoing(ui, repo, dest="default-push", **opts): | |
1713 | """show changesets not found in destination |
|
1713 | """show changesets not found in destination | |
1714 |
|
1714 | |||
1715 | Show changesets not found in the specified destination repo or the |
|
1715 | Show changesets not found in the specified destination repo or the | |
1716 | default push repo. These are the changesets that would be pushed |
|
1716 | default push repo. These are the changesets that would be pushed | |
1717 | if a push was requested. |
|
1717 | if a push was requested. | |
1718 |
|
1718 | |||
1719 | See pull for valid source format details. |
|
1719 | See pull for valid source format details. | |
1720 | """ |
|
1720 | """ | |
1721 | dest = ui.expandpath(dest, repo.root) |
|
1721 | dest = ui.expandpath(dest, repo.root) | |
1722 | other = hg.repository(ui, dest) |
|
1722 | other = hg.repository(ui, dest) | |
1723 | o = repo.findoutgoing(other) |
|
1723 | o = repo.findoutgoing(other) | |
1724 | o = repo.changelog.nodesbetween(o)[0] |
|
1724 | o = repo.changelog.nodesbetween(o)[0] | |
1725 | if opts['newest_first']: |
|
1725 | if opts['newest_first']: | |
1726 | o.reverse() |
|
1726 | o.reverse() | |
1727 | for n in o: |
|
1727 | for n in o: | |
1728 | parents = [p for p in repo.changelog.parents(n) if p != nullid] |
|
1728 | parents = [p for p in repo.changelog.parents(n) if p != nullid] | |
1729 | if opts['no_merges'] and len(parents) == 2: |
|
1729 | if opts['no_merges'] and len(parents) == 2: | |
1730 | continue |
|
1730 | continue | |
1731 | show_changeset(ui, repo, changenode=n) |
|
1731 | show_changeset(ui, repo, changenode=n) | |
1732 | if opts['patch']: |
|
1732 | if opts['patch']: | |
1733 | prev = (parents and parents[0]) or nullid |
|
1733 | prev = (parents and parents[0]) or nullid | |
1734 | dodiff(ui, ui, repo, prev, n) |
|
1734 | dodiff(ui, ui, repo, prev, n) | |
1735 | ui.write("\n") |
|
1735 | ui.write("\n") | |
1736 |
|
1736 | |||
1737 | def parents(ui, repo, rev=None, branches=None): |
|
1737 | def parents(ui, repo, rev=None, branches=None): | |
1738 | """show the parents of the working dir or revision |
|
1738 | """show the parents of the working dir or revision | |
1739 |
|
1739 | |||
1740 | Print the working directory's parent revisions. |
|
1740 | Print the working directory's parent revisions. | |
1741 | """ |
|
1741 | """ | |
1742 | if rev: |
|
1742 | if rev: | |
1743 | p = repo.changelog.parents(repo.lookup(rev)) |
|
1743 | p = repo.changelog.parents(repo.lookup(rev)) | |
1744 | else: |
|
1744 | else: | |
1745 | p = repo.dirstate.parents() |
|
1745 | p = repo.dirstate.parents() | |
1746 |
|
1746 | |||
1747 | br = None |
|
1747 | br = None | |
1748 | if branches is not None: |
|
1748 | if branches is not None: | |
1749 | br = repo.branchlookup(p) |
|
1749 | br = repo.branchlookup(p) | |
1750 | for n in p: |
|
1750 | for n in p: | |
1751 | if n != nullid: |
|
1751 | if n != nullid: | |
1752 | show_changeset(ui, repo, changenode=n, brinfo=br) |
|
1752 | show_changeset(ui, repo, changenode=n, brinfo=br) | |
1753 |
|
1753 | |||
1754 | def paths(ui, search=None): |
|
1754 | def paths(ui, search=None): | |
1755 | """show definition of symbolic path names |
|
1755 | """show definition of symbolic path names | |
1756 |
|
1756 | |||
1757 | Show definition of symbolic path name NAME. If no name is given, show |
|
1757 | Show definition of symbolic path name NAME. If no name is given, show | |
1758 | definition of available names. |
|
1758 | definition of available names. | |
1759 |
|
1759 | |||
1760 | Path names are defined in the [paths] section of /etc/mercurial/hgrc |
|
1760 | Path names are defined in the [paths] section of /etc/mercurial/hgrc | |
1761 | and $HOME/.hgrc. If run inside a repository, .hg/hgrc is used, too. |
|
1761 | and $HOME/.hgrc. If run inside a repository, .hg/hgrc is used, too. | |
1762 | """ |
|
1762 | """ | |
1763 | try: |
|
1763 | try: | |
1764 | repo = hg.repository(ui=ui) |
|
1764 | repo = hg.repository(ui=ui) | |
1765 | except hg.RepoError: |
|
1765 | except hg.RepoError: | |
1766 | pass |
|
1766 | pass | |
1767 |
|
1767 | |||
1768 | if search: |
|
1768 | if search: | |
1769 | for name, path in ui.configitems("paths"): |
|
1769 | for name, path in ui.configitems("paths"): | |
1770 | if name == search: |
|
1770 | if name == search: | |
1771 | ui.write("%s\n" % path) |
|
1771 | ui.write("%s\n" % path) | |
1772 | return |
|
1772 | return | |
1773 | ui.warn(_("not found!\n")) |
|
1773 | ui.warn(_("not found!\n")) | |
1774 | return 1 |
|
1774 | return 1 | |
1775 | else: |
|
1775 | else: | |
1776 | for name, path in ui.configitems("paths"): |
|
1776 | for name, path in ui.configitems("paths"): | |
1777 | ui.write("%s = %s\n" % (name, path)) |
|
1777 | ui.write("%s = %s\n" % (name, path)) | |
1778 |
|
1778 | |||
1779 | def pull(ui, repo, source="default", **opts): |
|
1779 | def pull(ui, repo, source="default", **opts): | |
1780 | """pull changes from the specified source |
|
1780 | """pull changes from the specified source | |
1781 |
|
1781 | |||
1782 | Pull changes from a remote repository to a local one. |
|
1782 | Pull changes from a remote repository to a local one. | |
1783 |
|
1783 | |||
1784 | This finds all changes from the repository at the specified path |
|
1784 | This finds all changes from the repository at the specified path | |
1785 | or URL and adds them to the local repository. By default, this |
|
1785 | or URL and adds them to the local repository. By default, this | |
1786 | does not update the copy of the project in the working directory. |
|
1786 | does not update the copy of the project in the working directory. | |
1787 |
|
1787 | |||
1788 | Valid URLs are of the form: |
|
1788 | Valid URLs are of the form: | |
1789 |
|
1789 | |||
1790 | local/filesystem/path |
|
1790 | local/filesystem/path | |
1791 | http://[user@]host[:port][/path] |
|
1791 | http://[user@]host[:port][/path] | |
1792 | https://[user@]host[:port][/path] |
|
1792 | https://[user@]host[:port][/path] | |
1793 | ssh://[user@]host[:port][/path] |
|
1793 | ssh://[user@]host[:port][/path] | |
1794 |
|
1794 | |||
1795 | SSH requires an accessible shell account on the destination machine |
|
1795 | SSH requires an accessible shell account on the destination machine | |
1796 | and a copy of hg in the remote path. With SSH, paths are relative |
|
1796 | and a copy of hg in the remote path. With SSH, paths are relative | |
1797 | to the remote user's home directory by default; use two slashes at |
|
1797 | to the remote user's home directory by default; use two slashes at | |
1798 | the start of a path to specify it as relative to the filesystem root. |
|
1798 | the start of a path to specify it as relative to the filesystem root. | |
1799 | """ |
|
1799 | """ | |
1800 | source = ui.expandpath(source, repo.root) |
|
1800 | source = ui.expandpath(source, repo.root) | |
1801 | ui.status(_('pulling from %s\n') % (source)) |
|
1801 | ui.status(_('pulling from %s\n') % (source)) | |
1802 |
|
1802 | |||
1803 | if opts['ssh']: |
|
1803 | if opts['ssh']: | |
1804 | ui.setconfig("ui", "ssh", opts['ssh']) |
|
1804 | ui.setconfig("ui", "ssh", opts['ssh']) | |
1805 | if opts['remotecmd']: |
|
1805 | if opts['remotecmd']: | |
1806 | ui.setconfig("ui", "remotecmd", opts['remotecmd']) |
|
1806 | ui.setconfig("ui", "remotecmd", opts['remotecmd']) | |
1807 |
|
1807 | |||
1808 | other = hg.repository(ui, source) |
|
1808 | other = hg.repository(ui, source) | |
1809 | revs = None |
|
1809 | revs = None | |
1810 | if opts['rev'] and not other.local(): |
|
1810 | if opts['rev'] and not other.local(): | |
1811 | raise util.Abort(_("pull -r doesn't work for remote repositories yet")) |
|
1811 | raise util.Abort(_("pull -r doesn't work for remote repositories yet")) | |
1812 | elif opts['rev']: |
|
1812 | elif opts['rev']: | |
1813 | revs = [other.lookup(rev) for rev in opts['rev']] |
|
1813 | revs = [other.lookup(rev) for rev in opts['rev']] | |
1814 | r = repo.pull(other, heads=revs) |
|
1814 | r = repo.pull(other, heads=revs) | |
1815 | if not r: |
|
1815 | if not r: | |
1816 | if opts['update']: |
|
1816 | if opts['update']: | |
1817 | return update(ui, repo) |
|
1817 | return update(ui, repo) | |
1818 | else: |
|
1818 | else: | |
1819 | ui.status(_("(run 'hg update' to get a working copy)\n")) |
|
1819 | ui.status(_("(run 'hg update' to get a working copy)\n")) | |
1820 |
|
1820 | |||
1821 | return r |
|
1821 | return r | |
1822 |
|
1822 | |||
1823 | def push(ui, repo, dest="default-push", **opts): |
|
1823 | def push(ui, repo, dest="default-push", **opts): | |
1824 | """push changes to the specified destination |
|
1824 | """push changes to the specified destination | |
1825 |
|
1825 | |||
1826 | Push changes from the local repository to the given destination. |
|
1826 | Push changes from the local repository to the given destination. | |
1827 |
|
1827 | |||
1828 | This is the symmetrical operation for pull. It helps to move |
|
1828 | This is the symmetrical operation for pull. It helps to move | |
1829 | changes from the current repository to a different one. If the |
|
1829 | changes from the current repository to a different one. If the | |
1830 | destination is local this is identical to a pull in that directory |
|
1830 | destination is local this is identical to a pull in that directory | |
1831 | from the current one. |
|
1831 | from the current one. | |
1832 |
|
1832 | |||
1833 | By default, push will refuse to run if it detects the result would |
|
1833 | By default, push will refuse to run if it detects the result would | |
1834 | increase the number of remote heads. This generally indicates the |
|
1834 | increase the number of remote heads. This generally indicates the | |
1835 | the client has forgotten to sync and merge before pushing. |
|
1835 | the client has forgotten to sync and merge before pushing. | |
1836 |
|
1836 | |||
1837 | Valid URLs are of the form: |
|
1837 | Valid URLs are of the form: | |
1838 |
|
1838 | |||
1839 | local/filesystem/path |
|
1839 | local/filesystem/path | |
1840 | ssh://[user@]host[:port][/path] |
|
1840 | ssh://[user@]host[:port][/path] | |
1841 |
|
1841 | |||
1842 | SSH requires an accessible shell account on the destination |
|
1842 | SSH requires an accessible shell account on the destination | |
1843 | machine and a copy of hg in the remote path. |
|
1843 | machine and a copy of hg in the remote path. | |
1844 | """ |
|
1844 | """ | |
1845 | dest = ui.expandpath(dest, repo.root) |
|
1845 | dest = ui.expandpath(dest, repo.root) | |
1846 | ui.status('pushing to %s\n' % (dest)) |
|
1846 | ui.status('pushing to %s\n' % (dest)) | |
1847 |
|
1847 | |||
1848 | if opts['ssh']: |
|
1848 | if opts['ssh']: | |
1849 | ui.setconfig("ui", "ssh", opts['ssh']) |
|
1849 | ui.setconfig("ui", "ssh", opts['ssh']) | |
1850 | if opts['remotecmd']: |
|
1850 | if opts['remotecmd']: | |
1851 | ui.setconfig("ui", "remotecmd", opts['remotecmd']) |
|
1851 | ui.setconfig("ui", "remotecmd", opts['remotecmd']) | |
1852 |
|
1852 | |||
1853 | other = hg.repository(ui, dest) |
|
1853 | other = hg.repository(ui, dest) | |
1854 | revs = None |
|
1854 | revs = None | |
1855 | if opts['rev']: |
|
1855 | if opts['rev']: | |
1856 | revs = [repo.lookup(rev) for rev in opts['rev']] |
|
1856 | revs = [repo.lookup(rev) for rev in opts['rev']] | |
1857 | r = repo.push(other, opts['force'], revs=revs) |
|
1857 | r = repo.push(other, opts['force'], revs=revs) | |
1858 | return r |
|
1858 | return r | |
1859 |
|
1859 | |||
1860 | def rawcommit(ui, repo, *flist, **rc): |
|
1860 | def rawcommit(ui, repo, *flist, **rc): | |
1861 | """raw commit interface (DEPRECATED) |
|
1861 | """raw commit interface (DEPRECATED) | |
1862 |
|
1862 | |||
1863 | (DEPRECATED) |
|
1863 | (DEPRECATED) | |
1864 | Lowlevel commit, for use in helper scripts. |
|
1864 | Lowlevel commit, for use in helper scripts. | |
1865 |
|
1865 | |||
1866 | This command is not intended to be used by normal users, as it is |
|
1866 | This command is not intended to be used by normal users, as it is | |
1867 | primarily useful for importing from other SCMs. |
|
1867 | primarily useful for importing from other SCMs. | |
1868 |
|
1868 | |||
1869 | This command is now deprecated and will be removed in a future |
|
1869 | This command is now deprecated and will be removed in a future | |
1870 | release, please use debugsetparents and commit instead. |
|
1870 | release, please use debugsetparents and commit instead. | |
1871 | """ |
|
1871 | """ | |
1872 |
|
1872 | |||
1873 | ui.warn(_("(the rawcommit command is deprecated)\n")) |
|
1873 | ui.warn(_("(the rawcommit command is deprecated)\n")) | |
1874 |
|
1874 | |||
1875 | message = rc['message'] |
|
1875 | message = rc['message'] | |
1876 | if not message and rc['logfile']: |
|
1876 | if not message and rc['logfile']: | |
1877 | try: |
|
1877 | try: | |
1878 | message = open(rc['logfile']).read() |
|
1878 | message = open(rc['logfile']).read() | |
1879 | except IOError: |
|
1879 | except IOError: | |
1880 | pass |
|
1880 | pass | |
1881 | if not message and not rc['logfile']: |
|
1881 | if not message and not rc['logfile']: | |
1882 | raise util.Abort(_("missing commit message")) |
|
1882 | raise util.Abort(_("missing commit message")) | |
1883 |
|
1883 | |||
1884 | files = relpath(repo, list(flist)) |
|
1884 | files = relpath(repo, list(flist)) | |
1885 | if rc['files']: |
|
1885 | if rc['files']: | |
1886 | files += open(rc['files']).read().splitlines() |
|
1886 | files += open(rc['files']).read().splitlines() | |
1887 |
|
1887 | |||
1888 | rc['parent'] = map(repo.lookup, rc['parent']) |
|
1888 | rc['parent'] = map(repo.lookup, rc['parent']) | |
1889 |
|
1889 | |||
1890 | try: |
|
1890 | try: | |
1891 | repo.rawcommit(files, message, rc['user'], rc['date'], *rc['parent']) |
|
1891 | repo.rawcommit(files, message, rc['user'], rc['date'], *rc['parent']) | |
1892 | except ValueError, inst: |
|
1892 | except ValueError, inst: | |
1893 | raise util.Abort(str(inst)) |
|
1893 | raise util.Abort(str(inst)) | |
1894 |
|
1894 | |||
1895 | def recover(ui, repo): |
|
1895 | def recover(ui, repo): | |
1896 | """roll back an interrupted transaction |
|
1896 | """roll back an interrupted transaction | |
1897 |
|
1897 | |||
1898 | Recover from an interrupted commit or pull. |
|
1898 | Recover from an interrupted commit or pull. | |
1899 |
|
1899 | |||
1900 | This command tries to fix the repository status after an interrupted |
|
1900 | This command tries to fix the repository status after an interrupted | |
1901 | operation. It should only be necessary when Mercurial suggests it. |
|
1901 | operation. It should only be necessary when Mercurial suggests it. | |
1902 | """ |
|
1902 | """ | |
1903 | if repo.recover(): |
|
1903 | if repo.recover(): | |
1904 | return repo.verify() |
|
1904 | return repo.verify() | |
1905 | return False |
|
1905 | return False | |
1906 |
|
1906 | |||
1907 | def remove(ui, repo, pat, *pats, **opts): |
|
1907 | def remove(ui, repo, pat, *pats, **opts): | |
1908 | """remove the specified files on the next commit |
|
1908 | """remove the specified files on the next commit | |
1909 |
|
1909 | |||
1910 | Schedule the indicated files for removal from the repository. |
|
1910 | Schedule the indicated files for removal from the repository. | |
1911 |
|
1911 | |||
1912 | This command schedules the files to be removed at the next commit. |
|
1912 | This command schedules the files to be removed at the next commit. | |
1913 | This only removes files from the current branch, not from the |
|
1913 | This only removes files from the current branch, not from the | |
1914 | entire project history. If the files still exist in the working |
|
1914 | entire project history. If the files still exist in the working | |
1915 | directory, they will be deleted from it. |
|
1915 | directory, they will be deleted from it. | |
1916 | """ |
|
1916 | """ | |
1917 | names = [] |
|
1917 | names = [] | |
1918 | def okaytoremove(abs, rel, exact): |
|
1918 | def okaytoremove(abs, rel, exact): | |
1919 | modified, added, removed, deleted, unknown = repo.changes(files=[abs]) |
|
1919 | modified, added, removed, deleted, unknown = repo.changes(files=[abs]) | |
1920 | reason = None |
|
1920 | reason = None | |
1921 | if modified: |
|
1921 | if modified: | |
1922 | reason = _('is modified') |
|
1922 | reason = _('is modified') | |
1923 | elif added: |
|
1923 | elif added: | |
1924 | reason = _('has been marked for add') |
|
1924 | reason = _('has been marked for add') | |
1925 | elif unknown: |
|
1925 | elif unknown: | |
1926 | reason = _('is not managed') |
|
1926 | reason = _('is not managed') | |
1927 | if reason: |
|
1927 | if reason: | |
1928 | if exact: |
|
1928 | if exact: | |
1929 | ui.warn(_('not removing %s: file %s\n') % (rel, reason)) |
|
1929 | ui.warn(_('not removing %s: file %s\n') % (rel, reason)) | |
1930 | else: |
|
1930 | else: | |
1931 | return True |
|
1931 | return True | |
1932 | for src, abs, rel, exact in walk(repo, (pat,) + pats, opts): |
|
1932 | for src, abs, rel, exact in walk(repo, (pat,) + pats, opts): | |
1933 | if okaytoremove(abs, rel, exact): |
|
1933 | if okaytoremove(abs, rel, exact): | |
1934 | if ui.verbose or not exact: |
|
1934 | if ui.verbose or not exact: | |
1935 | ui.status(_('removing %s\n') % rel) |
|
1935 | ui.status(_('removing %s\n') % rel) | |
1936 | names.append(abs) |
|
1936 | names.append(abs) | |
1937 | repo.remove(names, unlink=True) |
|
1937 | repo.remove(names, unlink=True) | |
1938 |
|
1938 | |||
1939 | def rename(ui, repo, *pats, **opts): |
|
1939 | def rename(ui, repo, *pats, **opts): | |
1940 | """rename files; equivalent of copy + remove |
|
1940 | """rename files; equivalent of copy + remove | |
1941 |
|
1941 | |||
1942 | Mark dest as copies of sources; mark sources for deletion. If |
|
1942 | Mark dest as copies of sources; mark sources for deletion. If | |
1943 | dest is a directory, copies are put in that directory. If dest is |
|
1943 | dest is a directory, copies are put in that directory. If dest is | |
1944 | a file, there can only be one source. |
|
1944 | a file, there can only be one source. | |
1945 |
|
1945 | |||
1946 | By default, this command copies the contents of files as they |
|
1946 | By default, this command copies the contents of files as they | |
1947 | stand in the working directory. If invoked with --after, the |
|
1947 | stand in the working directory. If invoked with --after, the | |
1948 | operation is recorded, but no copying is performed. |
|
1948 | operation is recorded, but no copying is performed. | |
1949 |
|
1949 | |||
1950 | This command takes effect in the next commit. |
|
1950 | This command takes effect in the next commit. | |
1951 |
|
1951 | |||
1952 | NOTE: This command should be treated as experimental. While it |
|
1952 | NOTE: This command should be treated as experimental. While it | |
1953 | should properly record rename files, this information is not yet |
|
1953 | should properly record rename files, this information is not yet | |
1954 | fully used by merge, nor fully reported by log. |
|
1954 | fully used by merge, nor fully reported by log. | |
1955 | """ |
|
1955 | """ | |
1956 | errs, copied = docopy(ui, repo, pats, opts) |
|
1956 | errs, copied = docopy(ui, repo, pats, opts) | |
1957 | names = [] |
|
1957 | names = [] | |
1958 | for abs, rel, exact in copied: |
|
1958 | for abs, rel, exact in copied: | |
1959 | if ui.verbose or not exact: |
|
1959 | if ui.verbose or not exact: | |
1960 | ui.status(_('removing %s\n') % rel) |
|
1960 | ui.status(_('removing %s\n') % rel) | |
1961 | names.append(abs) |
|
1961 | names.append(abs) | |
1962 | repo.remove(names, unlink=True) |
|
1962 | repo.remove(names, unlink=True) | |
1963 | return errs |
|
1963 | return errs | |
1964 |
|
1964 | |||
1965 | def revert(ui, repo, *pats, **opts): |
|
1965 | def revert(ui, repo, *pats, **opts): | |
1966 | """revert modified files or dirs back to their unmodified states |
|
1966 | """revert modified files or dirs back to their unmodified states | |
1967 |
|
1967 | |||
1968 | In its default mode, it reverts any uncommitted modifications made |
|
1968 | In its default mode, it reverts any uncommitted modifications made | |
1969 | to the named files or directories. This restores the contents of |
|
1969 | to the named files or directories. This restores the contents of | |
1970 | the affected files to an unmodified state. |
|
1970 | the affected files to an unmodified state. | |
1971 |
|
1971 | |||
1972 | Using the -r option, it reverts the given files or directories to |
|
1972 | Using the -r option, it reverts the given files or directories to | |
1973 | their state as of an earlier revision. This can be helpful to "roll |
|
1973 | their state as of an earlier revision. This can be helpful to "roll | |
1974 | back" some or all of a change that should not have been committed. |
|
1974 | back" some or all of a change that should not have been committed. | |
1975 |
|
1975 | |||
1976 | Revert modifies the working directory. It does not commit any |
|
1976 | Revert modifies the working directory. It does not commit any | |
1977 | changes, or change the parent of the current working directory. |
|
1977 | changes, or change the parent of the current working directory. | |
1978 |
|
1978 | |||
1979 | If a file has been deleted, it is recreated. If the executable |
|
1979 | If a file has been deleted, it is recreated. If the executable | |
1980 | mode of a file was changed, it is reset. |
|
1980 | mode of a file was changed, it is reset. | |
1981 |
|
1981 | |||
1982 | If names are given, all files matching the names are reverted. |
|
1982 | If names are given, all files matching the names are reverted. | |
1983 |
|
1983 | |||
1984 | If no arguments are given, all files in the repository are reverted. |
|
1984 | If no arguments are given, all files in the repository are reverted. | |
1985 | """ |
|
1985 | """ | |
1986 | node = opts['rev'] and repo.lookup(opts['rev']) or \ |
|
1986 | node = opts['rev'] and repo.lookup(opts['rev']) or \ | |
1987 | repo.dirstate.parents()[0] |
|
1987 | repo.dirstate.parents()[0] | |
1988 |
|
1988 | |||
1989 | files, choose, anypats = matchpats(repo, pats, opts) |
|
1989 | files, choose, anypats = matchpats(repo, pats, opts) | |
1990 | modified, added, removed, deleted, unknown = repo.changes(match=choose) |
|
1990 | modified, added, removed, deleted, unknown = repo.changes(match=choose) | |
1991 | repo.forget(added) |
|
1991 | repo.forget(added) | |
1992 | repo.undelete(removed) |
|
1992 | repo.undelete(removed) | |
1993 |
|
1993 | |||
1994 | return repo.update(node, False, True, choose, False) |
|
1994 | return repo.update(node, False, True, choose, False) | |
1995 |
|
1995 | |||
1996 | def root(ui, repo): |
|
1996 | def root(ui, repo): | |
1997 | """print the root (top) of the current working dir |
|
1997 | """print the root (top) of the current working dir | |
1998 |
|
1998 | |||
1999 | Print the root directory of the current repository. |
|
1999 | Print the root directory of the current repository. | |
2000 | """ |
|
2000 | """ | |
2001 | ui.write(repo.root + "\n") |
|
2001 | ui.write(repo.root + "\n") | |
2002 |
|
2002 | |||
2003 | def serve(ui, repo, **opts): |
|
2003 | def serve(ui, repo, **opts): | |
2004 | """export the repository via HTTP |
|
2004 | """export the repository via HTTP | |
2005 |
|
2005 | |||
2006 | Start a local HTTP repository browser and pull server. |
|
2006 | Start a local HTTP repository browser and pull server. | |
2007 |
|
2007 | |||
2008 | By default, the server logs accesses to stdout and errors to |
|
2008 | By default, the server logs accesses to stdout and errors to | |
2009 | stderr. Use the "-A" and "-E" options to log to files. |
|
2009 | stderr. Use the "-A" and "-E" options to log to files. | |
2010 | """ |
|
2010 | """ | |
2011 |
|
2011 | |||
2012 | if opts["stdio"]: |
|
2012 | if opts["stdio"]: | |
2013 | fin, fout = sys.stdin, sys.stdout |
|
2013 | fin, fout = sys.stdin, sys.stdout | |
2014 | sys.stdout = sys.stderr |
|
2014 | sys.stdout = sys.stderr | |
2015 |
|
2015 | |||
2016 | # Prevent insertion/deletion of CRs |
|
2016 | # Prevent insertion/deletion of CRs | |
2017 | util.set_binary(fin) |
|
2017 | util.set_binary(fin) | |
2018 | util.set_binary(fout) |
|
2018 | util.set_binary(fout) | |
2019 |
|
2019 | |||
2020 | def getarg(): |
|
2020 | def getarg(): | |
2021 | argline = fin.readline()[:-1] |
|
2021 | argline = fin.readline()[:-1] | |
2022 | arg, l = argline.split() |
|
2022 | arg, l = argline.split() | |
2023 | val = fin.read(int(l)) |
|
2023 | val = fin.read(int(l)) | |
2024 | return arg, val |
|
2024 | return arg, val | |
2025 | def respond(v): |
|
2025 | def respond(v): | |
2026 | fout.write("%d\n" % len(v)) |
|
2026 | fout.write("%d\n" % len(v)) | |
2027 | fout.write(v) |
|
2027 | fout.write(v) | |
2028 | fout.flush() |
|
2028 | fout.flush() | |
2029 |
|
2029 | |||
2030 | lock = None |
|
2030 | lock = None | |
2031 |
|
2031 | |||
2032 | while 1: |
|
2032 | while 1: | |
2033 | cmd = fin.readline()[:-1] |
|
2033 | cmd = fin.readline()[:-1] | |
2034 | if cmd == '': |
|
2034 | if cmd == '': | |
2035 | return |
|
2035 | return | |
2036 | if cmd == "heads": |
|
2036 | if cmd == "heads": | |
2037 | h = repo.heads() |
|
2037 | h = repo.heads() | |
2038 | respond(" ".join(map(hex, h)) + "\n") |
|
2038 | respond(" ".join(map(hex, h)) + "\n") | |
2039 | if cmd == "lock": |
|
2039 | if cmd == "lock": | |
2040 | lock = repo.lock() |
|
2040 | lock = repo.lock() | |
2041 | respond("") |
|
2041 | respond("") | |
2042 | if cmd == "unlock": |
|
2042 | if cmd == "unlock": | |
2043 | if lock: |
|
2043 | if lock: | |
2044 | lock.release() |
|
2044 | lock.release() | |
2045 | lock = None |
|
2045 | lock = None | |
2046 | respond("") |
|
2046 | respond("") | |
2047 | elif cmd == "branches": |
|
2047 | elif cmd == "branches": | |
2048 | arg, nodes = getarg() |
|
2048 | arg, nodes = getarg() | |
2049 | nodes = map(bin, nodes.split(" ")) |
|
2049 | nodes = map(bin, nodes.split(" ")) | |
2050 | r = [] |
|
2050 | r = [] | |
2051 | for b in repo.branches(nodes): |
|
2051 | for b in repo.branches(nodes): | |
2052 | r.append(" ".join(map(hex, b)) + "\n") |
|
2052 | r.append(" ".join(map(hex, b)) + "\n") | |
2053 | respond("".join(r)) |
|
2053 | respond("".join(r)) | |
2054 | elif cmd == "between": |
|
2054 | elif cmd == "between": | |
2055 | arg, pairs = getarg() |
|
2055 | arg, pairs = getarg() | |
2056 | pairs = [map(bin, p.split("-")) for p in pairs.split(" ")] |
|
2056 | pairs = [map(bin, p.split("-")) for p in pairs.split(" ")] | |
2057 | r = [] |
|
2057 | r = [] | |
2058 | for b in repo.between(pairs): |
|
2058 | for b in repo.between(pairs): | |
2059 | r.append(" ".join(map(hex, b)) + "\n") |
|
2059 | r.append(" ".join(map(hex, b)) + "\n") | |
2060 | respond("".join(r)) |
|
2060 | respond("".join(r)) | |
2061 | elif cmd == "changegroup": |
|
2061 | elif cmd == "changegroup": | |
2062 | nodes = [] |
|
2062 | nodes = [] | |
2063 | arg, roots = getarg() |
|
2063 | arg, roots = getarg() | |
2064 | nodes = map(bin, roots.split(" ")) |
|
2064 | nodes = map(bin, roots.split(" ")) | |
2065 |
|
2065 | |||
2066 | cg = repo.changegroup(nodes, 'serve') |
|
2066 | cg = repo.changegroup(nodes, 'serve') | |
2067 | while 1: |
|
2067 | while 1: | |
2068 | d = cg.read(4096) |
|
2068 | d = cg.read(4096) | |
2069 | if not d: |
|
2069 | if not d: | |
2070 | break |
|
2070 | break | |
2071 | fout.write(d) |
|
2071 | fout.write(d) | |
2072 |
|
2072 | |||
2073 | fout.flush() |
|
2073 | fout.flush() | |
2074 |
|
2074 | |||
2075 | elif cmd == "addchangegroup": |
|
2075 | elif cmd == "addchangegroup": | |
2076 | if not lock: |
|
2076 | if not lock: | |
2077 | respond("not locked") |
|
2077 | respond("not locked") | |
2078 | continue |
|
2078 | continue | |
2079 | respond("") |
|
2079 | respond("") | |
2080 |
|
2080 | |||
2081 | r = repo.addchangegroup(fin) |
|
2081 | r = repo.addchangegroup(fin) | |
2082 | respond("") |
|
2082 | respond("") | |
2083 |
|
2083 | |||
2084 | optlist = "name templates style address port ipv6 accesslog errorlog" |
|
2084 | optlist = "name templates style address port ipv6 accesslog errorlog" | |
2085 | for o in optlist.split(): |
|
2085 | for o in optlist.split(): | |
2086 | if opts[o]: |
|
2086 | if opts[o]: | |
2087 | ui.setconfig("web", o, opts[o]) |
|
2087 | ui.setconfig("web", o, opts[o]) | |
2088 |
|
2088 | |||
2089 | if opts['daemon'] and not opts['daemon_pipefds']: |
|
2089 | if opts['daemon'] and not opts['daemon_pipefds']: | |
2090 | rfd, wfd = os.pipe() |
|
2090 | rfd, wfd = os.pipe() | |
2091 | args = sys.argv[:] |
|
2091 | args = sys.argv[:] | |
2092 | args.append('--daemon-pipefds=%d,%d' % (rfd, wfd)) |
|
2092 | args.append('--daemon-pipefds=%d,%d' % (rfd, wfd)) | |
2093 | pid = os.spawnvp(os.P_NOWAIT | getattr(os, 'P_DETACH', 0), |
|
2093 | pid = os.spawnvp(os.P_NOWAIT | getattr(os, 'P_DETACH', 0), | |
2094 | args[0], args) |
|
2094 | args[0], args) | |
2095 | os.close(wfd) |
|
2095 | os.close(wfd) | |
2096 | os.read(rfd, 1) |
|
2096 | os.read(rfd, 1) | |
2097 | os._exit(0) |
|
2097 | os._exit(0) | |
2098 |
|
2098 | |||
2099 | try: |
|
2099 | try: | |
2100 | httpd = hgweb.create_server(repo) |
|
2100 | httpd = hgweb.create_server(repo) | |
2101 | except socket.error, inst: |
|
2101 | except socket.error, inst: | |
2102 | raise util.Abort(_('cannot start server: ') + inst.args[1]) |
|
2102 | raise util.Abort(_('cannot start server: ') + inst.args[1]) | |
2103 |
|
2103 | |||
2104 | if ui.verbose: |
|
2104 | if ui.verbose: | |
2105 | addr, port = httpd.socket.getsockname() |
|
2105 | addr, port = httpd.socket.getsockname() | |
2106 | if addr == '0.0.0.0': |
|
2106 | if addr == '0.0.0.0': | |
2107 | addr = socket.gethostname() |
|
2107 | addr = socket.gethostname() | |
2108 | else: |
|
2108 | else: | |
2109 | try: |
|
2109 | try: | |
2110 | addr = socket.gethostbyaddr(addr)[0] |
|
2110 | addr = socket.gethostbyaddr(addr)[0] | |
2111 | except socket.error: |
|
2111 | except socket.error: | |
2112 | pass |
|
2112 | pass | |
2113 | if port != 80: |
|
2113 | if port != 80: | |
2114 | ui.status(_('listening at http://%s:%d/\n') % (addr, port)) |
|
2114 | ui.status(_('listening at http://%s:%d/\n') % (addr, port)) | |
2115 | else: |
|
2115 | else: | |
2116 | ui.status(_('listening at http://%s/\n') % addr) |
|
2116 | ui.status(_('listening at http://%s/\n') % addr) | |
2117 |
|
2117 | |||
2118 | if opts['pid_file']: |
|
2118 | if opts['pid_file']: | |
2119 | fp = open(opts['pid_file'], 'w') |
|
2119 | fp = open(opts['pid_file'], 'w') | |
2120 | fp.write(str(os.getpid())) |
|
2120 | fp.write(str(os.getpid())) | |
2121 | fp.close() |
|
2121 | fp.close() | |
2122 |
|
2122 | |||
2123 | if opts['daemon_pipefds']: |
|
2123 | if opts['daemon_pipefds']: | |
2124 | rfd, wfd = [int(x) for x in opts['daemon_pipefds'].split(',')] |
|
2124 | rfd, wfd = [int(x) for x in opts['daemon_pipefds'].split(',')] | |
2125 | os.close(rfd) |
|
2125 | os.close(rfd) | |
2126 | os.write(wfd, 'y') |
|
2126 | os.write(wfd, 'y') | |
2127 | os.close(wfd) |
|
2127 | os.close(wfd) | |
2128 | sys.stdout.flush() |
|
2128 | sys.stdout.flush() | |
2129 | sys.stderr.flush() |
|
2129 | sys.stderr.flush() | |
2130 | fd = os.open(util.nulldev, os.O_RDWR) |
|
2130 | fd = os.open(util.nulldev, os.O_RDWR) | |
2131 | if fd != 0: os.dup2(fd, 0) |
|
2131 | if fd != 0: os.dup2(fd, 0) | |
2132 | if fd != 1: os.dup2(fd, 1) |
|
2132 | if fd != 1: os.dup2(fd, 1) | |
2133 | if fd != 2: os.dup2(fd, 2) |
|
2133 | if fd != 2: os.dup2(fd, 2) | |
2134 | if fd not in (0, 1, 2): os.close(fd) |
|
2134 | if fd not in (0, 1, 2): os.close(fd) | |
2135 |
|
2135 | |||
2136 | httpd.serve_forever() |
|
2136 | httpd.serve_forever() | |
2137 |
|
2137 | |||
2138 | def status(ui, repo, *pats, **opts): |
|
2138 | def status(ui, repo, *pats, **opts): | |
2139 | """show changed files in the working directory |
|
2139 | """show changed files in the working directory | |
2140 |
|
2140 | |||
2141 | Show changed files in the repository. If names are |
|
2141 | Show changed files in the repository. If names are | |
2142 | given, only files that match are shown. |
|
2142 | given, only files that match are shown. | |
2143 |
|
2143 | |||
2144 | The codes used to show the status of files are: |
|
2144 | The codes used to show the status of files are: | |
2145 | M = modified |
|
2145 | M = modified | |
2146 | A = added |
|
2146 | A = added | |
2147 | R = removed |
|
2147 | R = removed | |
2148 | ! = deleted, but still tracked |
|
2148 | ! = deleted, but still tracked | |
2149 | ? = not tracked |
|
2149 | ? = not tracked | |
2150 | """ |
|
2150 | """ | |
2151 |
|
2151 | |||
2152 | files, matchfn, anypats = matchpats(repo, pats, opts) |
|
2152 | files, matchfn, anypats = matchpats(repo, pats, opts) | |
2153 | cwd = (pats and repo.getcwd()) or '' |
|
2153 | cwd = (pats and repo.getcwd()) or '' | |
2154 | modified, added, removed, deleted, unknown = [ |
|
2154 | modified, added, removed, deleted, unknown = [ | |
2155 | [util.pathto(cwd, x) for x in n] |
|
2155 | [util.pathto(cwd, x) for x in n] | |
2156 | for n in repo.changes(files=files, match=matchfn)] |
|
2156 | for n in repo.changes(files=files, match=matchfn)] | |
2157 |
|
2157 | |||
2158 | changetypes = [(_('modified'), 'M', modified), |
|
2158 | changetypes = [(_('modified'), 'M', modified), | |
2159 | (_('added'), 'A', added), |
|
2159 | (_('added'), 'A', added), | |
2160 | (_('removed'), 'R', removed), |
|
2160 | (_('removed'), 'R', removed), | |
2161 | (_('deleted'), '!', deleted), |
|
2161 | (_('deleted'), '!', deleted), | |
2162 | (_('unknown'), '?', unknown)] |
|
2162 | (_('unknown'), '?', unknown)] | |
2163 |
|
2163 | |||
2164 | end = opts['print0'] and '\0' or '\n' |
|
2164 | end = opts['print0'] and '\0' or '\n' | |
2165 |
|
2165 | |||
2166 | for opt, char, changes in ([ct for ct in changetypes if opts[ct[0]]] |
|
2166 | for opt, char, changes in ([ct for ct in changetypes if opts[ct[0]]] | |
2167 | or changetypes): |
|
2167 | or changetypes): | |
2168 | if opts['no_status']: |
|
2168 | if opts['no_status']: | |
2169 | format = "%%s%s" % end |
|
2169 | format = "%%s%s" % end | |
2170 | else: |
|
2170 | else: | |
2171 | format = "%s %%s%s" % (char, end); |
|
2171 | format = "%s %%s%s" % (char, end); | |
2172 |
|
2172 | |||
2173 | for f in changes: |
|
2173 | for f in changes: | |
2174 | ui.write(format % f) |
|
2174 | ui.write(format % f) | |
2175 |
|
2175 | |||
2176 | def tag(ui, repo, name, rev_=None, **opts): |
|
2176 | def tag(ui, repo, name, rev_=None, **opts): | |
2177 | """add a tag for the current tip or a given revision |
|
2177 | """add a tag for the current tip or a given revision | |
2178 |
|
2178 | |||
2179 | Name a particular revision using <name>. |
|
2179 | Name a particular revision using <name>. | |
2180 |
|
2180 | |||
2181 | Tags are used to name particular revisions of the repository and are |
|
2181 | Tags are used to name particular revisions of the repository and are | |
2182 | very useful to compare different revision, to go back to significant |
|
2182 | very useful to compare different revision, to go back to significant | |
2183 | earlier versions or to mark branch points as releases, etc. |
|
2183 | earlier versions or to mark branch points as releases, etc. | |
2184 |
|
2184 | |||
2185 | If no revision is given, the tip is used. |
|
2185 | If no revision is given, the tip is used. | |
2186 |
|
2186 | |||
2187 | To facilitate version control, distribution, and merging of tags, |
|
2187 | To facilitate version control, distribution, and merging of tags, | |
2188 | they are stored as a file named ".hgtags" which is managed |
|
2188 | they are stored as a file named ".hgtags" which is managed | |
2189 | similarly to other project files and can be hand-edited if |
|
2189 | similarly to other project files and can be hand-edited if | |
2190 | necessary. The file '.hg/localtags' is used for local tags (not |
|
2190 | necessary. The file '.hg/localtags' is used for local tags (not | |
2191 | shared among repositories). |
|
2191 | shared among repositories). | |
2192 | """ |
|
2192 | """ | |
2193 | if name == "tip": |
|
2193 | if name == "tip": | |
2194 | raise util.Abort(_("the name 'tip' is reserved")) |
|
2194 | raise util.Abort(_("the name 'tip' is reserved")) | |
2195 | if rev_ is not None: |
|
2195 | if rev_ is not None: | |
2196 | ui.warn(_("use of 'hg tag NAME [REV]' is deprecated, " |
|
2196 | ui.warn(_("use of 'hg tag NAME [REV]' is deprecated, " | |
2197 | "please use 'hg tag [-r REV] NAME' instead\n")) |
|
2197 | "please use 'hg tag [-r REV] NAME' instead\n")) | |
2198 | if opts['rev']: |
|
2198 | if opts['rev']: | |
2199 | raise util.Abort(_("use only one form to specify the revision")) |
|
2199 | raise util.Abort(_("use only one form to specify the revision")) | |
2200 | if opts['rev']: |
|
2200 | if opts['rev']: | |
2201 | rev_ = opts['rev'] |
|
2201 | rev_ = opts['rev'] | |
2202 | if rev_: |
|
2202 | if rev_: | |
2203 | r = hex(repo.lookup(rev_)) |
|
2203 | r = hex(repo.lookup(rev_)) | |
2204 | else: |
|
2204 | else: | |
2205 | r = hex(repo.changelog.tip()) |
|
2205 | r = hex(repo.changelog.tip()) | |
2206 |
|
2206 | |||
2207 | disallowed = (revrangesep, '\r', '\n') |
|
2207 | disallowed = (revrangesep, '\r', '\n') | |
2208 | for c in disallowed: |
|
2208 | for c in disallowed: | |
2209 | if name.find(c) >= 0: |
|
2209 | if name.find(c) >= 0: | |
2210 | raise util.Abort(_("%s cannot be used in a tag name") % repr(c)) |
|
2210 | raise util.Abort(_("%s cannot be used in a tag name") % repr(c)) | |
2211 |
|
2211 | |||
2212 | repo.hook('pretag', throw=True, node=r, tag=name, |
|
2212 | repo.hook('pretag', throw=True, node=r, tag=name, | |
2213 | local=int(not not opts['local'])) |
|
2213 | local=int(not not opts['local'])) | |
2214 |
|
2214 | |||
2215 | if opts['local']: |
|
2215 | if opts['local']: | |
2216 | repo.opener("localtags", "a").write("%s %s\n" % (r, name)) |
|
2216 | repo.opener("localtags", "a").write("%s %s\n" % (r, name)) | |
2217 | repo.hook('tag', node=r, tag=name, local=1) |
|
2217 | repo.hook('tag', node=r, tag=name, local=1) | |
2218 | return |
|
2218 | return | |
2219 |
|
2219 | |||
2220 | for x in repo.changes(): |
|
2220 | for x in repo.changes(): | |
2221 | if ".hgtags" in x: |
|
2221 | if ".hgtags" in x: | |
2222 | raise util.Abort(_("working copy of .hgtags is changed " |
|
2222 | raise util.Abort(_("working copy of .hgtags is changed " | |
2223 | "(please commit .hgtags manually)")) |
|
2223 | "(please commit .hgtags manually)")) | |
2224 |
|
2224 | |||
2225 | repo.wfile(".hgtags", "ab").write("%s %s\n" % (r, name)) |
|
2225 | repo.wfile(".hgtags", "ab").write("%s %s\n" % (r, name)) | |
2226 | if repo.dirstate.state(".hgtags") == '?': |
|
2226 | if repo.dirstate.state(".hgtags") == '?': | |
2227 | repo.add([".hgtags"]) |
|
2227 | repo.add([".hgtags"]) | |
2228 |
|
2228 | |||
2229 | message = (opts['message'] or |
|
2229 | message = (opts['message'] or | |
2230 | _("Added tag %s for changeset %s") % (name, r)) |
|
2230 | _("Added tag %s for changeset %s") % (name, r)) | |
2231 | try: |
|
2231 | try: | |
2232 | repo.commit([".hgtags"], message, opts['user'], opts['date']) |
|
2232 | repo.commit([".hgtags"], message, opts['user'], opts['date']) | |
2233 | repo.hook('tag', node=r, tag=name, local=0) |
|
2233 | repo.hook('tag', node=r, tag=name, local=0) | |
2234 | except ValueError, inst: |
|
2234 | except ValueError, inst: | |
2235 | raise util.Abort(str(inst)) |
|
2235 | raise util.Abort(str(inst)) | |
2236 |
|
2236 | |||
2237 | def tags(ui, repo): |
|
2237 | def tags(ui, repo): | |
2238 | """list repository tags |
|
2238 | """list repository tags | |
2239 |
|
2239 | |||
2240 | List the repository tags. |
|
2240 | List the repository tags. | |
2241 |
|
2241 | |||
2242 | This lists both regular and local tags. |
|
2242 | This lists both regular and local tags. | |
2243 | """ |
|
2243 | """ | |
2244 |
|
2244 | |||
2245 | l = repo.tagslist() |
|
2245 | l = repo.tagslist() | |
2246 | l.reverse() |
|
2246 | l.reverse() | |
2247 | for t, n in l: |
|
2247 | for t, n in l: | |
2248 | try: |
|
2248 | try: | |
2249 | r = "%5d:%s" % (repo.changelog.rev(n), hex(n)) |
|
2249 | r = "%5d:%s" % (repo.changelog.rev(n), hex(n)) | |
2250 | except KeyError: |
|
2250 | except KeyError: | |
2251 | r = " ?:?" |
|
2251 | r = " ?:?" | |
2252 | ui.write("%-30s %s\n" % (t, r)) |
|
2252 | ui.write("%-30s %s\n" % (t, r)) | |
2253 |
|
2253 | |||
2254 | def tip(ui, repo, **opts): |
|
2254 | def tip(ui, repo, **opts): | |
2255 | """show the tip revision |
|
2255 | """show the tip revision | |
2256 |
|
2256 | |||
2257 | Show the tip revision. |
|
2257 | Show the tip revision. | |
2258 | """ |
|
2258 | """ | |
2259 | n = repo.changelog.tip() |
|
2259 | n = repo.changelog.tip() | |
2260 | br = None |
|
2260 | br = None | |
2261 | if opts['branches']: |
|
2261 | if opts['branches']: | |
2262 | br = repo.branchlookup([n]) |
|
2262 | br = repo.branchlookup([n]) | |
2263 | show_changeset(ui, repo, changenode=n, brinfo=br) |
|
2263 | show_changeset(ui, repo, changenode=n, brinfo=br) | |
2264 | if opts['patch']: |
|
2264 | if opts['patch']: | |
2265 | dodiff(ui, ui, repo, repo.changelog.parents(n)[0], n) |
|
2265 | dodiff(ui, ui, repo, repo.changelog.parents(n)[0], n) | |
2266 |
|
2266 | |||
2267 | def unbundle(ui, repo, fname, **opts): |
|
2267 | def unbundle(ui, repo, fname, **opts): | |
2268 | """apply a changegroup file |
|
2268 | """apply a changegroup file | |
2269 |
|
2269 | |||
2270 | Apply a compressed changegroup file generated by the bundle |
|
2270 | Apply a compressed changegroup file generated by the bundle | |
2271 | command. |
|
2271 | command. | |
2272 | """ |
|
2272 | """ | |
2273 | f = urllib.urlopen(fname) |
|
2273 | f = urllib.urlopen(fname) | |
2274 |
|
2274 | |||
2275 | if f.read(4) != "HG10": |
|
2275 | if f.read(4) != "HG10": | |
2276 | raise util.Abort(_("%s: not a Mercurial bundle file") % fname) |
|
2276 | raise util.Abort(_("%s: not a Mercurial bundle file") % fname) | |
2277 |
|
2277 | |||
2278 | def bzgenerator(f): |
|
2278 | def bzgenerator(f): | |
2279 | zd = bz2.BZ2Decompressor() |
|
2279 | zd = bz2.BZ2Decompressor() | |
2280 | for chunk in f: |
|
2280 | for chunk in f: | |
2281 | yield zd.decompress(chunk) |
|
2281 | yield zd.decompress(chunk) | |
2282 |
|
2282 | |||
2283 | bzgen = bzgenerator(util.filechunkiter(f, 4096)) |
|
2283 | bzgen = bzgenerator(util.filechunkiter(f, 4096)) | |
2284 | if repo.addchangegroup(util.chunkbuffer(bzgen)): |
|
2284 | if repo.addchangegroup(util.chunkbuffer(bzgen)): | |
2285 | return 1 |
|
2285 | return 1 | |
2286 |
|
2286 | |||
2287 | if opts['update']: |
|
2287 | if opts['update']: | |
2288 | return update(ui, repo) |
|
2288 | return update(ui, repo) | |
2289 | else: |
|
2289 | else: | |
2290 | ui.status(_("(run 'hg update' to get a working copy)\n")) |
|
2290 | ui.status(_("(run 'hg update' to get a working copy)\n")) | |
2291 |
|
2291 | |||
2292 | def undo(ui, repo): |
|
2292 | def undo(ui, repo): | |
2293 | """undo the last commit or pull |
|
2293 | """undo the last commit or pull | |
2294 |
|
2294 | |||
2295 | Roll back the last pull or commit transaction on the |
|
2295 | Roll back the last pull or commit transaction on the | |
2296 | repository, restoring the project to its earlier state. |
|
2296 | repository, restoring the project to its earlier state. | |
2297 |
|
2297 | |||
2298 | This command should be used with care. There is only one level of |
|
2298 | This command should be used with care. There is only one level of | |
2299 | undo and there is no redo. |
|
2299 | undo and there is no redo. | |
2300 |
|
2300 | |||
2301 | This command is not intended for use on public repositories. Once |
|
2301 | This command is not intended for use on public repositories. Once | |
2302 | a change is visible for pull by other users, undoing it locally is |
|
2302 | a change is visible for pull by other users, undoing it locally is | |
2303 | ineffective. |
|
2303 | ineffective. | |
2304 | """ |
|
2304 | """ | |
2305 | repo.undo() |
|
2305 | repo.undo() | |
2306 |
|
2306 | |||
2307 | def update(ui, repo, node=None, merge=False, clean=False, force=None, |
|
2307 | def update(ui, repo, node=None, merge=False, clean=False, force=None, | |
2308 | branch=None): |
|
2308 | branch=None): | |
2309 | """update or merge working directory |
|
2309 | """update or merge working directory | |
2310 |
|
2310 | |||
2311 | Update the working directory to the specified revision. |
|
2311 | Update the working directory to the specified revision. | |
2312 |
|
2312 | |||
2313 | If there are no outstanding changes in the working directory and |
|
2313 | If there are no outstanding changes in the working directory and | |
2314 | there is a linear relationship between the current version and the |
|
2314 | there is a linear relationship between the current version and the | |
2315 | requested version, the result is the requested version. |
|
2315 | requested version, the result is the requested version. | |
2316 |
|
2316 | |||
2317 | Otherwise the result is a merge between the contents of the |
|
2317 | Otherwise the result is a merge between the contents of the | |
2318 | current working directory and the requested version. Files that |
|
2318 | current working directory and the requested version. Files that | |
2319 | changed between either parent are marked as changed for the next |
|
2319 | changed between either parent are marked as changed for the next | |
2320 | commit and a commit must be performed before any further updates |
|
2320 | commit and a commit must be performed before any further updates | |
2321 | are allowed. |
|
2321 | are allowed. | |
2322 |
|
2322 | |||
2323 | By default, update will refuse to run if doing so would require |
|
2323 | By default, update will refuse to run if doing so would require | |
2324 | merging or discarding local changes. |
|
2324 | merging or discarding local changes. | |
2325 | """ |
|
2325 | """ | |
2326 | if branch: |
|
2326 | if branch: | |
2327 | br = repo.branchlookup(branch=branch) |
|
2327 | br = repo.branchlookup(branch=branch) | |
2328 | found = [] |
|
2328 | found = [] | |
2329 | for x in br: |
|
2329 | for x in br: | |
2330 | if branch in br[x]: |
|
2330 | if branch in br[x]: | |
2331 | found.append(x) |
|
2331 | found.append(x) | |
2332 | if len(found) > 1: |
|
2332 | if len(found) > 1: | |
2333 | ui.warn(_("Found multiple heads for %s\n") % branch) |
|
2333 | ui.warn(_("Found multiple heads for %s\n") % branch) | |
2334 | for x in found: |
|
2334 | for x in found: | |
2335 | show_changeset(ui, repo, changenode=x, brinfo=br) |
|
2335 | show_changeset(ui, repo, changenode=x, brinfo=br) | |
2336 | return 1 |
|
2336 | return 1 | |
2337 | if len(found) == 1: |
|
2337 | if len(found) == 1: | |
2338 | node = found[0] |
|
2338 | node = found[0] | |
2339 | ui.warn(_("Using head %s for branch %s\n") % (short(node), branch)) |
|
2339 | ui.warn(_("Using head %s for branch %s\n") % (short(node), branch)) | |
2340 | else: |
|
2340 | else: | |
2341 | ui.warn(_("branch %s not found\n") % (branch)) |
|
2341 | ui.warn(_("branch %s not found\n") % (branch)) | |
2342 | return 1 |
|
2342 | return 1 | |
2343 | else: |
|
2343 | else: | |
2344 | node = node and repo.lookup(node) or repo.changelog.tip() |
|
2344 | node = node and repo.lookup(node) or repo.changelog.tip() | |
2345 | return repo.update(node, allow=merge, force=clean, forcemerge=force) |
|
2345 | return repo.update(node, allow=merge, force=clean, forcemerge=force) | |
2346 |
|
2346 | |||
2347 | def verify(ui, repo): |
|
2347 | def verify(ui, repo): | |
2348 | """verify the integrity of the repository |
|
2348 | """verify the integrity of the repository | |
2349 |
|
2349 | |||
2350 | Verify the integrity of the current repository. |
|
2350 | Verify the integrity of the current repository. | |
2351 |
|
2351 | |||
2352 | This will perform an extensive check of the repository's |
|
2352 | This will perform an extensive check of the repository's | |
2353 | integrity, validating the hashes and checksums of each entry in |
|
2353 | integrity, validating the hashes and checksums of each entry in | |
2354 | the changelog, manifest, and tracked files, as well as the |
|
2354 | the changelog, manifest, and tracked files, as well as the | |
2355 | integrity of their crosslinks and indices. |
|
2355 | integrity of their crosslinks and indices. | |
2356 | """ |
|
2356 | """ | |
2357 | return repo.verify() |
|
2357 | return repo.verify() | |
2358 |
|
2358 | |||
2359 | # Command options and aliases are listed here, alphabetically |
|
2359 | # Command options and aliases are listed here, alphabetically | |
2360 |
|
2360 | |||
2361 | table = { |
|
2361 | table = { | |
2362 | "^add": |
|
2362 | "^add": | |
2363 | (add, |
|
2363 | (add, | |
2364 | [('I', 'include', [], _('include names matching the given patterns')), |
|
2364 | [('I', 'include', [], _('include names matching the given patterns')), | |
2365 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
|
2365 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], | |
2366 | _('hg add [OPTION]... [FILE]...')), |
|
2366 | _('hg add [OPTION]... [FILE]...')), | |
2367 | "addremove": |
|
2367 | "addremove": | |
2368 | (addremove, |
|
2368 | (addremove, | |
2369 | [('I', 'include', [], _('include names matching the given patterns')), |
|
2369 | [('I', 'include', [], _('include names matching the given patterns')), | |
2370 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
|
2370 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], | |
2371 | _('hg addremove [OPTION]... [FILE]...')), |
|
2371 | _('hg addremove [OPTION]... [FILE]...')), | |
2372 | "^annotate": |
|
2372 | "^annotate": | |
2373 | (annotate, |
|
2373 | (annotate, | |
2374 | [('r', 'rev', '', _('annotate the specified revision')), |
|
2374 | [('r', 'rev', '', _('annotate the specified revision')), | |
2375 | ('a', 'text', None, _('treat all files as text')), |
|
2375 | ('a', 'text', None, _('treat all files as text')), | |
2376 | ('u', 'user', None, _('list the author')), |
|
2376 | ('u', 'user', None, _('list the author')), | |
2377 | ('d', 'date', None, _('list the date')), |
|
2377 | ('d', 'date', None, _('list the date')), | |
2378 | ('n', 'number', None, _('list the revision number (default)')), |
|
2378 | ('n', 'number', None, _('list the revision number (default)')), | |
2379 | ('c', 'changeset', None, _('list the changeset')), |
|
2379 | ('c', 'changeset', None, _('list the changeset')), | |
2380 | ('I', 'include', [], _('include names matching the given patterns')), |
|
2380 | ('I', 'include', [], _('include names matching the given patterns')), | |
2381 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
|
2381 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], | |
2382 | _('hg annotate [-r REV] [-a] [-u] [-d] [-n] [-c] FILE...')), |
|
2382 | _('hg annotate [-r REV] [-a] [-u] [-d] [-n] [-c] FILE...')), | |
2383 | "bundle": |
|
2383 | "bundle": | |
2384 | (bundle, |
|
2384 | (bundle, | |
2385 | [], |
|
2385 | [], | |
2386 | _('hg bundle FILE DEST')), |
|
2386 | _('hg bundle FILE DEST')), | |
2387 | "cat": |
|
2387 | "cat": | |
2388 | (cat, |
|
2388 | (cat, | |
2389 | [('o', 'output', '', _('print output to file with formatted name')), |
|
2389 | [('o', 'output', '', _('print output to file with formatted name')), | |
2390 | ('r', 'rev', '', _('print the given revision')), |
|
2390 | ('r', 'rev', '', _('print the given revision')), | |
2391 | ('I', 'include', [], _('include names matching the given patterns')), |
|
2391 | ('I', 'include', [], _('include names matching the given patterns')), | |
2392 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
|
2392 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], | |
2393 | _('hg cat [OPTION]... FILE...')), |
|
2393 | _('hg cat [OPTION]... FILE...')), | |
2394 | "^clone": |
|
2394 | "^clone": | |
2395 | (clone, |
|
2395 | (clone, | |
2396 | [('U', 'noupdate', None, _('do not update the new working directory')), |
|
2396 | [('U', 'noupdate', None, _('do not update the new working directory')), | |
2397 | ('r', 'rev', [], |
|
2397 | ('r', 'rev', [], | |
2398 | _('a changeset you would like to have after cloning')), |
|
2398 | _('a changeset you would like to have after cloning')), | |
2399 | ('', 'pull', None, _('use pull protocol to copy metadata')), |
|
2399 | ('', 'pull', None, _('use pull protocol to copy metadata')), | |
2400 | ('e', 'ssh', '', _('specify ssh command to use')), |
|
2400 | ('e', 'ssh', '', _('specify ssh command to use')), | |
2401 | ('', 'remotecmd', '', |
|
2401 | ('', 'remotecmd', '', | |
2402 | _('specify hg command to run on the remote side'))], |
|
2402 | _('specify hg command to run on the remote side'))], | |
2403 | _('hg clone [OPTION]... SOURCE [DEST]')), |
|
2403 | _('hg clone [OPTION]... SOURCE [DEST]')), | |
2404 | "^commit|ci": |
|
2404 | "^commit|ci": | |
2405 | (commit, |
|
2405 | (commit, | |
2406 | [('A', 'addremove', None, _('run addremove during commit')), |
|
2406 | [('A', 'addremove', None, _('run addremove during commit')), | |
2407 | ('m', 'message', '', _('use <text> as commit message')), |
|
2407 | ('m', 'message', '', _('use <text> as commit message')), | |
2408 | ('l', 'logfile', '', _('read the commit message from <file>')), |
|
2408 | ('l', 'logfile', '', _('read the commit message from <file>')), | |
2409 | ('d', 'date', '', _('record datecode as commit date')), |
|
2409 | ('d', 'date', '', _('record datecode as commit date')), | |
2410 | ('u', 'user', '', _('record user as commiter')), |
|
2410 | ('u', 'user', '', _('record user as commiter')), | |
2411 | ('I', 'include', [], _('include names matching the given patterns')), |
|
2411 | ('I', 'include', [], _('include names matching the given patterns')), | |
2412 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
|
2412 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], | |
2413 | _('hg commit [OPTION]... [FILE]...')), |
|
2413 | _('hg commit [OPTION]... [FILE]...')), | |
2414 | "copy|cp": |
|
2414 | "copy|cp": | |
2415 | (copy, |
|
2415 | (copy, | |
2416 | [('A', 'after', None, _('record a copy that has already occurred')), |
|
2416 | [('A', 'after', None, _('record a copy that has already occurred')), | |
2417 | ('f', 'force', None, |
|
2417 | ('f', 'force', None, | |
2418 | _('forcibly copy over an existing managed file')), |
|
2418 | _('forcibly copy over an existing managed file')), | |
2419 | ('I', 'include', [], _('include names matching the given patterns')), |
|
2419 | ('I', 'include', [], _('include names matching the given patterns')), | |
2420 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
|
2420 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], | |
2421 | _('hg copy [OPTION]... [SOURCE]... DEST')), |
|
2421 | _('hg copy [OPTION]... [SOURCE]... DEST')), | |
2422 | "debugancestor": (debugancestor, [], _('debugancestor INDEX REV1 REV2')), |
|
2422 | "debugancestor": (debugancestor, [], _('debugancestor INDEX REV1 REV2')), | |
2423 | "debugrebuildstate": |
|
2423 | "debugrebuildstate": | |
2424 | (debugrebuildstate, |
|
2424 | (debugrebuildstate, | |
2425 | [('r', 'rev', '', _('revision to rebuild to'))], |
|
2425 | [('r', 'rev', '', _('revision to rebuild to'))], | |
2426 | _('debugrebuildstate [-r REV] [REV]')), |
|
2426 | _('debugrebuildstate [-r REV] [REV]')), | |
2427 | "debugcheckstate": (debugcheckstate, [], _('debugcheckstate')), |
|
2427 | "debugcheckstate": (debugcheckstate, [], _('debugcheckstate')), | |
2428 | "debugconfig": (debugconfig, [], _('debugconfig')), |
|
2428 | "debugconfig": (debugconfig, [], _('debugconfig')), | |
2429 | "debugsetparents": (debugsetparents, [], _('debugsetparents REV1 [REV2]')), |
|
2429 | "debugsetparents": (debugsetparents, [], _('debugsetparents REV1 [REV2]')), | |
2430 | "debugstate": (debugstate, [], _('debugstate')), |
|
2430 | "debugstate": (debugstate, [], _('debugstate')), | |
2431 | "debugdata": (debugdata, [], _('debugdata FILE REV')), |
|
2431 | "debugdata": (debugdata, [], _('debugdata FILE REV')), | |
2432 | "debugindex": (debugindex, [], _('debugindex FILE')), |
|
2432 | "debugindex": (debugindex, [], _('debugindex FILE')), | |
2433 | "debugindexdot": (debugindexdot, [], _('debugindexdot FILE')), |
|
2433 | "debugindexdot": (debugindexdot, [], _('debugindexdot FILE')), | |
2434 | "debugrename": (debugrename, [], _('debugrename FILE [REV]')), |
|
2434 | "debugrename": (debugrename, [], _('debugrename FILE [REV]')), | |
2435 | "debugwalk": |
|
2435 | "debugwalk": | |
2436 | (debugwalk, |
|
2436 | (debugwalk, | |
2437 | [('I', 'include', [], _('include names matching the given patterns')), |
|
2437 | [('I', 'include', [], _('include names matching the given patterns')), | |
2438 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
|
2438 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], | |
2439 | _('debugwalk [OPTION]... [FILE]...')), |
|
2439 | _('debugwalk [OPTION]... [FILE]...')), | |
2440 | "^diff": |
|
2440 | "^diff": | |
2441 | (diff, |
|
2441 | (diff, | |
2442 | [('r', 'rev', [], _('revision')), |
|
2442 | [('r', 'rev', [], _('revision')), | |
2443 | ('a', 'text', None, _('treat all files as text')), |
|
2443 | ('a', 'text', None, _('treat all files as text')), | |
2444 | ('p', 'show-function', None, |
|
2444 | ('p', 'show-function', None, | |
2445 | _('show which function each change is in')), |
|
2445 | _('show which function each change is in')), | |
2446 | ('w', 'ignore-all-space', None, |
|
2446 | ('w', 'ignore-all-space', None, | |
2447 | _('ignore white space when comparing lines')), |
|
2447 | _('ignore white space when comparing lines')), | |
2448 | ('I', 'include', [], _('include names matching the given patterns')), |
|
2448 | ('I', 'include', [], _('include names matching the given patterns')), | |
2449 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
|
2449 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], | |
2450 | _('hg diff [-a] [-I] [-X] [-r REV1 [-r REV2]] [FILE]...')), |
|
2450 | _('hg diff [-a] [-I] [-X] [-r REV1 [-r REV2]] [FILE]...')), | |
2451 | "^export": |
|
2451 | "^export": | |
2452 | (export, |
|
2452 | (export, | |
2453 | [('o', 'output', '', _('print output to file with formatted name')), |
|
2453 | [('o', 'output', '', _('print output to file with formatted name')), | |
2454 | ('a', 'text', None, _('treat all files as text')), |
|
2454 | ('a', 'text', None, _('treat all files as text')), | |
2455 | ('', 'switch-parent', None, _('diff against the second parent'))], |
|
2455 | ('', 'switch-parent', None, _('diff against the second parent'))], | |
2456 | _('hg export [-a] [-o OUTFILESPEC] REV...')), |
|
2456 | _('hg export [-a] [-o OUTFILESPEC] REV...')), | |
2457 | "forget": |
|
2457 | "forget": | |
2458 | (forget, |
|
2458 | (forget, | |
2459 | [('I', 'include', [], _('include names matching the given patterns')), |
|
2459 | [('I', 'include', [], _('include names matching the given patterns')), | |
2460 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
|
2460 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], | |
2461 | _('hg forget [OPTION]... FILE...')), |
|
2461 | _('hg forget [OPTION]... FILE...')), | |
2462 | "grep": |
|
2462 | "grep": | |
2463 | (grep, |
|
2463 | (grep, | |
2464 | [('0', 'print0', None, _('end fields with NUL')), |
|
2464 | [('0', 'print0', None, _('end fields with NUL')), | |
2465 | ('', 'all', None, _('print all revisions that match')), |
|
2465 | ('', 'all', None, _('print all revisions that match')), | |
2466 | ('i', 'ignore-case', None, _('ignore case when matching')), |
|
2466 | ('i', 'ignore-case', None, _('ignore case when matching')), | |
2467 | ('l', 'files-with-matches', None, |
|
2467 | ('l', 'files-with-matches', None, | |
2468 | _('print only filenames and revs that match')), |
|
2468 | _('print only filenames and revs that match')), | |
2469 | ('n', 'line-number', None, _('print matching line numbers')), |
|
2469 | ('n', 'line-number', None, _('print matching line numbers')), | |
2470 | ('r', 'rev', [], _('search in given revision range')), |
|
2470 | ('r', 'rev', [], _('search in given revision range')), | |
2471 | ('u', 'user', None, _('print user who committed change')), |
|
2471 | ('u', 'user', None, _('print user who committed change')), | |
2472 | ('I', 'include', [], _('include names matching the given patterns')), |
|
2472 | ('I', 'include', [], _('include names matching the given patterns')), | |
2473 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
|
2473 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], | |
2474 | _('hg grep [OPTION]... PATTERN [FILE]...')), |
|
2474 | _('hg grep [OPTION]... PATTERN [FILE]...')), | |
2475 | "heads": |
|
2475 | "heads": | |
2476 | (heads, |
|
2476 | (heads, | |
2477 | [('b', 'branches', None, _('show branches')), |
|
2477 | [('b', 'branches', None, _('show branches')), | |
2478 | ('r', 'rev', '', _('show only heads which are descendants of rev'))], |
|
2478 | ('r', 'rev', '', _('show only heads which are descendants of rev'))], | |
2479 | _('hg heads [-b] [-r <rev>]')), |
|
2479 | _('hg heads [-b] [-r <rev>]')), | |
2480 | "help": (help_, [], _('hg help [COMMAND]')), |
|
2480 | "help": (help_, [], _('hg help [COMMAND]')), | |
2481 | "identify|id": (identify, [], _('hg identify')), |
|
2481 | "identify|id": (identify, [], _('hg identify')), | |
2482 | "import|patch": |
|
2482 | "import|patch": | |
2483 | (import_, |
|
2483 | (import_, | |
2484 | [('p', 'strip', 1, |
|
2484 | [('p', 'strip', 1, | |
2485 | _('directory strip option for patch. This has the same\n') + |
|
2485 | _('directory strip option for patch. This has the same\n') + | |
2486 | _('meaning as the corresponding patch option')), |
|
2486 | _('meaning as the corresponding patch option')), | |
2487 | ('b', 'base', '', _('base path')), |
|
2487 | ('b', 'base', '', _('base path')), | |
2488 | ('f', 'force', None, |
|
2488 | ('f', 'force', None, | |
2489 | _('skip check for outstanding uncommitted changes'))], |
|
2489 | _('skip check for outstanding uncommitted changes'))], | |
2490 | _('hg import [-p NUM] [-b BASE] [-f] PATCH...')), |
|
2490 | _('hg import [-p NUM] [-b BASE] [-f] PATCH...')), | |
2491 | "incoming|in": (incoming, |
|
2491 | "incoming|in": (incoming, | |
2492 | [('M', 'no-merges', None, _('do not show merges')), |
|
2492 | [('M', 'no-merges', None, _('do not show merges')), | |
2493 | ('p', 'patch', None, _('show patch')), |
|
2493 | ('p', 'patch', None, _('show patch')), | |
2494 | ('n', 'newest-first', None, _('show newest record first'))], |
|
2494 | ('n', 'newest-first', None, _('show newest record first'))], | |
2495 | _('hg incoming [-p] [-n] [-M] [SOURCE]')), |
|
2495 | _('hg incoming [-p] [-n] [-M] [SOURCE]')), | |
2496 | "^init": (init, [], _('hg init [DEST]')), |
|
2496 | "^init": (init, [], _('hg init [DEST]')), | |
2497 | "locate": |
|
2497 | "locate": | |
2498 | (locate, |
|
2498 | (locate, | |
2499 | [('r', 'rev', '', _('search the repository as it stood at rev')), |
|
2499 | [('r', 'rev', '', _('search the repository as it stood at rev')), | |
2500 | ('0', 'print0', None, |
|
2500 | ('0', 'print0', None, | |
2501 | _('end filenames with NUL, for use with xargs')), |
|
2501 | _('end filenames with NUL, for use with xargs')), | |
2502 | ('f', 'fullpath', None, |
|
2502 | ('f', 'fullpath', None, | |
2503 | _('print complete paths from the filesystem root')), |
|
2503 | _('print complete paths from the filesystem root')), | |
2504 | ('I', 'include', [], _('include names matching the given patterns')), |
|
2504 | ('I', 'include', [], _('include names matching the given patterns')), | |
2505 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
|
2505 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], | |
2506 | _('hg locate [OPTION]... [PATTERN]...')), |
|
2506 | _('hg locate [OPTION]... [PATTERN]...')), | |
2507 | "^log|history": |
|
2507 | "^log|history": | |
2508 | (log, |
|
2508 | (log, | |
2509 | [('b', 'branches', None, _('show branches')), |
|
2509 | [('b', 'branches', None, _('show branches')), | |
2510 | ('k', 'keyword', [], _('search for a keyword')), |
|
2510 | ('k', 'keyword', [], _('search for a keyword')), | |
2511 | ('l', 'limit', '', _('limit number of changes displayed')), |
|
2511 | ('l', 'limit', '', _('limit number of changes displayed')), | |
2512 | ('r', 'rev', [], _('show the specified revision or range')), |
|
2512 | ('r', 'rev', [], _('show the specified revision or range')), | |
2513 | ('M', 'no-merges', None, _('do not show merges')), |
|
2513 | ('M', 'no-merges', None, _('do not show merges')), | |
2514 | ('m', 'only-merges', None, _('show only merges')), |
|
2514 | ('m', 'only-merges', None, _('show only merges')), | |
2515 | ('p', 'patch', None, _('show patch')), |
|
2515 | ('p', 'patch', None, _('show patch')), | |
2516 | ('I', 'include', [], _('include names matching the given patterns')), |
|
2516 | ('I', 'include', [], _('include names matching the given patterns')), | |
2517 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
|
2517 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], | |
2518 | _('hg log [OPTION]... [FILE]')), |
|
2518 | _('hg log [OPTION]... [FILE]')), | |
2519 | "manifest": (manifest, [], _('hg manifest [REV]')), |
|
2519 | "manifest": (manifest, [], _('hg manifest [REV]')), | |
2520 | "outgoing|out": (outgoing, |
|
2520 | "outgoing|out": (outgoing, | |
2521 | [('M', 'no-merges', None, _('do not show merges')), |
|
2521 | [('M', 'no-merges', None, _('do not show merges')), | |
2522 | ('p', 'patch', None, _('show patch')), |
|
2522 | ('p', 'patch', None, _('show patch')), | |
2523 | ('n', 'newest-first', None, _('show newest record first'))], |
|
2523 | ('n', 'newest-first', None, _('show newest record first'))], | |
2524 | _('hg outgoing [-M] [-p] [-n] [DEST]')), |
|
2524 | _('hg outgoing [-M] [-p] [-n] [DEST]')), | |
2525 | "^parents": |
|
2525 | "^parents": | |
2526 | (parents, |
|
2526 | (parents, | |
2527 | [('b', 'branches', None, _('show branches'))], |
|
2527 | [('b', 'branches', None, _('show branches'))], | |
2528 | _('hg parents [-b] [REV]')), |
|
2528 | _('hg parents [-b] [REV]')), | |
2529 | "paths": (paths, [], _('hg paths [NAME]')), |
|
2529 | "paths": (paths, [], _('hg paths [NAME]')), | |
2530 | "^pull": |
|
2530 | "^pull": | |
2531 | (pull, |
|
2531 | (pull, | |
2532 | [('u', 'update', None, |
|
2532 | [('u', 'update', None, | |
2533 | _('update the working directory to tip after pull')), |
|
2533 | _('update the working directory to tip after pull')), | |
2534 | ('e', 'ssh', '', _('specify ssh command to use')), |
|
2534 | ('e', 'ssh', '', _('specify ssh command to use')), | |
2535 | ('r', 'rev', [], _('a specific revision you would like to pull')), |
|
2535 | ('r', 'rev', [], _('a specific revision you would like to pull')), | |
2536 | ('', 'remotecmd', '', |
|
2536 | ('', 'remotecmd', '', | |
2537 | _('specify hg command to run on the remote side'))], |
|
2537 | _('specify hg command to run on the remote side'))], | |
2538 | _('hg pull [-u] [-e FILE] [-r REV]... [--remotecmd FILE] [SOURCE]')), |
|
2538 | _('hg pull [-u] [-e FILE] [-r REV]... [--remotecmd FILE] [SOURCE]')), | |
2539 | "^push": |
|
2539 | "^push": | |
2540 | (push, |
|
2540 | (push, | |
2541 | [('f', 'force', None, _('force push')), |
|
2541 | [('f', 'force', None, _('force push')), | |
2542 | ('e', 'ssh', '', _('specify ssh command to use')), |
|
2542 | ('e', 'ssh', '', _('specify ssh command to use')), | |
2543 | ('r', 'rev', [], _('a specific revision you would like to push')), |
|
2543 | ('r', 'rev', [], _('a specific revision you would like to push')), | |
2544 | ('', 'remotecmd', '', |
|
2544 | ('', 'remotecmd', '', | |
2545 | _('specify hg command to run on the remote side'))], |
|
2545 | _('specify hg command to run on the remote side'))], | |
2546 | _('hg push [-f] [-e FILE] [-r REV]... [--remotecmd FILE] [DEST]')), |
|
2546 | _('hg push [-f] [-e FILE] [-r REV]... [--remotecmd FILE] [DEST]')), | |
2547 | "rawcommit": |
|
2547 | "debugrawcommit|rawcommit": | |
2548 | (rawcommit, |
|
2548 | (rawcommit, | |
2549 | [('p', 'parent', [], _('parent')), |
|
2549 | [('p', 'parent', [], _('parent')), | |
2550 | ('d', 'date', '', _('date code')), |
|
2550 | ('d', 'date', '', _('date code')), | |
2551 | ('u', 'user', '', _('user')), |
|
2551 | ('u', 'user', '', _('user')), | |
2552 | ('F', 'files', '', _('file list')), |
|
2552 | ('F', 'files', '', _('file list')), | |
2553 | ('m', 'message', '', _('commit message')), |
|
2553 | ('m', 'message', '', _('commit message')), | |
2554 | ('l', 'logfile', '', _('commit message file'))], |
|
2554 | ('l', 'logfile', '', _('commit message file'))], | |
2555 | _('hg rawcommit [OPTION]... [FILE]...')), |
|
2555 | _('hg debugrawcommit [OPTION]... [FILE]...')), | |
2556 | "recover": (recover, [], _('hg recover')), |
|
2556 | "recover": (recover, [], _('hg recover')), | |
2557 | "^remove|rm": |
|
2557 | "^remove|rm": | |
2558 | (remove, |
|
2558 | (remove, | |
2559 | [('I', 'include', [], _('include names matching the given patterns')), |
|
2559 | [('I', 'include', [], _('include names matching the given patterns')), | |
2560 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
|
2560 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], | |
2561 | _('hg remove [OPTION]... FILE...')), |
|
2561 | _('hg remove [OPTION]... FILE...')), | |
2562 | "rename|mv": |
|
2562 | "rename|mv": | |
2563 | (rename, |
|
2563 | (rename, | |
2564 | [('A', 'after', None, _('record a rename that has already occurred')), |
|
2564 | [('A', 'after', None, _('record a rename that has already occurred')), | |
2565 | ('f', 'force', None, |
|
2565 | ('f', 'force', None, | |
2566 | _('forcibly copy over an existing managed file')), |
|
2566 | _('forcibly copy over an existing managed file')), | |
2567 | ('I', 'include', [], _('include names matching the given patterns')), |
|
2567 | ('I', 'include', [], _('include names matching the given patterns')), | |
2568 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
|
2568 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], | |
2569 | _('hg rename [OPTION]... [SOURCE]... DEST')), |
|
2569 | _('hg rename [OPTION]... [SOURCE]... DEST')), | |
2570 | "^revert": |
|
2570 | "^revert": | |
2571 | (revert, |
|
2571 | (revert, | |
2572 | [('r', 'rev', '', _('revision to revert to')), |
|
2572 | [('r', 'rev', '', _('revision to revert to')), | |
2573 | ('I', 'include', [], _('include names matching the given patterns')), |
|
2573 | ('I', 'include', [], _('include names matching the given patterns')), | |
2574 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
|
2574 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], | |
2575 | _('hg revert [-r REV] [NAME]...')), |
|
2575 | _('hg revert [-r REV] [NAME]...')), | |
2576 | "root": (root, [], _('hg root')), |
|
2576 | "root": (root, [], _('hg root')), | |
2577 | "^serve": |
|
2577 | "^serve": | |
2578 | (serve, |
|
2578 | (serve, | |
2579 | [('A', 'accesslog', '', _('name of access log file to write to')), |
|
2579 | [('A', 'accesslog', '', _('name of access log file to write to')), | |
2580 | ('d', 'daemon', None, _('run server in background')), |
|
2580 | ('d', 'daemon', None, _('run server in background')), | |
2581 | ('', 'daemon-pipefds', '', _('used internally by daemon mode')), |
|
2581 | ('', 'daemon-pipefds', '', _('used internally by daemon mode')), | |
2582 | ('E', 'errorlog', '', _('name of error log file to write to')), |
|
2582 | ('E', 'errorlog', '', _('name of error log file to write to')), | |
2583 | ('p', 'port', 0, _('port to use (default: 8000)')), |
|
2583 | ('p', 'port', 0, _('port to use (default: 8000)')), | |
2584 | ('a', 'address', '', _('address to use')), |
|
2584 | ('a', 'address', '', _('address to use')), | |
2585 | ('n', 'name', '', |
|
2585 | ('n', 'name', '', | |
2586 | _('name to show in web pages (default: working dir)')), |
|
2586 | _('name to show in web pages (default: working dir)')), | |
2587 | ('', 'pid-file', '', _('name of file to write process ID to')), |
|
2587 | ('', 'pid-file', '', _('name of file to write process ID to')), | |
2588 | ('', 'stdio', None, _('for remote clients')), |
|
2588 | ('', 'stdio', None, _('for remote clients')), | |
2589 | ('t', 'templates', '', _('web templates to use')), |
|
2589 | ('t', 'templates', '', _('web templates to use')), | |
2590 | ('', 'style', '', _('template style to use')), |
|
2590 | ('', 'style', '', _('template style to use')), | |
2591 | ('6', 'ipv6', None, _('use IPv6 in addition to IPv4'))], |
|
2591 | ('6', 'ipv6', None, _('use IPv6 in addition to IPv4'))], | |
2592 | _('hg serve [OPTION]...')), |
|
2592 | _('hg serve [OPTION]...')), | |
2593 | "^status|st": |
|
2593 | "^status|st": | |
2594 | (status, |
|
2594 | (status, | |
2595 | [('m', 'modified', None, _('show only modified files')), |
|
2595 | [('m', 'modified', None, _('show only modified files')), | |
2596 | ('a', 'added', None, _('show only added files')), |
|
2596 | ('a', 'added', None, _('show only added files')), | |
2597 | ('r', 'removed', None, _('show only removed files')), |
|
2597 | ('r', 'removed', None, _('show only removed files')), | |
2598 | ('d', 'deleted', None, _('show only deleted (but tracked) files')), |
|
2598 | ('d', 'deleted', None, _('show only deleted (but tracked) files')), | |
2599 | ('u', 'unknown', None, _('show only unknown (not tracked) files')), |
|
2599 | ('u', 'unknown', None, _('show only unknown (not tracked) files')), | |
2600 | ('n', 'no-status', None, _('hide status prefix')), |
|
2600 | ('n', 'no-status', None, _('hide status prefix')), | |
2601 | ('0', 'print0', None, |
|
2601 | ('0', 'print0', None, | |
2602 | _('end filenames with NUL, for use with xargs')), |
|
2602 | _('end filenames with NUL, for use with xargs')), | |
2603 | ('I', 'include', [], _('include names matching the given patterns')), |
|
2603 | ('I', 'include', [], _('include names matching the given patterns')), | |
2604 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
|
2604 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], | |
2605 | _('hg status [OPTION]... [FILE]...')), |
|
2605 | _('hg status [OPTION]... [FILE]...')), | |
2606 | "tag": |
|
2606 | "tag": | |
2607 | (tag, |
|
2607 | (tag, | |
2608 | [('l', 'local', None, _('make the tag local')), |
|
2608 | [('l', 'local', None, _('make the tag local')), | |
2609 | ('m', 'message', '', _('message for tag commit log entry')), |
|
2609 | ('m', 'message', '', _('message for tag commit log entry')), | |
2610 | ('d', 'date', '', _('record datecode as commit date')), |
|
2610 | ('d', 'date', '', _('record datecode as commit date')), | |
2611 | ('u', 'user', '', _('record user as commiter')), |
|
2611 | ('u', 'user', '', _('record user as commiter')), | |
2612 | ('r', 'rev', '', _('revision to tag'))], |
|
2612 | ('r', 'rev', '', _('revision to tag'))], | |
2613 | _('hg tag [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME')), |
|
2613 | _('hg tag [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME')), | |
2614 | "tags": (tags, [], _('hg tags')), |
|
2614 | "tags": (tags, [], _('hg tags')), | |
2615 | "tip": |
|
2615 | "tip": | |
2616 | (tip, |
|
2616 | (tip, | |
2617 | [('b', 'branches', None, _('show branches')), |
|
2617 | [('b', 'branches', None, _('show branches')), | |
2618 | ('p', 'patch', None, _('show patch'))], |
|
2618 | ('p', 'patch', None, _('show patch'))], | |
2619 | _('hg tip [-b] [-p]')), |
|
2619 | _('hg tip [-b] [-p]')), | |
2620 | "unbundle": |
|
2620 | "unbundle": | |
2621 | (unbundle, |
|
2621 | (unbundle, | |
2622 | [('u', 'update', None, |
|
2622 | [('u', 'update', None, | |
2623 | _('update the working directory to tip after unbundle'))], |
|
2623 | _('update the working directory to tip after unbundle'))], | |
2624 | _('hg unbundle [-u] FILE')), |
|
2624 | _('hg unbundle [-u] FILE')), | |
2625 | "undo": (undo, [], _('hg undo')), |
|
2625 | "undo": (undo, [], _('hg undo')), | |
2626 | "^update|up|checkout|co": |
|
2626 | "^update|up|checkout|co": | |
2627 | (update, |
|
2627 | (update, | |
2628 | [('b', 'branch', '', _('checkout the head of a specific branch')), |
|
2628 | [('b', 'branch', '', _('checkout the head of a specific branch')), | |
2629 | ('m', 'merge', None, _('allow merging of branches')), |
|
2629 | ('m', 'merge', None, _('allow merging of branches')), | |
2630 | ('C', 'clean', None, _('overwrite locally modified files')), |
|
2630 | ('C', 'clean', None, _('overwrite locally modified files')), | |
2631 | ('f', 'force', None, _('force a merge with outstanding changes'))], |
|
2631 | ('f', 'force', None, _('force a merge with outstanding changes'))], | |
2632 | _('hg update [-b TAG] [-m] [-C] [-f] [REV]')), |
|
2632 | _('hg update [-b TAG] [-m] [-C] [-f] [REV]')), | |
2633 | "verify": (verify, [], _('hg verify')), |
|
2633 | "verify": (verify, [], _('hg verify')), | |
2634 | "version": (show_version, [], _('hg version')), |
|
2634 | "version": (show_version, [], _('hg version')), | |
2635 | } |
|
2635 | } | |
2636 |
|
2636 | |||
2637 | globalopts = [ |
|
2637 | globalopts = [ | |
2638 | ('R', 'repository', '', _('repository root directory')), |
|
2638 | ('R', 'repository', '', _('repository root directory')), | |
2639 | ('', 'cwd', '', _('change working directory')), |
|
2639 | ('', 'cwd', '', _('change working directory')), | |
2640 | ('y', 'noninteractive', None, |
|
2640 | ('y', 'noninteractive', None, | |
2641 | _('do not prompt, assume \'yes\' for any required answers')), |
|
2641 | _('do not prompt, assume \'yes\' for any required answers')), | |
2642 | ('q', 'quiet', None, _('suppress output')), |
|
2642 | ('q', 'quiet', None, _('suppress output')), | |
2643 | ('v', 'verbose', None, _('enable additional output')), |
|
2643 | ('v', 'verbose', None, _('enable additional output')), | |
2644 | ('', 'debug', None, _('enable debugging output')), |
|
2644 | ('', 'debug', None, _('enable debugging output')), | |
2645 | ('', 'debugger', None, _('start debugger')), |
|
2645 | ('', 'debugger', None, _('start debugger')), | |
2646 | ('', 'traceback', None, _('print traceback on exception')), |
|
2646 | ('', 'traceback', None, _('print traceback on exception')), | |
2647 | ('', 'time', None, _('time how long the command takes')), |
|
2647 | ('', 'time', None, _('time how long the command takes')), | |
2648 | ('', 'profile', None, _('print command execution profile')), |
|
2648 | ('', 'profile', None, _('print command execution profile')), | |
2649 | ('', 'version', None, _('output version information and exit')), |
|
2649 | ('', 'version', None, _('output version information and exit')), | |
2650 | ('h', 'help', None, _('display help and exit')), |
|
2650 | ('h', 'help', None, _('display help and exit')), | |
2651 | ] |
|
2651 | ] | |
2652 |
|
2652 | |||
2653 | norepo = ("clone init version help debugancestor debugconfig debugdata" |
|
2653 | norepo = ("clone init version help debugancestor debugconfig debugdata" | |
2654 | " debugindex debugindexdot paths") |
|
2654 | " debugindex debugindexdot paths") | |
2655 |
|
2655 | |||
2656 | def find(cmd): |
|
2656 | def find(cmd): | |
2657 | """Return (aliases, command table entry) for command string.""" |
|
2657 | """Return (aliases, command table entry) for command string.""" | |
2658 | choice = None |
|
2658 | choice = None | |
2659 | count = 0 |
|
2659 | count = 0 | |
2660 | for e in table.keys(): |
|
2660 | for e in table.keys(): | |
2661 | aliases = e.lstrip("^").split("|") |
|
2661 | aliases = e.lstrip("^").split("|") | |
2662 | if cmd in aliases: |
|
2662 | if cmd in aliases: | |
2663 | return aliases, table[e] |
|
2663 | return aliases, table[e] | |
2664 | for a in aliases: |
|
2664 | for a in aliases: | |
2665 | if a.startswith(cmd): |
|
2665 | if a.startswith(cmd): | |
2666 | count += 1 |
|
2666 | count += 1 | |
2667 | choice = aliases, table[e] |
|
2667 | choice = aliases, table[e] | |
2668 | break |
|
2668 | break | |
2669 |
|
2669 | |||
2670 | if count > 1: |
|
2670 | if count > 1: | |
2671 | raise AmbiguousCommand(cmd) |
|
2671 | raise AmbiguousCommand(cmd) | |
2672 |
|
2672 | |||
2673 | if choice: |
|
2673 | if choice: | |
2674 | return choice |
|
2674 | return choice | |
2675 |
|
2675 | |||
2676 | raise UnknownCommand(cmd) |
|
2676 | raise UnknownCommand(cmd) | |
2677 |
|
2677 | |||
2678 | class SignalInterrupt(Exception): |
|
2678 | class SignalInterrupt(Exception): | |
2679 | """Exception raised on SIGTERM and SIGHUP.""" |
|
2679 | """Exception raised on SIGTERM and SIGHUP.""" | |
2680 |
|
2680 | |||
2681 | def catchterm(*args): |
|
2681 | def catchterm(*args): | |
2682 | raise SignalInterrupt |
|
2682 | raise SignalInterrupt | |
2683 |
|
2683 | |||
2684 | def run(): |
|
2684 | def run(): | |
2685 | sys.exit(dispatch(sys.argv[1:])) |
|
2685 | sys.exit(dispatch(sys.argv[1:])) | |
2686 |
|
2686 | |||
2687 | class ParseError(Exception): |
|
2687 | class ParseError(Exception): | |
2688 | """Exception raised on errors in parsing the command line.""" |
|
2688 | """Exception raised on errors in parsing the command line.""" | |
2689 |
|
2689 | |||
2690 | def parse(ui, args): |
|
2690 | def parse(ui, args): | |
2691 | options = {} |
|
2691 | options = {} | |
2692 | cmdoptions = {} |
|
2692 | cmdoptions = {} | |
2693 |
|
2693 | |||
2694 | try: |
|
2694 | try: | |
2695 | args = fancyopts.fancyopts(args, globalopts, options) |
|
2695 | args = fancyopts.fancyopts(args, globalopts, options) | |
2696 | except fancyopts.getopt.GetoptError, inst: |
|
2696 | except fancyopts.getopt.GetoptError, inst: | |
2697 | raise ParseError(None, inst) |
|
2697 | raise ParseError(None, inst) | |
2698 |
|
2698 | |||
2699 | if args: |
|
2699 | if args: | |
2700 | cmd, args = args[0], args[1:] |
|
2700 | cmd, args = args[0], args[1:] | |
2701 | aliases, i = find(cmd) |
|
2701 | aliases, i = find(cmd) | |
2702 | cmd = aliases[0] |
|
2702 | cmd = aliases[0] | |
2703 | defaults = ui.config("defaults", cmd) |
|
2703 | defaults = ui.config("defaults", cmd) | |
2704 | if defaults: |
|
2704 | if defaults: | |
2705 | args = defaults.split() + args |
|
2705 | args = defaults.split() + args | |
2706 | c = list(i[1]) |
|
2706 | c = list(i[1]) | |
2707 | else: |
|
2707 | else: | |
2708 | cmd = None |
|
2708 | cmd = None | |
2709 | c = [] |
|
2709 | c = [] | |
2710 |
|
2710 | |||
2711 | # combine global options into local |
|
2711 | # combine global options into local | |
2712 | for o in globalopts: |
|
2712 | for o in globalopts: | |
2713 | c.append((o[0], o[1], options[o[1]], o[3])) |
|
2713 | c.append((o[0], o[1], options[o[1]], o[3])) | |
2714 |
|
2714 | |||
2715 | try: |
|
2715 | try: | |
2716 | args = fancyopts.fancyopts(args, c, cmdoptions) |
|
2716 | args = fancyopts.fancyopts(args, c, cmdoptions) | |
2717 | except fancyopts.getopt.GetoptError, inst: |
|
2717 | except fancyopts.getopt.GetoptError, inst: | |
2718 | raise ParseError(cmd, inst) |
|
2718 | raise ParseError(cmd, inst) | |
2719 |
|
2719 | |||
2720 | # separate global options back out |
|
2720 | # separate global options back out | |
2721 | for o in globalopts: |
|
2721 | for o in globalopts: | |
2722 | n = o[1] |
|
2722 | n = o[1] | |
2723 | options[n] = cmdoptions[n] |
|
2723 | options[n] = cmdoptions[n] | |
2724 | del cmdoptions[n] |
|
2724 | del cmdoptions[n] | |
2725 |
|
2725 | |||
2726 | return (cmd, cmd and i[0] or None, args, options, cmdoptions) |
|
2726 | return (cmd, cmd and i[0] or None, args, options, cmdoptions) | |
2727 |
|
2727 | |||
2728 | def dispatch(args): |
|
2728 | def dispatch(args): | |
2729 | signal.signal(signal.SIGTERM, catchterm) |
|
2729 | signal.signal(signal.SIGTERM, catchterm) | |
2730 | try: |
|
2730 | try: | |
2731 | signal.signal(signal.SIGHUP, catchterm) |
|
2731 | signal.signal(signal.SIGHUP, catchterm) | |
2732 | except AttributeError: |
|
2732 | except AttributeError: | |
2733 | pass |
|
2733 | pass | |
2734 |
|
2734 | |||
2735 | try: |
|
2735 | try: | |
2736 | u = ui.ui() |
|
2736 | u = ui.ui() | |
2737 | except util.Abort, inst: |
|
2737 | except util.Abort, inst: | |
2738 | sys.stderr.write(_("abort: %s\n") % inst) |
|
2738 | sys.stderr.write(_("abort: %s\n") % inst) | |
2739 | sys.exit(1) |
|
2739 | sys.exit(1) | |
2740 |
|
2740 | |||
2741 | external = [] |
|
2741 | external = [] | |
2742 | for x in u.extensions(): |
|
2742 | for x in u.extensions(): | |
2743 | def on_exception(exc, inst): |
|
2743 | def on_exception(exc, inst): | |
2744 | u.warn(_("*** failed to import extension %s\n") % x[1]) |
|
2744 | u.warn(_("*** failed to import extension %s\n") % x[1]) | |
2745 | u.warn("%s\n" % inst) |
|
2745 | u.warn("%s\n" % inst) | |
2746 | if "--traceback" in sys.argv[1:]: |
|
2746 | if "--traceback" in sys.argv[1:]: | |
2747 | traceback.print_exc() |
|
2747 | traceback.print_exc() | |
2748 | if x[1]: |
|
2748 | if x[1]: | |
2749 | try: |
|
2749 | try: | |
2750 | mod = imp.load_source(x[0], x[1]) |
|
2750 | mod = imp.load_source(x[0], x[1]) | |
2751 | except Exception, inst: |
|
2751 | except Exception, inst: | |
2752 | on_exception(Exception, inst) |
|
2752 | on_exception(Exception, inst) | |
2753 | continue |
|
2753 | continue | |
2754 | else: |
|
2754 | else: | |
2755 | def importh(name): |
|
2755 | def importh(name): | |
2756 | mod = __import__(name) |
|
2756 | mod = __import__(name) | |
2757 | components = name.split('.') |
|
2757 | components = name.split('.') | |
2758 | for comp in components[1:]: |
|
2758 | for comp in components[1:]: | |
2759 | mod = getattr(mod, comp) |
|
2759 | mod = getattr(mod, comp) | |
2760 | return mod |
|
2760 | return mod | |
2761 | try: |
|
2761 | try: | |
2762 | mod = importh(x[0]) |
|
2762 | mod = importh(x[0]) | |
2763 | except Exception, inst: |
|
2763 | except Exception, inst: | |
2764 | on_exception(Exception, inst) |
|
2764 | on_exception(Exception, inst) | |
2765 | continue |
|
2765 | continue | |
2766 |
|
2766 | |||
2767 | external.append(mod) |
|
2767 | external.append(mod) | |
2768 | for x in external: |
|
2768 | for x in external: | |
2769 | cmdtable = getattr(x, 'cmdtable', {}) |
|
2769 | cmdtable = getattr(x, 'cmdtable', {}) | |
2770 | for t in cmdtable: |
|
2770 | for t in cmdtable: | |
2771 | if t in table: |
|
2771 | if t in table: | |
2772 | u.warn(_("module %s overrides %s\n") % (x.__name__, t)) |
|
2772 | u.warn(_("module %s overrides %s\n") % (x.__name__, t)) | |
2773 | table.update(cmdtable) |
|
2773 | table.update(cmdtable) | |
2774 |
|
2774 | |||
2775 | try: |
|
2775 | try: | |
2776 | cmd, func, args, options, cmdoptions = parse(u, args) |
|
2776 | cmd, func, args, options, cmdoptions = parse(u, args) | |
2777 | except ParseError, inst: |
|
2777 | except ParseError, inst: | |
2778 | if inst.args[0]: |
|
2778 | if inst.args[0]: | |
2779 | u.warn(_("hg %s: %s\n") % (inst.args[0], inst.args[1])) |
|
2779 | u.warn(_("hg %s: %s\n") % (inst.args[0], inst.args[1])) | |
2780 | help_(u, inst.args[0]) |
|
2780 | help_(u, inst.args[0]) | |
2781 | else: |
|
2781 | else: | |
2782 | u.warn(_("hg: %s\n") % inst.args[1]) |
|
2782 | u.warn(_("hg: %s\n") % inst.args[1]) | |
2783 | help_(u, 'shortlist') |
|
2783 | help_(u, 'shortlist') | |
2784 | sys.exit(-1) |
|
2784 | sys.exit(-1) | |
2785 | except AmbiguousCommand, inst: |
|
2785 | except AmbiguousCommand, inst: | |
2786 | u.warn(_("hg: command '%s' is ambiguous.\n") % inst.args[0]) |
|
2786 | u.warn(_("hg: command '%s' is ambiguous.\n") % inst.args[0]) | |
2787 | sys.exit(1) |
|
2787 | sys.exit(1) | |
2788 | except UnknownCommand, inst: |
|
2788 | except UnknownCommand, inst: | |
2789 | u.warn(_("hg: unknown command '%s'\n") % inst.args[0]) |
|
2789 | u.warn(_("hg: unknown command '%s'\n") % inst.args[0]) | |
2790 | help_(u, 'shortlist') |
|
2790 | help_(u, 'shortlist') | |
2791 | sys.exit(1) |
|
2791 | sys.exit(1) | |
2792 |
|
2792 | |||
2793 | if options["time"]: |
|
2793 | if options["time"]: | |
2794 | def get_times(): |
|
2794 | def get_times(): | |
2795 | t = os.times() |
|
2795 | t = os.times() | |
2796 | if t[4] == 0.0: # Windows leaves this as zero, so use time.clock() |
|
2796 | if t[4] == 0.0: # Windows leaves this as zero, so use time.clock() | |
2797 | t = (t[0], t[1], t[2], t[3], time.clock()) |
|
2797 | t = (t[0], t[1], t[2], t[3], time.clock()) | |
2798 | return t |
|
2798 | return t | |
2799 | s = get_times() |
|
2799 | s = get_times() | |
2800 | def print_time(): |
|
2800 | def print_time(): | |
2801 | t = get_times() |
|
2801 | t = get_times() | |
2802 | u.warn(_("Time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n") % |
|
2802 | u.warn(_("Time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n") % | |
2803 | (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3])) |
|
2803 | (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3])) | |
2804 | atexit.register(print_time) |
|
2804 | atexit.register(print_time) | |
2805 |
|
2805 | |||
2806 | u.updateopts(options["verbose"], options["debug"], options["quiet"], |
|
2806 | u.updateopts(options["verbose"], options["debug"], options["quiet"], | |
2807 | not options["noninteractive"]) |
|
2807 | not options["noninteractive"]) | |
2808 |
|
2808 | |||
2809 | # enter the debugger before command execution |
|
2809 | # enter the debugger before command execution | |
2810 | if options['debugger']: |
|
2810 | if options['debugger']: | |
2811 | pdb.set_trace() |
|
2811 | pdb.set_trace() | |
2812 |
|
2812 | |||
2813 | try: |
|
2813 | try: | |
2814 | try: |
|
2814 | try: | |
2815 | if options['help']: |
|
2815 | if options['help']: | |
2816 | help_(u, cmd, options['version']) |
|
2816 | help_(u, cmd, options['version']) | |
2817 | sys.exit(0) |
|
2817 | sys.exit(0) | |
2818 | elif options['version']: |
|
2818 | elif options['version']: | |
2819 | show_version(u) |
|
2819 | show_version(u) | |
2820 | sys.exit(0) |
|
2820 | sys.exit(0) | |
2821 | elif not cmd: |
|
2821 | elif not cmd: | |
2822 | help_(u, 'shortlist') |
|
2822 | help_(u, 'shortlist') | |
2823 | sys.exit(0) |
|
2823 | sys.exit(0) | |
2824 |
|
2824 | |||
2825 | if options['cwd']: |
|
2825 | if options['cwd']: | |
2826 | try: |
|
2826 | try: | |
2827 | os.chdir(options['cwd']) |
|
2827 | os.chdir(options['cwd']) | |
2828 | except OSError, inst: |
|
2828 | except OSError, inst: | |
2829 | raise util.Abort('%s: %s' % |
|
2829 | raise util.Abort('%s: %s' % | |
2830 | (options['cwd'], inst.strerror)) |
|
2830 | (options['cwd'], inst.strerror)) | |
2831 |
|
2831 | |||
2832 | if cmd not in norepo.split(): |
|
2832 | if cmd not in norepo.split(): | |
2833 | path = options["repository"] or "" |
|
2833 | path = options["repository"] or "" | |
2834 | repo = hg.repository(ui=u, path=path) |
|
2834 | repo = hg.repository(ui=u, path=path) | |
2835 | for x in external: |
|
2835 | for x in external: | |
2836 | if hasattr(x, 'reposetup'): |
|
2836 | if hasattr(x, 'reposetup'): | |
2837 | x.reposetup(u, repo) |
|
2837 | x.reposetup(u, repo) | |
2838 | d = lambda: func(u, repo, *args, **cmdoptions) |
|
2838 | d = lambda: func(u, repo, *args, **cmdoptions) | |
2839 | else: |
|
2839 | else: | |
2840 | d = lambda: func(u, *args, **cmdoptions) |
|
2840 | d = lambda: func(u, *args, **cmdoptions) | |
2841 |
|
2841 | |||
2842 | if options['profile']: |
|
2842 | if options['profile']: | |
2843 | import hotshot, hotshot.stats |
|
2843 | import hotshot, hotshot.stats | |
2844 | prof = hotshot.Profile("hg.prof") |
|
2844 | prof = hotshot.Profile("hg.prof") | |
2845 | r = prof.runcall(d) |
|
2845 | r = prof.runcall(d) | |
2846 | prof.close() |
|
2846 | prof.close() | |
2847 | stats = hotshot.stats.load("hg.prof") |
|
2847 | stats = hotshot.stats.load("hg.prof") | |
2848 | stats.strip_dirs() |
|
2848 | stats.strip_dirs() | |
2849 | stats.sort_stats('time', 'calls') |
|
2849 | stats.sort_stats('time', 'calls') | |
2850 | stats.print_stats(40) |
|
2850 | stats.print_stats(40) | |
2851 | return r |
|
2851 | return r | |
2852 | else: |
|
2852 | else: | |
2853 | return d() |
|
2853 | return d() | |
2854 | except: |
|
2854 | except: | |
2855 | # enter the debugger when we hit an exception |
|
2855 | # enter the debugger when we hit an exception | |
2856 | if options['debugger']: |
|
2856 | if options['debugger']: | |
2857 | pdb.post_mortem(sys.exc_info()[2]) |
|
2857 | pdb.post_mortem(sys.exc_info()[2]) | |
2858 | if options['traceback']: |
|
2858 | if options['traceback']: | |
2859 | traceback.print_exc() |
|
2859 | traceback.print_exc() | |
2860 | raise |
|
2860 | raise | |
2861 | except hg.RepoError, inst: |
|
2861 | except hg.RepoError, inst: | |
2862 | u.warn(_("abort: "), inst, "!\n") |
|
2862 | u.warn(_("abort: "), inst, "!\n") | |
2863 | except revlog.RevlogError, inst: |
|
2863 | except revlog.RevlogError, inst: | |
2864 | u.warn(_("abort: "), inst, "!\n") |
|
2864 | u.warn(_("abort: "), inst, "!\n") | |
2865 | except SignalInterrupt: |
|
2865 | except SignalInterrupt: | |
2866 | u.warn(_("killed!\n")) |
|
2866 | u.warn(_("killed!\n")) | |
2867 | except KeyboardInterrupt: |
|
2867 | except KeyboardInterrupt: | |
2868 | try: |
|
2868 | try: | |
2869 | u.warn(_("interrupted!\n")) |
|
2869 | u.warn(_("interrupted!\n")) | |
2870 | except IOError, inst: |
|
2870 | except IOError, inst: | |
2871 | if inst.errno == errno.EPIPE: |
|
2871 | if inst.errno == errno.EPIPE: | |
2872 | if u.debugflag: |
|
2872 | if u.debugflag: | |
2873 | u.warn(_("\nbroken pipe\n")) |
|
2873 | u.warn(_("\nbroken pipe\n")) | |
2874 | else: |
|
2874 | else: | |
2875 | raise |
|
2875 | raise | |
2876 | except IOError, inst: |
|
2876 | except IOError, inst: | |
2877 | if hasattr(inst, "code"): |
|
2877 | if hasattr(inst, "code"): | |
2878 | u.warn(_("abort: %s\n") % inst) |
|
2878 | u.warn(_("abort: %s\n") % inst) | |
2879 | elif hasattr(inst, "reason"): |
|
2879 | elif hasattr(inst, "reason"): | |
2880 | u.warn(_("abort: error: %s\n") % inst.reason[1]) |
|
2880 | u.warn(_("abort: error: %s\n") % inst.reason[1]) | |
2881 | elif hasattr(inst, "args") and inst[0] == errno.EPIPE: |
|
2881 | elif hasattr(inst, "args") and inst[0] == errno.EPIPE: | |
2882 | if u.debugflag: |
|
2882 | if u.debugflag: | |
2883 | u.warn(_("broken pipe\n")) |
|
2883 | u.warn(_("broken pipe\n")) | |
2884 | elif getattr(inst, "strerror", None): |
|
2884 | elif getattr(inst, "strerror", None): | |
2885 | if getattr(inst, "filename", None): |
|
2885 | if getattr(inst, "filename", None): | |
2886 | u.warn(_("abort: %s - %s\n") % (inst.strerror, inst.filename)) |
|
2886 | u.warn(_("abort: %s - %s\n") % (inst.strerror, inst.filename)) | |
2887 | else: |
|
2887 | else: | |
2888 | u.warn(_("abort: %s\n") % inst.strerror) |
|
2888 | u.warn(_("abort: %s\n") % inst.strerror) | |
2889 | else: |
|
2889 | else: | |
2890 | raise |
|
2890 | raise | |
2891 | except OSError, inst: |
|
2891 | except OSError, inst: | |
2892 | if hasattr(inst, "filename"): |
|
2892 | if hasattr(inst, "filename"): | |
2893 | u.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename)) |
|
2893 | u.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename)) | |
2894 | else: |
|
2894 | else: | |
2895 | u.warn(_("abort: %s\n") % inst.strerror) |
|
2895 | u.warn(_("abort: %s\n") % inst.strerror) | |
2896 | except util.Abort, inst: |
|
2896 | except util.Abort, inst: | |
2897 | u.warn(_('abort: '), inst.args[0] % inst.args[1:], '\n') |
|
2897 | u.warn(_('abort: '), inst.args[0] % inst.args[1:], '\n') | |
2898 | sys.exit(1) |
|
2898 | sys.exit(1) | |
2899 | except TypeError, inst: |
|
2899 | except TypeError, inst: | |
2900 | # was this an argument error? |
|
2900 | # was this an argument error? | |
2901 | tb = traceback.extract_tb(sys.exc_info()[2]) |
|
2901 | tb = traceback.extract_tb(sys.exc_info()[2]) | |
2902 | if len(tb) > 2: # no |
|
2902 | if len(tb) > 2: # no | |
2903 | raise |
|
2903 | raise | |
2904 | u.debug(inst, "\n") |
|
2904 | u.debug(inst, "\n") | |
2905 | u.warn(_("%s: invalid arguments\n") % cmd) |
|
2905 | u.warn(_("%s: invalid arguments\n") % cmd) | |
2906 | help_(u, cmd) |
|
2906 | help_(u, cmd) | |
2907 | except AmbiguousCommand, inst: |
|
2907 | except AmbiguousCommand, inst: | |
2908 | u.warn(_("hg: command '%s' is ambiguous.\n") % inst.args[0]) |
|
2908 | u.warn(_("hg: command '%s' is ambiguous.\n") % inst.args[0]) | |
2909 | help_(u, 'shortlist') |
|
2909 | help_(u, 'shortlist') | |
2910 | except UnknownCommand, inst: |
|
2910 | except UnknownCommand, inst: | |
2911 | u.warn(_("hg: unknown command '%s'\n") % inst.args[0]) |
|
2911 | u.warn(_("hg: unknown command '%s'\n") % inst.args[0]) | |
2912 | help_(u, 'shortlist') |
|
2912 | help_(u, 'shortlist') | |
2913 | except SystemExit: |
|
2913 | except SystemExit: | |
2914 | # don't catch this in the catch-all below |
|
2914 | # don't catch this in the catch-all below | |
2915 | raise |
|
2915 | raise | |
2916 | except: |
|
2916 | except: | |
2917 | u.warn(_("** unknown exception encountered, details follow\n")) |
|
2917 | u.warn(_("** unknown exception encountered, details follow\n")) | |
2918 | u.warn(_("** report bug details to mercurial@selenic.com\n")) |
|
2918 | u.warn(_("** report bug details to mercurial@selenic.com\n")) | |
2919 | u.warn(_("** Mercurial Distributed SCM (version %s)\n") |
|
2919 | u.warn(_("** Mercurial Distributed SCM (version %s)\n") | |
2920 | % version.get_version()) |
|
2920 | % version.get_version()) | |
2921 | raise |
|
2921 | raise | |
2922 |
|
2922 | |||
2923 | sys.exit(-1) |
|
2923 | sys.exit(-1) |
@@ -1,251 +1,249 | |||||
1 | Mercurial Distributed SCM |
|
1 | Mercurial Distributed SCM | |
2 |
|
2 | |||
3 | basic commands (use "hg help" for the full list or option "-v" for details): |
|
3 | basic commands (use "hg help" for the full list or option "-v" for details): | |
4 |
|
4 | |||
5 | add add the specified files on the next commit |
|
5 | add add the specified files on the next commit | |
6 | annotate show changeset information per file line |
|
6 | annotate show changeset information per file line | |
7 | clone make a copy of an existing repository |
|
7 | clone make a copy of an existing repository | |
8 | commit commit the specified files or all outstanding changes |
|
8 | commit commit the specified files or all outstanding changes | |
9 | diff diff repository (or selected files) |
|
9 | diff diff repository (or selected files) | |
10 | export dump the header and diffs for one or more changesets |
|
10 | export dump the header and diffs for one or more changesets | |
11 | init create a new repository in the given directory |
|
11 | init create a new repository in the given directory | |
12 | log show revision history of entire repository or files |
|
12 | log show revision history of entire repository or files | |
13 | parents show the parents of the working dir or revision |
|
13 | parents show the parents of the working dir or revision | |
14 | pull pull changes from the specified source |
|
14 | pull pull changes from the specified source | |
15 | push push changes to the specified destination |
|
15 | push push changes to the specified destination | |
16 | remove remove the specified files on the next commit |
|
16 | remove remove the specified files on the next commit | |
17 | revert revert modified files or dirs back to their unmodified states |
|
17 | revert revert modified files or dirs back to their unmodified states | |
18 | serve export the repository via HTTP |
|
18 | serve export the repository via HTTP | |
19 | status show changed files in the working directory |
|
19 | status show changed files in the working directory | |
20 | update update or merge working directory |
|
20 | update update or merge working directory | |
21 | add add the specified files on the next commit |
|
21 | add add the specified files on the next commit | |
22 | annotate show changeset information per file line |
|
22 | annotate show changeset information per file line | |
23 | clone make a copy of an existing repository |
|
23 | clone make a copy of an existing repository | |
24 | commit commit the specified files or all outstanding changes |
|
24 | commit commit the specified files or all outstanding changes | |
25 | diff diff repository (or selected files) |
|
25 | diff diff repository (or selected files) | |
26 | export dump the header and diffs for one or more changesets |
|
26 | export dump the header and diffs for one or more changesets | |
27 | init create a new repository in the given directory |
|
27 | init create a new repository in the given directory | |
28 | log show revision history of entire repository or files |
|
28 | log show revision history of entire repository or files | |
29 | parents show the parents of the working dir or revision |
|
29 | parents show the parents of the working dir or revision | |
30 | pull pull changes from the specified source |
|
30 | pull pull changes from the specified source | |
31 | push push changes to the specified destination |
|
31 | push push changes to the specified destination | |
32 | remove remove the specified files on the next commit |
|
32 | remove remove the specified files on the next commit | |
33 | revert revert modified files or dirs back to their unmodified states |
|
33 | revert revert modified files or dirs back to their unmodified states | |
34 | serve export the repository via HTTP |
|
34 | serve export the repository via HTTP | |
35 | status show changed files in the working directory |
|
35 | status show changed files in the working directory | |
36 | update update or merge working directory |
|
36 | update update or merge working directory | |
37 | Mercurial Distributed SCM |
|
37 | Mercurial Distributed SCM | |
38 |
|
38 | |||
39 | list of commands (use "hg help -v" to show aliases and global options): |
|
39 | list of commands (use "hg help -v" to show aliases and global options): | |
40 |
|
40 | |||
41 | add add the specified files on the next commit |
|
41 | add add the specified files on the next commit | |
42 | addremove add all new files, delete all missing files |
|
42 | addremove add all new files, delete all missing files | |
43 | annotate show changeset information per file line |
|
43 | annotate show changeset information per file line | |
44 | bundle create a changegroup file |
|
44 | bundle create a changegroup file | |
45 | cat output the latest or given revisions of files |
|
45 | cat output the latest or given revisions of files | |
46 | clone make a copy of an existing repository |
|
46 | clone make a copy of an existing repository | |
47 | commit commit the specified files or all outstanding changes |
|
47 | commit commit the specified files or all outstanding changes | |
48 | copy mark files as copied for the next commit |
|
48 | copy mark files as copied for the next commit | |
49 | diff diff repository (or selected files) |
|
49 | diff diff repository (or selected files) | |
50 | export dump the header and diffs for one or more changesets |
|
50 | export dump the header and diffs for one or more changesets | |
51 | forget don't add the specified files on the next commit |
|
51 | forget don't add the specified files on the next commit | |
52 | grep search for a pattern in specified files and revisions |
|
52 | grep search for a pattern in specified files and revisions | |
53 | heads show current repository heads |
|
53 | heads show current repository heads | |
54 | help show help for a given command or all commands |
|
54 | help show help for a given command or all commands | |
55 | identify print information about the working copy |
|
55 | identify print information about the working copy | |
56 | import import an ordered set of patches |
|
56 | import import an ordered set of patches | |
57 | incoming show new changesets found in source |
|
57 | incoming show new changesets found in source | |
58 | init create a new repository in the given directory |
|
58 | init create a new repository in the given directory | |
59 | locate locate files matching specific patterns |
|
59 | locate locate files matching specific patterns | |
60 | log show revision history of entire repository or files |
|
60 | log show revision history of entire repository or files | |
61 | manifest output the latest or given revision of the project manifest |
|
61 | manifest output the latest or given revision of the project manifest | |
62 | outgoing show changesets not found in destination |
|
62 | outgoing show changesets not found in destination | |
63 | parents show the parents of the working dir or revision |
|
63 | parents show the parents of the working dir or revision | |
64 | paths show definition of symbolic path names |
|
64 | paths show definition of symbolic path names | |
65 | pull pull changes from the specified source |
|
65 | pull pull changes from the specified source | |
66 | push push changes to the specified destination |
|
66 | push push changes to the specified destination | |
67 | rawcommit raw commit interface (DEPRECATED) |
|
|||
68 | recover roll back an interrupted transaction |
|
67 | recover roll back an interrupted transaction | |
69 | remove remove the specified files on the next commit |
|
68 | remove remove the specified files on the next commit | |
70 | rename rename files; equivalent of copy + remove |
|
69 | rename rename files; equivalent of copy + remove | |
71 | revert revert modified files or dirs back to their unmodified states |
|
70 | revert revert modified files or dirs back to their unmodified states | |
72 | root print the root (top) of the current working dir |
|
71 | root print the root (top) of the current working dir | |
73 | serve export the repository via HTTP |
|
72 | serve export the repository via HTTP | |
74 | status show changed files in the working directory |
|
73 | status show changed files in the working directory | |
75 | tag add a tag for the current tip or a given revision |
|
74 | tag add a tag for the current tip or a given revision | |
76 | tags list repository tags |
|
75 | tags list repository tags | |
77 | tip show the tip revision |
|
76 | tip show the tip revision | |
78 | unbundle apply a changegroup file |
|
77 | unbundle apply a changegroup file | |
79 | undo undo the last commit or pull |
|
78 | undo undo the last commit or pull | |
80 | update update or merge working directory |
|
79 | update update or merge working directory | |
81 | verify verify the integrity of the repository |
|
80 | verify verify the integrity of the repository | |
82 | version output version and copyright information |
|
81 | version output version and copyright information | |
83 | add add the specified files on the next commit |
|
82 | add add the specified files on the next commit | |
84 | addremove add all new files, delete all missing files |
|
83 | addremove add all new files, delete all missing files | |
85 | annotate show changeset information per file line |
|
84 | annotate show changeset information per file line | |
86 | bundle create a changegroup file |
|
85 | bundle create a changegroup file | |
87 | cat output the latest or given revisions of files |
|
86 | cat output the latest or given revisions of files | |
88 | clone make a copy of an existing repository |
|
87 | clone make a copy of an existing repository | |
89 | commit commit the specified files or all outstanding changes |
|
88 | commit commit the specified files or all outstanding changes | |
90 | copy mark files as copied for the next commit |
|
89 | copy mark files as copied for the next commit | |
91 | diff diff repository (or selected files) |
|
90 | diff diff repository (or selected files) | |
92 | export dump the header and diffs for one or more changesets |
|
91 | export dump the header and diffs for one or more changesets | |
93 | forget don't add the specified files on the next commit |
|
92 | forget don't add the specified files on the next commit | |
94 | grep search for a pattern in specified files and revisions |
|
93 | grep search for a pattern in specified files and revisions | |
95 | heads show current repository heads |
|
94 | heads show current repository heads | |
96 | help show help for a given command or all commands |
|
95 | help show help for a given command or all commands | |
97 | identify print information about the working copy |
|
96 | identify print information about the working copy | |
98 | import import an ordered set of patches |
|
97 | import import an ordered set of patches | |
99 | incoming show new changesets found in source |
|
98 | incoming show new changesets found in source | |
100 | init create a new repository in the given directory |
|
99 | init create a new repository in the given directory | |
101 | locate locate files matching specific patterns |
|
100 | locate locate files matching specific patterns | |
102 | log show revision history of entire repository or files |
|
101 | log show revision history of entire repository or files | |
103 | manifest output the latest or given revision of the project manifest |
|
102 | manifest output the latest or given revision of the project manifest | |
104 | outgoing show changesets not found in destination |
|
103 | outgoing show changesets not found in destination | |
105 | parents show the parents of the working dir or revision |
|
104 | parents show the parents of the working dir or revision | |
106 | paths show definition of symbolic path names |
|
105 | paths show definition of symbolic path names | |
107 | pull pull changes from the specified source |
|
106 | pull pull changes from the specified source | |
108 | push push changes to the specified destination |
|
107 | push push changes to the specified destination | |
109 | rawcommit raw commit interface (DEPRECATED) |
|
|||
110 | recover roll back an interrupted transaction |
|
108 | recover roll back an interrupted transaction | |
111 | remove remove the specified files on the next commit |
|
109 | remove remove the specified files on the next commit | |
112 | rename rename files; equivalent of copy + remove |
|
110 | rename rename files; equivalent of copy + remove | |
113 | revert revert modified files or dirs back to their unmodified states |
|
111 | revert revert modified files or dirs back to their unmodified states | |
114 | root print the root (top) of the current working dir |
|
112 | root print the root (top) of the current working dir | |
115 | serve export the repository via HTTP |
|
113 | serve export the repository via HTTP | |
116 | status show changed files in the working directory |
|
114 | status show changed files in the working directory | |
117 | tag add a tag for the current tip or a given revision |
|
115 | tag add a tag for the current tip or a given revision | |
118 | tags list repository tags |
|
116 | tags list repository tags | |
119 | tip show the tip revision |
|
117 | tip show the tip revision | |
120 | unbundle apply a changegroup file |
|
118 | unbundle apply a changegroup file | |
121 | undo undo the last commit or pull |
|
119 | undo undo the last commit or pull | |
122 | update update or merge working directory |
|
120 | update update or merge working directory | |
123 | verify verify the integrity of the repository |
|
121 | verify verify the integrity of the repository | |
124 | version output version and copyright information |
|
122 | version output version and copyright information | |
125 | hg add [OPTION]... [FILE]... |
|
123 | hg add [OPTION]... [FILE]... | |
126 |
|
124 | |||
127 | add the specified files on the next commit |
|
125 | add the specified files on the next commit | |
128 |
|
126 | |||
129 | Schedule files to be version controlled and added to the repository. |
|
127 | Schedule files to be version controlled and added to the repository. | |
130 |
|
128 | |||
131 | The files will be added to the repository at the next commit. |
|
129 | The files will be added to the repository at the next commit. | |
132 |
|
130 | |||
133 | If no names are given, add all files in the repository. |
|
131 | If no names are given, add all files in the repository. | |
134 |
|
132 | |||
135 | options: |
|
133 | options: | |
136 |
|
134 | |||
137 | -I --include include names matching the given patterns |
|
135 | -I --include include names matching the given patterns | |
138 | -X --exclude exclude names matching the given patterns |
|
136 | -X --exclude exclude names matching the given patterns | |
139 | hg add: option --skjdfks not recognized |
|
137 | hg add: option --skjdfks not recognized | |
140 | hg add [OPTION]... [FILE]... |
|
138 | hg add [OPTION]... [FILE]... | |
141 |
|
139 | |||
142 | add the specified files on the next commit |
|
140 | add the specified files on the next commit | |
143 |
|
141 | |||
144 | Schedule files to be version controlled and added to the repository. |
|
142 | Schedule files to be version controlled and added to the repository. | |
145 |
|
143 | |||
146 | The files will be added to the repository at the next commit. |
|
144 | The files will be added to the repository at the next commit. | |
147 |
|
145 | |||
148 | If no names are given, add all files in the repository. |
|
146 | If no names are given, add all files in the repository. | |
149 |
|
147 | |||
150 | options: |
|
148 | options: | |
151 |
|
149 | |||
152 | -I --include include names matching the given patterns |
|
150 | -I --include include names matching the given patterns | |
153 | -X --exclude exclude names matching the given patterns |
|
151 | -X --exclude exclude names matching the given patterns | |
154 | hg diff [-a] [-I] [-X] [-r REV1 [-r REV2]] [FILE]... |
|
152 | hg diff [-a] [-I] [-X] [-r REV1 [-r REV2]] [FILE]... | |
155 |
|
153 | |||
156 | diff repository (or selected files) |
|
154 | diff repository (or selected files) | |
157 |
|
155 | |||
158 | Show differences between revisions for the specified files. |
|
156 | Show differences between revisions for the specified files. | |
159 |
|
157 | |||
160 | Differences between files are shown using the unified diff format. |
|
158 | Differences between files are shown using the unified diff format. | |
161 |
|
159 | |||
162 | When two revision arguments are given, then changes are shown |
|
160 | When two revision arguments are given, then changes are shown | |
163 | between those revisions. If only one revision is specified then |
|
161 | between those revisions. If only one revision is specified then | |
164 | that revision is compared to the working directory, and, when no |
|
162 | that revision is compared to the working directory, and, when no | |
165 | revisions are specified, the working directory files are compared |
|
163 | revisions are specified, the working directory files are compared | |
166 | to its parent. |
|
164 | to its parent. | |
167 |
|
165 | |||
168 | Without the -a option, diff will avoid generating diffs of files |
|
166 | Without the -a option, diff will avoid generating diffs of files | |
169 | it detects as binary. With -a, diff will generate a diff anyway, |
|
167 | it detects as binary. With -a, diff will generate a diff anyway, | |
170 | probably with undesirable results. |
|
168 | probably with undesirable results. | |
171 |
|
169 | |||
172 | options: |
|
170 | options: | |
173 |
|
171 | |||
174 | -r --rev revision |
|
172 | -r --rev revision | |
175 | -a --text treat all files as text |
|
173 | -a --text treat all files as text | |
176 | -p --show-function show which function each change is in |
|
174 | -p --show-function show which function each change is in | |
177 | -w --ignore-all-space ignore white space when comparing lines |
|
175 | -w --ignore-all-space ignore white space when comparing lines | |
178 | -I --include include names matching the given patterns |
|
176 | -I --include include names matching the given patterns | |
179 | -X --exclude exclude names matching the given patterns |
|
177 | -X --exclude exclude names matching the given patterns | |
180 | hg status [OPTION]... [FILE]... |
|
178 | hg status [OPTION]... [FILE]... | |
181 |
|
179 | |||
182 | show changed files in the working directory |
|
180 | show changed files in the working directory | |
183 |
|
181 | |||
184 | Show changed files in the repository. If names are |
|
182 | Show changed files in the repository. If names are | |
185 | given, only files that match are shown. |
|
183 | given, only files that match are shown. | |
186 |
|
184 | |||
187 | The codes used to show the status of files are: |
|
185 | The codes used to show the status of files are: | |
188 | M = modified |
|
186 | M = modified | |
189 | A = added |
|
187 | A = added | |
190 | R = removed |
|
188 | R = removed | |
191 | ! = deleted, but still tracked |
|
189 | ! = deleted, but still tracked | |
192 | ? = not tracked |
|
190 | ? = not tracked | |
193 |
|
191 | |||
194 | aliases: st |
|
192 | aliases: st | |
195 |
|
193 | |||
196 | options: |
|
194 | options: | |
197 |
|
195 | |||
198 | -m --modified show only modified files |
|
196 | -m --modified show only modified files | |
199 | -a --added show only added files |
|
197 | -a --added show only added files | |
200 | -r --removed show only removed files |
|
198 | -r --removed show only removed files | |
201 | -d --deleted show only deleted (but tracked) files |
|
199 | -d --deleted show only deleted (but tracked) files | |
202 | -u --unknown show only unknown (not tracked) files |
|
200 | -u --unknown show only unknown (not tracked) files | |
203 | -n --no-status hide status prefix |
|
201 | -n --no-status hide status prefix | |
204 | -0 --print0 end filenames with NUL, for use with xargs |
|
202 | -0 --print0 end filenames with NUL, for use with xargs | |
205 | -I --include include names matching the given patterns |
|
203 | -I --include include names matching the given patterns | |
206 | -X --exclude exclude names matching the given patterns |
|
204 | -X --exclude exclude names matching the given patterns | |
207 | hg status [OPTION]... [FILE]... |
|
205 | hg status [OPTION]... [FILE]... | |
208 |
|
206 | |||
209 | show changed files in the working directory |
|
207 | show changed files in the working directory | |
210 | hg: unknown command 'foo' |
|
208 | hg: unknown command 'foo' | |
211 | Mercurial Distributed SCM |
|
209 | Mercurial Distributed SCM | |
212 |
|
210 | |||
213 | basic commands (use "hg help" for the full list or option "-v" for details): |
|
211 | basic commands (use "hg help" for the full list or option "-v" for details): | |
214 |
|
212 | |||
215 | add add the specified files on the next commit |
|
213 | add add the specified files on the next commit | |
216 | annotate show changeset information per file line |
|
214 | annotate show changeset information per file line | |
217 | clone make a copy of an existing repository |
|
215 | clone make a copy of an existing repository | |
218 | commit commit the specified files or all outstanding changes |
|
216 | commit commit the specified files or all outstanding changes | |
219 | diff diff repository (or selected files) |
|
217 | diff diff repository (or selected files) | |
220 | export dump the header and diffs for one or more changesets |
|
218 | export dump the header and diffs for one or more changesets | |
221 | init create a new repository in the given directory |
|
219 | init create a new repository in the given directory | |
222 | log show revision history of entire repository or files |
|
220 | log show revision history of entire repository or files | |
223 | parents show the parents of the working dir or revision |
|
221 | parents show the parents of the working dir or revision | |
224 | pull pull changes from the specified source |
|
222 | pull pull changes from the specified source | |
225 | push push changes to the specified destination |
|
223 | push push changes to the specified destination | |
226 | remove remove the specified files on the next commit |
|
224 | remove remove the specified files on the next commit | |
227 | revert revert modified files or dirs back to their unmodified states |
|
225 | revert revert modified files or dirs back to their unmodified states | |
228 | serve export the repository via HTTP |
|
226 | serve export the repository via HTTP | |
229 | status show changed files in the working directory |
|
227 | status show changed files in the working directory | |
230 | update update or merge working directory |
|
228 | update update or merge working directory | |
231 | hg: unknown command 'skjdfks' |
|
229 | hg: unknown command 'skjdfks' | |
232 | Mercurial Distributed SCM |
|
230 | Mercurial Distributed SCM | |
233 |
|
231 | |||
234 | basic commands (use "hg help" for the full list or option "-v" for details): |
|
232 | basic commands (use "hg help" for the full list or option "-v" for details): | |
235 |
|
233 | |||
236 | add add the specified files on the next commit |
|
234 | add add the specified files on the next commit | |
237 | annotate show changeset information per file line |
|
235 | annotate show changeset information per file line | |
238 | clone make a copy of an existing repository |
|
236 | clone make a copy of an existing repository | |
239 | commit commit the specified files or all outstanding changes |
|
237 | commit commit the specified files or all outstanding changes | |
240 | diff diff repository (or selected files) |
|
238 | diff diff repository (or selected files) | |
241 | export dump the header and diffs for one or more changesets |
|
239 | export dump the header and diffs for one or more changesets | |
242 | init create a new repository in the given directory |
|
240 | init create a new repository in the given directory | |
243 | log show revision history of entire repository or files |
|
241 | log show revision history of entire repository or files | |
244 | parents show the parents of the working dir or revision |
|
242 | parents show the parents of the working dir or revision | |
245 | pull pull changes from the specified source |
|
243 | pull pull changes from the specified source | |
246 | push push changes to the specified destination |
|
244 | push push changes to the specified destination | |
247 | remove remove the specified files on the next commit |
|
245 | remove remove the specified files on the next commit | |
248 | revert revert modified files or dirs back to their unmodified states |
|
246 | revert revert modified files or dirs back to their unmodified states | |
249 | serve export the repository via HTTP |
|
247 | serve export the repository via HTTP | |
250 | status show changed files in the working directory |
|
248 | status show changed files in the working directory | |
251 | update update or merge working directory |
|
249 | update update or merge working directory |
General Comments 0
You need to be logged in to leave comments.
Login now