mercurial/hg.py
changeset 659 3662e3d6b690
parent 658 f8098ae9f5b6
child 660 2c83350784c3
equal deleted inserted replaced
658:f8098ae9f5b6 659:3662e3d6b690
   212                 else:
   212                 else:
   213                     l = None
   213                     l = None
   214                 start = bs
   214                 start = bs
   215                 if fn != f:
   215                 if fn != f:
   216                     # item not found, insert a new one
   216                     # item not found, insert a new one
   217                     end = bs 
   217                     end = bs
   218                     if w[1] == 1:
   218                     if w[1] == 1:
   219                         sys.stderr.write("failed to remove %s from manifest" % f)
   219                         sys.stderr.write("failed to remove %s from manifest" % f)
   220                         sys.exit(1)
   220                         sys.exit(1)
   221                 else:
   221                 else:
   222                     # item is found, replace/delete the existing line
   222                     # item is found, replace/delete the existing line
   554                 try:
   554                 try:
   555                     bin_n = bin(n)
   555                     bin_n = bin(n)
   556                 except TypeError:
   556                 except TypeError:
   557                     bin_n = ''
   557                     bin_n = ''
   558                 self.tagscache[k.strip()] = bin_n
   558                 self.tagscache[k.strip()] = bin_n
   559             
   559 
   560             try:
   560             try:
   561                 # read each head of the tags file, ending with the tip
   561                 # read each head of the tags file, ending with the tip
   562                 # and add each tag found to the map, with "newer" ones
   562                 # and add each tag found to the map, with "newer" ones
   563                 # taking precedence
   563                 # taking precedence
   564                 fl = self.file(".hgtags")
   564                 fl = self.file(".hgtags")
   569                         if l:
   569                         if l:
   570                             n, k = l.split(" ", 1)
   570                             n, k = l.split(" ", 1)
   571                             addtag(self, k, n)
   571                             addtag(self, k, n)
   572             except KeyError:
   572             except KeyError:
   573                 pass
   573                 pass
   574             
   574 
   575             try:
   575             try:
   576                 f = self.opener("localtags")
   576                 f = self.opener("localtags")
   577                 for l in f:
   577                 for l in f:
   578                     n, k = l.split(" ", 1)
   578                     n, k = l.split(" ", 1)
   579                     addtag(self, k, n)
   579                     addtag(self, k, n)
   580             except IOError:
   580             except IOError:
   581                 pass
   581                 pass
   582             
   582 
   583             self.tagscache['tip'] = self.changelog.tip()
   583             self.tagscache['tip'] = self.changelog.tip()
   584         
   584 
   585         return self.tagscache
   585         return self.tagscache
   586 
   586 
   587     def tagslist(self):
   587     def tagslist(self):
   588         '''return a list of tags ordered by revision'''
   588         '''return a list of tags ordered by revision'''
   589         l = []
   589         l = []
   876 
   876 
   877     def add(self, list):
   877     def add(self, list):
   878         for f in list:
   878         for f in list:
   879             p = self.wjoin(f)
   879             p = self.wjoin(f)
   880             if not os.path.exists(p):
   880             if not os.path.exists(p):
   881                 self.ui.warn("%s does not exist!\n" % f)                
   881                 self.ui.warn("%s does not exist!\n" % f)
   882             elif not os.path.isfile(p):
   882             elif not os.path.isfile(p):
   883                 self.ui.warn("%s not added: mercurial only supports files currently\n" % f)
   883                 self.ui.warn("%s not added: mercurial only supports files currently\n" % f)
   884             elif self.dirstate.state(f) == 'n':
   884             elif self.dirstate.state(f) == 'n':
   885                 self.ui.warn("%s already tracked!\n" % f)
   885                 self.ui.warn("%s already tracked!\n" % f)
   886             else:
   886             else:
   909     def copy(self, source, dest):
   909     def copy(self, source, dest):
   910         p = self.wjoin(dest)
   910         p = self.wjoin(dest)
   911         if not os.path.exists(dest):
   911         if not os.path.exists(dest):
   912             self.ui.warn("%s does not exist!\n" % dest)
   912             self.ui.warn("%s does not exist!\n" % dest)
   913         elif not os.path.isfile(dest):
   913         elif not os.path.isfile(dest):
   914             self.ui.warn("copy failed: %s is not a file\n" % dest)            
   914             self.ui.warn("copy failed: %s is not a file\n" % dest)
   915         else:
   915         else:
   916             if self.dirstate.state(dest) == '?':
   916             if self.dirstate.state(dest) == '?':
   917                 self.dirstate.update([dest], "a")
   917                 self.dirstate.update([dest], "a")
   918             self.dirstate.copy(source, dest)
   918             self.dirstate.copy(source, dest)
   919 
   919