Show More
@@ -10,7 +10,7 b'' | |||
|
10 | 10 | import time, sys, signal |
|
11 | 11 | from mercurial import hg, mdiff, fancyopts, commands, ui |
|
12 | 12 | |
|
13 | def difftree(args, repo): | |
|
13 | def difftree(args, ui, repo): | |
|
14 | 14 | def __difftree(repo, files = None, node1 = None, node2 = None): |
|
15 | 15 | def date(c): |
|
16 | 16 | return time.asctime(time.gmtime(float(c[2].split(' ')[0]))) |
@@ -61,7 +61,7 b' def difftree(args, repo):' | |||
|
61 | 61 | revs.append(repo.lookup(args[1])) |
|
62 | 62 | args = args[2:] |
|
63 | 63 | if doptions['patch']: |
|
64 | commands.dodiff(repo, "", args, *revs) | |
|
64 | commands.dodiff(ui, repo, "", args, *revs) | |
|
65 | 65 | else: |
|
66 | 66 | __difftree(repo, args, *revs) |
|
67 | 67 | |
@@ -236,10 +236,10 b' signal.signal(signal.SIGTERM, catchterm)' | |||
|
236 | 236 | repo = hg.repository(ui = u) |
|
237 | 237 | |
|
238 | 238 | if cmd == "diff-tree": |
|
239 | difftree(args, repo) | |
|
239 | difftree(args, u, repo) | |
|
240 | 240 | |
|
241 | 241 | elif cmd == "cat-file": |
|
242 |
catfile(args, u |
|
|
242 | catfile(args, u, repo) | |
|
243 | 243 | |
|
244 | 244 | elif cmd == "rev-tree": |
|
245 | 245 | revtree(args, repo) |
@@ -32,7 +32,7 b' def relpath(repo, args):' | |||
|
32 | 32 | return [ os.path.normpath(os.path.join(p, x)) for x in args ] |
|
33 | 33 | return args |
|
34 | 34 | |
|
35 | def dodiff(repo, path, files = None, node1 = None, node2 = None): | |
|
35 | def dodiff(ui, repo, path, files = None, node1 = None, node2 = None): | |
|
36 | 36 | def date(c): |
|
37 | 37 | return time.asctime(time.gmtime(float(c[2].split(' ')[0]))) |
|
38 | 38 | |
@@ -49,6 +49,12 b' def dodiff(repo, path, files = None, nod' | |||
|
49 | 49 | node1 = repo.dirstate.parents()[0] |
|
50 | 50 | def read(f): return file(os.path.join(repo.root, f)).read() |
|
51 | 51 | |
|
52 | if ui.quiet: | |
|
53 | r = None | |
|
54 | else: | |
|
55 | hexfunc = ui.verbose and hg.hex or hg.short | |
|
56 | r = [hexfunc(node) for node in [node1, node2] if node] | |
|
57 | ||
|
52 | 58 | change = repo.changelog.read(node1) |
|
53 | 59 | mmap = repo.manifest.read(change[0]) |
|
54 | 60 | date1 = date(change) |
@@ -61,15 +67,15 b' def dodiff(repo, path, files = None, nod' | |||
|
61 | 67 | if f in mmap: |
|
62 | 68 | to = repo.file(f).read(mmap[f]) |
|
63 | 69 | tn = read(f) |
|
64 | sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f)) | |
|
70 | sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f, r)) | |
|
65 | 71 | for f in a: |
|
66 | 72 | to = None |
|
67 | 73 | tn = read(f) |
|
68 | sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f)) | |
|
74 | sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f, r)) | |
|
69 | 75 | for f in d: |
|
70 | 76 | to = repo.file(f).read(mmap[f]) |
|
71 | 77 | tn = None |
|
72 | sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f)) | |
|
78 | sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f, r)) | |
|
73 | 79 | |
|
74 | 80 | def show_changeset(ui, repo, rev=0, changenode=None, filelog=None): |
|
75 | 81 | """show a single changeset or file revision""" |
@@ -300,7 +306,7 b' def diff(ui, repo, *files, **opts):' | |||
|
300 | 306 | else: |
|
301 | 307 | files = relpath(repo, [""]) |
|
302 | 308 | |
|
303 | dodiff(repo, os.getcwd(), files, *revs) | |
|
309 | dodiff(ui, repo, os.getcwd(), files, *revs) | |
|
304 | 310 | |
|
305 | 311 | def export(ui, repo, changeset): |
|
306 | 312 | """dump the changeset header and diffs for a revision""" |
@@ -317,7 +323,7 b' def export(ui, repo, changeset):' | |||
|
317 | 323 | print change[4].rstrip() |
|
318 | 324 | |
|
319 | 325 | |
|
320 | dodiff(repo, "", None, prev, node) | |
|
326 | dodiff(ui, repo, "", None, prev, node) | |
|
321 | 327 | |
|
322 | 328 | def forget(ui, repo, file, *files): |
|
323 | 329 | """don't add the specified files on the next commit""" |
@@ -8,7 +8,8 b'' | |||
|
8 | 8 | import difflib, struct |
|
9 | 9 | from mercurial.mpatch import * |
|
10 | 10 | |
|
11 | def unidiff(a, ad, b, bd, fn): | |
|
11 | def unidiff(a, ad, b, bd, fn, r=None): | |
|
12 | ||
|
12 | 13 | if not a and not b: return "" |
|
13 | 14 | |
|
14 | 15 | if a == None: |
@@ -36,6 +37,10 b' def unidiff(a, ad, b, bd, fn):' | |||
|
36 | 37 | if l[ln][-1] != '\n': |
|
37 | 38 | l[ln] += "\n\ No newline at end of file\n" |
|
38 | 39 | |
|
40 | if r: | |
|
41 | l.insert(0, "diff %s %s\n" % | |
|
42 | (' '.join(["-r %s" % rev for rev in r]), fn)) | |
|
43 | ||
|
39 | 44 | return "".join(l) |
|
40 | 45 | |
|
41 | 46 | def textdiff(a, b): |
@@ -12,6 +12,7 b'' | |||
|
12 | 12 | + echo abc |
|
13 | 13 | + hg diff |
|
14 | 14 | + sed 's/\(\(---\|+++\).*\)\t.*/\1/' |
|
15 | diff -r c19d34741b0a a | |
|
15 | 16 | --- a/a |
|
16 | 17 | +++ b/a |
|
17 | 18 | @@ -1,1 +1,1 @@ |
@@ -65,6 +66,7 b' 1' | |||
|
65 | 66 | |
|
66 | 67 | + hg diff |
|
67 | 68 | + sed 's/\(\(---\|+++\).*\)\t.*/\1/' |
|
69 | diff -r 1e71731e6fbb a | |
|
68 | 70 | --- a/a |
|
69 | 71 | +++ b/a |
|
70 | 72 | @@ -1,1 +1,1 @@ |
General Comments 0
You need to be logged in to leave comments.
Login now