hgext/bookmarks.py
changeset 7552 a9221c7f51a4
parent 7491 b95ff487870e
parent 7550 fead6cf99a09
child 7622 4dd7b28003d2
equal deleted inserted replaced
7549:013a2baf8f85 7552:a9221c7f51a4
    62     We also store a backup of the previous state in undo.bookmarks that
    62     We also store a backup of the previous state in undo.bookmarks that
    63     can be copied back on rollback.
    63     can be copied back on rollback.
    64     '''
    64     '''
    65     if os.path.exists(repo.join('bookmarks')):
    65     if os.path.exists(repo.join('bookmarks')):
    66         util.copyfile(repo.join('bookmarks'), repo.join('undo.bookmarks'))
    66         util.copyfile(repo.join('bookmarks'), repo.join('undo.bookmarks'))
    67     file = repo.opener('bookmarks', 'w+')
       
    68     if current(repo) not in refs:
    67     if current(repo) not in refs:
    69         setcurrent(repo, None)
    68         setcurrent(repo, None)
       
    69     file = repo.opener('bookmarks', 'w+')
    70     for refspec, node in refs.items():
    70     for refspec, node in refs.items():
    71         file.write("%s %s\n" % (hex(node), refspec))
    71         file.write("%s %s\n" % (hex(node), refspec))
    72     file.close()
    72     file.close()
    73 
    73 
    74 def current(repo):
    74 def current(repo):
   136             raise util.Abort(_("a bookmark of the same name already exists"))
   136             raise util.Abort(_("a bookmark of the same name already exists"))
   137         if mark is None:
   137         if mark is None:
   138             raise util.Abort(_("new bookmark name required"))
   138             raise util.Abort(_("new bookmark name required"))
   139         marks[mark] = marks[rename]
   139         marks[mark] = marks[rename]
   140         del marks[rename]
   140         del marks[rename]
       
   141         if current(repo) == rename:
       
   142             setcurrent(repo, mark)
   141         write(repo, marks)
   143         write(repo, marks)
   142         return
   144         return
   143 
   145 
   144     if delete:
   146     if delete:
   145         if mark == None:
   147         if mark == None: