Show More
@@ -68,7 +68,7 b' def dodiff(repo, files = None, node1 = N' | |||||
68 | sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f)) |
|
68 | sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f)) | |
69 |
|
69 | |||
70 | def help(ui, cmd=None): |
|
70 | def help(ui, cmd=None): | |
71 | '''show help''' |
|
71 | '''show help for a given command or all commands''' | |
72 | if cmd: |
|
72 | if cmd: | |
73 | try: |
|
73 | try: | |
74 | i = find(cmd) |
|
74 | i = find(cmd) | |
@@ -77,42 +77,38 b' def help(ui, cmd=None):' | |||||
77 | except UnknownCommand: |
|
77 | except UnknownCommand: | |
78 | ui.warn("unknown command %s" % cmd) |
|
78 | ui.warn("unknown command %s" % cmd) | |
79 | sys.exit(0) |
|
79 | sys.exit(0) | |
80 |
|
80 | else: | ||
81 | ui.status("""\ |
|
81 | ui.status('hg commands:\n\n') | |
82 | hg commands: |
|
|||
83 |
|
82 | |||
84 | add [files...] add the given files in the next commit |
|
83 | h = {} | |
85 | addremove add all new files, delete all missing files |
|
84 | for e in table.values(): | |
86 | annotate [files...] show changeset number per file line |
|
85 | f = e[0] | |
87 | branch <path> create a branch of <path> in this directory |
|
86 | if f.__name__.startswith("debug"): continue | |
88 | checkout [changeset] checkout the latest or given changeset |
|
87 | d = "" | |
89 | commit commit all changes to the repository |
|
88 | if f.__doc__: | |
90 | diff [files...] diff working directory (or selected files) |
|
89 | d = f.__doc__.splitlines(0)[0].rstrip() | |
91 | dump <file> [rev] dump the latest or given revision of a file |
|
90 | h[f.__name__] = d | |
92 | dumpmanifest [rev] dump the latest or given revision of the manifest |
|
91 | ||
93 | export <rev> dump the changeset header and diffs for a revision |
|
92 | fns = h.keys() | |
94 | history show changeset history |
|
93 | fns.sort() | |
95 | init create a new repository in this directory |
|
94 | m = max(map(len, fns)) | |
96 | log <file> show revision history of a single file |
|
95 | for f in fns: | |
97 | merge <path> merge changes from <path> into local repository |
|
96 | ui.status(' %-*s %s\n' % (m, f, h[f])) | |
98 | recover rollback an interrupted transaction |
|
97 | ||
99 | remove [files...] remove the given files in the next commit |
|
98 | # Commands start here, listed alphabetically | |
100 | serve export the repository via HTTP |
|
|||
101 | status show new, missing, and changed files in working dir |
|
|||
102 | tags show current changeset tags |
|
|||
103 | undo undo the last transaction |
|
|||
104 | """) |
|
|||
105 |
|
99 | |||
106 | def add(ui, repo, file, *files): |
|
100 | def add(ui, repo, file, *files): | |
107 | '''add the specified files on the next commit''' |
|
101 | '''add the specified files on the next commit''' | |
108 | repo.add(relpath(repo, (file,) + files)) |
|
102 | repo.add(relpath(repo, (file,) + files)) | |
109 |
|
103 | |||
110 | def addremove(ui, repo): |
|
104 | def addremove(ui, repo): | |
|
105 | """add all new files, delete all missing files""" | |||
111 | (c, a, d, u) = repo.diffdir(repo.root) |
|
106 | (c, a, d, u) = repo.diffdir(repo.root) | |
112 | repo.add(a) |
|
107 | repo.add(a) | |
113 | repo.remove(d) |
|
108 | repo.remove(d) | |
114 |
|
109 | |||
115 | def annotate(u, repo, file, *files, **ops): |
|
110 | def annotate(u, repo, file, *files, **ops): | |
|
111 | """show changeset information per file line""" | |||
116 | def getnode(rev): |
|
112 | def getnode(rev): | |
117 | return hg.short(repo.changelog.node(rev)) |
|
113 | return hg.short(repo.changelog.node(rev)) | |
118 |
|
114 | |||
@@ -159,6 +155,7 b' def branch(ui, path):' | |||||
159 | os.system("cp -al %s/.hg .hg" % path) |
|
155 | os.system("cp -al %s/.hg .hg" % path) | |
160 |
|
156 | |||
161 | def cat(ui, repo, file, rev = []): |
|
157 | def cat(ui, repo, file, rev = []): | |
|
158 | """output the latest or given revision of a file""" | |||
162 | r = repo.file(file) |
|
159 | r = repo.file(file) | |
163 | n = r.tip() |
|
160 | n = r.tip() | |
164 | if rev: n = r.lookup(rev) |
|
161 | if rev: n = r.lookup(rev) | |
@@ -198,6 +195,7 b' def debugindexdot(ui, file):' | |||||
198 | print "}" |
|
195 | print "}" | |
199 |
|
196 | |||
200 | def diff(ui, repo, *files, **opts): |
|
197 | def diff(ui, repo, *files, **opts): | |
|
198 | """diff working directory (or selected files)""" | |||
201 | revs = [] |
|
199 | revs = [] | |
202 | if opts['rev']: |
|
200 | if opts['rev']: | |
203 | revs = map(lambda x: repo.lookup(x), opts['rev']) |
|
201 | revs = map(lambda x: repo.lookup(x), opts['rev']) | |
@@ -214,6 +212,7 b' def diff(ui, repo, *files, **opts):' | |||||
214 | dodiff(repo, files, *revs) |
|
212 | dodiff(repo, files, *revs) | |
215 |
|
213 | |||
216 | def export(ui, repo, changeset): |
|
214 | def export(ui, repo, changeset): | |
|
215 | """dump the changeset header and diffs for a revision""" | |||
217 | node = repo.lookup(changeset) |
|
216 | node = repo.lookup(changeset) | |
218 | prev, other = repo.changelog.parents(node) |
|
217 | prev, other = repo.changelog.parents(node) | |
219 | change = repo.changelog.read(node) |
|
218 | change = repo.changelog.read(node) | |
@@ -273,6 +272,57 b' def history(ui, repo):' | |||||
273 | print "description:" |
|
272 | print "description:" | |
274 | print changes[4] |
|
273 | print changes[4] | |
275 |
|
274 | |||
|
275 | def init(ui): | |||
|
276 | """create a repository""" | |||
|
277 | hg.repository(ui, ".", create=1) | |||
|
278 | ||||
|
279 | def log(ui, repo, f): | |||
|
280 | """show the revision history of a single file""" | |||
|
281 | f = relpath(repo, [f])[0] | |||
|
282 | ||||
|
283 | r = repo.file(f) | |||
|
284 | for i in range(r.count()): | |||
|
285 | n = r.node(i) | |||
|
286 | (p1, p2) = r.parents(n) | |||
|
287 | (h, h1, h2) = map(hg.hex, (n, p1, p2)) | |||
|
288 | (i1, i2) = map(r.rev, (p1, p2)) | |||
|
289 | cr = r.linkrev(n) | |||
|
290 | cn = hg.hex(repo.changelog.node(cr)) | |||
|
291 | print "rev: %4d:%s" % (i, h) | |||
|
292 | print "changeset: %4d:%s" % (cr, cn) | |||
|
293 | print "parents: %4d:%s" % (i1, h1) | |||
|
294 | if i2: print " %4d:%s" % (i2, h2) | |||
|
295 | changes = repo.changelog.read(repo.changelog.node(cr)) | |||
|
296 | print "user: %s" % changes[1] | |||
|
297 | print "date: %s" % time.asctime( | |||
|
298 | time.localtime(float(changes[2].split(' ')[0]))) | |||
|
299 | print "description:" | |||
|
300 | print changes[4].rstrip() | |||
|
301 | ||||
|
302 | ||||
|
303 | def manifest(ui, repo, rev = []): | |||
|
304 | """output the latest or given revision of the project manifest""" | |||
|
305 | n = repo.manifest.tip() | |||
|
306 | if rev: | |||
|
307 | n = repo.manifest.lookup(rev) | |||
|
308 | m = repo.manifest.read(n) | |||
|
309 | files = m.keys() | |||
|
310 | files.sort() | |||
|
311 | ||||
|
312 | for f in files: | |||
|
313 | print hg.hex(m[f]), f | |||
|
314 | ||||
|
315 | def parents(ui, repo, node = None): | |||
|
316 | '''show the parents of the current working dir''' | |||
|
317 | if node: | |||
|
318 | p = repo.changelog.parents(repo.lookup(hg.bin(node))) | |||
|
319 | else: | |||
|
320 | p = repo.dirstate.parents() | |||
|
321 | ||||
|
322 | for n in p: | |||
|
323 | if n != hg.nullid: | |||
|
324 | ui.write("%d:%s\n" % (repo.changelog.rev(n), hg.hex(n))) | |||
|
325 | ||||
276 | def patch(ui, repo, patches, opts): |
|
326 | def patch(ui, repo, patches, opts): | |
277 | """import an ordered set of patches""" |
|
327 | """import an ordered set of patches""" | |
278 | try: |
|
328 | try: | |
@@ -303,55 +353,6 b' def patch(ui, repo, patches, opts):' | |||||
303 | raise "patch failed!" |
|
353 | raise "patch failed!" | |
304 | repo.commit(files, text) |
|
354 | repo.commit(files, text) | |
305 |
|
355 | |||
306 | def init(ui): |
|
|||
307 | """create a repository""" |
|
|||
308 | hg.repository(ui, ".", create=1) |
|
|||
309 |
|
||||
310 | def log(ui, repo, f): |
|
|||
311 | f = relpath(repo, [f])[0] |
|
|||
312 |
|
||||
313 | r = repo.file(f) |
|
|||
314 | for i in range(r.count()): |
|
|||
315 | n = r.node(i) |
|
|||
316 | (p1, p2) = r.parents(n) |
|
|||
317 | (h, h1, h2) = map(hg.hex, (n, p1, p2)) |
|
|||
318 | (i1, i2) = map(r.rev, (p1, p2)) |
|
|||
319 | cr = r.linkrev(n) |
|
|||
320 | cn = hg.hex(repo.changelog.node(cr)) |
|
|||
321 | print "rev: %4d:%s" % (i, h) |
|
|||
322 | print "changeset: %4d:%s" % (cr, cn) |
|
|||
323 | print "parents: %4d:%s" % (i1, h1) |
|
|||
324 | if i2: print " %4d:%s" % (i2, h2) |
|
|||
325 | changes = repo.changelog.read(repo.changelog.node(cr)) |
|
|||
326 | print "user: %s" % changes[1] |
|
|||
327 | print "date: %s" % time.asctime( |
|
|||
328 | time.localtime(float(changes[2].split(' ')[0]))) |
|
|||
329 | print "description:" |
|
|||
330 | print changes[4].rstrip() |
|
|||
331 |
|
||||
332 |
|
||||
333 | def manifest(ui, repo, rev = []): |
|
|||
334 | n = repo.manifest.tip() |
|
|||
335 | if rev: |
|
|||
336 | n = repo.manifest.lookup(rev) |
|
|||
337 | m = repo.manifest.read(n) |
|
|||
338 | files = m.keys() |
|
|||
339 | files.sort() |
|
|||
340 |
|
||||
341 | for f in files: |
|
|||
342 | print hg.hex(m[f]), f |
|
|||
343 |
|
||||
344 | def parents(ui, repo, node = None): |
|
|||
345 | '''show the parents of the current working dir''' |
|
|||
346 | if node: |
|
|||
347 | p = repo.changelog.parents(repo.lookup(hg.bin(node))) |
|
|||
348 | else: |
|
|||
349 | p = repo.dirstate.parents() |
|
|||
350 |
|
||||
351 | for n in p: |
|
|||
352 | if n != hg.nullid: |
|
|||
353 | ui.write("%d:%s\n" % (repo.changelog.rev(n), hg.hex(n))) |
|
|||
354 |
|
||||
355 | def pull(ui, repo, source): |
|
356 | def pull(ui, repo, source): | |
356 | """pull changes from the specified source""" |
|
357 | """pull changes from the specified source""" | |
357 | paths = {} |
|
358 | paths = {} | |
@@ -387,6 +388,7 b' def rawcommit(ui, repo, files, rc):' | |||||
387 | repo.rawcommit(files, text, rc['user'], rc['date'], *rc['parent']) |
|
388 | repo.rawcommit(files, text, rc['user'], rc['date'], *rc['parent']) | |
388 |
|
389 | |||
389 | def recover(ui, repo): |
|
390 | def recover(ui, repo): | |
|
391 | """roll back an interrupted transaction""" | |||
390 | repo.recover() |
|
392 | repo.recover() | |
391 |
|
393 | |||
392 | def remove(ui, repo, file, *files): |
|
394 | def remove(ui, repo, file, *files): | |
@@ -394,6 +396,7 b' def remove(ui, repo, file, *files):' | |||||
394 | repo.remove(relpath(repo, (file,) + files)) |
|
396 | repo.remove(relpath(repo, (file,) + files)) | |
395 |
|
397 | |||
396 | def serve(ui, repo, **opts): |
|
398 | def serve(ui, repo, **opts): | |
|
399 | """export the repository via HTTP""" | |||
397 | from mercurial import hgweb |
|
400 | from mercurial import hgweb | |
398 | hgweb.server(repo.root, opts["name"], opts["templates"], |
|
401 | hgweb.server(repo.root, opts["name"], opts["templates"], | |
399 | opts["address"], opts["port"]) |
|
402 | opts["address"], opts["port"]) | |
@@ -415,6 +418,7 b' def status(ui, repo):' | |||||
415 | for f in u: print "?", f |
|
418 | for f in u: print "?", f | |
416 |
|
419 | |||
417 | def tags(ui, repo): |
|
420 | def tags(ui, repo): | |
|
421 | """list repository tags""" | |||
418 | repo.lookup(0) # prime the cache |
|
422 | repo.lookup(0) # prime the cache | |
419 | i = repo.tags.items() |
|
423 | i = repo.tags.items() | |
420 | i.sort() |
|
424 | i.sort() | |
@@ -426,11 +430,13 b' def tags(ui, repo):' | |||||
426 | print "%-30s %5d:%s" % (k, repo.changelog.rev(n), hg.hex(n)) |
|
430 | print "%-30s %5d:%s" % (k, repo.changelog.rev(n), hg.hex(n)) | |
427 |
|
431 | |||
428 | def tip(ui, repo): |
|
432 | def tip(ui, repo): | |
|
433 | """show the tip revision""" | |||
429 | n = repo.changelog.tip() |
|
434 | n = repo.changelog.tip() | |
430 | t = repo.changelog.rev(n) |
|
435 | t = repo.changelog.rev(n) | |
431 | ui.status("%d:%s\n" % (t, hg.hex(n))) |
|
436 | ui.status("%d:%s\n" % (t, hg.hex(n))) | |
432 |
|
437 | |||
433 | def undo(ui, repo): |
|
438 | def undo(ui, repo): | |
|
439 | """undo the last transaction""" | |||
434 | repo.undo() |
|
440 | repo.undo() | |
435 |
|
441 | |||
436 | def update(ui, repo, node=None): |
|
442 | def update(ui, repo, node=None): | |
@@ -453,6 +459,8 b' def verify(ui, repo):' | |||||
453 | """verify the integrity of the repository""" |
|
459 | """verify the integrity of the repository""" | |
454 | return repo.verify() |
|
460 | return repo.verify() | |
455 |
|
461 | |||
|
462 | # Command options and aliases are listed here, alphabetically | |||
|
463 | ||||
456 | table = { |
|
464 | table = { | |
457 | "add": (add, [], "hg add [files]"), |
|
465 | "add": (add, [], "hg add [files]"), | |
458 | "addremove": (addremove, [], "hg addremove"), |
|
466 | "addremove": (addremove, [], "hg addremove"), |
General Comments 0
You need to be logged in to leave comments.
Login now