Commits

Antonio Cuni committed d0d7666

add a bblink command to get bitbucket links

  • Participants
  • Parent commits 9b6f268

Comments (0)

Files changed (1)

             follower['first_name'],
             follower['last_name']))
 
+def bb_link(ui, repo, filename=None, **opts):
+    '''display a bitbucket link to the repository, or the the specific file if given'''
+    # XXX: might not work on windows, because it uses \ to separate paths
+    reponame = get_bbreponame(ui, repo, opts)
+    nodeid = str(repo[None])
+    if nodeid.endswith('+'):
+        # our wc is dirty, just take the node id and be happy
+        nodeid = nodeid[:-1]
+    if filename:
+        path = os.path.relpath(filename, repo.root)
+    else:
+        path = ''
+    url = 'http://bitbucket.org/%s/src/%s/%s'
+    url = url % (reponame, nodeid, path)
+    ui.write(url + '\n')
+
 def clone(orig, ui, source, dest=None, **opts):
     if source[:2] == 'bb' and ':' in source:
         protocol, rest = source.split(':', 1)
            'name of the repo at bitbucket (else guessed from repo dir)'),
           ],
          'hg bbcreate [-d desc] [-l lang] [-w site] reponame'),
+    'bblink':
+        (bb_link,
+         [],
+         'hg bblink filename'),
 }
 
 commands.norepo += ' bbcreate'