/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: Jasper Groenewegen
  • Date: 2008-07-27 12:01:40 UTC
  • mfrom: (576.3.2 improve-merge)
  • mto: This revision was merged to the branch mainline in revision 579.
  • Revision ID: colbrac@xs4all.nl-20080727120140-1agdlzkc9fumjk5f
Merge merge dialog improvements

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
20
21
 
21
22
import bzrlib
22
23
 
23
 
import bzrlib.osutils as osutils
 
24
from bzrlib import (
 
25
    bzrdir,
 
26
    diff,
 
27
    errors,
 
28
    osutils,
 
29
    urlutils,
 
30
    )
24
31
 
25
 
from bzrlib.info import _repo_rel_url
 
32
from bzrlib.diff import show_diff_trees
26
33
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
27
51
 
28
52
def get_location_info(repository, branch=None, working=None):
29
53
    """ Get known locations for working, branch and repository.
238
262
    if revno > 0:
239
263
        firstrev = repository.get_revision(history[0])
240
264
        age = int((time.time() - firstrev.timestamp) / 3600 / 24)
241
 
        ret['age'] = age
 
265
        ret['age'] = '%d days'%age
242
266
        ret['firstrev'] = osutils.format_date(firstrev.timestamp,
243
267
                                              firstrev.timezone)
244
268
 
257
281
    if repository.bzrdir.root_transport.listable():
258
282
        c, t = repository._revision_store.total_size(repository.get_transaction())
259
283
        ret['revisions'] = c
260
 
        ret['size'] = t
 
284
        ret['size'] = '%d KiB'%t
261
285
 
262
286
    return ret
263
287
 
276
300
 
277
301
    :param new_revision_spec:  if None, use working tree as new revision, otherwise use the tree for the specified revision.
278
302
    """
279
 
    import sys
280
 
    
281
 
    from bzrlib.diff import show_diff_trees
282
303
    
283
304
    if output == None:
284
305
        output = sys.stdout
285
306
    
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
 
    
290
307
    if old_revision_spec is None:
291
308
        old_tree = tree.basis_tree()
292
309
    else:
300
317
    return show_diff_trees(old_tree, new_tree, output, specific_files,
301
318
                           external_diff_options,
302
319
                           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)