[PATCH]mq:qimport support
Ling, Xiaofeng
xiaofeng.ling at intel.com
Tue Sep 13 09:26:21 CDT 2005
with qimport, we can add back any patches in stores.
we can also import new patches for mq.
like:
hg qimport 3
hg qimport ~/myfix.patch
diff -r a4985a9b1dbc contrib/mq
--- a/contrib/mq Tue Sep 13 13:45:56 2005
+++ b/contrib/mq Tue Sep 13 21:55:17 2005
@@ -188,6 +188,42 @@
del self.series[i]
self.series_dirty = 1
+ def qimport(self, repo, patch, msg=None):
+ if patch and os.path.isfile(patch):
+ import_patch = patch
+ patch = os.path.basename(import_patch)
+ patch_path = os.path.join(self.path, patch)
+ if os.path.exists(patch_path):
+ self.ui.warn("file: %s already exist\n" % patch_path)
+ sys.exit(1)
+ self.ui.write("importing %s ...\n" % import_patch)
+ cmd = "cp %s %s\n" % (import_patch, patch_path)
+ self.ui.write(cmd)
+ os.system(cmd)
+ else:
+ try:
+ sno = int(patch)
+ except(ValueError, OverflowError):
+ self.ui.warn("file %s not found\n" % patch)
+ sys.exit(1)
+ if sno >= len(self.stores):
+ self.ui.warn("This number %s is out of range\n" % sno)
+ sys.exit(1)
+ patch = self.stores[sno]
+ del self.stores[sno]
+ self.ui.write("adding %s ...\n" % patch)
+ patch_path = os.path.join(self.path, patch)
+
+ if not os.path.exists(patch_path):
+ self.ui.warn("file: %s not exist\n" % patch_path)
+ sys.exit(1)
+
+ insert = len(self.applied)
+ self.series[insert:insert] = [patch]
+ self.series_dirty = 1
+ self.stores_dirty = 1
+ self.push(repo, patch, False, False)
+
def new(self, repo, patch, msg=None):
insert = len(self.applied)
if msg:
@@ -749,6 +785,10 @@
"""create a new patch"""
repomap[repo].new(repo, patch, msg=opts['message'])
+def qimport(ui, repo, patch, **opts):
+ """import a patch"""
+ repomap[repo].qimport(repo, patch, msg=opts['message'])
+
def refresh(ui, repo, **opts):
"""update the current patch"""
repomap[repo].refresh(repo, short=opts['short'])
@@ -797,6 +837,8 @@
"qdelete": (delete, [], "hg qdelete [patch]"),
"^qinit": (init, [], "hg qinit"),
"qnew": (new, [('m', 'message', "", 'commit message')], "hg qnew [-m message ] patch"),
+ "qimport": (qimport, [('m', 'message', "", 'commit message')], "hg import [-m message ] patch"),
+ "qnext": (next, [], "hg qnext"),
"qnext": (next, [], "hg qnext"),
"qprev": (prev, [], "hg qprev"),
"^qpop": (pop, [('a', 'all', None, 'pop all patches'),
-------------------
Ling Xiaofeng(Daniel)
Open Source Technology Center
Intel China Software Center
iNet: 8-752-1243
8621-52574545-1243(O)
xfling at users.sourceforge.net
More information about the Mercurial
mailing list