25
25
from inventory import Inventory
26
26
from trace import mutter, note
27
from tree import Tree, EmptyTree, RevisionTree
27
from tree import Tree, EmptyTree, RevisionTree, WorkingTree
28
28
from inventory import InventoryEntry, Inventory
29
29
from osutils import isdir, quotefn, isfile, uuid, sha_file, username, \
30
30
format_date, compact_date, pumpfile, user_email, rand_bytes, splitpath, \
43
43
def find_branch(f, **args):
44
if f and (f.startswith('http://') or f.startswith('https://')):
44
if f.startswith('http://') or f.startswith('https://'):
45
45
import remotebranch
46
46
return remotebranch.RemoteBranch(f, **args)
213
210
and binary. binary files are untranslated byte streams. Text
214
211
control files are stored with Unix newlines and in UTF-8, even
215
212
if the platform or locale defaults are different.
217
Controlfiles should almost never be opened in write mode but
218
rather should be atomically copied and replaced using atomicfile.
221
215
fn = self.controlfilename(file_or_path)
919
def show_status(self, show_all=False, file_list=None):
920
"""Display single-line status for non-ignored working files.
922
The list is show sorted in order by file name.
924
>>> b = ScratchBranch(files=['foo', 'foo~'])
930
>>> b.commit("add foo")
932
>>> os.unlink(b.abspath('foo'))
936
self._need_readlock()
938
# We have to build everything into a list first so that it can
939
# sorted by name, incorporating all the different sources.
941
# FIXME: Rather than getting things in random order and then sorting,
942
# just step through in order.
944
# Interesting case: the old ID for a file has been removed,
945
# but a new file has been created under that name.
947
old = self.basis_tree()
948
new = self.working_tree()
950
items = diff_trees(old, new)
951
# We want to filter out only if any file was provided in the file_list.
952
if isinstance(file_list, list) and len(file_list):
953
items = [item for item in items if item[3] in file_list]
955
for fs, fid, oldname, newname, kind in items:
957
show_status(fs, kind,
958
oldname + ' => ' + newname)
959
elif fs == 'A' or fs == 'M':
960
show_status(fs, kind, newname)
962
show_status(fs, kind, oldname)
965
show_status(fs, kind, newname)
968
show_status(fs, kind, newname)
970
show_status(fs, kind, newname)
972
bailout("weird file state %r" % ((fs, fid),))
927
976
class ScratchBranch(Branch):
928
977
"""Special test class: a branch that cleans up after itself.