/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 olive/info_helper.py

  • Committer: Jelmer Vernooij
  • Date: 2007-07-15 18:12:57 UTC
  • Revision ID: jelmer@samba.org-20070715181257-g264qus2zyi3v39z
Add RevisionSelectionBox widget, use in TagDialog.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
18
 
19
19
import time
20
 
import sys
21
20
 
22
21
import bzrlib
23
22
 
24
 
from bzrlib import (
25
 
    bzrdir,
26
 
    diff,
27
 
    errors,
28
 
    osutils,
29
 
    urlutils,
30
 
    )
 
23
import bzrlib.osutils as osutils
31
24
 
32
 
from bzrlib.diff import show_diff_trees
 
25
from bzrlib.info import _repo_rel_url
33
26
from bzrlib.missing import find_unmerged
34
 
    
35
 
def _repo_rel_url(repo_url, inner_url):
36
 
    """Return path with common prefix of repository path removed.
37
 
 
38
 
    If path is not part of the repository, the original path is returned.
39
 
    If path is equal to the repository, the current directory marker '.' is
40
 
    returned.
41
 
    Otherwise, a relative path is returned, with trailing '/' stripped.
42
 
    """
43
 
    inner_url = urlutils.normalize_url(inner_url)
44
 
    repo_url = urlutils.normalize_url(repo_url)
45
 
    if inner_url == repo_url:
46
 
        return '.'
47
 
    result = urlutils.relative_url(repo_url, inner_url)
48
 
    if result != inner_url:
49
 
        result = result.rstrip('/')
50
 
    return result
51
27
 
52
28
def get_location_info(repository, branch=None, working=None):
53
29
    """ Get known locations for working, branch and repository.
262
238
    if revno > 0:
263
239
        firstrev = repository.get_revision(history[0])
264
240
        age = int((time.time() - firstrev.timestamp) / 3600 / 24)
265
 
        ret['age'] = '%d days'%age
 
241
        ret['age'] = age
266
242
        ret['firstrev'] = osutils.format_date(firstrev.timestamp,
267
243
                                              firstrev.timezone)
268
244
 
281
257
    if repository.bzrdir.root_transport.listable():
282
258
        c, t = repository._revision_store.total_size(repository.get_transaction())
283
259
        ret['revisions'] = c
284
 
        ret['size'] = '%d KiB'%t
 
260
        ret['size'] = t
285
261
 
286
262
    return ret
287
263
 
300
276
 
301
277
    :param new_revision_spec:  if None, use working tree as new revision, otherwise use the tree for the specified revision.
302
278
    """
 
279
    import sys
 
280
    
 
281
    from bzrlib.diff import show_diff_trees
303
282
    
304
283
    if output == None:
305
284
        output = sys.stdout
306
285
    
 
286
    def spec_tree(spec):
 
287
        revision_id = spec.in_store(tree.branch).rev_id
 
288
        return tree.branch.repository.revision_tree(revision_id)
 
289
    
307
290
    if old_revision_spec is None:
308
291
        old_tree = tree.basis_tree()
309
292
    else:
317
300
    return show_diff_trees(old_tree, new_tree, output, specific_files,
318
301
                           external_diff_options,
319
302
                           old_label=old_label, new_label=new_label)
320
 
 
321
 
def spec_tree(spec):
322
 
        revision_id = spec.in_store(tree.branch).rev_id
323
 
        return tree.branch.repository.revision_tree(revision_id)