Show More
@@ -651,7 +651,7 class changeset_printer(object): | |||||
651 | return 1 |
|
651 | return 1 | |
652 | return 0 |
|
652 | return 0 | |
653 |
|
653 | |||
654 |
def show(self, ctx, copies= |
|
654 | def show(self, ctx, copies=None, **props): | |
655 | if self.buffered: |
|
655 | if self.buffered: | |
656 | self.ui.pushbuffer() |
|
656 | self.ui.pushbuffer() | |
657 | self._show(ctx, copies, props) |
|
657 | self._show(ctx, copies, props) |
@@ -10,7 +10,7 from lock import release | |||||
10 | from i18n import _, gettext |
|
10 | from i18n import _, gettext | |
11 | import os, re, sys, difflib, time, tempfile |
|
11 | import os, re, sys, difflib, time, tempfile | |
12 | import hg, util, revlog, bundlerepo, extensions, copies, error |
|
12 | import hg, util, revlog, bundlerepo, extensions, copies, error | |
13 | import patch, help, mdiff, url, encoding |
|
13 | import patch, help, mdiff, url, encoding, templatekw | |
14 | import archival, changegroup, cmdutil, sshserver, hbisect |
|
14 | import archival, changegroup, cmdutil, sshserver, hbisect | |
15 | from hgweb import server |
|
15 | from hgweb import server | |
16 | import merge as merge_ |
|
16 | import merge as merge_ | |
@@ -2018,34 +2018,9 def log(ui, repo, *pats, **opts): | |||||
2018 | limit = cmdutil.loglimit(opts) |
|
2018 | limit = cmdutil.loglimit(opts) | |
2019 | count = 0 |
|
2019 | count = 0 | |
2020 |
|
2020 | |||
|
2021 | endrev = None | |||
2021 | if opts.get('copies') and opts.get('rev'): |
|
2022 | if opts.get('copies') and opts.get('rev'): | |
2022 | endrev = max(cmdutil.revrange(repo, opts.get('rev'))) + 1 |
|
2023 | endrev = max(cmdutil.revrange(repo, opts.get('rev'))) + 1 | |
2023 | else: |
|
|||
2024 | endrev = len(repo) |
|
|||
2025 | rcache = {} |
|
|||
2026 | def getrenamed(fn, rev): |
|
|||
2027 | '''looks up all renames for a file (up to endrev) the first |
|
|||
2028 | time the file is given. It indexes on the changerev and only |
|
|||
2029 | parses the manifest if linkrev != changerev. |
|
|||
2030 | Returns rename info for fn at changerev rev.''' |
|
|||
2031 | if fn not in rcache: |
|
|||
2032 | rcache[fn] = {} |
|
|||
2033 | fl = repo.file(fn) |
|
|||
2034 | for i in fl: |
|
|||
2035 | lr = fl.linkrev(i) |
|
|||
2036 | renamed = fl.renamed(fl.node(i)) |
|
|||
2037 | rcache[fn][lr] = renamed |
|
|||
2038 | if lr >= endrev: |
|
|||
2039 | break |
|
|||
2040 | if rev in rcache[fn]: |
|
|||
2041 | return rcache[fn][rev] |
|
|||
2042 |
|
||||
2043 | # If linkrev != rev (i.e. rev not found in rcache) fallback to |
|
|||
2044 | # filectx logic. |
|
|||
2045 | try: |
|
|||
2046 | return repo[rev][fn].renamed() |
|
|||
2047 | except error.LookupError: |
|
|||
2048 | return None |
|
|||
2049 |
|
2024 | |||
2050 | df = False |
|
2025 | df = False | |
2051 | if opts["date"]: |
|
2026 | if opts["date"]: | |
@@ -2075,8 +2050,10 def log(ui, repo, *pats, **opts): | |||||
2075 | else: |
|
2050 | else: | |
2076 | return |
|
2051 | return | |
2077 |
|
2052 | |||
|
2053 | copies = None | |||
|
2054 | if opts.get('copies') and rev: | |||
2078 | copies = [] |
|
2055 | copies = [] | |
2079 | if opts.get('copies') and rev: |
|
2056 | getrenamed = templatekw.getrenamedfn(repo, endrev=endrev) | |
2080 | for fn in ctx.files(): |
|
2057 | for fn in ctx.files(): | |
2081 | rename = getrenamed(fn, rev) |
|
2058 | rename = getrenamed(fn, rev) | |
2082 | if rename: |
|
2059 | if rename: |
@@ -6,7 +6,7 | |||||
6 | # GNU General Public License version 2, incorporated herein by reference. |
|
6 | # GNU General Public License version 2, incorporated herein by reference. | |
7 |
|
7 | |||
8 | from node import hex |
|
8 | from node import hex | |
9 | import encoding, patch, util |
|
9 | import encoding, patch, util, error | |
10 |
|
10 | |||
11 | def showlist(templ, name, values, plural=None, **args): |
|
11 | def showlist(templ, name, values, plural=None, **args): | |
12 | '''expand set of values. |
|
12 | '''expand set of values. | |
@@ -108,6 +108,38 def getlatesttags(repo, ctx, cache): | |||||
108 | latesttags[rev] = pdate, pdist + 1, ptag |
|
108 | latesttags[rev] = pdate, pdist + 1, ptag | |
109 | return latesttags[rev] |
|
109 | return latesttags[rev] | |
110 |
|
110 | |||
|
111 | def getrenamedfn(repo, endrev=None): | |||
|
112 | rcache = {} | |||
|
113 | if endrev is None: | |||
|
114 | endrev = len(repo) | |||
|
115 | ||||
|
116 | def getrenamed(fn, rev): | |||
|
117 | '''looks up all renames for a file (up to endrev) the first | |||
|
118 | time the file is given. It indexes on the changerev and only | |||
|
119 | parses the manifest if linkrev != changerev. | |||
|
120 | Returns rename info for fn at changerev rev.''' | |||
|
121 | if fn not in rcache: | |||
|
122 | rcache[fn] = {} | |||
|
123 | fl = repo.file(fn) | |||
|
124 | for i in fl: | |||
|
125 | lr = fl.linkrev(i) | |||
|
126 | renamed = fl.renamed(fl.node(i)) | |||
|
127 | rcache[fn][lr] = renamed | |||
|
128 | if lr >= endrev: | |||
|
129 | break | |||
|
130 | if rev in rcache[fn]: | |||
|
131 | return rcache[fn][rev] | |||
|
132 | ||||
|
133 | # If linkrev != rev (i.e. rev not found in rcache) fallback to | |||
|
134 | # filectx logic. | |||
|
135 | try: | |||
|
136 | return repo[rev][fn].renamed() | |||
|
137 | except error.LookupError: | |||
|
138 | return None | |||
|
139 | ||||
|
140 | return getrenamed | |||
|
141 | ||||
|
142 | ||||
111 | def showauthor(repo, ctx, templ, **args): |
|
143 | def showauthor(repo, ctx, templ, **args): | |
112 | return ctx.user() |
|
144 | return ctx.user() | |
113 |
|
145 | |||
@@ -141,8 +173,27 def showextras(repo, ctx, templ, **args) | |||||
141 | def showfileadds(repo, ctx, templ, revcache, **args): |
|
173 | def showfileadds(repo, ctx, templ, revcache, **args): | |
142 | return showlist(templ, 'file_add', getfiles(repo, ctx, revcache)[1], **args) |
|
174 | return showlist(templ, 'file_add', getfiles(repo, ctx, revcache)[1], **args) | |
143 |
|
175 | |||
144 | def showfilecopies(repo, ctx, templ, revcache, **args): |
|
176 | def showfilecopies(repo, ctx, templ, cache, revcache, **args): | |
145 | c = [{'name': x[0], 'source': x[1]} for x in revcache['copies']] |
|
177 | copies = revcache.get('copies') | |
|
178 | if copies is None: | |||
|
179 | if 'getrenamed' not in cache: | |||
|
180 | cache['getrenamed'] = getrenamedfn(repo) | |||
|
181 | copies = [] | |||
|
182 | getrenamed = cache['getrenamed'] | |||
|
183 | for fn in ctx.files(): | |||
|
184 | rename = getrenamed(fn, ctx.rev()) | |||
|
185 | if rename: | |||
|
186 | copies.append((fn, rename[0])) | |||
|
187 | ||||
|
188 | c = [{'name': x[0], 'source': x[1]} for x in copies] | |||
|
189 | return showlist(templ, 'file_copy', c, plural='file_copies', **args) | |||
|
190 | ||||
|
191 | # showfilecopiesswitch() displays file copies only if copy records are | |||
|
192 | # provided before calling the templater, usually with a --copies | |||
|
193 | # command line switch. | |||
|
194 | def showfilecopiesswitch(repo, ctx, templ, cache, revcache, **args): | |||
|
195 | copies = revcache.get('copies') or [] | |||
|
196 | c = [{'name': x[0], 'source': x[1]} for x in copies] | |||
146 | return showlist(templ, 'file_copy', c, plural='file_copies', **args) |
|
197 | return showlist(templ, 'file_copy', c, plural='file_copies', **args) | |
147 |
|
198 | |||
148 | def showfiledels(repo, ctx, templ, revcache, **args): |
|
199 | def showfiledels(repo, ctx, templ, revcache, **args): | |
@@ -184,6 +235,7 keywords = { | |||||
184 | 'extras': showextras, |
|
235 | 'extras': showextras, | |
185 | 'file_adds': showfileadds, |
|
236 | 'file_adds': showfileadds, | |
186 | 'file_copies': showfilecopies, |
|
237 | 'file_copies': showfilecopies, | |
|
238 | 'file_copies_switch': showfilecopiesswitch, | |||
187 | 'file_dels': showfiledels, |
|
239 | 'file_dels': showfiledels, | |
188 | 'file_mods': showfilemods, |
|
240 | 'file_mods': showfilemods, | |
189 | 'files': showfiles, |
|
241 | 'files': showfiles, |
@@ -1,7 +1,7 | |||||
1 | changeset = 'changeset: {rev}:{node|short}\n{branches}{tags}{parents}user: {author}\ndate: {date|date}\nsummary: {desc|firstline}\n\n' |
|
1 | changeset = 'changeset: {rev}:{node|short}\n{branches}{tags}{parents}user: {author}\ndate: {date|date}\nsummary: {desc|firstline}\n\n' | |
2 | changeset_quiet = '{rev}:{node|short}\n' |
|
2 | changeset_quiet = '{rev}:{node|short}\n' | |
3 | changeset_verbose = 'changeset: {rev}:{node|short}\n{branches}{tags}{parents}user: {author}\ndate: {date|date}\n{files}{file_copies}description:\n{desc|strip}\n\n\n' |
|
3 | changeset_verbose = 'changeset: {rev}:{node|short}\n{branches}{tags}{parents}user: {author}\ndate: {date|date}\n{files}{file_copies_switch}description:\n{desc|strip}\n\n\n' | |
4 | changeset_debug = 'changeset: {rev}:{node}\n{branches}{tags}{parents}{manifest}user: {author}\ndate: {date|date}\n{file_mods}{file_adds}{file_dels}{file_copies}{extras}description:\n{desc|strip}\n\n\n' |
|
4 | changeset_debug = 'changeset: {rev}:{node}\n{branches}{tags}{parents}{manifest}user: {author}\ndate: {date|date}\n{file_mods}{file_adds}{file_dels}{file_copies_switch}{extras}description:\n{desc|strip}\n\n\n' | |
5 | start_files = 'files: ' |
|
5 | start_files = 'files: ' | |
6 | file = ' {file}' |
|
6 | file = ' {file}' | |
7 | end_files = '\n' |
|
7 | end_files = '\n' | |
@@ -14,9 +14,9 end_file_adds = '\n' | |||||
14 | start_file_dels = 'files-: ' |
|
14 | start_file_dels = 'files-: ' | |
15 | file_del = ' {file_del}' |
|
15 | file_del = ' {file_del}' | |
16 | end_file_dels = '\n' |
|
16 | end_file_dels = '\n' | |
17 | start_file_copies = 'copies: ' |
|
17 | start_file_copies_switch = 'copies: ' | |
18 | file_copy = ' {name} ({source})' |
|
18 | file_copy = ' {name} ({source})' | |
19 | end_file_copies = '\n' |
|
19 | end_file_copies_switch = '\n' | |
20 | parent = 'parent: {rev}:{node|formatnode}\n' |
|
20 | parent = 'parent: {rev}:{node|formatnode}\n' | |
21 | manifest = 'manifest: {rev}:{node}\n' |
|
21 | manifest = 'manifest: {rev}:{node}\n' | |
22 | branch = 'branch: {branch}\n' |
|
22 | branch = 'branch: {branch}\n' |
@@ -94,8 +94,8 cat changelog | |||||
94 |
|
94 | |||
95 | echo "# keys work" |
|
95 | echo "# keys work" | |
96 | for key in author branches date desc file_adds file_dels file_mods \ |
|
96 | for key in author branches date desc file_adds file_dels file_mods \ | |
97 | 'file_copies%filecopy' files manifest node parents rev tags diffstat \ |
|
97 | 'file_copies%filecopy' 'file_copies_switch%filecopy' files \ | |
98 | extras; do |
|
98 | manifest node parents rev tags diffstat extras; do | |
99 | for mode in '' --verbose --debug; do |
|
99 | for mode in '' --verbose --debug; do | |
100 | hg log $mode --template "$key$mode: {$key}\n" |
|
100 | hg log $mode --template "$key$mode: {$key}\n" | |
101 | done |
|
101 | done |
@@ -380,7 +380,7 file_mods--debug: c | |||||
380 | file_mods--debug: |
|
380 | file_mods--debug: | |
381 | file_mods--debug: |
|
381 | file_mods--debug: | |
382 | file_mods--debug: |
|
382 | file_mods--debug: | |
383 | file_copies%filecopy: |
|
383 | file_copies%filecopy: fourth (second) | |
384 | file_copies%filecopy: |
|
384 | file_copies%filecopy: | |
385 | file_copies%filecopy: |
|
385 | file_copies%filecopy: | |
386 | file_copies%filecopy: |
|
386 | file_copies%filecopy: | |
@@ -389,7 +389,7 file_copies%filecopy: | |||||
389 | file_copies%filecopy: |
|
389 | file_copies%filecopy: | |
390 | file_copies%filecopy: |
|
390 | file_copies%filecopy: | |
391 | file_copies%filecopy: |
|
391 | file_copies%filecopy: | |
392 | file_copies%filecopy--verbose: |
|
392 | file_copies%filecopy--verbose: fourth (second) | |
393 | file_copies%filecopy--verbose: |
|
393 | file_copies%filecopy--verbose: | |
394 | file_copies%filecopy--verbose: |
|
394 | file_copies%filecopy--verbose: | |
395 | file_copies%filecopy--verbose: |
|
395 | file_copies%filecopy--verbose: | |
@@ -398,6 +398,7 file_copies%filecopy--verbose: | |||||
398 | file_copies%filecopy--verbose: |
|
398 | file_copies%filecopy--verbose: | |
399 | file_copies%filecopy--verbose: |
|
399 | file_copies%filecopy--verbose: | |
400 | file_copies%filecopy--verbose: |
|
400 | file_copies%filecopy--verbose: | |
|
401 | file_copies%filecopy--debug: fourth (second) | |||
401 | file_copies%filecopy--debug: |
|
402 | file_copies%filecopy--debug: | |
402 | file_copies%filecopy--debug: |
|
403 | file_copies%filecopy--debug: | |
403 | file_copies%filecopy--debug: |
|
404 | file_copies%filecopy--debug: | |
@@ -406,7 +407,33 file_copies%filecopy--debug: | |||||
406 | file_copies%filecopy--debug: |
|
407 | file_copies%filecopy--debug: | |
407 | file_copies%filecopy--debug: |
|
408 | file_copies%filecopy--debug: | |
408 | file_copies%filecopy--debug: |
|
409 | file_copies%filecopy--debug: | |
409 |
file_copies%filecopy |
|
410 | file_copies_switch%filecopy: | |
|
411 | file_copies_switch%filecopy: | |||
|
412 | file_copies_switch%filecopy: | |||
|
413 | file_copies_switch%filecopy: | |||
|
414 | file_copies_switch%filecopy: | |||
|
415 | file_copies_switch%filecopy: | |||
|
416 | file_copies_switch%filecopy: | |||
|
417 | file_copies_switch%filecopy: | |||
|
418 | file_copies_switch%filecopy: | |||
|
419 | file_copies_switch%filecopy--verbose: | |||
|
420 | file_copies_switch%filecopy--verbose: | |||
|
421 | file_copies_switch%filecopy--verbose: | |||
|
422 | file_copies_switch%filecopy--verbose: | |||
|
423 | file_copies_switch%filecopy--verbose: | |||
|
424 | file_copies_switch%filecopy--verbose: | |||
|
425 | file_copies_switch%filecopy--verbose: | |||
|
426 | file_copies_switch%filecopy--verbose: | |||
|
427 | file_copies_switch%filecopy--verbose: | |||
|
428 | file_copies_switch%filecopy--debug: | |||
|
429 | file_copies_switch%filecopy--debug: | |||
|
430 | file_copies_switch%filecopy--debug: | |||
|
431 | file_copies_switch%filecopy--debug: | |||
|
432 | file_copies_switch%filecopy--debug: | |||
|
433 | file_copies_switch%filecopy--debug: | |||
|
434 | file_copies_switch%filecopy--debug: | |||
|
435 | file_copies_switch%filecopy--debug: | |||
|
436 | file_copies_switch%filecopy--debug: | |||
410 | files: fourth second third |
|
437 | files: fourth second third | |
411 | files: second |
|
438 | files: second | |
412 | files: |
|
439 | files: |
@@ -141,7 +141,7 diff --git a/rename2 b/rename3-2 | |||||
141 | rename from rename2 |
|
141 | rename from rename2 | |
142 | rename to rename3-2 |
|
142 | rename to rename3-2 | |
143 | EOF |
|
143 | EOF | |
144 |
hg log -v |
|
144 | hg log -vr. --template '{rev} {files} / {file_copies%filecopy}\n' | |
145 |
|
145 | |||
146 | hg locate rename2 rename3 rename3-2 |
|
146 | hg locate rename2 rename3 rename3-2 | |
147 | hg cat rename3 |
|
147 | hg cat rename3 |
@@ -31,20 +31,24 hg log -vf a | |||||
31 | echo % many renames |
|
31 | echo % many renames | |
32 | hg log -vf e |
|
32 | hg log -vf e | |
33 |
|
33 | |||
34 | echo % log copies |
|
34 | echo '% log copies with --copies' | |
35 | hg log -vC --template '{rev} {file_copies%filecopy}\n' |
|
35 | hg log -vC --template '{rev} {file_copies%filecopy}\n' | |
|
36 | echo '% log copies switch without --copies' | |||
|
37 | hg log -v --template '{rev} {file_copies_switch%filecopy}\n' | |||
|
38 | echo '% log copies switch with --copies' | |||
|
39 | hg log -vC --template '{rev} {file_copies_switch%filecopy}\n' | |||
36 |
|
40 | |||
37 | echo % log copies, non-linear manifest |
|
41 | echo % log copies, non-linear manifest | |
38 | hg up -C 3 |
|
42 | hg up -C 3 | |
39 | hg mv dir/b e |
|
43 | hg mv dir/b e | |
40 | echo foo > foo |
|
44 | echo foo > foo | |
41 | hg ci -Ame2 -d '6 0' |
|
45 | hg ci -Ame2 -d '6 0' | |
42 |
hg log -v |
|
46 | hg log -v --template '{rev} {file_copies%filecopy}\n' -r 5 | |
43 |
|
47 | |||
44 | echo % log copies, execute bit set |
|
48 | echo % log copies, execute bit set | |
45 | chmod +x e |
|
49 | chmod +x e | |
46 | hg ci -me3 -d '7 0' |
|
50 | hg ci -me3 -d '7 0' | |
47 |
hg log -v |
|
51 | hg log -v --template '{rev} {file_copies%filecopy}\n' -r 6 | |
48 |
|
52 | |||
49 | echo '% log -p d' |
|
53 | echo '% log -p d' | |
50 | hg log -pv d |
|
54 | hg log -pv d |
@@ -76,7 +76,19 description: | |||||
76 | a |
|
76 | a | |
77 |
|
77 | |||
78 |
|
78 | |||
79 | % log copies |
|
79 | % log copies with --copies | |
|
80 | 4 e (dir/b) | |||
|
81 | 3 b (a) | |||
|
82 | 2 dir/b (b) | |||
|
83 | 1 b (a) | |||
|
84 | 0 | |||
|
85 | % log copies switch without --copies | |||
|
86 | 4 | |||
|
87 | 3 | |||
|
88 | 2 | |||
|
89 | 1 | |||
|
90 | 0 | |||
|
91 | % log copies switch with --copies | |||
80 | 4 e (dir/b) |
|
92 | 4 e (dir/b) | |
81 | 3 b (a) |
|
93 | 3 b (a) | |
82 | 2 dir/b (b) |
|
94 | 2 dir/b (b) |
@@ -387,10 +387,10 hg ci -m 'change foo' | |||||
387 | hg up -C 1 |
|
387 | hg up -C 1 | |
388 | hg qrefresh --git 2>&1 | grep -v 'saving bundle' |
|
388 | hg qrefresh --git 2>&1 | grep -v 'saving bundle' | |
389 | cat .hg/patches/bar |
|
389 | cat .hg/patches/bar | |
390 |
hg log -v |
|
390 | hg log -v --template '{rev} {file_copies%filecopy}\n' -r . | |
391 | hg qrefresh --git |
|
391 | hg qrefresh --git | |
392 | cat .hg/patches/bar |
|
392 | cat .hg/patches/bar | |
393 |
hg log -v |
|
393 | hg log -v --template '{rev} {file_copies%filecopy}\n' -r . | |
394 | hg qrefresh |
|
394 | hg qrefresh | |
395 | grep 'diff --git' .hg/patches/bar |
|
395 | grep 'diff --git' .hg/patches/bar | |
396 |
|
396 | |||
@@ -403,12 +403,12 hg mv bar quux | |||||
403 | hg mv baz bleh |
|
403 | hg mv baz bleh | |
404 | hg qrefresh --git 2>&1 | grep -v 'saving bundle' |
|
404 | hg qrefresh --git 2>&1 | grep -v 'saving bundle' | |
405 | cat .hg/patches/bar |
|
405 | cat .hg/patches/bar | |
406 |
hg log -v |
|
406 | hg log -v --template '{rev} {file_copies%filecopy}\n' -r . | |
407 | hg mv quux fred |
|
407 | hg mv quux fred | |
408 | hg mv bleh barney |
|
408 | hg mv bleh barney | |
409 | hg qrefresh --git |
|
409 | hg qrefresh --git | |
410 | cat .hg/patches/bar |
|
410 | cat .hg/patches/bar | |
411 |
hg log -v |
|
411 | hg log -v --template '{rev} {file_copies%filecopy}\n' -r . | |
412 |
|
412 | |||
413 | echo % refresh omitting an added file |
|
413 | echo % refresh omitting an added file | |
414 | hg qnew baz |
|
414 | hg qnew baz |
General Comments 0
You need to be logged in to leave comments.
Login now