Show More
@@ -60,17 +60,31 b" testedwith = b'ships-with-hg-core'" | |||||
60 | _(b'censor file from specified revision'), |
|
60 | _(b'censor file from specified revision'), | |
61 | _(b'REV'), |
|
61 | _(b'REV'), | |
62 | ), |
|
62 | ), | |
|
63 | ( | |||
|
64 | b'', | |||
|
65 | b'check-heads', | |||
|
66 | True, | |||
|
67 | _(b'check that repository heads are not affected'), | |||
|
68 | ), | |||
63 | (b't', b'tombstone', b'', _(b'replacement tombstone data'), _(b'TEXT')), |
|
69 | (b't', b'tombstone', b'', _(b'replacement tombstone data'), _(b'TEXT')), | |
64 | ], |
|
70 | ], | |
65 | _(b'-r REV [-t TEXT] [FILE]'), |
|
71 | _(b'-r REV [-t TEXT] [FILE]'), | |
66 | helpcategory=command.CATEGORY_MAINTENANCE, |
|
72 | helpcategory=command.CATEGORY_MAINTENANCE, | |
67 | ) |
|
73 | ) | |
68 | def censor(ui, repo, path, rev=b'', tombstone=b'', **opts): |
|
74 | def censor(ui, repo, path, rev=b'', tombstone=b'', check_heads=True, **opts): | |
69 | with repo.wlock(), repo.lock(): |
|
75 | with repo.wlock(), repo.lock(): | |
70 | return _docensor(ui, repo, path, rev, tombstone, **opts) |
|
76 | return _docensor( | |
|
77 | ui, | |||
|
78 | repo, | |||
|
79 | path, | |||
|
80 | rev, | |||
|
81 | tombstone, | |||
|
82 | check_heads=check_heads, | |||
|
83 | **opts, | |||
|
84 | ) | |||
71 |
|
85 | |||
72 |
|
86 | |||
73 | def _docensor(ui, repo, path, rev=b'', tombstone=b'', **opts): |
|
87 | def _docensor(ui, repo, path, rev=b'', tombstone=b'', check_heads=True, **opts): | |
74 | if not path: |
|
88 | if not path: | |
75 | raise error.Abort(_(b'must specify file path to censor')) |
|
89 | raise error.Abort(_(b'must specify file path to censor')) | |
76 | if not rev: |
|
90 | if not rev: | |
@@ -98,20 +112,22 b" def _docensor(ui, repo, path, rev=b'', t" | |||||
98 | raise error.Abort(_(b'file does not exist at revision %s') % rev) |
|
112 | raise error.Abort(_(b'file does not exist at revision %s') % rev) | |
99 |
|
113 | |||
100 | fnode = fctx.filenode() |
|
114 | fnode = fctx.filenode() | |
101 | heads = [] |
|
115 | if check_heads: | |
102 | repo_heads = repo.heads() |
|
116 | heads = [] | |
103 | msg = b'checking for the censored content in %d heads\n' % len(repo_heads) |
|
117 | repo_heads = repo.heads() | |
104 | ui.status(msg) |
|
118 | msg = b'checking for the censored content in %d heads\n' | |
105 | for headnode in repo_heads: |
|
119 | msg %= len(repo_heads) | |
106 | hc = repo[headnode] |
|
120 | ui.status(msg) | |
107 | if path in hc and hc.filenode(path) == fnode: |
|
121 | for headnode in repo_heads: | |
108 | heads.append(hc) |
|
122 | hc = repo[headnode] | |
109 | if heads: |
|
123 | if path in hc and hc.filenode(path) == fnode: | |
110 | headlist = b', '.join([short(c.node()) for c in heads]) |
|
124 | heads.append(hc) | |
111 | raise error.Abort( |
|
125 | if heads: | |
112 | _(b'cannot censor file in heads (%s)') % headlist, |
|
126 | headlist = b', '.join([short(c.node()) for c in heads]) | |
113 | hint=_(b'clean/delete and commit first'), |
|
127 | raise error.Abort( | |
114 | ) |
|
128 | _(b'cannot censor file in heads (%s)') % headlist, | |
|
129 | hint=_(b'clean/delete and commit first'), | |||
|
130 | ) | |||
115 |
|
131 | |||
116 | wp = wctx.parents() |
|
132 | wp = wctx.parents() | |
117 | if ctx.node() in [p.node() for p in wp]: |
|
133 | if ctx.node() in [p.node() for p in wp]: |
@@ -511,6 +511,10 b' Can import bundle where first revision o' | |||||
511 | (run 'hg update' to get a working copy) |
|
511 | (run 'hg update' to get a working copy) | |
512 | $ hg cat -r 0 target | head -n 10 |
|
512 | $ hg cat -r 0 target | head -n 10 | |
513 |
|
513 | |||
|
514 | Can skip the head checking steps | |||
|
515 | ||||
|
516 | $ hg --config extensions.censor= censor -r 0 --no-check-heads target | |||
|
517 | ||||
514 | #if revlogv2 |
|
518 | #if revlogv2 | |
515 |
|
519 | |||
516 | Testing feature that does not work in revlog v1 |
|
520 | Testing feature that does not work in revlog v1 |
General Comments 0
You need to be logged in to leave comments.
Login now