##// END OF EJS Templates
phases: make the working directory consistently a draft...
Rodrigo Damazio Bovendorp -
r44456:9c1fd975 default
parent child Browse files
Show More
@@ -112,6 +112,7 b' from .node import ('
112 nullid,
112 nullid,
113 nullrev,
113 nullrev,
114 short,
114 short,
115 wdirrev,
115 )
116 )
116 from .pycompat import (
117 from .pycompat import (
117 getattr,
118 getattr,
@@ -242,6 +243,7 b' class phasecache(object):'
242 """return a smartset for the given phases"""
243 """return a smartset for the given phases"""
243 self.loadphaserevs(repo) # ensure phase's sets are loaded
244 self.loadphaserevs(repo) # ensure phase's sets are loaded
244 phases = set(phases)
245 phases = set(phases)
246
245 if public not in phases:
247 if public not in phases:
246 # fast path: _phasesets contains the interesting sets,
248 # fast path: _phasesets contains the interesting sets,
247 # might only need a union and post-filtering.
249 # might only need a union and post-filtering.
@@ -252,21 +254,39 b' class phasecache(object):'
252 revs = set.union(*[self._phasesets[p] for p in phases])
254 revs = set.union(*[self._phasesets[p] for p in phases])
253 if repo.changelog.filteredrevs:
255 if repo.changelog.filteredrevs:
254 revs = revs - repo.changelog.filteredrevs
256 revs = revs - repo.changelog.filteredrevs
257
255 if subset is None:
258 if subset is None:
256 return smartset.baseset(revs)
259 return smartset.baseset(revs)
257 else:
260 else:
261 if wdirrev in subset and repo[None].phase() in phases:
262 # The working dir would never be in the cache, but it was
263 # in the subset being filtered for its phase, so add it to
264 # the output.
265 revs.add(wdirrev)
266
258 return subset & smartset.baseset(revs)
267 return subset & smartset.baseset(revs)
259 else:
268 else:
269 # phases keeps all the *other* phases.
260 phases = set(allphases).difference(phases)
270 phases = set(allphases).difference(phases)
261 if not phases:
271 if not phases:
262 return smartset.fullreposet(repo)
272 return smartset.fullreposet(repo)
273
274 # revs has the revisions in all *other* phases.
263 if len(phases) == 1:
275 if len(phases) == 1:
264 [p] = phases
276 [p] = phases
265 revs = self._phasesets[p]
277 revs = self._phasesets[p]
266 else:
278 else:
267 revs = set.union(*[self._phasesets[p] for p in phases])
279 revs = set.union(*[self._phasesets[p] for p in phases])
280
268 if subset is None:
281 if subset is None:
269 subset = smartset.fullreposet(repo)
282 subset = smartset.fullreposet(repo)
283
284 if wdirrev in subset and repo[None].phase() in phases:
285 # The working dir is in the subset being filtered, and its
286 # phase is in the phases *not* being returned, so add it to the
287 # set of revisions to filter out.
288 revs.add(wdirrev)
289
270 if not revs:
290 if not revs:
271 return subset
291 return subset
272 return subset.filter(lambda r: r not in revs)
292 return subset.filter(lambda r: r not in revs)
@@ -48,13 +48,58 b' Following commit are draft too'
48 1 1 B
48 1 1 B
49 0 1 A
49 0 1 A
50
50
51 Draft commit are properly created over public one:
51 Working directory phase is secret when its parent is secret.
52
53 $ hg phase --force --secret .
54 test-debug-phase: move rev 0: 1 -> 2
55 test-debug-phase: move rev 1: 1 -> 2
56 test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: draft -> secret
57 test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: draft -> secret
58 $ hg log -r 'wdir()' -T '{phase}\n'
59 secret
60 $ hg log -r 'wdir() and public()' -T '{phase}\n'
61 $ hg log -r 'wdir() and draft()' -T '{phase}\n'
62 $ hg log -r 'wdir() and secret()' -T '{phase}\n'
63 secret
64
65 Working directory phase is draft when its parent is draft.
66
67 $ hg phase --draft .
68 test-debug-phase: move rev 1: 2 -> 1
69 test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: secret -> draft
70 $ hg log -r 'wdir()' -T '{phase}\n'
71 draft
72 $ hg log -r 'wdir() and public()' -T '{phase}\n'
73 $ hg log -r 'wdir() and draft()' -T '{phase}\n'
74 draft
75 $ hg log -r 'wdir() and secret()' -T '{phase}\n'
76
77 Working directory phase is secret when a new commit will be created as secret,
78 even if the parent is draft.
79
80 $ hg log -r 'wdir() and secret()' -T '{phase}\n' \
81 > --config phases.new-commit='secret'
82 secret
83
84 Working directory phase is draft when its parent is public.
52
85
53 $ hg phase --public .
86 $ hg phase --public .
54 test-debug-phase: move rev 0: 1 -> 0
87 test-debug-phase: move rev 0: 1 -> 0
55 test-debug-phase: move rev 1: 1 -> 0
88 test-debug-phase: move rev 1: 1 -> 0
56 test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: draft -> public
89 test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: draft -> public
57 test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: draft -> public
90 test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: draft -> public
91 $ hg log -r 'wdir()' -T '{phase}\n'
92 draft
93 $ hg log -r 'wdir() and public()' -T '{phase}\n'
94 $ hg log -r 'wdir() and draft()' -T '{phase}\n'
95 draft
96 $ hg log -r 'wdir() and secret()' -T '{phase}\n'
97 $ hg log -r 'wdir() and secret()' -T '{phase}\n' \
98 > --config phases.new-commit='secret'
99 secret
100
101 Draft commit are properly created over public one:
102
58 $ hg phase
103 $ hg phase
59 1: public
104 1: public
60 $ hglog
105 $ hglog
General Comments 0
You need to be logged in to leave comments. Login now