bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
| 
1662.1.9
by Martin Pool
 Give a clear error for bzr status of an unversioned, nonexistent file. (Malone #3619)  | 
1  | 
# Copyright (C) 2005, 2006 Canonical Ltd
 | 
| 
1185.13.2
by Robert Collins
 Merge Aarons conflict plugin for 0.1rc1  | 
2  | 
#
 | 
| 
362
by Martin Pool
 - Import stat-cache code  | 
3  | 
# This program is free software; you can redistribute it and/or modify
 | 
4  | 
# it under the terms of the GNU General Public License as published by
 | 
|
5  | 
# the Free Software Foundation; either version 2 of the License, or
 | 
|
6  | 
# (at your option) any later version.
 | 
|
| 
1185.13.2
by Robert Collins
 Merge Aarons conflict plugin for 0.1rc1  | 
7  | 
#
 | 
| 
362
by Martin Pool
 - Import stat-cache code  | 
8  | 
# This program is distributed in the hope that it will be useful,
 | 
9  | 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|
10  | 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
|
11  | 
# GNU General Public License for more details.
 | 
|
| 
1185.13.2
by Robert Collins
 Merge Aarons conflict plugin for 0.1rc1  | 
12  | 
#
 | 
| 
362
by Martin Pool
 - Import stat-cache code  | 
13  | 
# You should have received a copy of the GNU General Public License
 | 
14  | 
# along with this program; if not, write to the Free Software
 | 
|
15  | 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 | 
|
16  | 
||
| 
1185.13.2
by Robert Collins
 Merge Aarons conflict plugin for 0.1rc1  | 
17  | 
import sys  | 
| 
1534.4.35
by Robert Collins
 Give branch its own basis tree and last_revision methods; deprecated branch.working_tree()  | 
18  | 
|
| 
1662.1.9
by Martin Pool
 Give a clear error for bzr status of an unversioned, nonexistent file. (Malone #3619)  | 
19  | 
from bzrlib.diff import _raise_if_nonexistent  | 
| 
1773.4.1
by Martin Pool
 Add pyflakes makefile target; fix many warnings  | 
20  | 
import bzrlib.errors as errors  | 
| 
1185.12.27
by Aaron Bentley
 Use line log for pending merges  | 
21  | 
from bzrlib.log import line_log  | 
| 
1534.4.35
by Robert Collins
 Give branch its own basis tree and last_revision methods; deprecated branch.working_tree()  | 
22  | 
from bzrlib.osutils import is_inside_any  | 
| 
1773.4.1
by Martin Pool
 Add pyflakes makefile target; fix many warnings  | 
23  | 
from bzrlib.symbol_versioning import (deprecated_function,  | 
24  | 
zero_eight,  | 
|
25  | 
        )
 | 
|
| 
362
by Martin Pool
 - Import stat-cache code  | 
26  | 
|
| 
1185.33.70
by Martin Pool
 Refactor status display code.  | 
27  | 
# TODO: when showing single-line logs, truncate to the width of the terminal
 | 
28  | 
# if known, but only if really going to the terminal (not into a file)
 | 
|
29  | 
||
| 
465
by Martin Pool
 - Move show_status() out of Branch into a new function in  | 
30  | 
|
| 
1551.2.9
by Aaron Bentley
 Fix status to work with checkouts  | 
31  | 
@deprecated_function(zero_eight)  | 
| 
1773.1.2
by Robert Collins
 Remove --all option from status.  | 
32  | 
def show_status(branch, show_unchanged=None,  | 
| 
483
by Martin Pool
 - change 'file_list' to more explanatory 'specific_files'  | 
33  | 
specific_files=None,  | 
| 
915
by Martin Pool
 - add simple test case for bzr status  | 
34  | 
show_ids=False,  | 
| 
974.1.48
by Aaron Bentley
 Status command shows pending merges  | 
35  | 
to_file=None,  | 
| 
1185.1.35
by Robert Collins
 Heikki Paajanen's status -r patch  | 
36  | 
show_pending=True,  | 
37  | 
revision=None):  | 
|
| 
1185.33.70
by Martin Pool
 Refactor status display code.  | 
38  | 
"""Display summary of changes.  | 
39  | 
||
| 
1551.2.11
by Aaron Bentley
 Niced up the documentation  | 
40  | 
    Please use show_tree_status instead.
 | 
41  | 
||
| 
1185.33.70
by Martin Pool
 Refactor status display code.  | 
42  | 
    By default this compares the working tree to a previous revision. 
 | 
43  | 
    If the revision argument is given, summarizes changes between the 
 | 
|
44  | 
    working tree and another, or between two revisions.
 | 
|
45  | 
||
46  | 
    The result is written out as Unicode and to_file should be able 
 | 
|
47  | 
    to encode that.
 | 
|
| 
465
by Martin Pool
 - Move show_status() out of Branch into a new function in  | 
48  | 
|
| 
1185.3.1
by Martin Pool
 - docstring fix from Magnus Therning  | 
49  | 
    show_unchanged
 | 
50  | 
        If set, includes unchanged files.
 | 
|
| 
465
by Martin Pool
 - Move show_status() out of Branch into a new function in  | 
51  | 
|
| 
483
by Martin Pool
 - change 'file_list' to more explanatory 'specific_files'  | 
52  | 
    specific_files
 | 
| 
465
by Martin Pool
 - Move show_status() out of Branch into a new function in  | 
53  | 
        If set, only show the status of files in this list.
 | 
| 
915
by Martin Pool
 - add simple test case for bzr status  | 
54  | 
|
| 
1185.3.1
by Martin Pool
 - docstring fix from Magnus Therning  | 
55  | 
    show_ids
 | 
56  | 
        If set, includes each file's id.
 | 
|
57  | 
||
| 
915
by Martin Pool
 - add simple test case for bzr status  | 
58  | 
    to_file
 | 
59  | 
        If set, write to this file (default stdout.)
 | 
|
| 
1185.3.1
by Martin Pool
 - docstring fix from Magnus Therning  | 
60  | 
|
61  | 
    show_pending
 | 
|
62  | 
        If set, write pending merges.
 | 
|
| 
1092.3.4
by Robert Collins
 update symlink branch to integration  | 
63  | 
|
| 
1185.1.35
by Robert Collins
 Heikki Paajanen's status -r patch  | 
64  | 
    revision
 | 
65  | 
        If None the compare latest revision with working tree
 | 
|
66  | 
        If one revision show compared it with working tree.
 | 
|
67  | 
        If two revisions show status between first and second.
 | 
|
| 
465
by Martin Pool
 - Move show_status() out of Branch into a new function in  | 
68  | 
    """
 | 
| 
1551.2.9
by Aaron Bentley
 Fix status to work with checkouts  | 
69  | 
show_tree_status(branch.bzrdir.open_workingtree(), show_unchanged,  | 
70  | 
specific_files, show_ids, to_file, show_pending, revision)  | 
|
71  | 
||
| 
1551.2.11
by Aaron Bentley
 Niced up the documentation  | 
72  | 
|
| 
1773.1.2
by Robert Collins
 Remove --all option from status.  | 
73  | 
def show_tree_status(wt, show_unchanged=None,  | 
| 
1551.2.9
by Aaron Bentley
 Fix status to work with checkouts  | 
74  | 
specific_files=None,  | 
75  | 
show_ids=False,  | 
|
76  | 
to_file=None,  | 
|
77  | 
show_pending=True,  | 
|
78  | 
revision=None):  | 
|
79  | 
"""Display summary of changes.  | 
|
80  | 
||
81  | 
    By default this compares the working tree to a previous revision. 
 | 
|
82  | 
    If the revision argument is given, summarizes changes between the 
 | 
|
83  | 
    working tree and another, or between two revisions.
 | 
|
84  | 
||
85  | 
    The result is written out as Unicode and to_file should be able 
 | 
|
86  | 
    to encode that.
 | 
|
87  | 
||
| 
1662.1.9
by Martin Pool
 Give a clear error for bzr status of an unversioned, nonexistent file. (Malone #3619)  | 
88  | 
    If showing the status of a working tree, extra information is included
 | 
89  | 
    about unknown files, conflicts, and pending merges.
 | 
|
90  | 
||
| 
1773.1.2
by Robert Collins
 Remove --all option from status.  | 
91  | 
    :param show_unchanged: Deprecated parameter. If set, includes unchanged 
 | 
92  | 
        files.
 | 
|
93  | 
    :param specific_files: If set, a list of filenames whose status should be
 | 
|
94  | 
        shown.  It is an error to give a filename that is not in the working 
 | 
|
| 
1662.1.9
by Martin Pool
 Give a clear error for bzr status of an unversioned, nonexistent file. (Malone #3619)  | 
95  | 
        tree, or in the working inventory or in the basis inventory.
 | 
| 
1773.1.2
by Robert Collins
 Remove --all option from status.  | 
96  | 
    :param show_ids: If set, includes each file's id.
 | 
97  | 
    :param to_file: If set, write to this file (default stdout.)
 | 
|
98  | 
    :param show_pending: If set, write pending merges.
 | 
|
99  | 
    :param revision: If None the compare latest revision with working tree
 | 
|
100  | 
        If not None it must be a RevisionSpec list.
 | 
|
| 
1551.2.9
by Aaron Bentley
 Fix status to work with checkouts  | 
101  | 
        If one revision show compared it with working tree.
 | 
102  | 
        If two revisions show status between first and second.
 | 
|
103  | 
    """
 | 
|
| 
1773.1.2
by Robert Collins
 Remove --all option from status.  | 
104  | 
if show_unchanged is not None:  | 
105  | 
warn("show_status_trees with show_unchanged has been deprecated "  | 
|
106  | 
"since bzrlib 0.9", DeprecationWarning, stacklevel=2)  | 
|
107  | 
||
108  | 
if to_file is None:  | 
|
| 
915
by Martin Pool
 - add simple test case for bzr status  | 
109  | 
to_file = sys.stdout  | 
| 
580
by Martin Pool
 - Use explicit lock methods on a branch, rather than doing it  | 
110  | 
|
| 
1551.2.9
by Aaron Bentley
 Fix status to work with checkouts  | 
111  | 
wt.lock_read()  | 
| 
580
by Martin Pool
 - Use explicit lock methods on a branch, rather than doing it  | 
112  | 
try:  | 
| 
1185.1.35
by Robert Collins
 Heikki Paajanen's status -r patch  | 
113  | 
new_is_working_tree = True  | 
114  | 
if revision is None:  | 
|
| 
1551.2.9
by Aaron Bentley
 Fix status to work with checkouts  | 
115  | 
new = wt  | 
| 
1534.4.35
by Robert Collins
 Give branch its own basis tree and last_revision methods; deprecated branch.working_tree()  | 
116  | 
old = new.basis_tree()  | 
| 
1185.1.35
by Robert Collins
 Heikki Paajanen's status -r patch  | 
117  | 
elif len(revision) > 0:  | 
118  | 
try:  | 
|
| 
1551.2.9
by Aaron Bentley
 Fix status to work with checkouts  | 
119  | 
rev_id = revision[0].in_history(wt.branch).rev_id  | 
120  | 
old = wt.branch.repository.revision_tree(rev_id)  | 
|
| 
1773.4.1
by Martin Pool
 Add pyflakes makefile target; fix many warnings  | 
121  | 
except errors.NoSuchRevision, e:  | 
122  | 
raise errors.BzrCommandError(str(e))  | 
|
| 
1540.2.6
by Robey Pointer
 make 'log' and 'status' treat '-r N..' as implicitly '-r N..-1'  | 
123  | 
if (len(revision) > 1) and (revision[1].spec is not None):  | 
| 
1185.1.35
by Robert Collins
 Heikki Paajanen's status -r patch  | 
124  | 
try:  | 
| 
1551.2.9
by Aaron Bentley
 Fix status to work with checkouts  | 
125  | 
rev_id = revision[1].in_history(wt.branch).rev_id  | 
126  | 
new = wt.branch.repository.revision_tree(rev_id)  | 
|
| 
1185.1.35
by Robert Collins
 Heikki Paajanen's status -r patch  | 
127  | 
new_is_working_tree = False  | 
| 
1773.4.1
by Martin Pool
 Add pyflakes makefile target; fix many warnings  | 
128  | 
except errors.NoSuchRevision, e:  | 
129  | 
raise errors.BzrCommandError(str(e))  | 
|
| 
1185.1.35
by Robert Collins
 Heikki Paajanen's status -r patch  | 
130  | 
else:  | 
| 
1551.2.9
by Aaron Bentley
 Fix status to work with checkouts  | 
131  | 
new = wt  | 
| 
1662.1.9
by Martin Pool
 Give a clear error for bzr status of an unversioned, nonexistent file. (Malone #3619)  | 
132  | 
_raise_if_nonexistent(specific_files, old, new)  | 
| 
1852.10.3
by Robert Collins
 Remove all uses of compare_trees and replace with Tree.changes_from throughout bzrlib.  | 
133  | 
delta = new.changes_from(old, want_unchanged=show_unchanged,  | 
| 
580
by Martin Pool
 - Use explicit lock methods on a branch, rather than doing it  | 
134  | 
specific_files=specific_files)  | 
| 
915
by Martin Pool
 - add simple test case for bzr status  | 
135  | 
delta.show(to_file,  | 
136  | 
show_ids=show_ids,  | 
|
| 
580
by Martin Pool
 - Use explicit lock methods on a branch, rather than doing it  | 
137  | 
show_unchanged=show_unchanged)  | 
138  | 
||
| 
1852.12.1
by Robert Collins
 Status should not special case conflicts on the tree type, rather just show the new trees conflicts regardless.  | 
139  | 
list_paths('unknown', new.unknowns(), specific_files, to_file)  | 
140  | 
conflict_title = False  | 
|
141  | 
        # show the new conflicts only for now. XXX: get them from the delta.
 | 
|
142  | 
for conflict in new.conflicts():  | 
|
143  | 
if conflict_title is False:  | 
|
144  | 
print >> to_file, "conflicts:"  | 
|
145  | 
conflict_title = True  | 
|
146  | 
print >> to_file, " %s" % conflict  | 
|
| 
1185.33.70
by Martin Pool
 Refactor status display code.  | 
147  | 
if new_is_working_tree and show_pending:  | 
148  | 
show_pending_merges(new, to_file)  | 
|
| 
580
by Martin Pool
 - Use explicit lock methods on a branch, rather than doing it  | 
149  | 
finally:  | 
| 
1551.2.9
by Aaron Bentley
 Fix status to work with checkouts  | 
150  | 
wt.unlock()  | 
| 
1185.33.70
by Martin Pool
 Refactor status display code.  | 
151  | 
|
152  | 
def show_pending_merges(new, to_file):  | 
|
153  | 
"""Write out a display of pending merges in a working tree."""  | 
|
154  | 
pending = new.pending_merges()  | 
|
155  | 
branch = new.branch  | 
|
156  | 
if len(pending) == 0:  | 
|
157  | 
        return
 | 
|
158  | 
print >>to_file, 'pending merges:'  | 
|
159  | 
last_revision = branch.last_revision()  | 
|
160  | 
if last_revision is not None:  | 
|
| 
1185.67.2
by Aaron Bentley
 Renamed Branch.storage to Branch.repository  | 
161  | 
ignore = set(branch.repository.get_ancestry(last_revision))  | 
| 
1185.33.70
by Martin Pool
 Refactor status display code.  | 
162  | 
else:  | 
| 
1551.6.19
by Aaron Bentley
 Fix pending merge status on empty trees  | 
163  | 
ignore = set([None])  | 
| 
1185.33.70
by Martin Pool
 Refactor status display code.  | 
164  | 
for merge in new.pending_merges():  | 
165  | 
ignore.add(merge)  | 
|
166  | 
try:  | 
|
| 
1861.1.1
by Adeodato Simó
 Really use terminal_width() for pending-merge display. r1707 mentioned  | 
167  | 
from bzrlib.osutils import terminal_width  | 
168  | 
width = terminal_width()  | 
|
| 
1185.67.2
by Aaron Bentley
 Renamed Branch.storage to Branch.repository  | 
169  | 
m_revision = branch.repository.get_revision(merge)  | 
| 
1861.1.1
by Adeodato Simó
 Really use terminal_width() for pending-merge display. r1707 mentioned  | 
170  | 
print >> to_file, ' ', line_log(m_revision, width - 3)  | 
| 
1185.67.2
by Aaron Bentley
 Renamed Branch.storage to Branch.repository  | 
171  | 
inner_merges = branch.repository.get_ancestry(merge)  | 
| 
1668.1.14
by Martin Pool
 merge olaf - InvalidRevisionId fixes  | 
172  | 
assert inner_merges[0] == None  | 
173  | 
inner_merges.pop(0)  | 
|
| 
1185.33.70
by Martin Pool
 Refactor status display code.  | 
174  | 
inner_merges.reverse()  | 
175  | 
for mmerge in inner_merges:  | 
|
176  | 
if mmerge in ignore:  | 
|
177  | 
                    continue
 | 
|
| 
1185.67.2
by Aaron Bentley
 Renamed Branch.storage to Branch.repository  | 
178  | 
mm_revision = branch.repository.get_revision(mmerge)  | 
| 
1861.1.1
by Adeodato Simó
 Really use terminal_width() for pending-merge display. r1707 mentioned  | 
179  | 
print >> to_file, ' ', line_log(mm_revision, width - 5)  | 
| 
1185.33.70
by Martin Pool
 Refactor status display code.  | 
180  | 
ignore.add(mmerge)  | 
| 
1773.4.1
by Martin Pool
 Add pyflakes makefile target; fix many warnings  | 
181  | 
except errors.NoSuchRevision:  | 
182  | 
print >> to_file, ' ', merge  | 
|
| 
580
by Martin Pool
 - Use explicit lock methods on a branch, rather than doing it  | 
183  | 
|
| 
1185.14.11
by Aaron Bentley
 moved conflict listing into status and stopped monkey-patching  | 
184  | 
def list_paths(header, paths, specific_files, to_file):  | 
185  | 
done_header = False  | 
|
186  | 
for path in paths:  | 
|
187  | 
if specific_files and not is_inside_any(specific_files, path):  | 
|
188  | 
            continue
 | 
|
189  | 
if not done_header:  | 
|
190  | 
print >>to_file, '%s:' % header  | 
|
191  | 
done_header = True  | 
|
192  | 
print >>to_file, ' ', path  |