Show More
@@ -68,7 +68,7 b' def dodiff(repo, files = None, node1 = N' | |||
|
68 | 68 | sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f)) |
|
69 | 69 | |
|
70 | 70 | def help(ui, cmd=None): |
|
71 | '''show help''' | |
|
71 | '''show help for a given command or all commands''' | |
|
72 | 72 | if cmd: |
|
73 | 73 | try: |
|
74 | 74 | i = find(cmd) |
@@ -77,42 +77,38 b' def help(ui, cmd=None):' | |||
|
77 | 77 | except UnknownCommand: |
|
78 | 78 | ui.warn("unknown command %s" % cmd) |
|
79 | 79 | sys.exit(0) |
|
80 | ||
|
81 | ui.status("""\ | |
|
82 | hg commands: | |
|
80 | else: | |
|
81 | ui.status('hg commands:\n\n') | |
|
83 | 82 | |
|
84 | add [files...] add the given files in the next commit | |
|
85 | addremove add all new files, delete all missing files | |
|
86 | annotate [files...] show changeset number per file line | |
|
87 | branch <path> create a branch of <path> in this directory | |
|
88 | checkout [changeset] checkout the latest or given changeset | |
|
89 | commit commit all changes to the repository | |
|
90 | diff [files...] diff working directory (or selected files) | |
|
91 | dump <file> [rev] dump the latest or given revision of a file | |
|
92 | dumpmanifest [rev] dump the latest or given revision of the manifest | |
|
93 | export <rev> dump the changeset header and diffs for a revision | |
|
94 | history show changeset history | |
|
95 | init create a new repository in this directory | |
|
96 | log <file> show revision history of a single file | |
|
97 | merge <path> merge changes from <path> into local repository | |
|
98 | recover rollback an interrupted transaction | |
|
99 | remove [files...] remove the given files in the next commit | |
|
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 | """) | |
|
83 | h = {} | |
|
84 | for e in table.values(): | |
|
85 | f = e[0] | |
|
86 | if f.__name__.startswith("debug"): continue | |
|
87 | d = "" | |
|
88 | if f.__doc__: | |
|
89 | d = f.__doc__.splitlines(0)[0].rstrip() | |
|
90 | h[f.__name__] = d | |
|
91 | ||
|
92 | fns = h.keys() | |
|
93 | fns.sort() | |
|
94 | m = max(map(len, fns)) | |
|
95 | for f in fns: | |
|
96 | ui.status(' %-*s %s\n' % (m, f, h[f])) | |
|
97 | ||
|
98 | # Commands start here, listed alphabetically | |
|
105 | 99 | |
|
106 | 100 | def add(ui, repo, file, *files): |
|
107 | 101 | '''add the specified files on the next commit''' |
|
108 | 102 | repo.add(relpath(repo, (file,) + files)) |
|
109 | 103 | |
|
110 | 104 | def addremove(ui, repo): |
|
105 | """add all new files, delete all missing files""" | |
|
111 | 106 | (c, a, d, u) = repo.diffdir(repo.root) |
|
112 | 107 | repo.add(a) |
|
113 | 108 | repo.remove(d) |
|
114 | 109 | |
|
115 | 110 | def annotate(u, repo, file, *files, **ops): |
|
111 | """show changeset information per file line""" | |
|
116 | 112 | def getnode(rev): |
|
117 | 113 | return hg.short(repo.changelog.node(rev)) |
|
118 | 114 | |
@@ -159,6 +155,7 b' def branch(ui, path):' | |||
|
159 | 155 | os.system("cp -al %s/.hg .hg" % path) |
|
160 | 156 | |
|
161 | 157 | def cat(ui, repo, file, rev = []): |
|
158 | """output the latest or given revision of a file""" | |
|
162 | 159 | r = repo.file(file) |
|
163 | 160 | n = r.tip() |
|
164 | 161 | if rev: n = r.lookup(rev) |
@@ -198,6 +195,7 b' def debugindexdot(ui, file):' | |||
|
198 | 195 | print "}" |
|
199 | 196 | |
|
200 | 197 | def diff(ui, repo, *files, **opts): |
|
198 | """diff working directory (or selected files)""" | |
|
201 | 199 | revs = [] |
|
202 | 200 | if opts['rev']: |
|
203 | 201 | revs = map(lambda x: repo.lookup(x), opts['rev']) |
@@ -214,6 +212,7 b' def diff(ui, repo, *files, **opts):' | |||
|
214 | 212 | dodiff(repo, files, *revs) |
|
215 | 213 | |
|
216 | 214 | def export(ui, repo, changeset): |
|
215 | """dump the changeset header and diffs for a revision""" | |
|
217 | 216 | node = repo.lookup(changeset) |
|
218 | 217 | prev, other = repo.changelog.parents(node) |
|
219 | 218 | change = repo.changelog.read(node) |
@@ -273,6 +272,57 b' def history(ui, repo):' | |||
|
273 | 272 | print "description:" |
|
274 | 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 | 326 | def patch(ui, repo, patches, opts): |
|
277 | 327 | """import an ordered set of patches""" |
|
278 | 328 | try: |
@@ -303,55 +353,6 b' def patch(ui, repo, patches, opts):' | |||
|
303 | 353 | raise "patch failed!" |
|
304 | 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 | 356 | def pull(ui, repo, source): |
|
356 | 357 | """pull changes from the specified source""" |
|
357 | 358 | paths = {} |
@@ -387,6 +388,7 b' def rawcommit(ui, repo, files, rc):' | |||
|
387 | 388 | repo.rawcommit(files, text, rc['user'], rc['date'], *rc['parent']) |
|
388 | 389 | |
|
389 | 390 | def recover(ui, repo): |
|
391 | """roll back an interrupted transaction""" | |
|
390 | 392 | repo.recover() |
|
391 | 393 | |
|
392 | 394 | def remove(ui, repo, file, *files): |
@@ -394,6 +396,7 b' def remove(ui, repo, file, *files):' | |||
|
394 | 396 | repo.remove(relpath(repo, (file,) + files)) |
|
395 | 397 | |
|
396 | 398 | def serve(ui, repo, **opts): |
|
399 | """export the repository via HTTP""" | |
|
397 | 400 | from mercurial import hgweb |
|
398 | 401 | hgweb.server(repo.root, opts["name"], opts["templates"], |
|
399 | 402 | opts["address"], opts["port"]) |
@@ -415,6 +418,7 b' def status(ui, repo):' | |||
|
415 | 418 | for f in u: print "?", f |
|
416 | 419 | |
|
417 | 420 | def tags(ui, repo): |
|
421 | """list repository tags""" | |
|
418 | 422 | repo.lookup(0) # prime the cache |
|
419 | 423 | i = repo.tags.items() |
|
420 | 424 | i.sort() |
@@ -426,11 +430,13 b' def tags(ui, repo):' | |||
|
426 | 430 | print "%-30s %5d:%s" % (k, repo.changelog.rev(n), hg.hex(n)) |
|
427 | 431 | |
|
428 | 432 | def tip(ui, repo): |
|
433 | """show the tip revision""" | |
|
429 | 434 | n = repo.changelog.tip() |
|
430 | 435 | t = repo.changelog.rev(n) |
|
431 | 436 | ui.status("%d:%s\n" % (t, hg.hex(n))) |
|
432 | 437 | |
|
433 | 438 | def undo(ui, repo): |
|
439 | """undo the last transaction""" | |
|
434 | 440 | repo.undo() |
|
435 | 441 | |
|
436 | 442 | def update(ui, repo, node=None): |
@@ -453,6 +459,8 b' def verify(ui, repo):' | |||
|
453 | 459 | """verify the integrity of the repository""" |
|
454 | 460 | return repo.verify() |
|
455 | 461 | |
|
462 | # Command options and aliases are listed here, alphabetically | |
|
463 | ||
|
456 | 464 | table = { |
|
457 | 465 | "add": (add, [], "hg add [files]"), |
|
458 | 466 | "addremove": (addremove, [], "hg addremove"), |
General Comments 0
You need to be logged in to leave comments.
Login now