Mercurial > hg
annotate mercurial/strip.py @ 48378:3d6eb119200d
dirstate-item: allow mtime to be None in "parentdata"
This will be useful to filter out unreliable mtime.
Differential Revision: https://phab.mercurial-scm.org/D11782
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 17 Nov 2021 10:26:48 +0100 |
parents | 5ced12cfa41b |
children | 6000f5b25c9b |
rev | line source |
---|---|
28377
81ad683278b8
strip: use absolute_import
timeless <timeless@mozdev.org>
parents:
28288
diff
changeset
|
1 from __future__ import absolute_import |
81ad683278b8
strip: use absolute_import
timeless <timeless@mozdev.org>
parents:
28288
diff
changeset
|
2 |
45865
d7a508a75d72
strip: move into core
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
45514
diff
changeset
|
3 from .i18n import _ |
d7a508a75d72
strip: move into core
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
45514
diff
changeset
|
4 from .pycompat import getattr |
d7a508a75d72
strip: move into core
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
45514
diff
changeset
|
5 from . import ( |
28377
81ad683278b8
strip: use absolute_import
timeless <timeless@mozdev.org>
parents:
28288
diff
changeset
|
6 bookmarks as bookmarksmod, |
81ad683278b8
strip: use absolute_import
timeless <timeless@mozdev.org>
parents:
28288
diff
changeset
|
7 cmdutil, |
81ad683278b8
strip: use absolute_import
timeless <timeless@mozdev.org>
parents:
28288
diff
changeset
|
8 error, |
81ad683278b8
strip: use absolute_import
timeless <timeless@mozdev.org>
parents:
28288
diff
changeset
|
9 hg, |
81ad683278b8
strip: use absolute_import
timeless <timeless@mozdev.org>
parents:
28288
diff
changeset
|
10 lock as lockmod, |
48116
5ced12cfa41b
errors: raise InputError on bad revset to revrange() iff provided by the user
Martin von Zweigbergk <martinvonz@google.com>
parents:
48096
diff
changeset
|
11 logcmdutil, |
44856
b7808443ed6a
mergestate: split out merge state handling code from main merge module
Augie Fackler <augie@google.com>
parents:
44452
diff
changeset
|
12 mergestate as mergestatemod, |
32897
799db2af824c
py3: convert keys of kwargs back to bytes using pycompat.byteskwargs()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32337
diff
changeset
|
13 pycompat, |
32337
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
29841
diff
changeset
|
14 registrar, |
28377
81ad683278b8
strip: use absolute_import
timeless <timeless@mozdev.org>
parents:
28288
diff
changeset
|
15 repair, |
81ad683278b8
strip: use absolute_import
timeless <timeless@mozdev.org>
parents:
28288
diff
changeset
|
16 scmutil, |
81ad683278b8
strip: use absolute_import
timeless <timeless@mozdev.org>
parents:
28288
diff
changeset
|
17 util, |
81ad683278b8
strip: use absolute_import
timeless <timeless@mozdev.org>
parents:
28288
diff
changeset
|
18 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
19 |
28377
81ad683278b8
strip: use absolute_import
timeless <timeless@mozdev.org>
parents:
28288
diff
changeset
|
20 release = lockmod.release |
19822
a194a33f8cb2
mq: prepare a strip extension for extraction
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
21 |
a194a33f8cb2
mq: prepare a strip extension for extraction
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
22 cmdtable = {} |
32337
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
29841
diff
changeset
|
23 command = registrar.command(cmdtable) |
19823
6fb14d21fe9d
strip: move checksubstate from mq to strip
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19822
diff
changeset
|
24 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
25 |
42490
3a1988e915f9
strip: remove unused excsuffix argument from checklocalchanges()
Martin von Zweigbergk <martinvonz@google.com>
parents:
42470
diff
changeset
|
26 def checklocalchanges(repo, force=False): |
22925
68df36ce3d8a
strip: make checklocalchanges() return full status tuple
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22057
diff
changeset
|
27 s = repo.status() |
19824
237e40b2c1ff
strip: move checklocalchanges from mq to strip
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19823
diff
changeset
|
28 if not force: |
42532
12243f15d53e
statecheck: added support for STATES
Taapas Agrawal <taapas2897@gmail.com>
parents:
42492
diff
changeset
|
29 cmdutil.checkunfinished(repo) |
42491
1474f5d84662
strip: use bailifchanged() instead of reimplementing it
Martin von Zweigbergk <martinvonz@google.com>
parents:
42490
diff
changeset
|
30 cmdutil.bailifchanged(repo) |
42532
12243f15d53e
statecheck: added support for STATES
Taapas Agrawal <taapas2897@gmail.com>
parents:
42492
diff
changeset
|
31 else: |
12243f15d53e
statecheck: added support for STATES
Taapas Agrawal <taapas2897@gmail.com>
parents:
42492
diff
changeset
|
32 cmdutil.checkunfinished(repo, skipmerge=True) |
22925
68df36ce3d8a
strip: make checklocalchanges() return full status tuple
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22057
diff
changeset
|
33 return s |
19824
237e40b2c1ff
strip: move checklocalchanges from mq to strip
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19823
diff
changeset
|
34 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
35 |
34574
05c2a9f37a1d
strip: factor out update target selection
Paul Morelle <paul.morelle@octobus.net>
parents:
33488
diff
changeset
|
36 def _findupdatetarget(repo, nodes): |
05c2a9f37a1d
strip: factor out update target selection
Paul Morelle <paul.morelle@octobus.net>
parents:
33488
diff
changeset
|
37 unode, p2 = repo.changelog.parents(nodes[0]) |
34621
5613fb1583d6
strip: take branch into account when selecting update target (issue5540)
Paul Morelle <paul.morelle@octobus.net>
parents:
34574
diff
changeset
|
38 currentbranch = repo[None].branch() |
34574
05c2a9f37a1d
strip: factor out update target selection
Paul Morelle <paul.morelle@octobus.net>
parents:
33488
diff
changeset
|
39 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
40 if ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
41 util.safehasattr(repo, b'mq') |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46113
diff
changeset
|
42 and p2 != repo.nullid |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
43 and p2 in [x.node for x in repo.mq.applied] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
44 ): |
34574
05c2a9f37a1d
strip: factor out update target selection
Paul Morelle <paul.morelle@octobus.net>
parents:
33488
diff
changeset
|
45 unode = p2 |
34621
5613fb1583d6
strip: take branch into account when selecting update target (issue5540)
Paul Morelle <paul.morelle@octobus.net>
parents:
34574
diff
changeset
|
46 elif currentbranch != repo[unode].branch(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
47 pwdir = b'parents(wdir())' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
48 revset = b'max(((parents(%ln::%r) + %r) - %ln::%r) and branch(%s))' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
49 branchtarget = repo.revs( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
50 revset, nodes, pwdir, pwdir, nodes, pwdir, currentbranch |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
51 ) |
34621
5613fb1583d6
strip: take branch into account when selecting update target (issue5540)
Paul Morelle <paul.morelle@octobus.net>
parents:
34574
diff
changeset
|
52 if branchtarget: |
5613fb1583d6
strip: take branch into account when selecting update target (issue5540)
Paul Morelle <paul.morelle@octobus.net>
parents:
34574
diff
changeset
|
53 cl = repo.changelog |
5613fb1583d6
strip: take branch into account when selecting update target (issue5540)
Paul Morelle <paul.morelle@octobus.net>
parents:
34574
diff
changeset
|
54 unode = cl.node(branchtarget.first()) |
34574
05c2a9f37a1d
strip: factor out update target selection
Paul Morelle <paul.morelle@octobus.net>
parents:
33488
diff
changeset
|
55 |
05c2a9f37a1d
strip: factor out update target selection
Paul Morelle <paul.morelle@octobus.net>
parents:
33488
diff
changeset
|
56 return unode |
05c2a9f37a1d
strip: factor out update target selection
Paul Morelle <paul.morelle@octobus.net>
parents:
33488
diff
changeset
|
57 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
58 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
59 def strip( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
60 ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
61 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
62 revs, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
63 update=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
64 backup=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
65 force=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
66 bookmarks=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
67 soft=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
68 ): |
32919
daceeed34ad2
strip: use context manager for locking in strip()
Martin von Zweigbergk <martinvonz@google.com>
parents:
32897
diff
changeset
|
69 with repo.wlock(), repo.lock(): |
19825
4b4997068143
strip: move the strip helper function for mq to strip
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19824
diff
changeset
|
70 |
4b4997068143
strip: move the strip helper function for mq to strip
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19824
diff
changeset
|
71 if update: |
4b4997068143
strip: move the strip helper function for mq to strip
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19824
diff
changeset
|
72 checklocalchanges(repo, force=force) |
34574
05c2a9f37a1d
strip: factor out update target selection
Paul Morelle <paul.morelle@octobus.net>
parents:
33488
diff
changeset
|
73 urev = _findupdatetarget(repo, revs) |
19825
4b4997068143
strip: move the strip helper function for mq to strip
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19824
diff
changeset
|
74 hg.clean(repo, urev) |
26748
5ba0a99ff27f
dirstate: make dirstate.write() callers pass transaction object to it
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26624
diff
changeset
|
75 repo.dirstate.write(repo.currenttransaction()) |
19825
4b4997068143
strip: move the strip helper function for mq to strip
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19824
diff
changeset
|
76 |
41798
8c42b4a3d447
strip: introduce a soft strip option
Boris Feld <boris.feld@octobus.net>
parents:
41397
diff
changeset
|
77 if soft: |
8c42b4a3d447
strip: introduce a soft strip option
Boris Feld <boris.feld@octobus.net>
parents:
41397
diff
changeset
|
78 repair.softstrip(ui, repo, revs, backup) |
8c42b4a3d447
strip: introduce a soft strip option
Boris Feld <boris.feld@octobus.net>
parents:
41397
diff
changeset
|
79 else: |
8c42b4a3d447
strip: introduce a soft strip option
Boris Feld <boris.feld@octobus.net>
parents:
41397
diff
changeset
|
80 repair.strip(ui, repo, revs, backup) |
21847
f6f122f4813b
strip: remove bookmarks after strip succeed (issue4295)
David Soria Parra <davidsp@fb.com>
parents:
20102
diff
changeset
|
81 |
26972
4b0c3df5d635
strip: renaming local variables
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
26748
diff
changeset
|
82 repomarks = repo._bookmarks |
27029
8279c5d116a0
strip: strip a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
26988
diff
changeset
|
83 if bookmarks: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
84 with repo.transaction(b'strip') as tr: |
27052
b9d0b45df7b2
strip: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
27030
diff
changeset
|
85 if repo._activebookmark in bookmarks: |
b9d0b45df7b2
strip: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
27030
diff
changeset
|
86 bookmarksmod.deactivate(repo) |
33488
eb344bbac18c
bookmark: use 'applychanges' when stripping
Boris Feld <boris.feld@octobus.net>
parents:
32920
diff
changeset
|
87 repomarks.applychanges(repo, tr, [(b, None) for b in bookmarks]) |
27872
a54afc4475d7
with: use a context manager for transaction in strip
Bryan O'Sullivan <bryano@fb.com>
parents:
27839
diff
changeset
|
88 for bookmark in sorted(bookmarks): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
89 ui.write(_(b"bookmark '%s' deleted\n") % bookmark) |
19826
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
90 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
91 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
92 @command( |
45865
d7a508a75d72
strip: move into core
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
45514
diff
changeset
|
93 b"debugstrip", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
94 [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
95 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
96 b'r', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
97 b'rev', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
98 [], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
99 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
100 b'strip specified revision (optional, ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
101 b'can specify revisions without this ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
102 b'option)' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
103 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
104 _(b'REV'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
105 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
106 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
107 b'f', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
108 b'force', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
109 None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
110 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
111 b'force removal of changesets, discard ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
112 b'uncommitted changes (no backup)' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
113 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
114 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
115 (b'', b'no-backup', None, _(b'do not save backup bundle')), |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
116 ( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
117 b'', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
118 b'nobackup', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
119 None, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
120 _(b'do not save backup bundle (DEPRECATED)'), |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45865
diff
changeset
|
121 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
122 (b'n', b'', None, _(b'ignored (DEPRECATED)')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
123 ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
124 b'k', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
125 b'keep', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
126 None, |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43105
diff
changeset
|
127 _(b"do not modify working directory during strip"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
128 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
129 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
130 b'B', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
131 b'bookmark', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
132 [], |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43105
diff
changeset
|
133 _(b"remove revs only reachable from given bookmark"), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
134 _(b'BOOKMARK'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
135 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
136 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
137 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
138 b'soft', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
139 None, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
140 _(b"simply drop changesets from visible history (EXPERIMENTAL)"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
141 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
142 ], |
45865
d7a508a75d72
strip: move into core
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
45514
diff
changeset
|
143 _(b'hg debugstrip [-k] [-f] [-B bookmark] [-r] REV...'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
144 helpcategory=command.CATEGORY_MAINTENANCE, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
145 ) |
45865
d7a508a75d72
strip: move into core
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
45514
diff
changeset
|
146 def debugstrip(ui, repo, *revs, **opts): |
19826
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
147 """strip changesets and all their descendants from the repository |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
148 |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
149 The strip command removes the specified changesets and all their |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
150 descendants. If the working directory has uncommitted changes, the |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
151 operation is aborted unless the --force flag is supplied, in which |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
152 case changes will be discarded. |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
153 |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
154 If a parent of the working directory is stripped, then the working |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
155 directory will automatically be updated to the most recent |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
156 available ancestor of the stripped parent after the operation |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
157 completes. |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
158 |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
159 Any stripped changesets are stored in ``.hg/strip-backup`` as a |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
160 bundle (see :hg:`help bundle` and :hg:`help unbundle`). They can |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
161 be restored by running :hg:`unbundle .hg/strip-backup/BUNDLE`, |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
162 where BUNDLE is the bundle file created by the strip. Note that |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
163 the local revision numbers will in general be different after the |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
164 restore. |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
165 |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
166 Use the --no-backup option to discard the backup bundle once the |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
167 operation completes. |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
168 |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
169 Strip is not a history-rewriting operation and can be used on |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
170 changesets in the public phase. But if the stripped changesets have |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
171 been pushed to a remote repository you will likely pull them again. |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
172 |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
173 Return 0 on success. |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
174 """ |
32897
799db2af824c
py3: convert keys of kwargs back to bytes using pycompat.byteskwargs()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32337
diff
changeset
|
175 opts = pycompat.byteskwargs(opts) |
22057
445472225ccd
strip: remove -b/--backup codepaths
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
21854
diff
changeset
|
176 backup = True |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
177 if opts.get(b'no_backup') or opts.get(b'nobackup'): |
22057
445472225ccd
strip: remove -b/--backup codepaths
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
21854
diff
changeset
|
178 backup = False |
19826
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
179 |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
180 cl = repo.changelog |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
181 revs = list(revs) + opts.get(b'rev') |
48116
5ced12cfa41b
errors: raise InputError on bad revset to revrange() iff provided by the user
Martin von Zweigbergk <martinvonz@google.com>
parents:
48096
diff
changeset
|
182 revs = set(logcmdutil.revrange(repo, revs)) |
19826
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
183 |
27839
7ec3cb246291
with: use context manager for wlock in shelve stripcmd
Bryan O'Sullivan <bryano@fb.com>
parents:
27052
diff
changeset
|
184 with repo.wlock(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
185 bookmarks = set(opts.get(b'bookmark')) |
27029
8279c5d116a0
strip: strip a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
26988
diff
changeset
|
186 if bookmarks: |
26972
4b0c3df5d635
strip: renaming local variables
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
26748
diff
changeset
|
187 repomarks = repo._bookmarks |
27029
8279c5d116a0
strip: strip a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
26988
diff
changeset
|
188 if not bookmarks.issubset(repomarks): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
189 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
190 _(b"bookmark '%s' not found") |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
191 % b','.join(sorted(bookmarks - set(repomarks.keys()))) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
192 ) |
20096
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
193 |
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
194 # If the requested bookmark is not the only one pointing to a |
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
195 # a revision we have to only delete the bookmark and not strip |
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
196 # anything. revsets cannot detect that case. |
27029
8279c5d116a0
strip: strip a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
26988
diff
changeset
|
197 nodetobookmarks = {} |
43105
649d3ac37a12
py3: define and use pycompat.iteritems() for hgext/
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43089
diff
changeset
|
198 for mark, node in pycompat.iteritems(repomarks): |
27029
8279c5d116a0
strip: strip a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
26988
diff
changeset
|
199 nodetobookmarks.setdefault(node, []).append(mark) |
8279c5d116a0
strip: strip a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
26988
diff
changeset
|
200 for marks in nodetobookmarks.values(): |
8279c5d116a0
strip: strip a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
26988
diff
changeset
|
201 if bookmarks.issuperset(marks): |
38131
46c2b19a1263
scmutil: move repair.stripbmrevset as scmutil.bookmarkrevs (API)
David Demelier <markand@malikania.fr>
parents:
36341
diff
changeset
|
202 rsrevs = scmutil.bookmarkrevs(repo, marks[0]) |
27030
cf9ed6d32ccb
strip: changing bookmark argument to be a list
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
27029
diff
changeset
|
203 revs.update(set(rsrevs)) |
20096
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
204 if not revs: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
205 with repo.lock(), repo.transaction(b'bookmark') as tr: |
33488
eb344bbac18c
bookmark: use 'applychanges' when stripping
Boris Feld <boris.feld@octobus.net>
parents:
32920
diff
changeset
|
206 bmchanges = [(b, None) for b in bookmarks] |
eb344bbac18c
bookmark: use 'applychanges' when stripping
Boris Feld <boris.feld@octobus.net>
parents:
32920
diff
changeset
|
207 repomarks.applychanges(repo, tr, bmchanges) |
32920
8dbcb66ac160
strip: use context manager for locking and transaction in stripcmd()
Martin von Zweigbergk <martinvonz@google.com>
parents:
32919
diff
changeset
|
208 for bookmark in sorted(bookmarks): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
209 ui.write(_(b"bookmark '%s' deleted\n") % bookmark) |
20096
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
210 |
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
211 if not revs: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
212 raise error.Abort(_(b'empty revision set')) |
20096
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
213 |
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
214 descendants = set(cl.descendants(revs)) |
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
215 strippedrevs = revs.union(descendants) |
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
216 roots = revs.difference(descendants) |
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
217 |
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
218 # if one of the wdir parent is stripped we'll need |
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
219 # to update away to an earlier revision |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
220 update = any( |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46113
diff
changeset
|
221 p != repo.nullid and cl.rev(p) in strippedrevs |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
222 for p in repo.dirstate.parents() |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
223 ) |
20096
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
224 |
44452
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
43117
diff
changeset
|
225 rootnodes = {cl.node(r) for r in roots} |
19826
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
226 |
20096
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
227 q = getattr(repo, 'mq', None) |
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
228 if q is not None and q.applied: |
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
229 # refresh queue state if we're about to strip |
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
230 # applied patches |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
231 if cl.rev(repo.lookup(b'qtip')) in strippedrevs: |
20096
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
232 q.applieddirty = True |
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
233 start = 0 |
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
234 end = len(q.applied) |
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
235 for i, statusentry in enumerate(q.applied): |
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
236 if statusentry.node in rootnodes: |
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
237 # if one of the stripped roots is an applied |
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
238 # patch, only part of the queue is stripped |
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
239 start = i |
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
240 break |
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
241 del q.applied[start:end] |
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
242 q.savedirty() |
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
243 |
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
244 revs = sorted(rootnodes) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
245 if update and opts.get(b'keep'): |
34574
05c2a9f37a1d
strip: factor out update target selection
Paul Morelle <paul.morelle@octobus.net>
parents:
33488
diff
changeset
|
246 urev = _findupdatetarget(repo, revs) |
20102
04eaa8eec6a0
strip.stripcmd: remove redundant wlock acquire/release
Siddharth Agarwal <sid0@fb.com>
parents:
20101
diff
changeset
|
247 uctx = repo[urev] |
20096
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
248 |
20102
04eaa8eec6a0
strip.stripcmd: remove redundant wlock acquire/release
Siddharth Agarwal <sid0@fb.com>
parents:
20101
diff
changeset
|
249 # only reset the dirstate for files that would actually change |
04eaa8eec6a0
strip.stripcmd: remove redundant wlock acquire/release
Siddharth Agarwal <sid0@fb.com>
parents:
20101
diff
changeset
|
250 # between the working context and uctx |
45509
2bc978921e8a
strip: with --keep, consider all revs "removed" from the wcp (issue6270)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44856
diff
changeset
|
251 descendantrevs = repo.revs(b"only(., %d)", uctx.rev()) |
20102
04eaa8eec6a0
strip.stripcmd: remove redundant wlock acquire/release
Siddharth Agarwal <sid0@fb.com>
parents:
20101
diff
changeset
|
252 changedfiles = [] |
04eaa8eec6a0
strip.stripcmd: remove redundant wlock acquire/release
Siddharth Agarwal <sid0@fb.com>
parents:
20101
diff
changeset
|
253 for rev in descendantrevs: |
04eaa8eec6a0
strip.stripcmd: remove redundant wlock acquire/release
Siddharth Agarwal <sid0@fb.com>
parents:
20101
diff
changeset
|
254 # blindly reset the files, regardless of what actually changed |
04eaa8eec6a0
strip.stripcmd: remove redundant wlock acquire/release
Siddharth Agarwal <sid0@fb.com>
parents:
20101
diff
changeset
|
255 changedfiles.extend(repo[rev].files()) |
20096
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
256 |
20102
04eaa8eec6a0
strip.stripcmd: remove redundant wlock acquire/release
Siddharth Agarwal <sid0@fb.com>
parents:
20101
diff
changeset
|
257 # reset files that only changed in the dirstate too |
04eaa8eec6a0
strip.stripcmd: remove redundant wlock acquire/release
Siddharth Agarwal <sid0@fb.com>
parents:
20101
diff
changeset
|
258 dirstate = repo.dirstate |
48096
97c5d1c22489
dirstate-item: use `maybe_clean` instead of `state` in `strip`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
259 dirchanges = [ |
97c5d1c22489
dirstate-item: use `maybe_clean` instead of `state` in `strip`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
260 f for f in dirstate if not dirstate.get_entry(f).maybe_clean |
97c5d1c22489
dirstate-item: use `maybe_clean` instead of `state` in `strip`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
261 ] |
20102
04eaa8eec6a0
strip.stripcmd: remove redundant wlock acquire/release
Siddharth Agarwal <sid0@fb.com>
parents:
20101
diff
changeset
|
262 changedfiles.extend(dirchanges) |
20096
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
263 |
20102
04eaa8eec6a0
strip.stripcmd: remove redundant wlock acquire/release
Siddharth Agarwal <sid0@fb.com>
parents:
20101
diff
changeset
|
264 repo.dirstate.rebuild(urev, uctx.manifest(), changedfiles) |
26748
5ba0a99ff27f
dirstate: make dirstate.write() callers pass transaction object to it
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26624
diff
changeset
|
265 repo.dirstate.write(repo.currenttransaction()) |
24709
69154e0ae384
strip: properly clear resolve state with --keep (issue4593)
Matt Mackall <mpm@selenic.com>
parents:
24471
diff
changeset
|
266 |
69154e0ae384
strip: properly clear resolve state with --keep (issue4593)
Matt Mackall <mpm@selenic.com>
parents:
24471
diff
changeset
|
267 # clear resolve state |
45490
0ce6af73f481
mergestate: make some callers not pass pointless node argument
Martin von Zweigbergk <martinvonz@google.com>
parents:
44856
diff
changeset
|
268 mergestatemod.mergestate.clean(repo) |
24709
69154e0ae384
strip: properly clear resolve state with --keep (issue4593)
Matt Mackall <mpm@selenic.com>
parents:
24471
diff
changeset
|
269 |
20102
04eaa8eec6a0
strip.stripcmd: remove redundant wlock acquire/release
Siddharth Agarwal <sid0@fb.com>
parents:
20101
diff
changeset
|
270 update = False |
20096
88e172871ad7
strip: hold wlock for entire duration
Siddharth Agarwal <sid0@fb.com>
parents:
20009
diff
changeset
|
271 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
272 strip( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
273 ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
274 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
275 revs, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
276 backup=backup, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
277 update=update, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
278 force=opts.get(b'force'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
279 bookmarks=bookmarks, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
280 soft=opts[b'soft'], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42532
diff
changeset
|
281 ) |
19826
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
282 |
4b1cbcfdabf7
mq: extract strip function as its standalone extension (issue3824)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
19825
diff
changeset
|
283 return 0 |