hgext/mq.py
changeset 3024 a4374f7331e4
parent 2994 c203ccd7d838
child 3069 bc3fe3b5b785
child 3072 e20e7e2623b0
equal deleted inserted replaced
3023:d838bfac668d 3024:a4374f7331e4
   917         if len(self.applied) == 0:
   917         if len(self.applied) == 0:
   918             self.ui.write("No patches applied\n")
   918             self.ui.write("No patches applied\n")
   919             return 1
   919             return 1
   920         wlock = repo.wlock()
   920         wlock = repo.wlock()
   921         self.check_toppatch(repo)
   921         self.check_toppatch(repo)
   922         (top, patch) = (self.applied[-1].rev, self.applied[-1].name)
   922         (top, patchfn) = (self.applied[-1].rev, self.applied[-1].name)
   923         top = revlog.bin(top)
   923         top = revlog.bin(top)
   924         cparents = repo.changelog.parents(top)
   924         cparents = repo.changelog.parents(top)
   925         patchparent = self.qparents(repo, top)
   925         patchparent = self.qparents(repo, top)
   926         message, comments, user, date, patchfound = self.readheaders(patch)
   926         message, comments, user, date, patchfound = self.readheaders(patchfn)
   927 
   927 
   928         patchf = self.opener(patch, "w")
   928         patchf = self.opener(patchfn, "w")
   929         msg = opts.get('msg', '').rstrip()
   929         msg = opts.get('msg', '').rstrip()
   930         if msg:
   930         if msg:
   931             if comments:
   931             if comments:
   932                 # Remove existing message.
   932                 # Remove existing message.
   933                 ci = 0
   933                 ci = 0
   993 
   993 
   994             m = list(util.unique(mm))
   994             m = list(util.unique(mm))
   995             r = list(util.unique(dd))
   995             r = list(util.unique(dd))
   996             a = list(util.unique(aa))
   996             a = list(util.unique(aa))
   997             filelist = filter(matchfn, util.unique(m + r + a))
   997             filelist = filter(matchfn, util.unique(m + r + a))
   998             self.printdiff(repo, patchparent, files=filelist,
   998             patch.diff(repo, patchparent, files=filelist, match=matchfn,
   999                            changes=(m, a, r, [], u), fp=patchf)
   999                        fp=patchf, changes=(m, a, r, [], u),
       
  1000                        opts=self.diffopts())
  1000             patchf.close()
  1001             patchf.close()
  1001 
  1002 
  1002             changes = repo.changelog.read(tip)
  1003             changes = repo.changelog.read(tip)
  1003             repo.dirstate.setparents(*cparents)
  1004             repo.dirstate.setparents(*cparents)
  1004             copies = [(f, repo.dirstate.copied(f)) for f in a]
  1005             copies = [(f, repo.dirstate.copied(f)) for f in a]
  1017             repo.dirstate.update(mm, 'n', st_mtime=0)
  1018             repo.dirstate.update(mm, 'n', st_mtime=0)
  1018             repo.dirstate.forget(forget)
  1019             repo.dirstate.forget(forget)
  1019 
  1020 
  1020             if not msg:
  1021             if not msg:
  1021                 if not message:
  1022                 if not message:
  1022                     message = "patch queue: %s\n" % patch
  1023                     message = "patch queue: %s\n" % patchfn
  1023                 else:
  1024                 else:
  1024                     message = "\n".join(message)
  1025                     message = "\n".join(message)
  1025             else:
  1026             else:
  1026                 message = msg
  1027                 message = msg
  1027 
  1028 
  1028             self.strip(repo, top, update=False, backup='strip', wlock=wlock)
  1029             self.strip(repo, top, update=False, backup='strip', wlock=wlock)
  1029             n = repo.commit(filelist, message, changes[1], force=1, wlock=wlock)
  1030             n = repo.commit(filelist, message, changes[1], force=1, wlock=wlock)
  1030             self.applied[-1] = statusentry(revlog.hex(n), patch)
  1031             self.applied[-1] = statusentry(revlog.hex(n), patchfn)
  1031             self.applied_dirty = 1
  1032             self.applied_dirty = 1
  1032         else:
  1033         else:
  1033             self.printdiff(repo, patchparent, fp=patchf)
  1034             self.printdiff(repo, patchparent, fp=patchf)
  1034             patchf.close()
  1035             patchf.close()
  1035             self.pop(repo, force=True, wlock=wlock)
  1036             self.pop(repo, force=True, wlock=wlock)