--- a/hgext/mq.py Mon Jul 16 17:39:03 2007 -0500
+++ b/hgext/mq.py Tue Jul 17 08:22:43 2007 +0200
@@ -909,7 +909,16 @@
patchparent = self.qparents(repo, top)
message, comments, user, date, patchfound = self.readheaders(patchfn)
- patchf = self.opener(patchfn, "w")
+ patchf = self.opener(patchfn, 'r+')
+
+ # if the patch was a git patch, refresh it as a git patch
+ for line in patchf:
+ if line.startswith('diff --git'):
+ self.diffopts().git = True
+ break
+ patchf.seek(0)
+ patchf.truncate()
+
msg = opts.get('msg', '').rstrip()
if msg:
if comments:
--- a/mercurial/commands.py Mon Jul 16 17:39:03 2007 -0500
+++ b/mercurial/commands.py Tue Jul 17 08:22:43 2007 +0200
@@ -2025,11 +2025,13 @@
for name, path in ui.configitems("paths"):
ui.write("%s = %s\n" % (name, path))
-def postincoming(ui, repo, modheads, optupdate):
+def postincoming(ui, repo, modheads, optupdate, wasempty):
if modheads == 0:
return
if optupdate:
- if modheads == 1:
+ if wasempty:
+ return hg.update(repo, repo.lookup('default'))
+ elif modheads == 1:
return hg.update(repo, repo.changelog.tip()) # update
else:
ui.status(_("not updating, since new heads added\n"))
@@ -2091,8 +2093,9 @@
error = _("Other repository doesn't support revision lookup, so a rev cannot be specified.")
raise util.Abort(error)
+ wasempty = repo.changelog.count() == 0
modheads = repo.pull(other, heads=revs, force=opts['force'])
- return postincoming(ui, repo, modheads, opts['update'])
+ return postincoming(ui, repo, modheads, opts['update'], wasempty)
def push(ui, repo, dest=None, **opts):
"""push changes to the specified destination
@@ -2656,6 +2659,7 @@
"""
fnames = (fname1,) + fnames
result = None
+ wasempty = repo.changelog.count() == 0
for fname in fnames:
if os.path.exists(fname):
f = open(fname, "rb")
@@ -2664,7 +2668,7 @@
gen = changegroup.readbundle(f, fname)
modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
- return postincoming(ui, repo, modheads, opts['update'])
+ return postincoming(ui, repo, modheads, opts['update'], wasempty)
def update(ui, repo, node=None, rev=None, clean=False, date=None):
"""update working directory
--- a/mercurial/localrepo.py Mon Jul 16 17:39:03 2007 -0500
+++ b/mercurial/localrepo.py Tue Jul 17 08:22:43 2007 +0200
@@ -119,22 +119,43 @@
self.hook('pretag', throw=True, node=hex(node), tag=name, local=local)
+ def writetag(fp, name, munge, prevtags):
+ if prevtags and prevtags[-1] != '\n':
+ fp.write('\n')
+ fp.write('%s %s\n' % (hex(node), munge and munge(name) or name))
+ fp.close()
+ self.hook('tag', node=hex(node), tag=name, local=local)
+
+ prevtags = ''
if local:
+ try:
+ fp = self.opener('localtags', 'r+')
+ except IOError, err:
+ fp = self.opener('localtags', 'a')
+ else:
+ prevtags = fp.read()
+
# local tags are stored in the current charset
- self.opener('localtags', 'a').write('%s %s\n' % (hex(node), name))
- self.hook('tag', node=hex(node), tag=name, local=local)
+ writetag(fp, name, None, prevtags)
return
+ if use_dirstate:
+ try:
+ fp = self.wfile('.hgtags', 'rb+')
+ except IOError, err:
+ fp = self.wfile('.hgtags', 'ab')
+ else:
+ prevtags = fp.read()
+ else:
+ try:
+ prevtags = self.filectx('.hgtags', parent).data()
+ except revlog.LookupError:
+ pass
+ fp = self.wfile('.hgtags', 'wb')
+
# committed tags are stored in UTF-8
- line = '%s %s\n' % (hex(node), util.fromlocal(name))
- if use_dirstate:
- self.wfile('.hgtags', 'ab').write(line)
- else:
- try:
- ntags = self.filectx('.hgtags', parent).data()
- except revlog.LookupError:
- ntags = ''
- self.wfile('.hgtags', 'wb').write(ntags + line)
+ writetag(fp, name, util.fromlocal, prevtags)
+
if use_dirstate and self.dirstate.state('.hgtags') == '?':
self.add(['.hgtags'])
--- a/tests/test-hook.out Mon Jul 16 17:39:03 2007 -0500
+++ b/tests/test-hook.out Tue Jul 17 08:22:43 2007 +0200
@@ -40,6 +40,7 @@
added 3 changesets with 2 changes to 2 files
(run 'hg update' to get a working copy)
pretag hook: HG_LOCAL=0 HG_NODE=4c52fb2e402287dd5dc052090682536c8406c321 HG_TAG=a
+tag hook: HG_LOCAL=0 HG_NODE=4c52fb2e402287dd5dc052090682536c8406c321 HG_TAG=a
precommit hook: HG_PARENT1=4c52fb2e402287dd5dc052090682536c8406c321
pretxncommit hook: HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PARENT1=4c52fb2e402287dd5dc052090682536c8406c321
4:8ea2ef7ad3e8
--- a/tests/test-mq Mon Jul 16 17:39:03 2007 -0500
+++ b/tests/test-mq Tue Jul 17 08:22:43 2007 +0200
@@ -319,6 +319,8 @@
hg qrefresh --git
cat .hg/patches/bar
hg log -vC --template '{rev} {file_copies%filecopy}\n' -r .
+hg qrefresh
+grep 'diff --git' .hg/patches/bar
echo
hg up -C 1
--- a/tests/test-mq.out Mon Jul 16 17:39:03 2007 -0500
+++ b/tests/test-mq.out Tue Jul 17 08:22:43 2007 +0200
@@ -325,6 +325,8 @@
rename from foo
rename to baz
2 baz (foo)
+diff --git a/bar b/bar
+diff --git a/foo b/baz
1 files updated, 0 files merged, 2 files removed, 0 files unresolved
2 files updated, 0 files merged, 1 files removed, 0 files unresolved
--- a/tests/test-pull Mon Jul 16 17:39:03 2007 -0500
+++ b/tests/test-pull Tue Jul 17 08:22:43 2007 +0200
@@ -18,3 +18,9 @@
cat foo
hg manifest --debug
hg pull
+
+echo % issue 622
+cd ..
+hg init empty
+cd empty
+hg pull -u ../test
--- a/tests/test-pull.out Mon Jul 16 17:39:03 2007 -0500
+++ b/tests/test-pull.out Tue Jul 17 08:22:43 2007 +0200
@@ -21,3 +21,11 @@
pulling from http://localhost:20059/
searching for changes
no changes found
+% issue 622
+pulling from ../test
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
--- a/tests/test-tag Mon Jul 16 17:39:03 2007 -0500
+++ b/tests/test-tag Tue Jul 17 08:22:43 2007 +0200
@@ -27,4 +27,17 @@
hg tag -l 'xx
newline'
hg tag -l 'xx:xx'
-true
+
+echo % issue 601
+mv .hg/localtags .hg/ltags
+head -1 .hg/ltags | tr -d '\n' > .hg/localtags
+cat .hg/localtags
+hg tag -l localnewline
+cat .hg/localtags
+
+mv .hgtags hgtags
+head -1 hgtags | tr -d '\n' > .hgtags
+hg ci -d '1000000 0' -m'broken manual edit of .hgtags'
+cat .hgtags
+hg tag -d '1000000 0' newline
+cat .hgtags
--- a/tests/test-tag.out Mon Jul 16 17:39:03 2007 -0500
+++ b/tests/test-tag.out Tue Jul 17 08:22:43 2007 +0200
@@ -30,3 +30,8 @@
3ecf002a1c572a2f3bb4e665417e60fca65bbd42 bleah1
abort: '\n' cannot be used in a tag name
abort: ':' cannot be used in a tag name
+% issue 601
+3ecf002a1c572a2f3bb4e665417e60fca65bbd42 bleah13ecf002a1c572a2f3bb4e665417e60fca65bbd42 bleah1
+f68b039e72eacbb2e68b0543e1f6e50990aa2bb5 localnewline
+0acdaf8983679e0aac16e811534eb49d7ee1f2b4 foobar0acdaf8983679e0aac16e811534eb49d7ee1f2b4 foobar
+6ae703d793c8b1f097116869275ecd97b2977a2b newline