/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/status.py

  • Committer: Jelmer Vernooij
  • Date: 2009-02-25 15:36:48 UTC
  • mfrom: (4048 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4050.
  • Revision ID: jelmer@samba.org-20090225153648-7r5mk20nr9dttqbf
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
                     versioned=False):
46
46
    """Display summary of changes.
47
47
 
48
 
    By default this compares the working tree to a previous revision. 
49
 
    If the revision argument is given, summarizes changes between the 
 
48
    By default this compares the working tree to a previous revision.
 
49
    If the revision argument is given, summarizes changes between the
50
50
    working tree and another, or between two revisions.
51
51
 
52
 
    The result is written out as Unicode and to_file should be able 
 
52
    The result is written out as Unicode and to_file should be able
53
53
    to encode that.
54
54
 
55
55
    If showing the status of a working tree, extra information is included
56
56
    about unknown files, conflicts, and pending merges.
57
57
 
58
 
    :param show_unchanged: Deprecated parameter. If set, includes unchanged 
 
58
    :param show_unchanged: Deprecated parameter. If set, includes unchanged
59
59
        files.
60
60
    :param specific_files: If set, a list of filenames whose status should be
61
 
        shown.  It is an error to give a filename that is not in the working 
 
61
        shown.  It is an error to give a filename that is not in the working
62
62
        tree, or in the working inventory or in the basis inventory.
63
63
    :param show_ids: If set, includes each file's id.
64
64
    :param to_file: If set, write to this file (default stdout.)
78
78
 
79
79
    if to_file is None:
80
80
        to_file = sys.stdout
81
 
    
 
81
 
82
82
    wt.lock_read()
83
83
    try:
84
84
        new_is_working_tree = True
103
103
        old.lock_read()
104
104
        new.lock_read()
105
105
        try:
106
 
            _raise_if_nonexistent(specific_files, old, new)
 
106
            specific_files, nonexistents \
 
107
                = _filter_nonexistent(specific_files, old, new)
107
108
            want_unversioned = not versioned
108
109
            if short:
109
110
                changes = new.iter_changes(old, show_unchanged, specific_files,
137
138
                else:
138
139
                    prefix = ' '
139
140
                to_file.write("%s %s\n" % (prefix, conflict))
 
141
            # Show files that were requested but don't exist (and are
 
142
            # not versioned).  We don't involve delta in this; these
 
143
            # paths are really the province of just the status
 
144
            # command, since they have more to do with how it was
 
145
            # invoked than with the tree it's operating on.
 
146
            if nonexistents and not short:
 
147
                to_file.write("nonexistent:\n")
 
148
            for nonexistent in nonexistents:
 
149
                # We could calculate prefix outside the loop but, given
 
150
                # how rarely this ought to happen, it's OK and arguably
 
151
                # slightly faster to do it here (ala conflicts above)
 
152
                if short:
 
153
                    prefix = 'X  '
 
154
                else:
 
155
                    prefix = ' '
 
156
                to_file.write("%s %s\n" % (prefix, nonexistent))
140
157
            if (new_is_working_tree and show_pending):
141
158
                show_pending_merges(new, to_file, short, verbose=verbose)
142
159
        finally:
143
160
            old.unlock()
144
161
            new.unlock()
 
162
            if nonexistents:
 
163
              raise errors.PathsDoNotExist(nonexistents)
145
164
    finally:
146
165
        wt.unlock()
147
166
 
254
273
            to_file.write(sub_prefix + log_message + '\n')
255
274
 
256
275
 
257
 
def _raise_if_nonexistent(paths, old_tree, new_tree):
258
 
    """Complain if paths are not in either inventory or tree.
259
 
 
260
 
    It's OK with the files exist in either tree's inventory, or 
261
 
    if they exist in the tree but are not versioned.
262
 
    
 
276
def _filter_nonexistent(orig_paths, old_tree, new_tree):
 
277
    """Convert orig_paths to two sorted lists and return them.
 
278
 
 
279
    The first is orig_paths paths minus the items in the second list,
 
280
    and the second list is paths that are not in either inventory or
 
281
    tree (they don't qualify if they exist in the tree's inventory, or
 
282
    if they exist in the tree but are not versioned.)
 
283
 
 
284
    If either of the two lists is empty, return it as an empty list.
 
285
 
263
286
    This can be used by operations such as bzr status that can accept
264
287
    unknown or ignored files.
265
288
    """
266
 
    mutter("check paths: %r", paths)
267
 
    if not paths:
268
 
        return
269
 
    s = old_tree.filter_unversioned_files(paths)
 
289
    mutter("check paths: %r", orig_paths)
 
290
    if not orig_paths:
 
291
        return orig_paths, []
 
292
    s = old_tree.filter_unversioned_files(orig_paths)
270
293
    s = new_tree.filter_unversioned_files(s)
271
 
    s = [path for path in s if not new_tree.has_filename(path)]
272
 
    if s:
273
 
        raise errors.PathsDoNotExist(sorted(s))
274
 
 
275
 
 
 
294
    nonexistent = [path for path in s if not new_tree.has_filename(path)]
 
295
    remaining   = [path for path in orig_paths if not path in nonexistent]
 
296
    # Sorting the 'remaining' list doesn't have much effect in
 
297
    # practice, since the various status output sections will sort
 
298
    # their groups individually.  But for consistency of this
 
299
    # function's API, it's better to sort both than just 'nonexistent'.
 
300
    return sorted(remaining), sorted(nonexistent)