Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/cmdutil.py @ 30018:2963fba2d18a
log: copy the way of ancestor traversal to --follow matcher (issue5376)
We can't use fctx.linkrev() because follow() revset tries hard to simulate
the traversal of changelog DAG, not filelog DAG. This patch fixes
_makefollowlogfilematcher() to walk file ancestors in the same way as
revset._follow().
I'll factor out a common function in future patches.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 24 Sep 2016 19:58:23 +0900 |
parents | 96b2dd3b184d |
children | 3dcaf1c4e90d |
comparison
equal
deleted
inserted
replaced
30017:96b2dd3b184d | 30018:2963fba2d18a |
---|---|
1939 # When displaying a revision with --patch --follow FILE, we have | 1939 # When displaying a revision with --patch --follow FILE, we have |
1940 # to know which file of the revision must be diffed. With | 1940 # to know which file of the revision must be diffed. With |
1941 # --follow, we want the names of the ancestors of FILE in the | 1941 # --follow, we want the names of the ancestors of FILE in the |
1942 # revision, stored in "fcache". "fcache" is populated by | 1942 # revision, stored in "fcache". "fcache" is populated by |
1943 # reproducing the graph traversal already done by --follow revset | 1943 # reproducing the graph traversal already done by --follow revset |
1944 # and relating linkrevs to file names (which is not "correct" but | 1944 # and relating revs to file names (which is not "correct" but |
1945 # good enough). | 1945 # good enough). |
1946 fcache = {} | 1946 fcache = {} |
1947 fcacheready = [False] | 1947 fcacheready = [False] |
1948 pctx = repo['.'] | 1948 pctx = repo['.'] |
1949 | 1949 |
1950 def populate(): | 1950 def populate(): |
1951 for fn in files: | 1951 for fn in files: |
1952 fctx = pctx[fn] | 1952 fctx = pctx[fn] |
1953 fcache.setdefault(fctx.linkrev(), set()).add(fctx.path()) | 1953 fcache.setdefault(fctx.introrev(), set()).add(fctx.path()) |
1954 for c in fctx.ancestors(followfirst=followfirst): | 1954 for c in fctx.ancestors(followfirst=followfirst): |
1955 fcache.setdefault(c.linkrev(), set()).add(c.path()) | 1955 fcache.setdefault(c.rev(), set()).add(c.path()) |
1956 | 1956 |
1957 def filematcher(rev): | 1957 def filematcher(rev): |
1958 if not fcacheready[0]: | 1958 if not fcacheready[0]: |
1959 # Lazy initialization | 1959 # Lazy initialization |
1960 fcacheready[0] = True | 1960 fcacheready[0] = True |