mercurial/commands.py
changeset 386 494c8e3f47f3
parent 371 6e3436082697
child 387 c07c6fb2f0a8
equal deleted inserted replaced
385:e9e1efd5291c 386:494c8e3f47f3
   331     for i in range(repo.changelog.count() - 1, -1, -1):
   331     for i in range(repo.changelog.count() - 1, -1, -1):
   332         show_changeset(ui, repo, rev=i)
   332         show_changeset(ui, repo, rev=i)
   333 
   333 
   334 def identify(ui, repo):
   334 def identify(ui, repo):
   335     """print information about the working copy"""
   335     """print information about the working copy"""
   336     (c, a, d, u) = repo.diffdir(repo.root)
       
   337     mflag = (c or a or d or u) and "+" or ""
       
   338     parents = [p for p in repo.dirstate.parents() if p != hg.nullid]
   336     parents = [p for p in repo.dirstate.parents() if p != hg.nullid]
   339     if not parents:
   337     if not parents:
   340         ui.write("unknown\n")
   338         ui.write("unknown\n")
   341         return
   339         return
   342 
   340 
   343     tstring = ''
   341     hexfunc = ui.verbose and hg.hex or hg.short
       
   342     (c, a, d, u) = repo.diffdir(repo.root)
       
   343     output = ["%s%s" % ('+'.join([hexfunc(parent) for parent in parents]),
       
   344                         (c or a or d) and "+" or "")]
       
   345 
   344     if not ui.quiet:
   346     if not ui.quiet:
   345         tags = sum(map(repo.nodetags, parents), [])
   347         # multiple tags for a single parent separated by '/'
   346         tstring = " " + ' + '.join(tags)
   348         parenttags = ['/'.join(tags)
   347 
   349                       for tags in map(repo.nodetags, parents) if tags]
   348     hexfunc = ui.verbose and hg.hex or hg.short
   350         # tags for multiple parents separated by ' + '
   349     pstring = '+'.join([hexfunc(parent) for parent in parents])
   351         output.append(' + '.join(parenttags))
   350     ui.write("%s%s%s\n" % (pstring, mflag, tstring))
   352 
       
   353     ui.write("%s\n" % ' '.join(output))
   351 
   354 
   352 def init(ui, source=None):
   355 def init(ui, source=None):
   353     """create a new repository or copy an existing one"""
   356     """create a new repository or copy an existing one"""
   354 
   357 
   355     if source:
   358     if source: