hgkw/keyword.py
branch0.9.3-compat
changeset 73 26c78e6f67b8
parent 72 28455872cb0e
child 75 c4daf4753ed3
equal deleted inserted replaced
72:28455872cb0e 73:26c78e6f67b8
    30     **.py = expand
    30     **.py = expand
    31     ...
    31     ...
    32 '''
    32 '''
    33 
    33 
    34 from mercurial.node import *
    34 from mercurial.node import *
    35 from mercurial.i18n import _
    35 from mercurial.i18n import gettext as _
    36 from mercurial import context, filelog, revlog, util
    36 from mercurial import context, filelog, revlog, util
    37 import os.path, re
    37 import os.path, re
    38 
    38 
    39 
    39 
    40 re_kw = re.compile(
    40 re_kw = re.compile(
   159 
   159 
   160             # check in files
   160             # check in files
   161             new = {}
   161             new = {}
   162             linkrev = self.changelog.count()
   162             linkrev = self.changelog.count()
   163             commit.sort()
   163             commit.sort()
   164             is_exec = util.execfunc(self.root, m1.execf)
       
   165             is_link = util.linkfunc(self.root, m1.linkf)
       
   166             for f in commit:
   164             for f in commit:
   167                 ui.note(f + "\n")
   165                 ui.note(f + "\n")
   168                 try:
   166                 try:
   169                     new[f] = self.filecommit(f, m1, m2, linkrev, tr, changed)
   167                     new[f] = self.filecommit(f, m1, m2, linkrev, tr, changed)
   170                     m1.set(f, is_exec(f), is_link(f))
   168                     m1.set(f, util.is_exec(self.wjoin(f), m1.execf(f)))
   171                 except OSError:
   169                 except IOError:
   172                     if use_dirstate:
   170                     if use_dirstate:
   173                         ui.warn(_("trouble committing %s!\n") % f)
   171                         ui.warn(_("trouble committing %s!\n") % f)
   174                         raise
   172                         raise
   175                     else:
   173                     else:
   176                         remove.append(f)
   174                         remove.append(f)
   177 
   175 
   178             # update manifest
   176             # update manifest
   179             m1.update(new)
   177             m1.update(new)
   180             remove.sort()
   178             remove.sort()
   181             removed = []
       
   182 
   179 
   183             for f in remove:
   180             for f in remove:
   184                 if f in m1:
   181                 if f in m1:
   185                     del m1[f]
   182                     del m1[f]
   186                     removed.append(f)
   183             mn = self.manifest.add(m1, tr, linkrev, c1[0], c2[0], (new, remove))
   187             mn = self.manifest.add(m1, tr, linkrev, c1[0], c2[0], (new, removed))
       
   188 
   184 
   189             # add changeset
   185             # add changeset
   190             new = new.keys()
   186             new = new.keys()
   191             new.sort()
   187             new.sort()
   192 
   188 
   198                 edittext.append("")
   194                 edittext.append("")
   199                 edittext.append("HG: user: %s" % user)
   195                 edittext.append("HG: user: %s" % user)
   200                 if p2 != nullid:
   196                 if p2 != nullid:
   201                     edittext.append("HG: branch merge")
   197                     edittext.append("HG: branch merge")
   202                 edittext.extend(["HG: changed %s" % f for f in changed])
   198                 edittext.extend(["HG: changed %s" % f for f in changed])
   203                 edittext.extend(["HG: removed %s" % f for f in removed])
   199                 edittext.extend(["HG: removed %s" % f for f in remove])
   204                 if not changed and not remove:
   200                 if not changed and not remove:
   205                     edittext.append("HG: no files changed")
   201                     edittext.append("HG: no files changed")
   206                 edittext.append("")
   202                 edittext.append("")
   207                 # run editor in the repository root
   203                 # run editor in the repository root
   208                 olddir = os.getcwd()
   204                 olddir = os.getcwd()
   216             if not lines:
   212             if not lines:
   217                 return None
   213                 return None
   218             text = '\n'.join(lines)
   214             text = '\n'.join(lines)
   219             if branchname:
   215             if branchname:
   220                 extra["branch"] = branchname
   216                 extra["branch"] = branchname
   221             n = self.changelog.add(mn, changed + removed, text, tr, p1, p2,
   217             n = self.changelog.add(mn, changed + remove, text, tr, p1, p2,
   222                                    user, date, extra)
   218                                    user, date, extra)
   223             self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1,
   219             self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1,
   224                       parent2=xp2)
   220                       parent2=xp2)
   225 
   221 
   226             # substitute keywords
   222             # substitute keywords