/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to backend/fileops.py

  • Committer: Szilveszter Farkas (Phanatic)
  • Date: 2006-07-06 17:08:45 UTC
  • mto: (0.14.1 main) (93.1.1 win32.bialix)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: Szilveszter.Farkas@gmail.com-20060706170845-da015b629f5876a4
2006-07-06  Szilveszter Farkas <Szilveszter.Farkas@gmail.com>

    * I'm not dead :)
    * backend/errors.py: added some exceptions related to fileops.move()
    * backend/fileops.py: implemented move()
    * backend/info_helper.py: added diff_helper()
    * backend/info.py: implemented diff()

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
import bzrlib.errors as errors
22
22
 
23
 
from errors import (DirectoryAlreadyExists, NoFilesSpecified, NoMatchingFiles,
 
23
from errors import (DirectoryAlreadyExists, MissingArgumentError,
 
24
                    MultipleMoveError, NoFilesSpecified, NoMatchingFiles,
24
25
                    NotVersionedError)
25
26
 
 
27
def add(file_list):
 
28
    """ Add listed files to the branch. 
 
29
    
 
30
    :param file_list - list of files to be added (using full paths)
 
31
    
 
32
    :return: count of ignored files
 
33
    """
 
34
    import bzrlib.add
 
35
    
 
36
    added, ignored = bzrlib.add.smart_add(file_list)
 
37
    
 
38
    match_len = 0
 
39
    for glob, paths in ignored.items():
 
40
        match_len += len(paths)
 
41
    
 
42
    return match_len
 
43
 
26
44
def mkdir(directory):
27
45
    """ Create new versioned directory.
28
46
    
39
57
        wt, dd = WorkingTree.open_containing(directory)
40
58
        wt.add([dd])
41
59
 
42
 
def add(file_list):
43
 
    """ Add listed files to the branch. 
44
 
    
45
 
    :param file_list - list of files to be added (using full paths)
46
 
    
47
 
    :return: count of ignored files
 
60
def move(names_list):
 
61
    """ Move or rename given files.
 
62
    
 
63
    :param file_list: if two elements, then rename the first to the second, if more elements then move all of them to the directory specified in the last element
48
64
    """
49
 
    import bzrlib.add
50
 
    
51
 
    added, ignored = bzrlib.add.smart_add(file_list)
52
 
    
53
 
    match_len = 0
54
 
    for glob, paths in ignored.items():
55
 
        match_len += len(paths)
56
 
    
57
 
    return match_len
 
65
    from bzrlib.builtins import tree_files
 
66
    
 
67
    if len(names_list) < 2:
 
68
        raise MissingArgumentError
 
69
    tree, rel_names = tree_files(names_list)
 
70
        
 
71
    if os.path.isdir(names_list[-1]):
 
72
        # move into existing directory
 
73
        for pair in tree.move(rel_names[:-1], rel_names[-1]):
 
74
            pass
 
75
    else:
 
76
        if len(names_list) != 2:
 
77
            raise MultipleMoveError
 
78
        tree.rename_one(rel_names[0], rel_names[1])
58
79
 
59
80
def remove(file_list, new=False):
60
81
    """ Make selected files unversioned.